Location: PHPKode > projects > GBook > gbook/guestbook.php
<?
// GBook made by Racin Nygaard. If you have any questions please ask them on irc (darkking @ Efnet)
// Or email me at: hide@address.com :)

// If you remove this line the script won't work.
// This is where your username and password etc. lays...
include("config.php");
include("translation.php");
global $bantable, $database, $designtable, $logopoint, $table, $link, $table, $database, $table, $org, $trans;

$query = "select * from $designtable" or die(mysql_error());
$result = mysql_db_query($database, $query, $link) or die(mysql_error());
$design = mysql_fetch_row($result);

$title = $design[1];
$background = $design[2];
$picture = $design[3];
$tablebg = $design[4];
$txtcolor = $design[5];
$logopoint = $design[6];
$aover = $design[7];
$alink = $design[8];
$active = $design[9];
$avis = $design[10];

// Remove this if you want to disable ip banning
$query = "select * from $bantable" or die(mysql_error());
$result = mysql_db_query($database, $query, $link) or die(mysql_error());

while ($ip = mysql_fetch_row($result))
if ($ip[1] == getenv ("remote_addr"))
{
	echo '<META HTTP-EQUIV="refresh" CONTENT="0; URL=banned.html">';
}
else
{ echo ""; }
mysql_free_result($result);

// Starting HTML
echo "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<html>
<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
<title> $title </title> 
<style type=\"text/css\">
BODY {
        SCROLLBAR-FACE-COLOR: #B0B0B0; SCROLLBAR-HIGHLIGHT-COLOR: #000000;
        SCROLLBAR-SHADOW-COLOR: #333333; SCROLLBAR-3DLIGHT-COLOR: #2e425a;
        SCROLLBAR-ARROW-COLOR: #3300FF; SCROLLBAR-TRACK-COLOR: #000000;
        SCROLLBAR-DARKSHADOW-COLOR: #000000; BACKGROUND-COLOR: $background;
}
A:link {
        COLOR: $alink; TEXT-DECORATION: none
}
A:active {
        COLOR: $active; TEXT-DECORATION: none
}
A:visited {
        COLOR: $avis; TEXT-DECORATION: none
}
A:hover {
        COLOR: $aover;
}
</style></head>
<br><center><a href='$logopoint'>
<img src='$picture' border=\"0\" alt=\"Logo\"></a></center><br><br>
<hr><br><br>
<Table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"  border=\"0\">
<tr><td width=\"100%\"> 
<div align=\"left\">";

// Counting how many entries there are..
$query = "select count(*) from $table order by id DESC" or die(mysql_error());
$result = mysql_db_query($database, $query, $link) or die(mysql_error());
$count = mysql_fetch_row($result);
echo "<font color='$txtcolor'>There are ".$count[0]." posts in the guestbook.<br>";
mysql_free_result($result);

// This "link" stuff..
$query = "select * from $table order by id DESC" or die(mysql_error());
$result = mysql_db_query($database, $query, $link) or die(mysql_error());
$count = mysql_fetch_row($result);
for ($i = 1; $count[0] >= $i; $i=$i+10)
{
$idg = $i + 10;
$limitg = $i - 1;
$from = $i;
$to = $i + 9;
echo '<a href="index.php?id='.$idg.'&limit=' . $limitg . '&check=yes"><u>' . $from . '-' . $to . '</u> </a>';
}
mysql_free_result($result);

echo "</div><div align=\"right\">";
// The code
echo date("H:i:s - d.m.y")."</font>";
if (isset($_COOKIE["checklogin"]) && $_COOKIE["checklogin"] == $adminpassword)
{
echo
"</div><div align=\"left\"><a href=\"admin.php\">Admin menu</a>";
}
else 
{
echo "</div><div align=\"left\"><a href=\"login.php\">Admin login</a>";
}
echo "
</div><div align=\"left\"><a href=\"sign.php\">Sign Guestbook</a></div>
</td></tr>
</table>";

// 10 posts pr. page ...
if (!isset($_GET["check"]))
{
$query = "select * from $table order by id DESC" or die(mysql_error());
$result = mysql_db_query($database, $query, $link) or die(mysql_error());
$count = mysql_fetch_row($result);
for ($i = 1; $count[0] >= $i; $i=$i+10)
{
$id = $i + 10;
$limit = $i - 1;
}
}
else
{
$id = $_GET["id"];
$limit = $_GET["limit"];
}

// Don't edit this part unless you know what you are doing.
// Overview over entry
// Entry 6 = POST
// Entry 5 = HOMEPAGE
// Entry 4 = EMAIL
// Entry 3 = IP
// Entry 2 = DATE
// Entry 1 = NAME
// Entry 0 = ID

if (isset($_COOKIE["checklogin"]) && $_COOKIE["checklogin"] == $adminpassword)
{
// Outputting if logged in.
$query = "select * from $table where id < $id AND id > $limit order by id DESC" or die(mysql_error());
$result = mysql_db_query($database, $query, $link) or die("This will only appear as long
as you don't have any posts in your guestbook.<br><br>To remove it, click on 'Sign
Guestbook' and post something");
while ($entry = mysql_fetch_row($result))
{
echo "
<Table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" width=\"100%\">
<tr><td height=\"23\" bgcolor='$tablebg'>
<pre><font face=\"Verdana,Geneva,Arial,Helvetica,sans-serif\" color='$txtcolor' size=\"1\">";
echo str_replace($org, $trans, htmlentities($entry[6]));
echo "</font></pre><font face=\"Verdana,Geneva,Arial,Helvetica,sans-serif\" color='$txtcolor' size=\"1\">
<map name=\"map\"><div align=\"right\"><a href=\"admin.php?mod&id=".$entry[0]."\">MODIFY POST</a>&nbsp;&nbsp;&nbsp;<a href=\"admin.php?del&id=".$entry[0]."\"> DELETE POST</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Written by <a href=\"mailto:".htmlentities($entry[4])."\">
".htmlentities($entry[1])."</a>&nbsp;(Homepage: 
<a href=\"".htmlentities($entry[5])."\" target=\"_blank\">".htmlentities($entry[5])."</a> , IP:
".htmlentities($entry[3]).")&nbsp;&nbsp;
".htmlentities($entry[2])."<br></div></map></font></td></tr></table>"; 
}
mysql_free_result($result);
}
else
{
    
// Outputting if not logged in
    $query = "select * from $table where id < $id AND id > $limit order by id DESC" or die(mysql_error());
$result = mysql_db_query($database, $query, $link) or die("This will only appear as long
as you don't have any posts in your guestbook.<br><br>To remove it, click on 'Sign
Guestbook' and post something");
while ($entry = mysql_fetch_row($result))
{
echo "
<Table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" width=\"100%\">
<tr><td height=\"23\" bgcolor='$tablebg'>
<pre><font face=\"Verdana,Geneva,Arial,Helvetica,sans-serif\" color='$txtcolor' size=\"1\">";
echo str_replace($org, $trans, htmlentities($entry[6]));
echo "</font></pre><font face=\"Verdana,Geneva,Arial,Helvetica,sans-serif\" color='$txtcolor' size=\"1\">
<map name=\"map\"><div align=\"right\"> Written by 
<a href=\"mailto:".htmlentities($entry[4])."\">
".htmlentities($entry[1])."</a>&nbsp;(Homepage: 
<a href=\"".htmlentities($entry[5])."\" target=\"_blank\">".htmlentities($entry[5])."</a> , IP:
".htmlentities($entry[3]).")&nbsp;&nbsp;
".htmlentities($entry[2])."<br></div></map></font></td></tr></table>"; 
}
mysql_free_result($result);
}

echo "</div><div align=\"left\"><a href=\"sign.php\">Sign
Guestbook</a></div>";

// Link stuff...
$query = "select * from $table order by id DESC" or die(mysql_error());
$result = mysql_db_query($database, $query, $link) or die(mysql_error());
$count = mysql_fetch_row($result);
for ($i = 1; $count[0] >= $i; $i=$i+10)
{
$idg = $i + 10;
$limitg = $i - 1;
$from = $i;
$to = $i + 9;
echo '<a href="index.php?id='.$idg.'&limit=' . $limitg . '&check=yes"><u>' . $from . '-' . $to . '</u> </a>';
}
mysql_free_result($result);
echo "<br><br><div align=\"center\"><font color='$txtcolor'><u>This
guestbook is running</u><a href=\"http://darkking-gbook.sourceforge.net\"><u> GBook 
0.5</u></a></font></div><br></html>";

?>
Return current item: GBook