Location: PHPKode > projects > PBL Guestbook > pbl-guestbook/pblguestbook.php
<?php
$language = 'en'; // en for english
$template = 'template.html'; // must be valid!
$thisprogram = 'pblguestbook.php'; // change this if you rename this file

// MYSQL REQUIRED PARAMETERS
$GLOBALS['sqlhost'] = 'localhost';
$GLOBALS['sqluser'] = 'username';
$GLOBALS['sqlpass'] = 'password';
$GLOBALS['sqldbnm'] = 'database_name';

////////////////////////////////////////
// NOTHING ELSE NEEDS TO BE MODIFIED! :)
////////////////////////////////////////

// ESTABLISH A MYSQL CONNECTION
mysql_connect ($GLOBALS['sqlhost'], $GLOBALS['sqluser'], $GLOBALS['sqlpass']);
mysql_select_db ($GLOBALS['sqldbnm']);

// CHECK FOR CUSTOM LANGUAGE FILE IF REQUESTED
if (file_exists("pblguestbook_language_$language.php"))
	{
	require ("pblguestbook_language_$language.php");
	}
else
	{
	require ("pblguestbook_language_en.php");
	}

$program = "PBL GuestBook v 1.32"; // name and version of script (do not change; will fail)
list($progname,$version) = split (" v ",$program);
$progname = str_replace(" ","_",$progname);

$config = get_config();
$fontface = $config['fontface'];
$fontsize = $config['fontsize'];
$fontcolor = $config['fontcolor'];
$booktitle = $config['title'];

$data .= "\n<BR>\n";

if ($config['password'] == '' && $_GET['action'] != 'install') {header("Location: $thisprogram?action=install"); exit;}

// AUTOMATICALLY ADD THE NEW OPTIONS PARAMETERS FOR USERS WHO ARE UPGRADING FROM AN OLDER VERSION
if (!isset($config['icode_req']))
	{
	@mysql_query("ALTER TABLE `pblguestbook_config` ADD `icode_req` INT( 1 ) DEFAULT '1' NOT NULL ;");
	}
if (!isset($config['icode_font']))
	{
	@mysql_query("ALTER TABLE `pblguestbook_config` ADD `icode_font` TINYTEXT NOT NULL ;");
	mysql_query("UPDATE `pblguestbook_config` SET `icode_font` = 'actionj.ttf'");
	}
if (!isset($config['icode_bgimg']))
	{
	@mysql_query("ALTER TABLE `pblguestbook_config` ADD `icode_bgimg` TINYTEXT NOT NULL ;");
	mysql_query("UPDATE `pblguestbook_config` SET `icode_bgimg` = 'imgcodebg.gif'");
	}
if (!isset($config['icode_fontsize']))
	{
	@mysql_query("ALTER TABLE `pblguestbook_config` ADD `icode_fontsize` TINYTEXT NOT NULL ;");
	mysql_query("UPDATE `pblguestbook_config` SET `icode_fontsize` = '30'");
	}
if (!isset($config['icode_fontcolor']))
	{
	@mysql_query("ALTER TABLE `pblguestbook_config` ADD `icode_fontcolor` TINYTEXT NOT NULL ;");
	mysql_query("UPDATE `pblguestbook_config` SET `icode_fontcolor` = '#000000'");
	}
if (!isset($config['icode_bgcolor']))
	{
	@mysql_query("ALTER TABLE `pblguestbook_config` ADD `icode_bgcolor` TINYTEXT NOT NULL ;");
	mysql_query("UPDATE `pblguestbook_config` SET `icode_bgcolor` = '#FFFFFF'");
	}
if (!isset($config['appfirst']))
	{
	@mysql_query("ALTER TABLE `pblguestbook_config` ADD `appfirst` INT( 1 ) DEFAULT '0' NOT NULL ;");
	@mysql_query("ALTER TABLE `pblguestbook_posts` ADD `app` INT( 1 ) DEFAULT '1' NOT NULL ;");
	}


if ($config['icode_req'] == '1')
	{
	require ("imgcode.php");
	}


if ($_GET['action'] == 'view')
	{
	if ($_GET['start'] == '' || $_GET['start'] == '0')
		{
		$start = '0';
		}
	else
		{
		$start = $_GET['start'];
		$back = "<A STYLE=COLOR:$config[link]; HREF=\"$thisprogram?action=view&start=" . ($start - $config['perpage']);
		$back .= "\" STYLE=\"text-decoration:none;\">&#171; " . $mes['previous'] . "</A>";
		$back = str_replace("&start=0","",$back);
		}
	$end = $start + $config['perpage'];
	$totalres = mysql_query("SELECT * FROM `pblguestbook_posts`");
	$totalposts = mysql_num_rows($totalres);
	if ($totalposts > $end)
		{
		$next = "<A STYLE=COLOR:$config[link]; HREF=\"$thisprogram?action=view&start=" . ($start + $config['perpage']);
		$next .= "\" STYLE=\"text-decoration:none;\">" . $mes['next'] . " &#187;</A>";
		}
	if ($back != '' && $next != '') {$div = "&nbsp;&middot;&nbsp;";}
	$picount = 0;
	$maxpages = $totalposts / $config['perpage'];
	if (ereg("\.",$maxpages))
		{
		list ($maxpages,$remainder) = split("\.",$maxpages);
		$maxpages++;
		}
	for ($i = 1; $i <= $maxpages; $i++)
		{
		if ($i > 1)
			{
			$picount += $config['perpage'];
			}
		if ($picount == $start)
			{
			$isipage = "SELECTED";
			}
		else
			{
			$isipage = "";
			}
		$piurl = "$thisprogram?action=view&start=$picount";
		$piurl = str_replace("&start=0","",$piurl);
		$pilist .= "<OPTION onMouseDown=\"window.location.href='$piurl';\" $isipage>$i</OPTION>";
		}
	$title = str_replace('$booktitle',$booktitle,$mes['page_view_title']);
	$predata .= "<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%><TD>";
	$predata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">\n";
	$predata .= "<B>$booktitle &#187; <I>" . strtoupper($mes['view']);
	$predata .= "</I></B> (<A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=sign>" . $mes['sign'];
	$predata .= "</A>)</TD><TD STYLE=TEXT-ALIGN:right;><SELECT STYLE=\"FONT-SIZE:10;FONT-FAMILY;Arial;\" NAME=page>$pilist</SELECT> <SMALL>$back$div$next</SMALL></TD></TABLE>";
	$data .= ontable($predata) . "\n<P>\n";
	$enditem = $config['perpage'];
	$result = mysql_query("SELECT `id` FROM `pblguestbook_posts` WHERE `app` = '1' ORDER BY `time` DESC LIMIT $start,$enditem");
	while ($myrow = mysql_fetch_array($result))
		{
		$pdata = make_post($myrow['id']);
		$data .= ontable($pdata) . "\n<P>\n";
		}
	}


elseif ($_GET['action'] == 'sign')
	{
	$_POST['website'] = str_replace("http://","",$_POST['website']);
	$lastres = mysql_query("SELECT * FROM `pblguestbook_posts` ORDER BY `time` DESC LIMIT 1");
	$lr = mysql_fetch_array($lastres);
	$newtime = time();
	$newtime += ($config['timezone'] * 3600);
	if (($newtime - $lr['time']) <= $config['hamsecs'] && $lr['ip'] == $_SERVER['REMOTE_ADDR'] && $config['hammer'] == '1')
		{
		$hammer = 'y';
		}
	if ($_POST['name'] != '' && $hammer != 'y' && $_POST['preview'] == '' && strtoupper($_POST['icode']) == get_image_code())
		{
		foreach ($_POST as $name => $value)
			{
			$_POST["$name"] = str_replace("\n","<BR>",$value);
			}
		foreach ($_POST as $name => $value)
			{
			$_POST["$name"] = str_replace("\t","",$value);
			}
		foreach ($_POST as $name => $value)
			{
			$_POST["$name"] = str_replace("\r","",$value);
			}
		foreach ($_POST as $name => $value)
			{
			$_POST["$name"] = str_replace('|',"&#166;",$value);
			}
		foreach ($_POST as $name => $value)
			{
			$_POST["$name"] = preg_replace("/\<SCRIPT(.*?)\>(.*?)\<\/SCRIPT(.*?)\>/i", "SCRIPT BLOCKED", $value);
			}
		if ($config['customq1'] != '' && $_POST['customq1'] != '')
			{
			$config['customq1'] = str_replace('\'','\\\'',$config['customq1']);
			$conqd1 = "$config[customq1]|$_POST[customq1]";
			}
		if ($config['customq2'] != '' && $_POST[customq2] != '')
			{
			$config['customq2'] = str_replace('\'','\\\'',$config['customq2']);
			$conqd2 = "$config[customq2]|$_POST[customq2]";
			}
		if ($config['customq3'] != '' && $_POST['customq3'] != '')
			{
			$config['customq3'] = str_replace('\'','\\\'',$config['customq3']);
			$conqd3 = "$config[customq3]|$_POST[customq3]";
			}
		if ($config['customq4'] != '' && $_POST['customq4'] != '')
			{
			$config['customq4'] = str_replace('\'','\\\'',$config['customq4']);
			$conqd4 = "$config[customq4]|$_POST[customq4]";
			}
		if ($config['customq5'] != '' && $_POST['customq5'] != '')
			{
			$config['customq5'] = str_replace('\'','\\\'',$config['customq5']);
			$conqd5 = "$config[customq5]|$_POST[customq5]";
			}
		$time = time();
		$time += ($config['timezone'] * 3600);
		if ($config['appfirst'] == '1')
			{
			$appmode = "0";
			$appwarnnotice = "<P>" . $mes['must_approved_first'];
			}
		else
			{
			$appmode = "1";
			}
		$query = "INSERT INTO `pblguestbook_posts` (`name`,`email`,`ip`,`time`,`website`,`customq1`,`customq2`,";
		$query .= "`customq3`,`customq4`,`customq5`,`rate`,`comments`,`private`,`app`) VALUES('$_POST[name]',";
		$query .= "'$_POST[email]','$_SERVER[REMOTE_ADDR]','$time','$_POST[website]',";
		$query .= "'$conqd1','$conqd2','$conqd3','$conqd4','$conqd5',";
		$query .= "'$_POST[rate]','$_POST[comments]','$_POST[private]','$appmode')";
		if (mysql_query($query))
			{
			if ($config['notify'] == '1' && $config['email'] != '')
				{
				$mes['notify_subject'] = str_replace('$booktitle',$booktitle,$mes['notify_subject']);
				$mes['notify_text'] = str_replace('$booktitle',$booktitle,$mes['notify_text']);
				mail ($config['email'],$mes['notify_subject'],$mes['notify_text']);
				}
			$result = $mes['post_success'] . $appwarnnotice;
			}
		else
			{
			$result = $mes['post_failure'];
			}
		$data .= ontable($result) . "<P>";
		}
	elseif ($_POST['name'] != '' && $hammer == 'y' && $_POST['preview'] == '')
		{
		$data .= ontable($mes['error_hammering']) . "\n<P>\n";
		}
	elseif ($_POST['name'] != '' && strtoupper($_POST['icode']) != get_image_code() && $_POST['preview'] == '' && $config['icode_req'] == '1')
		{
		$data .= ontable($mes['error_icode']) . "\n<P>\n";
		}
	elseif ($_POST['name'] != '' && $_POST['preview'] != '')
		{
		$time = time();
		$time += ($config['timezone'] * 3600);
		foreach ($_POST as $name => $value)
			{
			$_POST["$name"] = str_replace("\n","<BR>",$value);
			}
		foreach ($_POST as $name => $value)
			{
			$_POST["$name"] = str_replace("\t","",$value);
			}
		foreach ($_POST as $name => $value)
			{
			$_POST["$name"] = str_replace("\r","",$value);
			}
		foreach ($_POST as $name => $value)
			{
			$_POST["$name"] = str_replace('|',"&#166;",$value);
			}
		foreach ($_POST as $name => $value)
			{
			$_POST["$name"] = preg_replace("/\<SCRIPT(.*?)\>(.*?)\<\/SCRIPT(.*?)\>/i", "SCRIPT BLOCKED", $value);
			}
		$pdata = "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>";
		$pdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['posted_by'];
		$pdata .= ": <B>$_POST[name]</B> &middot; " . $mes['time'] . ": <B>" . date("g:ia d M. Y",$time);
		$pdata .= "</B>";
		if ($_POST['email'] != '')
			{
			$emailbut = "&nbsp;<A STYLE=COLOR:$config[link]; HREF=\"mailto:$_POST[email]\"><IMG SRC=$config[emailbut] BORDER=0 ALT=\"";
			$emailbut .= $mes['email'] . "\"></A>&nbsp;";
			}
		if ($_POST['website'] != '')
			{
			if ($emailbut != '') {$space = "&nbsp;";}
			$homebut = "&nbsp;<A STYLE=COLOR:$config[link]; HREF=\"http://$_POST[website]\"><IMG SRC=$config[homebut] BORDER=0 ALT=\"";
			$homebut .= $mes['website'] . "\"></A>&nbsp;";
			}
		if ($_SERVER['REMOTE_ADDR'] != '' && $config['showip'] == '1')
			{
			if ($homebut != '') {$space2 = "&nbsp;";}
			$ipbut = "&nbsp;<IMG SRC=$config[ipbut] BORDER=0 ALT=\"";
			$ipbut .= $_SERVER[REMOTE_ADDR] . "\">&nbsp;";
			}
		if ($ipbut != '') {$space3 = "&nbsp;";}
		$delbut = "&nbsp;<A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=delete&id=$_POST[id]><IMG SRC=$config[delbut] BORDER=0 ALT=\"";
		$delbut .= $mes['delete'] . "\"></A>&nbsp;";
		$pdata .= "</TD><TD STYLE=TEXT-ALIGN:right;><FONT SIZE=1>$emailbut$homebut$ipbut$delbut</FONT></TD></TR>";
		if ($_POST['customq1'] || $_POST['customq2'] || $_POST['customq2'] || $_POST['customq2'] || $_POST['customq2'] || $_POST['rate'])
			{
			$pdata .= "<TR><TD COLSPAN=2 HEIGHT=20></TD></TR>";
			}
		if ($_POST['customq1'] != '')
			{
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>$config[customq1]:</B> <I>" . stripslashes($_POST['customq1']) . "</I></SMALL></FONT></TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($_POST['customq2'] != '')
			{
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>$config[customq2]:</B> <I>" . stripslashes($_POST['customq2']) . "</I></SMALL></FONT></TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($_POST['customq3'] != '')
			{
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>$config[customq3]:</B> <I>" . stripslashes($_POST['customq3']) . "</I></SMALL></FONT></TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($_POST['customq4'] != '')
			{
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>$config[customq4]:</B> <I>" . stripslashes($_POST['customq4']) . "</I></SMALL></FONT></TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($_POST['customq5'] != '')
			{
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>$config[customq5]:</B> <I>" . stripslashes($_POST['customq5']) . "</I></SMALL></FONT></TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($_POST['rate'] != '' && $config['rate'] == '1')
			{
			$postrate = "<OPTION VALUE=$_POST[rate]>$_POST[rate]</OPTION>";
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>" . $mes['ratesite'] . ":</B> <I>" . $_POST['rate'] . "</I></SMALL></FONT>";
			$pdata .= "</TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($_POST['comments'] != '')
			{
			$tempcomments = $_POST['comments'];
			if ($config['html'] != '1')
				{
				$tempcomments = str_replace("<","&LT;",$tempcomments);
				$tempcomments = str_replace(">","&GT;",$tempcomments);
				$tempcomments = str_replace("&LT;BR&GT;","<BR>",$tempcomments);
				}
			if ($config['emoticons'] == '1')
				{
				$tempcomments = str_replace(":)","<IMG SRC=\"" . $config['emo_smile'] .
				"\" ALIGN=ABSMIDDLE>",$tempcomments);
				$tempcomments = str_replace(":D","<IMG SRC=\"" . $config['emo_grin'] .
				"\" ALIGN=ABSMIDDLE>",$tempcomments);
				$tempcomments = str_replace(";)","<IMG SRC=\"" . $config['emo_wink'] .
				"\" ALIGN=ABSMIDDLE>",$tempcomments);
				$tempcomments = str_replace(":(","<IMG SRC=\"" . $config['emo_frown'] .
				"\" ALIGN=ABSMIDDLE>",$tempcomments);
				$tempcomments = str_replace(":P","<IMG SRC=\"" . $config['emo_tongue'] .
				"\" ALIGN=ABSMIDDLE>",$tempcomments);
				}
			$pdata .= "<TR><TD COLSPAN=2><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<BR><BLOCKQUOTE><SMALL>" . stripslashes($tempcomments) . "</SMALL></BLOCKQUOTE></FONT></TD></TR>";
			}
		$_POST['comments'] = str_replace("<BR>","\n",$_POST['comments']);
		if ($_POST['private'] == '1') {$isprivate = "CHECKED";}
		$pdata .= "</TABLE>";
		$data .= ontable($pdata) . "\n<P>\n";
		}


	$title = str_replace('$booktitle',$booktitle,$mes['page_sign_title']);
	$predata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">\n";
	$predata .= "<B>$booktitle &#187; <I>" . strtoupper($mes['sign']);
	$predata .= "</I></B> (<A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=view>" . $mes['view'];
	$predata .= "</A>)";
	$data .= ontable($predata) . "<P>";
	$signdata .= "<FORM ACTION=$thisprogram?action=sign METHOD=POST><TABLE WIDTH=100%>";
	$signdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['name'];
	$signdata .= ":</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=name SIZE=30 VALUE=\"$_POST[name]\"></TD></TR>";
	$signdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['email'];
	$signdata .= ":</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=email SIZE=30 VALUE=$_POST[email]></TD></TR>";
	$signdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['website'];
	$signdata .= ":</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=website SIZE=30 VALUE=\"http://" . $_POST[website];
	$signdata .= "\"></TD></TR>";
	if ($config['customq1'] != '')
		{
		$signdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $config['customq1'];
		$signdata .= ":</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=customq1 SIZE=30 VALUE=\"" . stripslashes($_POST['customq1']) . "\"></TD></TR>";
		}
	if ($config['customq2'] != '')
		{
		$signdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $config['customq2'];
		$signdata .= ":</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=customq2 SIZE=30 VALUE=\"" . stripslashes($_POST['customq2']) . "\"></TD></TR>";
		}
	if ($config['customq3'] != '')
		{
		$signdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $config['customq3'];
		$signdata .= ":</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=customq3 SIZE=30 VALUE=\"" . stripslashes($_POST['customq3']) . "\"></TD></TR>";
		}
	if ($config['customq4'] != '')
		{
		$signdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $config['customq4'];
		$signdata .= ":</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=customq4 SIZE=30 VALUE=\"" . stripslashes($_POST['customq4']) . "\"></TD></TR>";
		}
	if ($config['customq5'] != '')
		{
		$signdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $config['customq5'];
		$signdata .= ":</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=customq5 SIZE=30 VALUE=\"" . stripslashes($_POST['customq5']) . "\"></TD></TR>";
		}
	if ($config['rate'] == '1')
		{
		$signdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['ratesite'];
		$signdata .= ":</TD><TD ALIGN=RIGHT><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
		$signdata .= $mes['ten_is_high'] . " <SELECT NAME=rate>" . $postrate;
		$signdata .= "<OPTION VALUE=\"\">--</OPTION>";
		$signdata .= "<OPTION VALUE=1>1</OPTION>";
		$signdata .= "<OPTION VALUE=2>2</OPTION>";
		$signdata .= "<OPTION VALUE=3>3</OPTION>";
		$signdata .= "<OPTION VALUE=4>4</OPTION>";
		$signdata .= "<OPTION VALUE=5>5</OPTION>";
		$signdata .= "<OPTION VALUE=6>6</OPTION>";
		$signdata .= "<OPTION VALUE=7>7</OPTION>";
		$signdata .= "<OPTION VALUE=8>8</OPTION>";
		$signdata .= "<OPTION VALUE=9>9</OPTION>";
		$signdata .= "<OPTION VALUE=10>10</OPTION>";
		$signdata .= "</SELECT></TD></TR>";
		}
	$_POST['comments'] = stripslashes($_POST['comments']);
	$signdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['comments'];
	$signdata .= ":</TD><TD ALIGN=RIGHT><TEXTAREA ROWS=6 COLS=30 NAME=comments>$_POST[comments]</TEXTAREA></TD></TR>";
	$signdata .= "<TR><TD COLSPAN=2 ALIGN=RIGHT><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
	$signdata .= $mes['make_private'] . " <INPUT TYPE=CHECKBOX NAME=private VALUE=1 $isprivate></TD></TR>";
	if ($config['icode_req'] == '1')
		{
		$signdata .= "<TR><TD COLSPAN=2><BR></TD></TR>";
		$signdata .= "<TR><TD><IMG SRC=$thisprogram?action=imgcode ALIGN=MIDDLE> :</TD><TD><INPUT TYPE=TEXT NAME=icode SIZE=30 VALUE=\"" . $_POST['icode'] . "\"></TD></TR>";
		}
	$signdata .= "</TABLE>";
	$data .= ontable($signdata);
	$data .= "<P>\n<CENTER>\n";
	$data .= "<INPUT TYPE=SUBMIT NAME=preview VALUE=\"" . $mes['preview'] . "\">";
	$data .= "&nbsp;&nbsp;&nbsp;<INPUT TYPE=SUBMIT NAME=post VALUE=\"-----> " . $mes['post'] . " <-----\"></FORM>";
	}


elseif ($_GET['action'] == 'delete' && $_GET['id'] != '')
	{
	$title = $mes['delete'];
	if ($_COOKIE['pblguestbook'] != '')
		{
		mysql_query("DELETE FROM `pblguestbook_posts` WHERE `id` = '$_GET[id]'");
		$result = $mes['post_delete_success'] . " [ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=view>" . $mes['view'] . "</A> ]";
		}
	else
		{
		$result = $mes['post_delete_failure'] . " [ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=view>" . $mes['view'] . "</A> ]";
		}
	$data .= ontable($result) . "\n<P>\n";
	}


elseif ($_GET['action'] == 'approve')
	{
	$title = $mes['approve'];
	if ($_COOKIE['pblguestbook'] == '')
		{
		$data .= ontable($mes['error_login_first'] . "<P><BLOCKQUOTE>" .
		" [ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=admin>" . $mes['page_admin_title'] . "</A> ]</BLOCKQUOTE>") . "\n<P>\n";
		}
	else
		{
		if (isset($_GET['id']))
			{
			$updquery = "UPDATE `pblguestbook_posts` SET `app` = '1' WHERE `id` = '" . $_GET['id'] . "'";
			if (mysql_query($updquery))
				{
				$data .= ontable($mes['post_approved']) . "\n<P>\n";
				}
			}
		$result = mysql_query("SELECT `id` FROM `pblguestbook_posts` WHERE `app` = '0' ORDER BY `time`");
		if (mysql_num_rows($result) > 0)
			{
			while ($myrow = mysql_fetch_array($result))
				{
				$pdata = make_post($myrow['id'],2);
				$data .= ontable($pdata) . "\n<P>\n";
				}
			}
		else
			{
			$data .= ontable($mes['none_to_approve']) . "\n<P>\n";
			}
		}
	}


elseif ($_GET['action'] == 'backup' && $_GET['type'] != '')
	{
	$title = $mes['backup'];
	if ($_COOKIE['pblguestbook'] == '')
		{
		$data .= ontable($mes['error_login_first'] . "<P><BLOCKQUOTE>" .
		" [ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=admin>" . $mes['page_admin_title'] . "</A> ]</BLOCKQUOTE>") . "\n<P>\n";
		}
	else
		{
		$query = "SELECT * FROM `pblguestbook_" . $_GET['type'] . "`";
		$res = mysql_query($query);
		while ($row = mysql_fetch_array($res, MYSQL_ASSOC))
			{
			$budata .= "INSERT INTO `pblguestbook_$_GET[type]` (";
			$rowcount = count($row);
			$count = '0';
			foreach ($row as $iname => $ivalue)
				{
				$count++;
				$budata .= "`$iname`";
				if ($count != $rowcount) {$budata .= ', ';}
				}
			$budata .= ") VALUES (";
			$count = '0';
			foreach ($row as $iname => $ivalue)
				{
				$count++;
				$ivalue = str_replace('\'','\\\'',$ivalue);
				$ivalue = str_replace("\r","",$ivalue);
				$ivalue = str_replace("\n",'<!-- MYSQL NEW LINE -->',$ivalue);
				$budata .= "'" . $ivalue . "'";
				if ($count != $rowcount) {$budata .= ', ';}
				}
			$budata .= ");\r\n";
			}
		//$budata = str_replace("\r","",$budata);
		$location = "pblguestbook_backup_" . $_GET['type'] . ".txt";
		$fh = fopen($location,"w+");
		fwrite ($fh,$budata);
		fclose ($fh);
		$mes['page_view_title'] = str_replace('$booktitle',$booktitle,$mes['page_view_title']);
		$mes['backup_created'] = str_replace('$type',$_GET['type'],$mes['backup_created']);
		$mes['backup_created'] = str_replace('$location',$location,$mes['backup_created']);
		$data .= ontable($mes['backup_created'] . "<P><BLOCKQUOTE>" .
		" [ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=admin>" . $mes['page_admin_title'] . "</A> ]</BLOCKQUOTE>") . "\n<P>\n";
		}
	}


elseif ($_GET['action'] == 'restore' && $_GET['type'] != '')
	{
	$title = $mes['restore'];
	if ($_COOKIE['pblguestbook'] == '')
		{
		$data .= ontable($mes['error_login_first'] . "<P><BLOCKQUOTE>" .
		" [ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=admin>" . $mes['page_admin_title'] . "</A> ]</BLOCKQUOTE>") . "\n<P>\n";
		}
	else
		{
		$filedata = file_get_contents("pblguestbook_backup_" . $_GET['type'] . ".txt");
		$filearray = explode("\n",$filedata);
		$query2 = "TRUNCATE TABLE `pblguestbook_" . $_GET['type'] . "`";
		mysql_query($query2);
		foreach ($filearray as $line)
			{
			$line = str_replace("\r","",$line);
			$line = str_replace("\n","",$line);
			mysql_query($line);
			}
		$mes['backup_restored'] = str_replace('$type',$_GET['type'],$mes['backup_restored']);
		$data .= ontable($newdata . $mes['backup_restored'] . "<P><BLOCKQUOTE>" .
		" [ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=admin>" . $mes['page_admin_title'] . "</A> ]</BLOCKQUOTE>") . "\n<P>\n";
		}
	}


elseif ($_GET['action'] == 'password')
	{
	$title = $mes['update_password'];
	$_POST['pass1'] = stripslashes($_POST['pass1']);
	if ($_COOKIE['pblguestbook'] == '')
		{
		$data .= ontable($mes['error_login_first'] . "<P><BLOCKQUOTE>" .
		" [ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=admin>" . $mes['page_admin_title'] . "</A> ]</BLOCKQUOTE>") . "\n<P>\n";
		}
	else
		{
		if (md5($_POST['oldpass']) == $config['password'] && $_POST['pass1'] == $_POST['pass2'] && $_POST['pass1'])
			{
			$md5pass = md5($_POST['pass1']);
			mysql_query("UPDATE `pblguestbook_config` SET `password` = '$md5pass'");
			$data .= ontable($newdata . $mes['password_updated'] . "<P><BLOCKQUOTE>" .
			" [ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=admin>" . $mes['page_admin_title'] . "</A> ]</BLOCKQUOTE>") . "\n<P>\n";
			}
		elseif ($_POST['pass1'] != $_POST['pass2'])
			{
			$data .= ontable($mes['error_pass_twice']) . "\n<P>\n";
			}
		$pdata .= "<FORM ACTION=$thisprogram?action=password METHOD=POST>\n<CENTER>\n";
		$pdata .= "<TABLE>";
		$pdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['old_password'];
		$pdata .= ":</TD><TD><INPUT TYPE=PASSWORD NAME=oldpass SIZE=24></TD></TR>";
		$pdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['new_password'];
		$pdata .= ":</TD><TD><INPUT TYPE=PASSWORD NAME=pass1 SIZE=24></TD></TR>";
		$pdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['new_password2'];
		$pdata .= ":</TD><TD><INPUT TYPE=PASSWORD NAME=pass2 SIZE=24></TD></TR>";
		$pdata .= "</TABLE><P><INPUT TYPE=SUBMIT VALUE=\"" . $mes['update_password'] . "\"></FORM>\n</CENTER>\n";
		$data .= ontable($pdata) . "\n<P>\n";
		}
	}


elseif ($_GET['action'] == 'install')
	{
	$title = $mes['install'];
	if ($_COOKIE['pblguestbook'] == '' && $config['password'] != '')
		{
		$data .= ontable($mes['error_login_first']) . "\n<P>\n";
		}
	else
		{
		mysql_query("DROP TABLE `pblguestbook_config`");
		mysql_query("DROP TABLE `pblguestbook_posts`");

		$query = "CREATE TABLE `pblguestbook_config` (
		`title` text NOT NULL,
		`timezone` text NOT NULL,
		`password` text NOT NULL,
		`fontsize` text NOT NULL,
		`fontface` text NOT NULL,
		`fontcolor` text NOT NULL,
		`link` text NOT NULL,
		`tablebordercolor` text NOT NULL,
		`tableborderx` text NOT NULL,
		`tablebgcolor` text NOT NULL,
		`width` text NOT NULL,
		`perpage` int(3) NOT NULL default '0',
		`showip` int(1) NOT NULL default '0',
		`html` int(1) NOT NULL default '0',
		`rate` int(1) NOT NULL default '0',
		`hammer` int(1) NOT NULL default '0',
		`notify` int(1) NOT NULL default '0',
		`emoticons` int(1) NOT NULL default '0',
		`customq1` text NOT NULL,
		`customq2` text NOT NULL,
		`customq3` text NOT NULL,
		`customq4` text NOT NULL,
		`customq5` text NOT NULL,
		`emailbut` text NOT NULL,
		`homebut` text NOT NULL,
		`ipbut` text NOT NULL,
		`delbut` text NOT NULL,
		`emo_smile` text NOT NULL,
		`emo_frown` text NOT NULL,
		`emo_grin` text NOT NULL,
		`emo_wink` text NOT NULL,
		`emo_tongue` text NOT NULL,
		`hamsecs` int(6) NOT NULL default '30',
		`email` text NOT NULL
		) TYPE=MyISAM;";

		mysql_query($query);

		$query = "INSERT INTO `pblguestbook_config` VALUES ('pblguestbook', '', '25f66d09583995c8fbf858e439e0ab33',";
		$query .= " '2', 'Arial', '#404040', '#00008B', ";
		$query .= "'#808080', '1', '#E0E0E0', '500', 20, 0, 0, 0, 0, 0, 0, '', '', '', '', '', ";
		$query .= "'but_email.gif', 'but_home.gif', 'but_ip.gif', 'but_del.gif', 'smile.gif', ";
		$query .= "'frown.gif', 'grin.gif', 'wink.gif', 'tongue.gif', 60, '');";
    
		mysql_query($query);

		$query = "CREATE TABLE `pblguestbook_posts` (
		`id` int(10) NOT NULL auto_increment,
		`name` text NOT NULL,
		`email` text NOT NULL,
		`ip` text NOT NULL,
		`time` text NOT NULL,
		`website` text NOT NULL,
		`customq1` longtext NOT NULL,
		`customq2` longtext NOT NULL,
		`customq3` longtext NOT NULL,
		`customq4` longtext NOT NULL,
		`customq5` longtext NOT NULL,
		`rate` int(2) NOT NULL default '0',
		`comments` longtext NOT NULL,
		`private` int(1) NOT NULL default '0',
		PRIMARY KEY  (`id`)
		) TYPE=MyISAM AUTO_INCREMENT=1;";

		mysql_query($query);

		$adminlink = "&nbsp;[ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=admin&password=pbl>" . $mes['page_admin_title'] . "</A>] ";

		$data .= ontable($mes['install_success'] . $adminlink) . "\n<P>\n";
		}
	}


elseif ($_GET['action'] == 'admin')
	{
	$title = $mes['page_admin_title'];
	$data .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">\n";
	if ($_POST['process'] == 'y' && $_COOKIE['pblguestbook'] != '')
		{
		$result = save_config();
		if (mysql_query($result))
			{
			$result = $mes['config_saved'] . " [ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=view>" . $mes['view'] . "</A> ]";
			}
		else
			{
			$result = $result . $mes['config_save_error'];
			}
		$data .= ontable("... " . $result) . "\n<P>";
		$config = get_config(); // get updated config info for form
		$fontface = $config['fontface'];
		$fontsize = $config['fontsize'];
		$fontcolor = $config['fontcolor'];
		$booktitle = $config['title'];
		setcookie ("pblguestbook",$_POST['password'],"0");
		}
	if ($_COOKIE['pblguestbook'] != $config['password'] && md5($_POST['password']) != $config['password'])
		{
		$predata .= "<CENTER>" . str_replace('$booktitle',$booktitle,$mes['att_login_to_admin']) . "<P>\n";
		$predata .= "<FORM ACTION=$thisprogram?action=admin METHOD=POST>\n";
		$predata .= $mes['password'] . ": <INPUT TYPE=PASSWORD NAME=password VALUE=\"" . $_GET[password];
		$predata .= "\"> <INPUT TYPE=SUBMIT VALUE=\"";
		$predata .= $mes['login'] . "\">\n</FORM>\n";
		$data .= ontable($predata);
		}
	elseif ($_COOKIE['pblguestbook'] != $config['password'] && md5($_POST['password']) == $config['password'] && $_POST['process'] == '')
		{
		setcookie ("pblguestbook",md5($_POST['password']),"0");
		header ("Location: $thisprogram?action=admin");
		}
	else
		{
		$adda .= "<CENTER><B STYLE=LETTER-SPACING:5px;>";
		if ($config['appfirst'] == '1')
			{
			$adda .= "[ <A HREF=$thisprogram?action=approve>" . $mes['approve'] . "</A> ]&nbsp;";
			}
		$adda .= "[ <A HREF=$thisprogram?action=view>" . $mes['view'] . "</A> ] [ <A HREF=$thisprogram?action=sign>" . $mes['sign'] . "</A> ]</B><P>[ <A HREF=$thisprogram?action=password>" . $mes['not_change_password'] . "</A> ]</CENTER><P>";
		$adda .= "<CENTER><FORM ACTION=$thisprogram?action=admin METHOD=POST>";
		$adda .= "<INPUT TYPE=HIDDEN NAME=process VALUE=y><TABLE WIDTH=100% BGCOLOR=\"$config[tablebgcolor]\">\n";
		$adda .= "<TR><TD WIDTH=150>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['version'];
		$adda .= "&#185;:</FONT>";
		$adda .= "</TD><TD WIDTH=* ALIGN=RIGHT><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
		$adda .= "<B>$version</B> <A STYLE=COLOR:$config[link]; HREF=http://www.pixelatedbylev.com/au.php?p=$progname&v=$version>[";
		$adda .= $mes['auto_update'] . "]</A></FONT>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD WIDTH=150>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['language'];
		$adda .= "&#178;:</FONT>";
		$adda .= "</TD><TD WIDTH=* ALIGN=RIGHT><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
		$adda .= strtoupper($language);
		$adda .= " (pblguestbook_language_$language.php)</FONT>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['title_of_book'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=title VALUE=\"" . $config['title']. "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['timezone_offset'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
		$adda .= $mes['24_24'] . "&nbsp;<INPUT TYPE=TEXT NAME=timezone VALUE=\"" . $config['timezone']. "\" SIZE=2 MAXLENGTH=3>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<INPUT TYPE=HIDDEN NAME=\"password\" VALUE=\"" . $config['password'] . "\">";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['font_size'] . ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=fontsize VALUE=\"" . $config['fontsize']. "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['font_face'] . ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=fontface VALUE=\"" . $config['fontface']. "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['font_color'] . ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=fontcolor VALUE=\"" . $config['fontcolor'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['link_color'] . ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=link VALUE=\"" . $config['link'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['table_bgcolor'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=tablebgcolor VALUE=\"" . $config['tablebgcolor'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['table_bordercolor'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=tablebordercolor VALUE=\"";
		$adda .= $config['tablebordercolor'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['table_border_thickness'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=tableborderx VALUE=\"" . $config['tableborderx'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['width'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=width VALUE=\"" . $config['width'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['perpage'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=perpage VALUE=\"" . $config['perpage'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['custom_question'];
		$adda .= "1:</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=customq1 VALUE=\"" . $config['customq1'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['custom_question'];
		$adda .= "2:</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=customq2 VALUE=\"" . $config['customq2'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['custom_question'];
		$adda .= "3:</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=customq3 VALUE=\"" . $config['customq3'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['custom_question'];
		$adda .= "4:</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=customq4 VALUE=\"" . $config['customq4'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['custom_question'];
		$adda .= "5:</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=customq5 VALUE=\"" . $config['customq5'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['email_button'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=emailbut VALUE=\"" . $config['emailbut'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['home_button'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=homebut VALUE=\"" . $config['homebut'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['ip_button'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=ipbut VALUE=\"" . $config['ipbut'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['del_button'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=delbut VALUE=\"" . $config['delbut'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['emo_smile'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=emo_smile VALUE=\"" . $config['emo_smile'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['emo_frown'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=emo_frown VALUE=\"" . $config['emo_frown'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['emo_grin'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=emo_grin VALUE=\"" . $config['emo_grin'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['emo_tongue'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=emo_tongue VALUE=\"" . $config['emo_tongue'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['emo_wink'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=emo_wink VALUE=\"" . $config['emo_wink'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['showip'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT MAXLENGTH=1 NAME=showip VALUE=\"" . $config['showip'];
		$adda .= "\" SIZE=2><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\"> 0 = " . $mes['no'] . "; 1 = " . $mes['yes'];
		$adda .= "</FONT></TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['allowhtml'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT MAXLENGTH=1 NAME=html VALUE=\"" . $config['html'];
		$adda .= "\" SIZE=2><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\"> 0 = " . $mes['no'] . "; 1 = " . $mes['yes'];
		$adda .= "</FONT></TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['allowrate'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT MAXLENGTH=1 NAME=rate VALUE=\"" . $config['rate'];
		$adda .= "\" SIZE=2><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\"> 0 = " . $mes['no'] . "; 1 = " . $mes['yes'];
		$adda .= "</FONT></TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['prevent_hammering'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT MAXLENGTH=1 NAME=hammer VALUE=\"" . $config['hammer'];
		$adda .= "\" SIZE=2><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\"> 0 = " . $mes['no'] . "; 1 = " . $mes['yes'];
		$adda .= "</FONT></TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['enable_notification'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT MAXLENGTH=1 NAME=notify VALUE=\"" . $config['notify'];
		$adda .= "\" SIZE=2><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\"> 0 = " . $mes['no'] . "; 1 = " . $mes['yes'];
		$adda .= "</FONT></TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['enable_emoticons'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT MAXLENGTH=1 NAME=emoticons VALUE=\"" . $config['emoticons'];
		$adda .= "\" SIZE=2><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\"> 0 = " . $mes['no'] . "; 1 = " . $mes['yes'];
		$adda .= "</FONT></TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['enable_icode'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT MAXLENGTH=1 NAME=icode_req VALUE=\"" . $config['icode_req'];
		$adda .= "\" SIZE=2><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\"> 0 = " . $mes['no'] . "; 1 = " . $mes['yes'];
		$adda .= "</FONT></TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['approve_before_public'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT MAXLENGTH=1 NAME=appfirst VALUE=\"" . $config['appfirst'];
		$adda .= "\" SIZE=2><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\"> 0 = " . $mes['no'] . "; 1 = " . $mes['yes'];
		$adda .= "</FONT></TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['hammer_seconds'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=hamsecs VALUE=\"" . $config['hamsecs'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['email_to_notify'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=email VALUE=\"" . $config['email'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['icode_fontface'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=icode_font VALUE=\"" . $config['icode_font'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['icode_fontsize'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=icode_fontsize VALUE=\"" . $config['icode_fontsize'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['icode_fontcolor'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=icode_fontcolor VALUE=\"" . $config['icode_fontcolor'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['icode_bgcolor'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=icode_bgcolor VALUE=\"" . $config['icode_bgcolor'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "<TR><TD>";
		$adda .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['icode_bgimg'];
		$adda .= ":</FONT>";
		$adda .= "</TD><TD ALIGN=RIGHT><INPUT TYPE=TEXT NAME=icode_bgimg VALUE=\"" . $config['icode_bgimg'];
		$adda .= "\" SIZE=24>";
		$adda .= "</TD></TR>\n\n";
		$adda .= "</TABLE>";
		$adda .= "<P><SMALL>" . $mes['not_version_info'] . "<P>" .  $mes['not_language_info'] . "</SMALL>";
		$adda .= "</CENTER>\n";
		$data .= ontable($adda) . "\n<P>\n";
		$data .= "<CENTER><INPUT TYPE=SUBMIT VALUE=\"[ " . $mes['save_config'] . " ]\"></CENTER>\n</FORM><P>";
		$budata .= "<CENTER>";
		$budata .= "<A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=backup&type=config>" . $mes['backup_config'] . "</A>";
		$budata .= "&nbsp;&middot;&nbsp;";
		$budata .= "<A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=restore&type=config>" . $mes['restore_config'] . "</A>";
		$budata .= "&nbsp;&middot;&nbsp;";
		$budata .= "<A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=backup&type=posts>" . $mes['backup_posts'] . "</A>";
		$budata .= "&nbsp;&middot;&nbsp;";
		$budata .= "<A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=restore&type=posts>" . $mes['restore_posts'] . "</A>";
		$budata .= "</CENTER>";
		$data .= ontable($budata) . "\n<P>\n";
		$redata .= "<FORM ACTION=$thisprogram?action=install METHOD=POST>\n" . $mes['revert_to_install'] . "\n<P>\n";
		$redata .= "<CENTER><INPUT TYPE=SUBMIT VALUE=\"" . $mes['revert'] . "\"></CENTER></FORM>";
		$data .= ontable($redata) . "\n<P>\n";
		}
	}

elseif ($_GET['action'] == 'imgcode')
	{
	image_code($config['icode_fontcolor'],$config['icode_bgcolor'],$config['icode_fontsize'],$config['icode_font'],$config['icode_bgimg']);
	}

else
	{
	$title = $config['title'];
	$datb .= "<FONT FACE=\"$fontface\" SIZE=" . $fontsize . " COLOR=\"$fontcolor\">\n";
	$totres = mysql_query("SELECT `id` FROM `pblguestbook_posts`");
	$numofposts = mysql_num_rows($totres);
	$prires = mysql_query("SELECT `id` FROM `pblguestbook_posts` WHERE `private` = '1'");
	$privateposts = mysql_num_rows($prires);
	$unares = mysql_query("SELECT `id` FROM `pblguestbook_posts` WHERE `app` = '0'");
	$unapprovedposts = mysql_num_rows($unares);
	$datb .= "<CENTER>\n";
	$datb .= "<B>$numofposts</B> " . $mes['total_posts'] . "; <B>$privateposts</B> " . $mes['private_posts'] . "; <B>$unapprovedposts</B> " . $mes['unapproved_posts'] . "<P>";
	if ($config['rate'] == '1')
		{
		$ratres = mysql_query("SELECT `id`,`rate` FROM `pblguestbook_posts` WHERE `rate` != '0'");
		$people = mysql_num_rows($ratres);
		while ($ratrow = mysql_fetch_array($ratres))
			{
			$sumofvotes += $ratrow[rate];
			}
		$average = round(($sumofvotes / $people),2);
		$mes['not_site_is_rated'] = str_replace('$people',$people,$mes['not_site_is_rated']);
		$mes['not_site_is_rated'] = str_replace('$average',$average,$mes['not_site_is_rated']);
		$datb .= "<SMALL>" . $mes['not_site_is_rated'] . "</SMALL><P>";
		}
	$datb .= "<BIG>";
	$datb .= "<A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=view>" . str_replace('$booktitle',$booktitle,$mes['page_view_title']) . "</A>";
	$datb .= "&nbsp;&middot;&nbsp;";
	$datb .= "<A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=sign>" . str_replace('$booktitle',$booktitle,$mes['page_sign_title']) . "</A>";
	$datb .= "</BIG><P>[ <A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=admin>" . $mes['page_admin_title'] . "</A> ]</CENTER>";
	$data .= ontable($datb);
	}

$footer = get_footer();
if ($footer == '' || !ereg("www.pixelatedbylev.com",$footer) || !ereg("$program",$footer) || !ereg("PBL GuestBook",$footer))
	{
	header("Location: http://www.pixelatedbylev.com/footer.php");
	exit;
	}
$data .= "\n\n\n<P>" . ontable("<CENTER><SMALL>$footer</SMALL></CENTER>") . "\n<BR><BR>\n\n";

$fh = fopen($template,r);
$template = fread($fh,filesize($template));
fclose($fh);
$newtitle = $title . " - " . $program;
$newdata = str_replace('$title',$newtitle,$template);
$newdata = str_replace('$meta',$meta,$newdata);
$newdata = str_replace('$data',$data,$newdata);
echo $newdata;

// COMMON PROGRAM FUNCTIONS

function make_post ($id,$amode = 1)
	{
	global $config;
	global $mes;
	global $fontface;
	global $fontsize;
	global $fontcolor;
	global $thisprogram;
	$query = "SELECT * FROM `pblguestbook_posts` WHERE `id` = '$id';";
	$res = mysql_query($query);
	if (mysql_num_rows($res) > 0)
		{
		$myrow = mysql_fetch_array($res);
		$emailbut = '';
		$homebut = '';
		$pdata = "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>";
		$pdata .= "<TR><TD><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">" . $mes['posted_by'];
		$pdata .= ": <B>$myrow[name]</B> &middot; " . $mes['time'] . ": <B>" . date("g:ia d M. Y",$myrow[time]);
		$pdata .= "</B>";
		if ($config['appfirst'] == '1' && $amode == 2)
			{
			$applink = "&nbsp;<A HREF=\"$thisprogram?action=approve&id=$id\" STYLE=\"FONT-WEIGHT:bold;\">" . strtoupper($mes['approve']) . "</A>";
			}
		if ($myrow['email'] != '')
			{
			$emailbut = "&nbsp;<A STYLE=COLOR:$config[link]; HREF=\"mailto:$myrow[email]\"><IMG SRC=$config[emailbut] BORDER=0 ALT=\"";
			$emailbut .= $mes['email'] . "\" ALIGN=MIDDLE></A>&nbsp;";
			}
		if ($myrow['website'] != '')
			{
			if ($emailbut != '') {$space = "&nbsp;";}
			$homebut = "&nbsp;<A STYLE=COLOR:$config[link]; HREF=\"http://$myrow[website]\"><IMG SRC=$config[homebut] BORDER=0 ALT=\"";
			$homebut .= $mes['website'] . "\" ALIGN=MIDDLE></A>&nbsp;";
			}
		if ($myrow['ip'] != '' && $config['showip'] == '1')
			{
			if ($homebut != '') {$space2 = "&nbsp;";}
			$ipbut = "&nbsp;<IMG SRC=$config[ipbut] BORDER=0 ALT=\"";
			$ipbut .= $myrow[ip] . "\" ALIGN=MIDDLE>&nbsp;";
			}
		if ($ipbut != '') {$space3 = "&nbsp;";}
		$delbut = "&nbsp;<A STYLE=COLOR:$config[link]; HREF=$thisprogram?action=delete&id=$myrow[id]><IMG SRC=$config[delbut] BORDER=0 ALT=\"";
		$delbut .= $mes['delete'] . "\" ALIGN=MIDDLE></A>&nbsp;";
		$pdata .= "</TD><TD STYLE=TEXT-ALIGN:right;><FONT SIZE=$fontsize>$applink$emailbut$homebut$ipbut$delbut</FONT></TD></TR>";
		if ($myrow['customq1'] || $myrow['customq2'] || $myrow['customq2'] || $myrow['customq2'] || $myrow['customq2'] || $myrow['rate'])
			{
			$pdata .= "<TR><TD COLSPAN=2 HEIGHT=20></TD></TR>";
			}
		if ($myrow['customq1'] != '')
			{
			list($q1,$a1) = split ("\|",$myrow['customq1']);
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>$q1:</B> <I>$a1</I></SMALL></FONT></TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($myrow['customq2'] != '')
			{
			list($q2,$a2) = split ("\|",$myrow['customq2']);
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>$q2:</B> <I>$a2</I></SMALL></FONT></TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($myrow['customq3'] != '')
			{
			list($q3,$a3) = split ("\|",$myrow['customq3']);
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>$q3:</B> <I>$a3</I></SMALL></FONT></TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($myrow['customq4'] != '')
			{
			list($q4,$a4) = split ("\|",$myrow['customq4']);
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>$q4:</B> <I>$a4</I></SMALL></FONT></TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($myrow['customq5'] != '')
			{
			list($q5,$a5) = split ("\|",$myrow['customq5']);
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>$q5:</B> <I>$a5</I></SMALL></FONT></TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($myrow['rate'] != '0' && $config['rate'] == '1')
			{
			$pdata .= "<TR><TD COLSPAN=2><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TD WIDTH=40></TD><TD>";
			$pdata .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<SMALL><B>" . $mes['ratesite'] . ":</B> <I>" . $myrow[rate] . "</I></SMALL></FONT>";
			$pdata .= "</TD><TD WIDTH=40></TD></TABLE></TD></TR>";
			}
		if ($myrow['comments'] != '')
			{
			if ($config['html'] != '1')
				{
				$myrow['comments'] = str_replace("<","&LT;",$myrow['comments']);
				$myrow['comments'] = str_replace(">","&GT;",$myrow['comments']);
				$myrow['comments'] = str_replace("&LT;BR&GT;","<BR>",$myrow['comments']);
				}
			if ($config['emoticons'] == '1')
				{
				$myrow['comments'] = str_replace(":)","<IMG SRC=\"" . $config['emo_smile'] .
				"\" ALIGN=ABSMIDDLE>",$myrow['comments']);
				$myrow['comments'] = str_replace(":D","<IMG SRC=\"" . $config['emo_grin'] .
				"\" ALIGN=ABSMIDDLE>",$myrow['comments']);
				$myrow['comments'] = str_replace(";)","<IMG SRC=\"" . $config['emo_wink'] .
				"\" ALIGN=ABSMIDDLE>",$myrow['comments']);
				$myrow['comments'] = str_replace(":(","<IMG SRC=\"" . $config['emo_frown'] .
				"\" ALIGN=ABSMIDDLE>",$myrow['comments']);
				$myrow['comments'] = str_replace(":P","<IMG SRC=\"" . $config['emo_tongue'] .
				"\" ALIGN=ABSMIDDLE>",$myrow['comments']);
				}
			$pdata .= "<TR><TD COLSPAN=2><FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">";
			$pdata .= "<BR><BLOCKQUOTE><SMALL>$myrow[comments]</SMALL></BLOCKQUOTE></FONT></TD></TR>";
			}
		$pdata .= "</TABLE>";
		if ($myrow['private'] == '1' && $_COOKIE['pblguestbook'] == '')
			{
			$pdata = "<B>" . $mes['error_private_message'] . "</B>";
			}
		}
	return $pdata;
	}

function get_footer ()
	{
	global $config;
	$data = "\n\n<SMALL>Powered by <A STYLE=\"COLOR:$config[link];\" HREF=\"http://www.pixelatedbylev.com\" TARGET=\"_top\">" . $GLOBALS['program'] . "</A>!</SMALL>";
	return $data;
	}

function get_config ()
	{
	if ($result = mysql_query("SELECT * FROM `pblguestbook_config` LIMIT 0,1"))
		{
		$dbval = mysql_fetch_array($result);
		}
	return $dbval;
	}

function save_config ()
	{
	$numofparts = count($_POST) - 2;
	$count = '0';
	if ($_POST['showip'] != '1') {$_POST['showip'] = '0';}
	if ($_POST['html'] != '1') {$_POST['html'] = '0';}
	if ($_POST['rate'] != '1') {$_POST['rate'] = '0';}
	if ($_POST['hammer'] != '1') {$_POST['hammer'] = '0';}
	if ($_POST['notify'] != '1') {$_POST['notify'] = '0';}
	if ($_POST['emoticons'] != '1') {$_POST['emoticons'] = '0';}
	if ($_POST['appfirst'] != '1') {$_POST['appfirst'] = '0';}
	foreach ($_POST as $name => $value)
		{
		if ($name != 'process' && $name != 'password2')
			{
			$count++;
			//if ($name == 'password') {$value = md5($value);}
			$result .= "`$name` = '$value'";
			if ($count <= $numofparts) {$result .= ", ";}
			}
		}
	$query = "UPDATE `pblguestbook_config` SET $result";
	return $query;
	}

function ontable ($text)
	{
	$config = get_config();
	$fontface = $config['fontface'];
	$fontsize = $config['fontsize'];
	$fontcolor = $config['fontcolor'];
	$booktitle = $config['title'];
	$data .= "<CENTER><TABLE BGCOLOR=\"$config[tablebordercolor]\" CELLPADDING=\"";
	$data .= "$config[tableborderx]\" CELLSPACING=0 BORDER=0 WIDTH=";
	$data .= "\"$config[width]\"><TD>";
	$data .= "<TABLE WIDTH=100% BGCOLOR=\"$config[tablebgcolor]\"><TD>";
	$data .= "<FONT FACE=\"$fontface\" SIZE=$fontsize COLOR=\"$fontcolor\">$text</FONT></TD></TABLE></TD></TABLE>\n";
	$data .= "</CENTER>";
	return $data;
	}

?>
Return current item: PBL Guestbook