SOURCE OF GUEST.PHP
This parses the user-inputted data from guest.html, adds it to guest.txt, then outputs it.


<?php

	$max_length = 2001;
	$the_date = date("F jS, Y  g:ia");
	$guest_name = $_POST["name"];
	$comments = $_POST["comments"];
	$coffee = $_POST["coffee"];
	
	function cleanUp($inputString) {
		
		//GET RID OF WHITESPACE
		$inputString = trim($inputString);
		
		//GET RID OF HTML AND PHP TAGS
		$inputString = strip_tags($inputString);

		//GET RID OF UNESCAPED SLASHES
		$inputString = stripslashes($inputString);
		
		//CONVERT REMAINING TAG CHARACTERS INTO HTML
		$inputString = htmlspecialchars($inputString);
		
		//PUT html breaks where newlines are
		$inputString = nl2br($inputString);
		
		//HAVE FUN FIXING SWEAR WORDS
		//This ireplace (case insenstivie) function doesn't work with versions before 5
		//$inputString = str_ireplace ("fuck", "froop", $inputString);
		$inputString = str_replace ("fuck", "froop", $inputString);
		$inputString = str_replace ("Fuck", "Froop", $inputString);
		$inputString = str_replace ("FUCK", "FROOP", $inputString);
		$inputString = str_replace ("shit", "shwartz", $inputString);
		$inputString = str_replace ("Shit", "Shwartz", $inputString);
		$inputString = str_replace ("SHIT", "SHWARTZ", $inputString);
		$inputString = str_replace ("sh*t", "shwartz", $inputString);
		$inputString = str_replace ("cunt", "cute part", $inputString);
		$inputString = str_replace ("Cunt", "Cute Part", $inputString);
		$inputString = str_replace ("whore", "professional lady", $inputString);
		$inputString = str_replace ("damn", "gosh darn diddy", $inputString);
		$inputString = str_replace ("ass", "donkey", $inputString);
		
		return $inputString;
	}
	
	function whichCupper($cofPref) {
	
		if ($cofPref == "black")
			$my_coffee = "Black";	    
		else if ($cofPref == "cream")
			$my_coffee = "With Cream";		
		else if ($cofPref == "sugar")
			$my_coffee = "With Sugar";
		else if ($cofPref == "creamsugar")
			$my_coffee = "With Cream and Sugar";
		else if ($cofPref == "tea")
			$my_coffee = "I Drink Tea!";
		else
			$my_coffee = "Venti Cafe Latte Skinny with Whip";
	
		return $my_coffee;	
	
	}

	//OPEN GUESTBOOK FILE
	if (! ($f = fopen("guest.txt","a+") ) )
		exit("Error opening guestbook");
	
	//IF FIELDS AREN'T EMPTY
	if( strlen(trim($guest_name)) >= 1 || strlen(trim($comments)) >= 1 ) {
	
		//BLACK BACKGROUND (SO STARS DON'T INTERRUPT WORDS)
		fwrite($f, "<table BGCOLOR='#000000' CELLPADDING='5'><tr><td> </td><td>");
	
		//WRITE DATE
		fwrite($f, "<br /><font color='#33FFFF'> <i>");
		fwrite($f, $the_date);
		fwrite($f, "</i></font>");

		//CLEAN UP AND PUT NAME IN FILE
		fwrite($f, "<br /> <b>Name:  </b>");
		$clean_name = cleanUp($guest_name);
		fwrite($f, $clean_name, $max_length);
		
		//PUT IN COFFEE PREFERENCE
		fwrite($f, "<br /> <b>Coffee?  </b>");
		$coffee = whichCupper($coffee);
		fwrite($f, $coffee, $max_length);

		//CLEAN UP AND PUT COMMENTS IN FILE
		fwrite($f, "<br /> <b>Comments:  </b><br />");
		$clean_comments = cleanUp($comments);
		fwrite($f, $clean_comments, $max_length);
		
		//END OF BLACK BACKGROUND, LINE
		fwrite($f, "</td></tr></table>");
		fwrite($f, "<br /><hr /><br />");

	}
	
	if (! ($f = fopen("guest.txt","r") ) )
		exit("Error opening guestbook");

	//OUTPUT FILE TO HTML GUESTBOOK
	while (!feof($f)) {
		$x = fgetc($f);
	
		//CHECK FOR EXTRA SYMBOLS THAT COULD BE MESSY?
		if ($x == "$")
			echo "$ "; 
		else if ($x == ":") {
			$y = fgetc($f);
			if (ctype_digit($y))
				echo $x . $y;
			else
				echo ": " . $y; 
		}
		else if ($x == "&") {
			$y = fgetc($f);
			if ($y != "q")
				echo "& " . $y; 
			else
				echo $x  . $y;
		}
		else if ($x == "?")
			echo "? "; 
		else
			echo $x;
	}


	fclose($f);

?>