<?
Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
extract($HTTP_COOKIE_VARS);
extract($HTTP_SERVER_VARS);
extract($HTTP_SESSION_VARS);
function tr_to_win($str)
{
$str=strtr($str,array("__"=>" ","_"=>"","a"=>"а","b"=>"б","v"=>"в","g"=>"г","d"=>"д","e"=>"е","yo"=>"ё","zh"=>"ж","z"=>"з","i"=>"и","j"=>"й","k"=>"к","l"=>"л","m"=>"м","n"=>"н","o"=>"о","p"=>"п","r"=>"р","s"=>"с","t"=>"т","u"=>"у","f"=>"ф","h"=>"х","c"=>"ц","ch"=>"ч","sh"=>"ш","sch"=>"щ","q"=>"ъ","x"=>"ы","%"=>"ь","ye"=>"э","yu"=>"ю","ya"=>"я",
"A"=>"А","B"=>"Б","V"=>"В","G"=>"Г","D"=>"Д","E"=>"Е","YO"=>"Ё","ZH"=>"Ж","Z"=>"З","I"=>"И","J"=>"Й","K"=>"К","L"=>"Л","M"=>"М","N"=>"Н","O"=>"О","P"=>"П","R"=>"Р","S"=>"С","T"=>"Т","U"=>"У","F"=>"Ф","H"=>"Х","C"=>"Ц","CH"=>"Ч","SH"=>"Ш","SCH"=>"Щ","Q"=>"Ъ","X"=>"Ы","YE"=>"Э","YU"=>"Ю","YA"=>"Я"));
return $str;
}
# Смайлики ;-)
$s1 = "<img src='../../img/sm/sm.gif' alt='smile' />";
$s2 = "<img src='../../img/sm/biggrin.gif' alt='smile' />";
$s3 = "<img src='../../img/sm/razz.gif' alt='smile'/>";
$s4 = "<img src='../../img/sm/cool.gif' alt='smile' />";
$s5 = "<img src='../../img/sm/mad.gif' alt='smile' />";
$s6 = "<img src='../../img/sm/redface.gif' alt='smile' />";
$s7 = "<img src='../../img/sm/wink.gif' alt='smile' />";
$s8 = "<img src='../../img/sm/rolleyes.gif' alt='smile' />";
$s9 = "<img src='../../img/sm/confused.gif' alt='smile' />";
$s10 = "<img src='../../img/sm/eek.gif' alt='smile' />";
$s11 = "<img src='../../img/sm/cry.gif' alt='smile' />";
session_name("SESID");
session_start();
require("../../mysql.php");
$messages = mysql_query("select * from `guestbook` order by id desc ;");
require ("../../config.php"); # Подключаем настройки сайта. (config.php)
require ("../../themes/$themes.php"); # Вставляем скин сайта.
$page=hack_to_good($_GET['page']);
if ($page<=0)
{$page=1;}
$count = mysql_num_rows($messages);
if(!$_GET[act])
{
echo "<div style='text-align: center'>Гостевая</div>";
echo "<div>";
echo "<a href='index.php?act=add'>добавить</a>";
echo "<br /><a href='./'>обновить</a><br /></div>";
# количество сообщений
while($massiv = mysql_fetch_array($messages))
{
if ($i<=$page*$kmess & $i>=($page-1)*$kmess)
{
$az= @mysql_query("select * from `users` where name='$massiv[nik]';");
$array = @mysql_fetch_array($az);
echo "<div class='admin'><a href='../search.php?user=$array[id]'>$massiv[nik]</a> ".date("d-m-Y (H:i)", $massiv[date])."<br />";
echo "</div>";
echo "$massiv[text]";
if (!empty($massiv['admin']))
{
echo "<div class='admin'>Админ: $massiv[admin]</div>";
}
if ($_SESSION['login']==$nickadmina && md5($_SESSION['pass'])==$passadmina)
{
echo "<div class='raz'>$massiv[ip] - $massiv[browser]</div>";
}
echo "<br />";
}
++$i;
}
if ($count>$kmess)
{
$next=$page+1;
print "<div><a href='index.php?page=".$next."'>Далее</a> l ";
}
$prev=$page-1;
if ($prev!=0)
{print "<a href='index.php?page=".$prev."'>Назад</a></div>";}
# закончили выводить
# выводим навигацию по страничкам
}
echo "<br /><div>Сообщений: $count</div>";
# главная офф
if ($_GET[act]=="add")
{
$rand = rand(1000, 9999);
$_SESSION['rand'] = "$rand";
# форма добавления сообщений
$user=$_SESSION['login'];
if (empty($_SESSION['login']))
{$user="Посетитель";}
echo "<div>Добавление сообщения";
echo "<form action='index.php?act=send' method='post'>
<font color='red'>Вы - $user!</font>
<br />Cообщение<br />
<textarea rows='5' name='msg'></textarea><br/><br />
<input type='checkbox' name='msgtrans' value='1' /> Транслит сообщения
<br /><br /> * Проверочное число $rand:<br/><input size=\"4\" maxlength=\"4\" name=\"imgrand\" value=\"\" /><br />
<input type='hidden' name='session_id' value='".session_id()."' />
<input type='submit' value='добавить' />
</form>";
echo "<a href='index.php?act=smile'>Смайлы</a><br />";
echo "<a href='index.php?act=trans'>Транслит</a><br /></div>";
}
if($_GET[act]=="send")
{
$mess=hack_to_good(htmlspecialchars(stripslashes(trim($mess))));
$realtime=hack_to_good(htmlspecialchars(stripslashes(trim($realtime))));
$name=hack_to_good(htmlspecialchars(stripslashes(trim($name))));
$REMOTE_ADDR=hack_to_good(htmlspecialchars(stripslashes(trim($REMOTE_ADDR))));
$login=hack_to_good(htmlspecialchars(stripslashes(trim($login))));
if (!empty($msg))
{ $realtime=time()+$sdvigclock*3600;
$btime=$realtime-20;
$re = mysql_query("select count(*) from `guestbook` where ip='".$REMOTE_ADDR."' and date>'".$btime."';");
$res=mysql_fetch_row($re);
if(empty($_POST['imgrand']))
{
$error = $error."Не введено проверочное число";
}
if(!empty($_POST['imgrand']))
{
if($_POST['imgrand'] != $_SESSION['rand'])
{
$error = $error."Проверочное число неверно";
}
}
if ($res[0]>=1)
{$error = $error."Новое сообщение можно добавлять через 20 сек.\n";}
}
if ($_POST['session_id'] != session_id())
{
$error = $error."Попытка передачи данных с другого хоста. Скрипт остановлен!\n";
}
if (empty($msg))
{
$error = $error."Вы не ввели сообщение!\n";
}
$msg = hack_to_good(htmlspecialchars(stripslashes($msg)));
if (empty($error))
{
$msg = str_replace("\n"," ",$msg);
$msg = str_replace("\r"," ",$msg);
$sm1 = array(':-))',':-)',':-P','8-)',':-(',':-O',';-)',':roll:',':rf:','8-(','-(');
$sm2 = array("$s1","$s2","$s3","$s4","$s5","$s6","$s7","$s8","$s9","$s10","$s11");
if ($_POST[msgtrans]!=1)
{
$msg=str_replace($sm1,$sm2,$msg);
}
$msg=str_replace('|','!',$msg);
$msg=trim("$msg");
if ($_POST[msgtrans]==1)
{
$msg = tr_to_win($msg);
}
$name=$_SESSION['login'];
if (empty($_SESSION['login']))
{
$name="Посетитель";
}
$realtime=time()+$sdvigclock*3600;
$search_bad_words = array("'хуй'si","'хуи'si","'пизд'si","'ёб'si","'сука'si","'суки'si","'дроч'si","'хуя'si","'ссуч'si");
$replace = array("*","*","*","*","*","*","*","*","*");
$msg = preg_replace($search_bad_words,$replace,$msg);
$msg=antiadres($msg);
mysql_query("insert into `guestbook` values(0,'".$realtime."','$name','".$REMOTE_ADDR."','".getenv(HTTP_USER_AGENT)."','".$msg."','');");
$user = mysql_query("select * from `users` where name='".$_SESSION['login']."';");
$arr = mysql_fetch_array($user);
$mess = $arr['postguest']+1;
mysql_query("update `users` set postguest='".$mess."' where name='".$_SESSION['login']."';");
echo "<div>+ 1 Ваше новое!<br /><a href='./'>В гостевую</a></div>";
}
else
{
echo "<div>Во время добавления<br /> записи произошли <br />
следующие ошибки</div>";
echo "<div class='b'>";
echo $error;
echo "</div>";
echo "<div><a href='./index.php?act=add'>Добавить заново</a><br />";
echo "<a href='./'>В гостевую</a></div>";
}
}
if ($_GET[act]=="smile")
{
echo "<div>Доступные смайлы";
echo "<br/>
<img src='../../img/sm/sm.gif' alt=':-))' /> :-)) <br />
<img src='../../img/sm/biggrin.gif' alt=':-)' /> :-) <br />
<img src='../../img/sm/razz.gif' alt=':-P' /> :-P <br />
<img src='../../img/sm/cool.gif' alt='8-)' /> 8-) <br />
<img src='../../img/sm/mad.gif' alt=':-(' /> :-( <br />
<img src='../../img/sm/redface.gif' alt=':-O' /> :-O <br />
<img src='../../img/sm/wink.gif' alt=';-)' /> ;-) <br />
<img src='../../img/sm/rolleyes.gif' alt=':roll:' /> :roll: <br />
<img src='../../img/sm/confused.gif' alt=':rf:' /> :rf: <br />
<img src='../../img/sm/eek.gif' alt='8-(' /> 8-( <br />
<img src='../../img/sm/cry.gif' alt='-(' /> -( <br />
";
echo "<br/><a href='index.php?act=add'>К добавлению сообщения</a>";
echo "<br/><a href='./'>В гостевую</a></div>";
}
if ($_GET[act]=="trans")
{
echo "<div>Правила транслита";
echo "<br/>
а - a<br/>
б - b<br/>
в - v<br/>
г - g<br/>
д - d<br/>
е - e<br/>
ё - yo<br/>
ж - zh<br/>
з - z<br/>
и - i<br/>
к - k<br/>
л - l<br/>
м - m<br/>
н - n<br/>
о - o<br/>
п - p<br/>
р - r<br/>
с - s<br/>
т - t<br/>
у - u<br/>
ф - f<br/>
х - h<br/>
ц - c<br/>
ч - ch<br/>
ш - sh<br/>
щ - sch<br/>
ъ - q<br/>
ы - x<br/>
ь - %<br/>
э - ye<br/>
ю - yu<br/>
я - ya<br/><br/>
А - A<br/>
Б - B<br/>
В - V<br/>
Г - G<br/>
Д - D<br/>
Е - E<br/>
Ё - YO<br/>
Ж - ZH<br/>
З - Z<br/>
И - I<br/>
К - K<br/>
Л - L<br/>
М - M<br/>
Н - N<br/>
О - O<br/>
П - P<br/>
Р - R<br/>
С - S<br/>
Т - T<br/>
У - U<br/>
Ф - F<br/>
Х - H<br/>
Ц - C<br/>
Ч - CH<br/>
Ш - SH<br/>
Щ - SCH<br/>
Ъ - Q<br/>
Ы - X<br/>
Э - YE<br/>
Ю - YU<br/>
Я - YA<br/>
<br/>";
echo "<br/><a href='index.php?act=add'>К добавлению сообщения</a>";
echo "<br/><a href='./'>В гостевую</a></div>";
}
require ("../../foot.php");
?>