Full-service Internet Marketing & Web Development
Recent Posts

Sponsors
![]() |
V0o039s GuestBookCode Wizard, 12-30-2006 |
This is a nifty little guestbook I built, pretty much from the ground up (with a little help from my Evil Walrus Buddies (and my other buddy Travis.Bickle(http://aphex.bigfathead.com))) to be just a simple, yet editable guestbook.
All you need is to have this file, and one other called "guestbook.txt" in the same directory, the .txt file needs full permissions so the php can write to it.
If you use it, drop me an email at : v0o@v0od0o.com
L8rs
V0o
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////
///Author : V0oD0o
///Topic : Simple Guestbook.
///Notes : A guestbook written with this page
/// and a file containg the comments.
/// Commenting nicked from Trav.(pfff)
///URL: http://www.v0od0o.com
///
///Use: You can use this script or all its parts seperately however you like.
/// I except no responsibility for loss of life, data or cheese sandwiches.
/// If you *do* use it, drop me an email (v0o@v0od0o.com) to let me
// know where you used it so i can have a look!
/// Ammendments: 07/01/01: Rewriting small portion to read backwards,
/// so the latest post is at the top.
///
///Date: 06/01/2002
//////////////////////////////////////////////////////////////////////////////////////////////////
//Change these to suit you = make sure the HTML color *DOES NOT* have the "#"
$pageTitle = "V0o's GuestBook"; //Page Title
$font = "verdana"; //The font Used
$color = "ffffff"; //The Main Font Color
$bgcolor = "000000"; //The page Background Color
$tableColor = "666666"; //The table background color
$fontSize = "1"; //Font size.
$linkColor = "ffffff"; //Link Color.
$visitLink = "ffffff"; //Visited Link Color.
$activeLink = "ffffff"; //Active Link
$formFieldbg = "000000"; //Form Field Background Color
$formFieldOut = "ffffff"; //Form Field Outline Color.
$formFieldText = "ffffff"; //Form Field Text Color.
// ------- +++++++ DO NOT CHANGE ANYTHING BELOW THIS LINE!!! +++++++ -----------
//Globals
$main_file = "guestbook.txt";
//Open the .txt file for reading.
$fp = fopen($main_file, "r");
//Open the file for writing at end of file.
$fpw = fopen($main_file, "r+");
//Start checking - is this a fresh visit or a form?
if ($name && $email && $comments){
//Basic Vandal Checking
$comments = strip_tags($comments, "<b>,</b>,<i>,</i>");
//Remove the pap
$comments = ereg_replace("(
)|(
)|(
)", "<br>", $comments);
//Grab a TimeStamp
$date = date("[d.M.y]-[G:i]");
//Grab the old posts.
$old_comments = fread ($fp, filesize($main_file));
//Close the file.
fclose($fp);
//Make the form contents fgetcsv compatible
$write_to = "$email|$name|$url|$comments|$date
";
//Write it to the file
fputs($fpw, "$write_to $old_comments"); }
//close the file
fclose ($fpw);
?>
<html>
<head>
<?php echo ("<title>".$pageTitle."</title>"); ?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php echo ("<body bgcolor="#$bgcolor" link="#$linkColor" vlink="#$visitLink" alink="#$activeLink">"); ?>
<?php
//echo ("<font color="#ffffff">These are the old comments".$old_comments."</font>");
//Open the file for reading again.
$fp = fopen($main_file, "r");
// Loop through the "guestbook.txt" file, outputting the variables.
while ($stuff = fgetcsv($fp, 9999, "|")){
$comment = stripslashes($stuff[3]);
$num = count ($stuff);
for ($coun=0; $coun<$num; $coun++); {
echo ("<table width="426" border="0" cellspacing="0" cellpadding="2" bgcolor="$tableColor">");
echo ("<tr valign="top">");
echo ("<td width="88"><font size="$fontSize" face="$font" color="#$color"><b>Date:</b></font></td>");
echo ("<td width="330"><font size="$fontSize" face="$font" color="#$color">$stuff[4]</font></td>");
echo ("</tr>");
echo ("<tr valign="top">");
echo ("<td width="88"><font size="$fontSize" face="$font" color="#$color"><b>Name:</b></font></td>");
echo ("<td width="330"><font size="$fontSize" face="$font" color="#$color"><a href="mailto:$stuff[0]">$stuff[1]</a></font></td>");
echo ("</tr>");
echo ("<tr valign="top">");
echo ("<td width="88"><font size="$fontSize" face="$font" color="#$color"><b>URL:</b></font></td>");
echo ("<td width="330"><font size="$fontSize" face="$font" color="#$color"><a href="http://$stuff[2]">$stuff[2]</a></font></td>");
echo ("</tr>");
echo ("<tr valign="top">");
echo ("<td width="88"><font size="$fontSize" face="$font" color="#$color"><b>Comments:</b></font></td>");
echo ("<td width="330"><font size="$fontSize" face="$font" color="#$color">$comment</font></td>");
echo ("</tr>");
echo ("</table>");
echo ("<br>");
}
}
fclose ($fp);
echo ("<form method="post" action="guestbook.php">");
echo ("<table width="502" border="0" cellspacing="0" cellpadding="2">");
echo ("<tr valign="top"> ");
echo ("<td width="116" height="16" valign="middle"><font size="$fontSize" color="#$color" face="$font">Name:</font></td>");
echo ("<td width="378" height="16"><font size="$fontSize" color="#$color" face="$font"> ");
echo ("<input type="text" name="name" size="30" style="border: 1px solid #$formFieldOut; font-family: $font; color: #$formFieldText; background-color: #$formFieldbg;">");
echo ("</font></td>");
echo ("</tr>");
echo ("<tr valign="top">");
echo ("<td width="116" valign="middle"><font size="$fontSize" color="#$color" face="$font">Email</font></td>");
echo ("<td width="378"><font size="$fontSize" color="#$color" face="$font">");
echo ("<input type="text" name="email" size="30" style="border: 1px solid #$formFieldOut; font-family: $font; color: #$formFieldText; background-color: #$formFieldbg;">");
echo ("</font></td>");
echo ("</tr>");
echo ("<tr valign="top">");
echo ("<td height="20" width="116" valign="middle"><font size="$fontSize" color="#$color" face="$font">URL: (HTTP://) </font></td>");
echo ("<td height="20" width="378"><font size="$fontSize" color="#$color" face="$font">");
echo ("<input type="text" name="url" size="30" style="border: 1px solid #$formFieldOut; font-family: $font; color: #$formFieldText; background-color: #$formFieldbg;">");
echo ("</font></td>");
echo ("</tr>");
echo ("<tr valign="top">");
echo ("<td height="71" width="116"><font size="$fontSize" face="$font" color="#$color">Comments:</font></td>");
echo ("<td height="71" width="378"><font size="$fontSize" face="$font" color="#$color">");
echo ("<textarea name="comments" cols="30" rows="12" style="border: 1px solid #$formFieldOut; font-family: $font; color: #$formFieldText; background-color: #$formFieldbg;"></textarea>");
echo ("</font><font size="$fontSize" color="#$color"><br>");
echo ("<br>");
echo ("<input type="submit" name="Submit" value="Post Your Comments" style="border: 1px solid #$formFieldOut; font-family: $font; color: #$formFieldText; background-color: #$formFieldbg;">");
echo ("</font></td>");
echo ("</tr>");
echo ("</table>");
echo ("</form>");
?>
</body>
</html>
|
|
Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments

