View file gb/index.php

File size: 15.19Kb
<?
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);
include'../config.php';
echo'<bgsound src="sound.wav">';
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;
}
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;  
 

 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 "  $i";
     else echo "  <a href=\"$url$i\">$i</a>";
 } # for
 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 "  </div>";
}

$s1 = "<img src=\"../smiles/sm.gif\" alt=\"\" />";    	
$s2 = "<img src=\"../smiles/biggrin.gif\" alt=\"\" />"; 
$s3 = "<img src=\"../smiles/razz.gif\" alt=\"\" />";
$s4 = "<img src=\"../smiles/cool.gif\" alt=\"\" />";
$s5 = "<img src=\"../smiles/mad.gif\" alt=\"\" />";
$s6 = "<img src=\"../smiles/redface.gif\" alt=\"\" />";
$s7 = "<img src=\"../smiles/wink.gif\" alt=\"\" />";
$s8 = "<img src=\"../smiles/rolleyes.gif\" alt=\"\" />";
$s9 = "<img src=\"../smiles/confused.gif\" alt=\"\" />";
$s10 = "<img src=\"../smiles/eek.gif\" alt=\"\" />";
$s11 = "<img src=\"../smiles/cry.gif\" alt=\"\" />";
session_name("SESID");
session_start();
require ("../include/head.php");
$gzip="9";                   
$guestmes="$gb_post";
  if(!$_GET[act])        
{
echo '<br/>
<div>Добавление сообщения<form action="index.php?act=send" method="post">
      * имя<br />
       <input type="text" name="name" maxlength="32" value="" /><br />
       <input type="checkbox" name="nametrans" value="1" /> Транслит имени
      <br />* сообщение<br />
        <input type="text" name="msg" maxlength="" value="" /><br />
        <input type="checkbox" name="msgtrans" value="1" /> Транслит сообщения
      <br />
      <input type="submit" value="добавить" />  <a/><br/>
  </form><a href="'.$home.'/gb/index.php#">Обновить</a><br/><a href="index.php?act=smile">Смайлы</a><br /><a href="index.php?act=trans">Транслит</a><br /></div>
</a></span></td>';
$num_sep =$guestmes;
$preview="../data/gb.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++) 
{

          $viewmess = file("../data/gb.dat");
          $viewmess = explode("|", $viewmess[$i]);
          $name_user = $viewmess[0];
          $device_user = $viewmess[1];
          $time_user = $viewmess[2];
          $mail_user = $viewmess[3];
          $url_user = $viewmess[4];
          $mess_user = $viewmess[5];
          $mess_admin = $viewmess[6];
          $mess_admin1 = $viewmess[7];
          $mess_admin2 = $viewmess[8];
  	     echo "<hr><b>$name_user<br /></b>";
  	     if ($_SESSION['login']==$nickadmina && md5($_SESSION['pass'])==$passadmina)
             {
  	            echo "$device_user<br />";
  	         }
  	     echo "$time_user<br />";
   	     if (!empty($mail_user))
   	     {
  	      echo "<a href=\"index.php?act=sendmail&amp;to=$mail_user&amp;for=$name_user\">$mail_user</a><br />";
   	     }
  	      echo "<a href=\"$url_user\">$url_user</a>";
  	     
  	     	 echo "$mess_user";
  	     	 if (!empty($mess_admin))
    	     {
  	     echo "<font color=red>Админ $nickadmina: $mess_admin</a></font>";
  	     	 }
  	     	 if (!empty($mess_admin1))
    	     {
  	     echo "<font color=red>Админ $nickadmina: $mess_admin1</a></font>";
  	     	 }
  	     	 if (!empty($mess_admin2))
    	     {
  	     echo "<font color=red>Админ $nickadmina: $mess_admin2</a></font>";
  	     	 }
        echo "<hr>";
} 
echo "<div>Страницы: ";
if ($count>$num_sep) 
nav_page(ceil($count/$num_sep),(isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page']: 1),"index.php?page=");
echo "</div>";
echo "<p>В гостевой $count сообщений</p>\n";
}

if ($_GET[act]=="add")
{

      echo "<br/><div>Добавление сообщения";
echo   "<form action=\"index.php?act=send\" method=\"post\">
      * имя<br />
       <input type=\"text\" name=\"name\" maxlength=\"32\" value=\"$name\" /><br />
       <input type=\"checkbox\" name=\"nametrans\" value=\"1\" /> Транслит имени
      <br />* сообщение<br />
        <input type=\"text\" name=\"msg\" maxlength=\"$length\" value=\"$msg\" /><br />
        <input type=\"checkbox\" name=\"msgtrans\" value=\"1\" /> Транслит сообщения
      <br />
      <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")
	
{
$u1=getenv("HTTP_USER_AGENT");
$mobile=strtok($u1,"/");
$user="$mobile: $REMOTE_ADDR";
$currHour=date("H",time());
	$currDate=date("d.m.y", time());
	$currTime=date("$currHour:i", time());
    $time="$currTime-$currDate";

	$name = trim($_POST[name]);
    $msg = trim($_POST[msg]);
    $banlist = file("../data/ban.dat");
    $ban =  $user;
    $result  =  false ; 
			foreach ($banlist as $key => $string) 
				{ 
				 if($ban==trim(array_shift($banlist))) 
					{ 
			         $error = $error."<br />Доступ в гостевую для<br /> <b>$ban</b><br /> закрыт!\n" ;
					 $result  =  true ;
					} 
				}
					  if (!empty($msg))
					  {
$msglist = file("../data/gb.dat");
if(empty($check))
{
$check = count($msglist);
}
   for ($i = 0; $i <= $check; $i++)
   {
$oldmsg = explode('|',$msglist[$i]);
$oldmsg = $oldmsg[5];
$oldmsg = "$oldmsg|";
$oldmsg = explode('|',$oldmsg);
    $newmsg =  $msg;
    $result  =  false ; 
    
			foreach ($oldmsg as $key => $string) 
				{ 
				if($newmsg==trim(array_shift($oldmsg))) 
					{ 
			$error = $error."<br />сообщение<br /><br /><i>$newmsg</i><br /><br />уже есть в базе!\n" ;
					 $result  =  true ;
					  }}
			          }}
      if (empty($msg))
      {
        $error = $error."<br />Вы не ввели сообщение!\n";
      }
      if (empty($name))
      {
        $error = $error."<br />Вы не ввели имя!\n";
      }
      if (!empty($_POST[email]))
      {
        if (!preg_match("/[0-9a-z_]+@[0-9a-z_^\.]+\.[a-z]{2,3}/i", $_POST[email]))
        {
          $error = $error."<br />Неверно введен е-mail. Введите e-mail
          в виде <i>[email protected]</i>!";
        }
      }
      if (!empty($_POST[url]))
      {
       
        }
$name = substr($HTTP_POST_VARS["name"],0,32);
$name = htmlspecialchars(stripslashes($name));
$time = substr($HTTP_POST_VARS["time"],0,32);
$time = htmlspecialchars(stripslashes($time)); 
$email = substr($HTTP_POST_VARS["email"],0,32);
$email = htmlspecialchars(stripslashes($email));
$url = substr($HTTP_POST_VARS["url"],0,36);
$url = htmlspecialchars(stripslashes($url));
$msg = substr($HTTP_POST_VARS["msg"],0,1024);
$msg = htmlspecialchars(stripslashes($msg));

if (empty($error)) 
  {
  	  $currHour=date("H",time());
	$currDate=date("d.m.y", time());
	$currTime=date("$currHour:i", time());
    $time="$currTime-$currDate";

    	$msg = eregi_replace("(.*)\\[url\\](.*)\\[/url\\](.*)","\\1<a
                       href=\\2>\\2</a>\\3",$msg);
    $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);
}
$url = str_replace('http://','',$url);
$url = str_replace("$url","http://$url",$url);

if ($_POST[nametrans]==1)
{
$name = tr_to_win($name);
}
    $base = '../data/gb.dat';
		
    $back = @file_get_contents("../data/gb.dat");
    $file = fopen("$base","w");
    fputs($file,"$name|$user|$time|$email|$url|$msg"."\r\n"."$back");
    fclose($file);
   echo "<br/><div>Сообщение успешно добавлено<br /><a href=\"./\">В гостевую</a></div>";

  }
  else
  {   

 echo "<p><div>Во время добавления<br /> записи произошли <br />
      следующие ошибки</div></p>";
      echo "<p><div class=b>";
      echo $error;
      echo "</div></p>";
        echo "<p><div><a href=\"./index.php?act=add\">Добавить заново</a><br />";
        echo "<a href=\"./\">В гостевую</a></div></p>";
  }
}
   if ($_GET[act]=="smile") 
   {
      
      echo "<div>Доступные смайлы";
    
echo "<p>
<img src=\"../smiles/sm.gif\" alt=\":-))\" />  :-)) <br />
<img src=\"../smiles/biggrin.gif\" alt=\":-)\" />  :-) <br />
<img src=\"../smiles/razz.gif\" alt=\":-P\" />  :-P <br />
<img src=\"../smiles/cool.gif\" alt=\"8-)\" />  8-) <br />
<img src=\"../smiles/mad.gif\" alt=\":-(\" />  :-( <br />
<img src=\"../smiles/redface.gif\" alt=\":-O\" />  :-O <br />
<img src=\"../smiles/wink.gif\" alt=\";-)\" />  ;-) <br />
<img src=\"../smiles/rolleyes.gif\" alt=\":roll:\" />  :roll: <br />
<img src=\"../smiles/confused.gif\" alt=\":rf:\" />  :rf: <br />
<img src=\"../smiles/eek.gif\" alt=\"8-(\" />  8-( <br />
<img src=\"../smiles/cry.gif\" alt=\"-(\" />  -( <br />

</p>";
  	
  echo "<p><a href=\"index.php?act=add\">К добавлению сообщения</a></p>";  
  echo "<p><a href=\"./\">В гостевую</a></p></div>";
   
   }
   
  if ($_GET[act]=="trans") 
   {
      
      echo "<div>Правила транслита";
    
echo "<p>
а - 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/>

</p>";
  	
  echo "<p><a href=\"index.php?act=add\">К добавлению сообщения</a></p>";  
  echo "<p><a href=\"./\">В гостевую</a></p></div>";
   
   }
  	
   	if ($act=="sendmail")
   	{ 

   		      echo "<p>отправка e-mail сообщения для $for</p>";

echo "<form method=\"post\" action=\"index.php?act=mail\"><p class=\"p3\">";
echo "кому";
echo "<br /><input type=\"text\" name=\"mail\" maxlength=\"50\" value=\"$to\"/><br />";
echo "тема";
echo "<br /><input type=\"text\" name=\"tema\" maxlength=\"50\" value=\"\"/><br />";
echo "ваш e-mail";
echo "<br /><input type=\"text\" name=\"email\" value=\"\"/>";
echo "<br />сообщение<br />";

	echo "<textarea rows=\"3\" size=\"500\" name=\"text\">";
	echo "</textarea><br />";
		
			echo "
       <input type=\"submit\" name=\"do\" value=\"отправить\"/></p></form>";
  echo "<p class=\"p1\"><a href=\"./\">В гостевую</a></p>";
 }
   	 
   	 if($act=="mail")
   	 {
function myErrorHandler ($errno, $errstr, $errfile, $errline) {}
set_error_handler("myErrorHandler");

  $text=htmlspecialchars(stripslashes($text));
        $tema=htmlspecialchars(stripslashes($tema));
        $tema = substr($HTTP_POST_VARS["tema"],0,50);
$text = substr($HTTP_POST_VARS["text"],0,1000);
	if (!eregi("^([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)$", $mail))
 {  
echo "<p>";
   echo"Несуществующий адрес e-mail!<br /><br />";
           echo"<a href=\"./\">Пожалуйста повторите!</a>";
exit;}
	
if ($text == "") {  
echo "<p>";
    echo"Вы не написали сообщениe!<br /><br />";
         echo"<a href=\"./\">Пожалуйста повторите!</a>";
              echo"</p>";
exit;}
	if ($email == "") {$email="no@email";}else
if (!eregi("^([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)$", $email))
 { 
echo"<p class=\"p3\">";
   echo"Несуществующий адрес e-mail!<br /><br />";
       echo"Если вы пишите адрес, то указывайте корректный e-mail, или НЕ пишите его вообще!<br /><br />";
           echo"<a href=\"./\">Пожалуйста повторите!</a>";
                  echo"</p>";
exit;}
    $headers="Content-Type: text/html; charset=utf-8\n";
$headers.="From: $email\nX-Mailer: PHP v.".phpversion();
mail($mail,$tema,$text,$headers);

echo"<p>";
    echo"Спасибо, ваше сообщение отправлено!<br />";
           echo"<br /><a href=\"./\">В гостевую</a></p>";
   	 }
require ("../include/foot.php");
?>