Very simple guestbook script/software?

Soldato
Joined
1 Sep 2005
Posts
10,001
Location
Scottish Highlands
Im after some very simple guestbook type software. It needs to be able to run without MySQL and be able to fit into a html/css page without too much trouble. Ive tried a few, but none of them work how I want. The closest I have found is one that used flash and php, but unfortunately it didn't seem to work properly. Any suggestions?
 
Ive got one somewhere you can have,
Made it as part of a uni assignment last year.

Its just a simple guestbook where people say whatever, leave their name and email and it is stored in a text file.
You can then reply to each comment or make a new one of your own.

It is here infact

grab me on MSN sometime today and Ill give you the files or you can let me know what you want changing and I can change anything for you :)
 
Heh, use his!

I got distracted just after I posted. No sense in me trying to finish if he has a good one ready made for ya :)

EDIT: Have you got the source code, so I can nosey at it? :D
 
Cheers guys. That one looks perfect Tom. When I try it though, it throw up errors, do you know about these? I should be on MSN later tonight, so i'll grab it off you then. :)
 
ok sorted now, you have to make a folder called data and have the permissions to read and write for everyone. Its so that it can create a new text file for every comment.

Forgot I had a new text file for every comment, I can change it to just 1 text file but I don't have time at the moment.

Here's the code anyway so I am sure someone can help you with that if you need 1 file only :)

Include.php
PHP:
<?php
function htmlHeader() //HTML Headers
{
	$strHead.= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
	$strHead.= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
	$strHead.= "<head>\n";
	$strHead.= "<meta http-equiv=\"Content-type\" content=\"text/html; charset=iso-8859-1\" />\n";
	$strHead.= "<meta http-equiv=\"Content-Language\" content=\"en-us\" />\n";
	$strHead.= "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">";
	$strHead.= "<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\"/>\n";
	$strHead.= "<title>Tom Sinclair - Guestbook</title>\n";
	$strHead.= "</head>\n";
	$strHead.= "<body>\n";
	//$strHead.="<div id=\"Wrapper\">";
	return $strHead;
	
}

// GET FORM POST or GET
 function GetPost($get_string) {
      If (isset($_POST[$get_string])) {
         return $_POST[$get_string];
      } elseif (isset($_GET[$get_string])) {
         return $_GET[$get_string];
      } else {
         return "";
      }
 }

function displaycomment($strfilename, $intComment, $strfile)
{
	$handle = fopen($strfilename, "r") or exit("Error opening file"); //Opens file, read only, if it can't then creates an error
	While(!feof($handle)) //Goes through file line by line until eof(end of file)
		{
				//Set variable to blanks
				$strline = "";
				$strdata = "";
				$intComments = 0;
				$strSwitch = "";
					
				$strline = fgets($handle); //Gets line, stores it in a variable
				If (strlen($strline) > 0)
					{					
						Switch (substr($strline, 0, 1) ) //Gets 1st Chr, determines if it's a comment or a reply, outputs HTML accordingly
							{
								case "~":
									$strdata = explode("|", $strline); //Exploded data array
									echo "<div class=\"comment\">";
									echo "<div class=\"name\"><a href=\"mailto:".$strdata[3]."\">".$strdata[2]."</a></div>";
									echo "<div class=\"info\">".$strdata[1]."</div>";
									echo $strdata[4];
									echo "<div class=\"comReply\"><A href=\"index.php?p=reply&file=".substr($strfile, 0, strlen($strfile) - 4)."\">Reply</a></div>";
									if ($_SESSION['allowed'] == "TRUE") 
									{ 
										echo "<div class=\"comDelete\"><A href=\"index.php?p=delete&file=".substr($strfile, 0, strlen($strfile) - 4)."\">Delete</a></div>";	
										//index.php?p=delete&file=".substr($strfile, 0, strlen($strfile) - 4)."
									}
									echo "<div class=\"comNumber\">#".($intComment+1)."</div>";
									echo "</div>";					
								break;
								
								case "#":
									$strdata = explode("|", $strline);
									echo "<div class=\"reply\">";
									echo "<div class=\"name\"><a href=\"mailto:".$strdata[3]."\">".$strdata[2]."</a></div>";
									echo "<div class=\"info\">".$strdata[1]."</div>";
									echo $strdata[4];
									echo "</div>";
								break;	
							}
					}			
			}
	fclose($handle);	
}

function writeReply($strReplyFile, $strName, $strEmail, $strReply)
{
	If ($strReplyFile != "" && $strName != "" && $strEmail != "" && $strReply != "")
	{
		$strReplyfilename = getcwd()."/data/".$strReplyFile.".txt";
		$handle = fopen($strReplyfilename, "a") or exit("Error opening file"); //Opens file Write pointer at end of file, if it can't then creates an error		
		$strReplyContent = "\r\n#|".Date("m/d/y")." - ".Date("H:i:s")."|".$strName."|".$strEmail."|".$strReply; //To be writen to textfile
		if (fwrite($handle, $strReplyContent) === FALSE)
		{
			return FALSE;
		} else {
			return TRUE;
		}				
		fclose($handle);
	} else {
		return FALSE;
	}			
}

function writeComment($strName, $strEmail, $strComment)
{
	If ($strName != "" && $strEmail != "" && $strComment != "")
	{
		$strdirectory = getcwd()."/data/"; //Gets current working directory, adds the directory data to it		
		
		// Get comment files in comment (data) directory
		$strFiles = array();
		$handle = opendir($strdirectory) or die("Directory not found!"); //Opens directory
		
		while($entry = readdir($handle)) //Scans through, uses an array to sort out files and subdirs
		{
			if(!is_dir($entry) && $entry != ".." && $entry != ".")
			{
		    	$strFiles[] = $entry;
		    }
		}
		closedir($handle); //Close handle for directory
		sort($strFiles); //Sorts files/directory
		
		$intComCount = count($strFiles); //number of comments (actually files)
		$strLastFile = $strFiles[$intComCount - 1]; // Last filename in comment data dir
		$intNewFile = intval(substr($strLastFile, 0, strlen($strLastFile) - 4)) + 1; //Strips off the .txt, converts string to integer, adds 1
		$strNewFile = $intNewFile.".txt"; //new string for file creation
		$strCommentContent = "~|".Date("m/d/y")." - ".Date("H:i:s")."|".$strName."|".$strEmail."|".$strComment; //to be written to textfile
		
		$handle = fopen($strdirectory.$strNewFile, "w");
		if (fwrite($handle, $strCommentContent) === FALSE)
		{
			return FALSE;
		} else {
			return TRUE;
		}		
		fclose($handle);
	} else {
		return FALSE;
	}				
}
?>

Index.php
PHP:
<?php
//No Page Caching
Header('Cache-Control: no-cache');
Header('Pragma: no-cache');

require "include.php"; //require include file, creates fatal error over include function

//Start Session
if (session_start() <> True) {
   session_start();
}
if (isset($_SESSION['allowed']) == False) $_SESSION['allowed'] = "FALSE"; //Admin Session

Switch (GetPost("p")) // Page Switching
	{
		// ********* Default Page - Gets Comments/Replies *********
		default: 
			echo htmlHeader(); //echos html headers
		?>
			<div id="CommentEntry"><h1>Post A Comment</h1>
				<form action="index.php?p=comment" method="post" id="PostForm">
					<div>
						<ul>
							<li>Name -<br/><input type="text" name="comName"></input></li><br/>
							<li>Email -<br/><input type="text" name="comEmail"></input></li><br/>
							<li>Comment -<br/><textarea name="comCom"></textarea></li><br/>
							<li><input type="submit" value="Post Comment"/>&nbsp;<input type="reset" value="Clear"></li>
							
						</ul>
					</div>
				</form>
				<div id="LoginContainer"><h1>Admin Section</h1>	
					
				<?php
				if ($_SESSION['allowed'] == "FALSE") //Not logged in, display loging form
					{
				?>
					<form action="index.php?p=admin" method="post" id="LoginForm">
						<div>
							<ul>
								<li>Username -<br/><input type="text" name="adminUser"></input></li><br/>
								<li>Password -<br/><input type="password" name="adminPass"></input></li><br/>
								<li><input type="submit" value="Login"/></li>
							</ul>
						</div>
					</form>
				<?php
					} else { //Logged in, display logout form
				?>
					<form action="index.php?p=logout" method="post">
						<div>
							<ul>
								<li><input type="submit" value="Logout"/></li>
							</ul>
						</div>
					</form>
				<?php
					}
				?>	
				</div>
			</div>
			
		<div id="CurrentComments">
			<h1>Comments</h1>
		
			
		<?php //***********Comment retrival PHP******************
		$strdirectory = getcwd()."/data/"; //Gets current working directory, adds the directory data to it
		
		// Get comment files in comment (data) directory
		$strFiles = array();
		$handle = opendir($strdirectory) or die("Directory not found!"); //Opens directory
		
		while($entry = readdir($handle)) //Scans through, uses an array to sort out files and subdirs
			{
				if(!is_dir($entry) && $entry != ".." && $entry != ".")
					{
		            	$strFiles[] = $entry;
		        	}
			}
			
		closedir($handle); //Close handle for directory
		sort($strFiles); //Sorts files/directory
		$intComCount = count($strFiles); //number of comments (actually files)
		
		//Entries numbers
		echo "<div id=\"Entries\">";
		if($intComCount > 0){
			if($intComCount == 1){
				echo "1 Entry";
			} else {
				echo "$intComCount entries";
			}
		} else {
			echo "Currently there are no entries in the guestbook.<br/>How about posting a comment?";
		}
		echo "</div>";
		
		//Generates comment information
		for($i=0; $i < $intComCount; $i++) //Goes through comment files, displays them
			{
			displaycomment($strdirectory . $strFiles[$i], $i, $strFiles[$i]);
			}
			break;
		
		//**********************Form Page for Reply **************
		case "reply":
			echo htmlHeader();
?>
			<div id="CommentReply"><h1>Post a Reply</h1>
				<form action="index.php?p=reply2" method="post" id="PostForm">
				<input type="hidden" name="filenumber" value="<?php echo GetPost("file"); ?>">
					<div>
						<ul>
							<li>Name -<br/><input type="text" name="replyName" class="textentry"></input></li><br/>
							<li>Email -<br/><input type="text" name="replyEmail" class="textentry"></input></li><br/>
							<li>Comment -<br/><textarea name="replyComment" class="textentry"></textarea></li><br/>
							<li><input type="submit" value="Post Reply"/>&nbsp;<input type="reset" value="Clear"></li>
						</ul>
					</div>

<?php
			break;
			
		//*******************Redirection from Reply form*********************
		case "reply2":
			if (writeReply(GetPost("filenumber"),GetPost("replyName"), GetPost("replyEmail"), GetPost("replyComment")) != FALSE)
			{
				header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php");
			} else {
				echo htmlHeader();
				echo "An Error has occured, Please go back a check the entered data!<br/>";
				echo "<A HREF='javascript:history.go(-1)'>Go Back</A>";
			}
			break;
			
		case "comment":
			if (writeComment(GetPost("comName"), GetPost("comEmail"), GetPost("comCom")) != FALSE)
			{
				header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php");
			} else {
				echo htmlHeader();
				echo "An Error has occured, Please go back a check the entered data!<br/>";
				echo "<A HREF=\"javascript:history.go(-1)\">Go Back</A>";
			}
			break;
		
		//********************* ADMIN LOGIN *****************8		
		case "admin":
			//Admin Username and Password
			$strUsr = "CHANGEME";
			$strPass = "CHANGEME";
			
			if (GetPost("adminUser") == $strUsr && GetPost("adminPass") == $strPass)
			{
				$_SESSION['allowed'] = "TRUE";
				header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); //redirect back to main page
			} else {
				echo htmlHeader();
				echo "An Error has occured, Please go back a check the entered data!<br/>";
				echo "<A HREF='javascript:history.go(-1)'>Go Back</A>";	
			}
			break;	
			
			//*****************ADMIN LOGOUT*****************	
			case "logout":
				session_destroy(); //deletes all sessions
				header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); //redirects back to main page
				break;
				
			
			//*************DELETE COMMENT*************
			case "delete":
				if ($_SESSION['allowed'] == "TRUE" && GetPost("file") != "") 
				{
					$strDelFile = getcwd()."/data/".GetPost("file").".txt";
					$fh = fopen($strDelFile, 'w') or die("can't open file"); //Make sure we have complete access to file, isn't already open etc
					fclose($fh);
					if (unlink($strDelFile) == TRUE)
					{
						header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); //redirects back to main page					
					} else {
						echo htmlHeader();
						echo "An Error has occured deleting a comment, Please go back and try again!<br/>";
						echo "<A HREF='javascript:history.go(-1)'>Go Back</A>";	
					}
				}
				break;					
}
?>	
</div>
</body>
</html>


There is even an admin section to delete unwanted comments, this will just delete the text file so any replies to that comment will go with it. The username/password is near the bottom in the Index.php page.


Let me know how you get on with it anyway
 
Oooh that looks good. Gonna have a proper nosey at that tomorrow.

I think I know enough PHP to knock up a comments/guestbook feature myself but seeing a working script [and a very nice one at that] should give me some good ideas and better direction.

I am happy to have a crack at changing the code to save to one file instead of many if you want it changing Messiah. Actually, I might just do it as an exercise regardless :p
 
Whoops just typed this message out onto my mac instead of PC :/ bed time I think lol

yeah go for it in regards to editing it and making it neater/more efficient/secure

It was something I did for my 1st PHP assignment at uni last year, managed to get 78% overall with the guestbook and my sweet shop!
Got a nice PHP job from those 2 things but it only lasted 2 months, not touched PHP in about 3 months, really need to get back into it as it seemed alright, just code bores me to death!

Make sure you post the edited code back here or a working URL so I can have a look :)
 
I will do.

If I can get it working the way I want, I may incorporate it into a personal website I have started working on. With your permission of course.
 
I made a simple one a while back in college for my ICT Course work, feel free to use.

http://www.lolism.net/col_project/home.php?kse=comments

Code:
<FORM method="post" action="comment/action.php">
<b><font face="Verdana" size="1" color="#FFFFFF">Name</font></b><BR>
<INPUT name="name" type="text" size="30" class="input">
<BR>
<b><font face="Verdana" size="1" color="#FFFFFF">Comment</font></b><BR>
<TEXTAREA name="comment" rows=6 cols=60 wrap="virtual" class="input">
</TEXTAREA>
<BR>
<INPUT name="submit" type="submit" value="Submit" class="input">
&nbsp; 
<input type="reset" class="input">
<br>
<BR>
</FORM>
<font face="verdana" size="1"><a href="?kse=show">Show comments</a></font>

action:
PHP:
<link href="style.css" rel="stylesheet" type="text/css">
<?php

$file = fopen("comments.db", "a");
$commentor = $_POST['name'];
$comment = $_POST['comment'];

if((empty($commentor)) || (empty($comment)))
{
print "Please fill out all required fields.";
}
else
{
fputs($file, "<font face=\"verdana\" size=\"1\" color=\"#ffffff\"><strong>$commentor</strong>:<br/> $comment<br/></font><hr noshade color=\"#ffffff\" size=\"1\"> \r\n", 500);
fclose($file);

print "Message Posted. You can now <a href=\"../home.php?kse=show\">view your message</a>";
}
?>

show comments:
PHP:
<?php

$file = fopen("comments.db", "r");

while (!feof($file))
{
$line = fgets($file, 500);
print $line;
}
fclose($file);

?>
 
Yeah just let me know how it all pans out and if you need any help just email me or post on here

Just been going through your code and it is pretty good. I shouldn't have any problem tweaking it.

Two things I'd like to mention though..

1: In your index.php you have a big chunk of code that is [at a glance] identicle to a chunk of code in your include.php. In the index.php you use it to get the number of comments. Any reason why you didn't create a new "countComments" function?

2: Your formatting is evil! :p

Code:
// GET FORM POST or GET
 function GetPost($get_string) {
      If (isset($_POST[$get_string])) {
         return $_POST[$get_string];
      } elseif (isset($_GET[$get_string])) {
         return $_GET[$get_string];
      } else {
         return "";
      }
 }

That is awful! Really hard to follow code when written like that. The above should be

Code:
// GET FORM POST or GET
function GetPost($get_string) 
{
      If (isset($_POST[$get_string])) 
      {
         return $_POST[$get_string];
      } 
      elseif (isset($_GET[$get_string])) 
      {
         return $_GET[$get_string];
      } 
      else 
      {
         return "";
      }
 }

Looks a lot better in my opinion.

Wasn't a dig as such. Just i'm a formatting snob :D
 
lol its just the way I code :p

I'll have a look at the index and include about that as I can't remember at the mo and I'm off to bed in a moment!
 
That one seems to work a treat Tom, cheers. Ive now managed to fit the guestbook into my site and it seems to work pretty well. However there seems to be a slight problem with my page in IE6. It works fine in Opera and Firefox. The problem is the top flash element not showing properly. Ive tried to figure out what the problem is, but I can't seem to find it. So are there any glaringly obvious errors in the code?

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


	<head>
		<title>Alasdair Fowler Photography</title>
		<link rel="stylesheet" type="text/css" href="mystyle.css"/>
	</head>

<body> 
	<div align="center">	
		<script type="text/javascript" src="swfobject.js"></script>

		<div id="pinstripesides">
			<div id="monoSlideshow1">
				<p><strong>Please install Flash and turn on Javascript.</strong></p>
			</div>
		
				<div align="center" id="navbar">
					<ul>
					<li><a href="index.html">Home</a></li>
					<li><a href="About.html">About</a></li>
					<li><a href="Messages.html">Messages</a></li>
					<li><a href="Links.html">Links</a></li>
					<li><a href="Contact.html">Contact</a></li>
					</ul>
				</div>

				<div id="content">

					<?php 
					//No Page Caching 
					Header('Cache-Control: no-cache'); 
					Header('Pragma: no-cache'); 

					require "include.php"; //require include file, creates fatal error over include function 

					//Start Session 
					if (session_start() <> True) { 
 					session_start(); 
					} 
					if (isset($_SESSION['allowed']) == False) $_SESSION['allowed'] = "FALSE"; //Admin Session 

					Switch (GetPost("p")) // Page Switching 
    					{ 
        				// ********* Default Page - Gets Comments/Replies ********* 
        				default:  
            			echo htmlHeader(); //echos html headers 
        				?> 

            			<div id="guestbook"><h1>Post A Comment</h1> 
                				<form action="index.php?p=comment" method="post" id="PostForm"> 

                    			<div> 
                        			<ul> 
                            			<li>Name<br/><input type="text" name="comName"></input></li><br/> 
                            			<li>Email<br/><input type="text" name="comEmail"></input></li><br/> 
                            			<li>Comment<br/><textarea name="comCom"></textarea></li><br/> 
                            			<li><input type="submit" value="Post Comment"/>&nbsp;<input type="reset" value="Clear"></li>                              
                       				</ul> 
                    			</div> 

                				</form>

                 				<div id="LoginContainer"><h1>Admin Section</h1>                         
                					<?php 
                					if ($_SESSION['allowed'] == "FALSE") //Not logged in, display loging form 
                    				{ 
                					?> 

							<div id="guestbook">
                    					<form action="index.php?p=admin" method="post" id="LoginForm"> 
                        				<div> 
                            					<ul> 
                                				<li>Username<br/><input type="text" name="adminUser"></input></li><br/> 
                                				<li>Password<br/><input type="password" name="adminPass"></input></li><br/> 
                                				<li><input type="submit" value="Login"/></li> 
                            					</ul> 
                        				</div> 
                    					</form> 
							</div>

                					<?php 
                    				} else { //Logged in, display logout form 
                					?> 

                    				<form action="index.php?p=logout" method="post"> 
                        			<div> 
                            				<ul> 
                                			<li><input type="submit" value="Logout"/></li> 
                            				</ul> 
                        			</div> 
                   				</form> 

				            	<?php 
                    				} 
                					?>     
                				</div> 
            			</div> 
             			<div id="guestbookcomments">
        					<div id="CurrentComments"> 
            					<h1>Comments</h1>         
						</div> 
             
        						<?php //***********Comment retrival PHP****************** 
       						$strdirectory = getcwd()."/data/"; //Gets current working directory, adds the directory data to it 
         
        						// Get comment files in comment (data) directory 
        						$strFiles = array(); 
        						$handle = opendir($strdirectory) or die("Directory not found!"); //Opens directory 
         
        						while($entry = readdir($handle)) //Scans through, uses an array to sort out files and subdirs 
            					{ 
                					if(!is_dir($entry) && $entry != ".." && $entry != ".") 
                    				{ 
                        			$strFiles[] = $entry; 
                    				} 
            					} 
             
        						closedir($handle); //Close handle for directory 
        						sort($strFiles); //Sorts files/directory 
        						$intComCount = count($strFiles); //number of comments (actually files) 
         
        						//Entries numbers 
        						echo "<div id=\"Entries\">"; 
        						if($intComCount > 0){ 
            					if($intComCount == 1){ 
                					echo "1 Entry"; 
            					} else { 
                					echo "$intComCount entries"; 
            					} 
        						} else { 
            					echo "Currently there are no entries in the guestbook.<br/>How about posting a comment?"; 
        						} 
        						echo "</div>"; 
         
        						//Generates comment information 
        						for($i=0; $i < $intComCount; $i++) //Goes through comment files, displays them 
            					{ 
            					displaycomment($strdirectory . $strFiles[$i], $i, $strFiles[$i]); 
            					} 
            					break; 

         
        						//**********************Form Page for Reply ************** 
        						case "reply": 
            					echo htmlHeader(); 
							?> 

            					<div id="guestbook">
								<h1>Post a Reply</h1> 
                						<form action="index.php?p=reply2" method="post" id="PostForm"> 
                						<input type="hidden" name="filenumber" value="<?php echo GetPost("file"); ?>"> 
                    					<div> 
                        					<ul> 
                            					<li>Name<br/><input type="text" name="replyName" class="textentry"></input></li><br/> 
                            					<li>Email<br/><input type="text" name="replyEmail" class="textentry"></input></li><br/> 
                            					<li>Comment<br/><textarea name="replyComment" class="textentry"></textarea></li><br/> 
                            					<li><input type="submit" value="Post Reply"/>&nbsp;<input type="reset" value="Clear"></li> 
                        					</ul> 
                    					</div> 

								<?php 
            						break; 

             
        							//*******************Redirection from Reply form********************* 
        							case "reply2": 
            						if (writeReply(GetPost("filenumber"),GetPost("replyName"), GetPost("replyEmail"), GetPost("replyComment")) != FALSE) 
            						{ 
                						header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); 
            						} else { 
                						echo htmlHeader(); 
                						echo "An Error has occured, Please go back a check the entered data!<br/>"; 
                						echo "<A HREF='javascript:history.go(-1)'>Go Back</A>"; 
            						} 
            						break; 
             
        							case "comment": 
            						if (writeComment(GetPost("comName"), GetPost("comEmail"), GetPost("comCom")) != FALSE) 
            						{ 
                						header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); 
            						} else { 
                						echo htmlHeader(); 
                						echo "An Error has occured, Please go back a check the entered data!<br/>"; 
                						echo "<A HREF=\"javascript:history.go(-1)\">Go Back</A>"; 
            						} 
            						break; 
         

        							//********************* ADMIN LOGIN *****************8         
        							case "admin": 
            						//Admin Username and Password 
            						$strUsr = "CHANGEME"; 
            						$strPass = "CHANGEME"; 
             
            						if (GetPost("adminUser") == $strUsr && GetPost("adminPass") == $strPass) 
            						{ 
                						$_SESSION['allowed'] = "TRUE"; 
                						header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); //redirect back to main page 
            						} else { 
                						echo htmlHeader(); 
                						echo "An Error has occured, Please go back a check the entered data!<br/>"; 
                						echo "<A HREF='javascript:history.go(-1)'>Go Back</A>";     
            						} 
            						break;     

             
            						//*****************ADMIN LOGOUT*****************     
            						case "logout": 
                						session_destroy(); //deletes all sessions 
                						header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); //redirects back to main page 
                						break; 
                 
             
            						//*************DELETE COMMENT************* 
            						case "delete": 
                						if ($_SESSION['allowed'] == "TRUE" && GetPost("file") != "")  
                						{ 
                    					$strDelFile = getcwd()."/data/".GetPost("file").".txt"; 
                    					$fh = fopen($strDelFile, 'w') or die("can't open file"); //Make sure we have complete access to file, isn't already open etc 
                    					fclose($fh); 
                    					if (unlink($strDelFile) == TRUE) 
                    					{ 
                       					header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); //redirects back to main page                     
                    					} else { 
                        				echo htmlHeader(); 
                        				echo "An Error has occured deleting a comment, Please go back and try again!<br/>"; 
                        				echo "<A HREF='javascript:history.go(-1)'>Go Back</A>";     
                    					} 
                						} 
                						break;                     
								} 
								?>     
							</div>
						</div>
					</div>
	
					<script type="text/javascript">
					var fo = new SWFObject("monoslideshow.swf", "FOmonoSlideshow", "800", "100", "7", "#000000");
					fo.addVariable("showLogo", "false");
					fo.addVariable("dataFile", "monoslideshow2.xml");
					fo.write("monoSlideshow1");
					</script>

					<div id="footer">
						<div id="footertext">
							<p>All images and content are the copyright of Alasdair Fowler</p>
						</div>		
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
http://www.afowler.co.uk/index.php

Alsoi what is controlling the size of the gaps between the sections (Admin Section, Comments) etc? And finally, where do I set the Admin password and username? Sorry for the noob questions, but im slowly getting there.
 
Back
Top Bottom