<?
error_reporting(0);
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
Гостевая книга
</title>
<style type="text/css">
body
{
font-weight: normal;
font-size: small;
font-family: sans-serif;
color: #A0A0FF;
color: #805000;
background-color:black;
}
div
{margin: 3px 0px 3px 0px
}
div.title
{color:#FF8000;
font-weight: bold;
text-align: center;
}
div.header
{
color: #E0E0E0;
text-align: center;
background-color: #404040;
padding: 2px;
border-top: 1px solid #707070;
border-left: 1px solid #707070;
border-right: 1px solid #202020;
border-bottom: 1px solid #202020;
}
div.nav
{
color: #E0E0E0;
text-align: center;
background-color: #202040;
padding: 2px;
border-top: 1px solid # 404060;
border-left: 1px solid #404060;
border-right: 1px solid #101020;
border-bottom: 1px solid #101020;
margin: 5px 0px 5px;
}
a
{
color: #FF8000;
}
a:visited
{
color: #806040;
}
a:active
{
color: #FFE000;
}
div.nav a
{
color: #8080FF;
}
</style>
</head>
<body>
<div>
<center>';
if (!$act)
{
echo '<div class="title"><center>Гостевая книга</center></div>';
if ($infa=="two_msg")
{
echo '<span style="color:red">Сработал антиспам!</span><br/>';
}
if ($infa=="msg_error")
{
echo '<span style="color:red">Нужно ввести сообщение!</span><br/>';
}
if ($infa=="error_name")
{
echo '<span style="color:red">Нужно ввести имя!</span><br/>';
}
if ($infa=="mat")
{
echo '<span style="color:red">Сработал антифлуд!</span><br/>';
}
if ($infa==add)
{
$rand=rand(111,999);
echo "<form action=\"guest.php\" method=\"post\">
<input type=\"hidden\" name=\"act\" value=\"send\" />
<input type=\"hidden\" name=\"rand\" value=\"$rand\" />
Представтесь:<br />
<input type=\"text\" name=\"name\" maxlength=\"20\" value=\"$name\"/><br/>
Ваше сообщение:<br/>
<textarea cols=\"20\" rows=\"3\" name=\"msg\">$msg</textarea><br/>
<input type=\"submit\" value=\"добавить\"/></form>";
}
else
{
echo '<a href="guest.php?infa=add">Добавить</a><br/>';
}
if (!file_exists("guest.dat"))
{
echo '<span style="color:red">
В гостевой еще нет сообщений!</span><br/>';
}
else
{
echo '<a href="guest.php?rand='.rand(111,999).'">Обновить</a><br/>';
echo '</center>';
$num_sep=10;
$preview="guest.dat";
$preview=file($preview);
$count=count($preview);
$num_page=1;
if (isset($HTTP_GET_VARS['page']))
{
if (($HTTP_GET_VARS['page']>0) and ($HTTP_GET_VARS['page']<=ceil($count/$num_sep))) $num_page=$HTTP_GET_VARS['page'];
}
for ( $i=($num_page-1)*$num_sep; $i<=(($num_page*$num_sep<$count) ? $num_page*$num_sep-1: $count-1); $i++)
{
$vm = file("guest.dat");
$vm = explode("||", $vm[$i]);
echo '<div class="header"><center><span style="color: #ff4000"><b>
'.$vm[0].'</b></span> [<a href="guest.php?act=delmsg&str='.$i.'">D</a>] [<a href="guest.php?act=edit&str='.$i.'">E</a>]<br/>
<span style="color: #008000">
'.$vm[1].'</span><br/>
<span style="color: #ffe000">
'.date("H:i d.m.y", $vm[2]-3600).'</span><br/>
</center></div>
'.$vm[3].'<br/>';
}
echo "<center><div class=\"header\"><center>Сообщений: $count<br/>";
}
if ($count>$num_sep)
nav_page(ceil($count/$num_sep),(isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page']: 1),"guest.php?page=");
echo '</center></div><div class="nav"><center>';
echo '<a href="guest.php?act=del">Очистить гостевую</a><br/>';
echo '</center></div>';
}
if ($act=="send")
{
$msg=str_replace(">",">", $msg);
$msg=str_replace("<","<", $msg);
$name=str_replace(">",">", $name);
$name=str_replace("<","<", $name);
$name=str_replace("
","", $name);
$msg=str_replace("
","<br/>", $msg);
$msg=str_replace(" ","", $msg);
$name=str_replace(" ","", $name);
$msg=preg_replace("!(http://[\S]+)([\s]|$)!i","<a href=\"\\1\">\\1</a> ",$msg);
if (preg_match('/ хуй| Хуй| ХУЙ| ПИЗДА| пизда| Пизда| пиздец| Пиздец| ПИЗДЕЦ| лох| Лох| ЛОХ| блядь| Блядь| БЛЯДЬ| СУКА| сука| Сука| Заебал| ЗАЕБАЛ| заебал|wml.su/i', $name, $arr))
{
$mat=$arr[0];
}
if (preg_match('/ хуй| Хуй| ХУЙ| ПИЗДА| пизда| Пизда| пиздец| Пиздец| ПИЗДЕЦ| лох| Лох| ЛОХ| блядь| Блядь| БЛЯДЬ| СУКА| сука| Сука| Заебал| ЗАЕБАЛ| заебал|wml.su/i', $msg, $arr))
{
$mat=$arr[0];
}
if (!empty($mat))
{
$error = $error."mat";
}
if (empty($msg))
{
$error = $error."msg_error";
}
if (empty($name))
{
$error = $error."error_name";
}
$m=file("guest.dat");
$m=explode("||", $m[0]);
$numb=$m[4];
if ($rand==$numb)
{
$error=$error."two_msg";
}
$bw=getenv("HTTP_USER_AGENT");
$brows=strtok($bw," ");
$name = substr($HTTP_POST_VARS["name"],0,20);
$name = htmlspecialchars(stripslashes($name));
$msg = substr($HTTP_POST_VARS["msg"],0,1500);
$msg = trim($msg);
if (empty($error))
{
$base = 'guest.dat';
$back = @file_get_contents("guest.dat");
$file = fopen("$base","w");
fputs($file,"$name||$brows||".time()."||$msg||$rand||\r\n"."$back");
flock ($file,LOCK_UN);
fclose($file);
header ("Location: guest.php");
}
else
{
header ("Location: guest.php?infa=$error");
}
}
if($act=="del")
{
echo '<div class="title"><center>
Очистка гостевой
</center></div>';
echo "Вы действительно хотите очистить гостевую?<br/>
<a href=\"guest.php?act=del2\">Очистить</a><br/>
<a href=\"guest.php\">Отмена</a><br/>";
}
if ($act=="del2")
{
$basedel = "guest.dat";
$file = fopen("$basedel","w");
fclose($file);
header ("location: guest.php");
}
if ($act=="delmsg")
{
echo '<div class="title"><center>
Удаляем сообщение
</center></div>';
echo "Вы действительно хотите удалить это сообщение?<br/><a href=\"guest.php?act=delmsg2&str=$str\">Удалить</a><br/>
<a href=\"guest.php\">Отмена</a><br/>";
}
if ($act=="delmsg2")
{
$basedel = "guest.dat";
$basestr = file("$basedel");
$delstr = trim($basestr[$str]);
$buff = @file_get_contents($basedel);
$buff =str_replace("$delstr\r\n","",$buff);
$file = fopen("$basedel","w");
fputs($file,"$buff");
fclose($file);
header ("location: guest.php");
}
if ($act=="edit")
{
$editfile = "guest.dat";
$basestr = file("$editfile");
$editst = trim($basestr[$str]);
$edits = explode('||',$editst);
if(!$msg)
{
$name=htmlspecialchars(stripslashes($edits[0]));
$brows=htmlspecialchars(stripslashes($edits[1]));
$timemes=htmlspecialchars(stripslashes($edits[2]));
$msg=htmlspecialchars(stripslashes($edits[3]));
$rand=htmlspecialchars(stripslashes($edits[4]));
echo '<div class="title"><center>
Редактор сообщений
</center></div>';
echo "<div><center><form action=\"$PHP_SELF\" method=\"post\">
<input type=\"hidden\" name=\"act\" value=\"edit\"/>
<input type=\"hidden\" name=\"rand\" value=\"$rand\"/>
<input type=\"hidden\" name=\"str\" value=\"$str\"/>
<input type=\"hidden\" name=\"file\" value=\"$file\"/>
<input type=\"hidden\" name=\"name\" value=\"$name\"/>
<input type=\"hidden\" name=\"brows\" value=\"$brows\"/>
<input type=\"hidden\" name=\"timemes\" value=\"$timemes\"/>
Сообщение:<br/>
<input type=\"text\" name=\"msg\" maxlength=\"3000\" value=\"$msg\" />
<br/><input type=\"submit\" value=\"изменить\" />
</form></center></div>";
echo "<div class=\"nav\"><center>
<a href=\"guest.php\">Назад</a><br/>
</center></div>";
}
else
{
$msg=str_replace("
","<br/>", $msg);
$buff = @file_get_contents($editfile);
$buff =str_replace("$editst","$name||$brows||$timemes||$msg||$rand||",$buff);
$fileed = fopen("$editfile","w");
fputs($fileed,"$buff");
fclose($fileed);
header ("location: guest.php");
}
}
echo '<div class="nav"><center>
<a href="/index.php">Главная</a><br/>
© Proton 2007-2008<br/>
Powered by <a href="http://wapf.h2m.ru">Wap-Forum</a><br/>
</center></div>
</center>
</div>
</body>
</html>';
function nav_page($count,$num_page,$url)
{
$page_nav=3;
$begin_loop=1;
$end_loop=$count;
if ($num_page>$count or $num_page<1) $num_page=1;
echo "Страницы: ";
if ($num_page>$page_nav)
{
echo "<a href=\"$url".($page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0)))."\">".($page_nav*(floor($num_page/$page_nav)-1-($num_page%$page_nav==0 ? 1: 0))+1)."-".($page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0)))."</a>...";
$begin_loop=$page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0))+1;
}
if ($count>$page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0)+1)) { $end_loop=$page_nav*ceil($num_page/$page_nav); }
for ($i = $begin_loop; $i <= $end_loop; $i++) {
if ($i==$num_page) echo " <b>$i</b>";
else echo " <a href=\"$url$i\">$i</a>";
}
if ($count>$page_nav*(floor($num_page/$page_nav)-($num_page%$page_nav==0 ? 1: 0)+1)) {
echo "... <a href=\"$url".($page_nav*ceil($num_page/$page_nav)+1)."\">".($page_nav*ceil($num_page/$page_nav)+1);
if ($page_nav*ceil($num_page/$page_nav)+1<$count) {
echo "-".($count<=$page_nav*(ceil($num_page/$page_nav)+1) ? $count: $page_nav*(ceil($num_page/$page_nav)+1));
}
echo "</a>";
}
echo "<br/>";
}
?>