View file file/news/kom.php

File size: 9.51Kb
<?

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='' />";    	
$s2 = "<img src='../../img/sm/biggrin.gif' alt='' />"; 
$s3 = "<img src='../../img/sm/razz.gif' alt='' />";
$s4 = "<img src='../../img/sm/cool.gif' alt='' />";
$s5 = "<img src='../../img/sm/mad.gif' alt='' />";
$s6 = "<img src='../../img/sm/redface.gif' alt='' />";
$s7 = "<img src='../../img/sm/wink.gif' alt='' />";
$s8 = "<img src='../../img/sm/rolleyes.gif' alt='' />";
$s9 = "<img src='../../img/sm/confused.gif' alt='' />";
$s10 = "<img src='../../img/sm/eek.gif' alt='' />";
$s11 = "<img src='../../img/sm/cry.gif' alt='' />";


session_name("SESID");
session_start();
require("../../mysql.php");
require ("../../config.php"); # Подключаем настройки сайта. (config.php)
require ("../../themes/$themes.php"); # Вставляем скин сайта.
  $id=htmlspecialchars($_GET[id]);	
  $id=intval($id);
  
  
  
  if(!$_GET[act])        
{
    
  echo "<center>Коментарии новости</center>";
  $news = @mysql_query("select * from `news` where type='news' and idnews='".$id."';");
  $massivnews = @mysql_fetch_array($news);
  $nme = mysql_num_rows($news);
    if ($nme!=1){}
    else 
    {
  echo"<div class='admin'><font color='red'>$massivnews[shortnews]</font> ".date("d.m.y (H:i)", $massivnews['date'])."  <br/>$massivnews[fullnews]<br/>Автор: $massivnews[author]</div> ";
  echo "<div><a href='kom.php?id=$id&amp;act=add'>добавить</a></div><div class='admin'>";
$messages = @mysql_query("select * from `news` where type='comm' and idnews='".$id."'order by id desc ;");
      $page=hack_to_good($_GET['page']);
      if ($page<=0)
      {$page=1;}
$count = @mysql_num_rows($messages);
   while($massiv = @mysql_fetch_array($messages)) 
   {if ($i<=$page*10 & $i>=($page-1)*10)
	{  
   $user=$massiv['author'];
   	   if ($massiv['author']=="Посетитель")
   	   {$user="";}
   	   $az1= mysql_query("select * from `users` where name='$massiv[author]';");
$array1 = mysql_fetch_array($az1);
   echo"<a href='../../search.php?user=".$array1[id]."'>$massiv[author]</a> ".date("d.m.y (H:i)", $massiv[date])."<br/>$massiv[fullnews]";
     if ($_SESSION['login']==$nickadmina && md5($_SESSION['pass'])==$passadmina)
    {    echo "<br/><a href='../../admin/ban.php?news=".$massiv[id]."'>Банить IP</a> $massiv[ip]";}
    }
    echo '</div>';
    ++$i;
   }
   if ($count>10)
	{
	$next=$page+1;
	print "<br/><a href='kom.php?id=$id&amp;page=".$next."'>Далее</a> l ";
	}
	$prev=$page-1;
	if ($prev!=0)
	{print "<br/><a href='kom.php?id=$id&amp;page=".$prev."'>Назад</a>";}
   echo "<div class='b'>Комментариев $count</div> ";
}
  }
if ($_GET[act]=="add")
{
	  $news = mysql_query("select * from `news` where type='news' and idnews='".$id."';");
  $massivnews = mysql_fetch_array($news);
  $nme = mysql_num_rows($news);
    if ($nme!=1){}
    else 
    {
	
	 # форма добавления сообщений
      echo "<div>Добавление коментария";
echo   "<form action='kom.php?id=".$id."&amp;act=send' method='post'>
* сообщение<br />
        <input type='text' name='msg' maxlength='100' value='".$msg."' /><br />
        <input type='checkbox' name='msgtrans' value='1' /> Транслит сообщения
      <br />
      <input type='submit' value='добавить' />  
  </form>";

  echo "* - поля, обязательные для заполнения<br />";	  
  echo "<a href='kom.php?id=$id&amp;act=smile'>Смайлы</a><br />";
  echo "<a href='kom.php?id=$id&amp;act=trans'>Транслит</a><br /></div>";  
}
}
if($_GET[act]=="send")
	
{
$u1=getenv("HTTP_USER_AGENT");
$mobile=strtok($u1,"/");
$user="$mobile: $REMOTE_ADDR";
$realtime=time()+$sdvigclock*3600;
$currHour=date("H",$realtime);
	$currDate=date("d.m.y", $realtime);
	$currTime=date("$currHour:i", $realtime);
    $time="$currTime-$currDate";

	$name = trim($_POST[name]);
    $msg = trim($_POST[msg]);
			
					  if (!empty($msg))
					  {

  
			         }
      if (empty($msg))
      {
        $error = $error."<br />Вы не ввели сообщение!\n";
      }
$msg = htmlspecialchars(stripslashes($msg));

if (empty($error)) 
  {$realtime=time()+$sdvigclock*3600;
  	$currHour=date("H",$realtime);
	$currDate=date("d.m.y", $realtime);
	$currTime=date("$currHour:i", $realtime);
    $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=hack_to_good(trim("$msg"));
if ($_POST[msgtrans]==1)
{
$msg = tr_to_win($msg);
}
$login=$_SESSION['login'];
if (Empty($login))
{
$login="Посетитель";
}
$realtime=time()+$sdvigclock*3600;


$news = @mysql_query("select * from `news` where type='news' and idnews='".$id."';");
  $massivnews = @mysql_fetch_array($news);
  $nme = mysql_num_rows($news);
    if ($nme!=1){}
    else 
    {
    	$id=htmlspecialchars(stripslashes(trim($id)));
    		$realtime=htmlspecialchars(stripslashes(trim($realtime)));
    			$msg=htmlspecialchars(stripslashes(trim($msg)));
    				$login=htmlspecialchars(stripslashes(trim($login)));
    					$REMOTE_ADDR=htmlspecialchars(stripslashes(trim($REMOTE_ADDR)));

   @mysql_query("insert into `news` values('0','$id','comm','".$realtime."', '', '".$msg."', '".$login."','".$REMOTE_ADDR."','".getenv(HTTP_USER_AGENT)."');");
   echo "<div>Коментарий успешно добавлен<br /><a href='kom.php?id=".$id."'>К коментариям</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='kom.php?id=".$id."&amp;act=add'>Добавить заново</a><br />";
        echo "<br/><a href='kom.php?id=".$id."'>К коментариям</a></div></p>";
  }
}
   if ($_GET[act]=="smile") 
   {
      
      echo "<div>Доступные смайлы";
echo "<p>
<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 />
</p>";
echo "<p><a href='kom.php?id=".$id."&amp;act=add'>К добавлению коментария</a></p>";  
echo "<p><a href=\"kom.php?id=".$id."'>К коментариям</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='kom.php?id=$id&amp;act=add'>К добавлению сообщения</a></p>"; 
  echo "<p><a href='kom.php?id=$id'>К коментариям</a></p></div>"; 
  }
 
require ("../../foot.php"); # Вставляем низ сайта. (templates/foot.php)
?>