<!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"/> <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"/> <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>