Location: PHPKode > projects > Graphical Guestbook > graphical-guestbook/upload.php3
<?
header("Expires: Sun, Oct 24 1999 22:58:40 BST");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " BST");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

define("FILE", "COUNTER");

function getCount()
	{
	$filename = __FILE__.".COUNT";
	if (file_exists($filename))
		{
		$fd = fopen($filename, "r");
		$count = fgets($fd, 128); # 128 digits of visitor
		fclose($fd);
		}
	else
		echo "The admin needs to <cite>touch ".$filename."</cite> then <cite>chmod 666</cite> it.";
	settype($count, "integer"); # if blank will set to 0
	return $count;
	}

function putCount($count)
	{
	$filename = __FILE__.".COUNT";
	$fd = fopen($filename, "w+");
	settype($count, "string");
	fputs($fd, $count);
	fclose($fd);
	}
?>

<html>
<body alink="#ff0000" link="#0000ee" text="#000000" vlink="#551a8b" bgcolor="#FFFFFF">
<?
$width = 300;
$height = 300;
$next = getCount()+1;

$imagedata = base64_decode($foo);

if ($foo!="" && $next<200) # qad hack to stop using all my space
	{
	$fd = fopen("images/".$next.".png", "w");
	fwrite($fd, $imagedata);
	fclose($fd);
	putCount($next);
	}

echo "<center>";
echo "<table bgcolor=\"#cee2ef\"><tr><td>";
$j = 3;
for ($i=1;$i<$next;$i++)
	{
	$j++;
	if ($j>=3) 
		{
		$j=0;
		echo "<br>";
		}
	echo "&nbsp;<img src=\"image.php3?img=$i.png\">&nbsp;";
	}
echo "</td></tr></table>";
echo "</center>";

echo "<table bgcolor=red><tr><td>";
echo "<applet code=\"Scribble.class\" width=".$width." height=".$height."></applet>";
echo "</td></tr></table>";

echo "<p>Please draw your entry and hit submit. Wait for the message that the data is sent. You will need to reload your page to see the current submission</p>";

?>

<p>
Image <a href="images">archive</a>
</p>

</body>
</html>
Return current item: Graphical Guestbook