View file waplend/adguest.php

File size: 5.44Kb
<?
include "tools.php";
include "head.php";
$realtime=time()+$sdvigclock*3600;
      $page=$_GET['page'];
      if ($page<=0)
      {$page=1;}
$messages = mysql_query("select * from `guest` order by id desc ;");

$qw = mysql_fetch_array(mysql_query("SELECT * FROM `administration`where `iduser`='".$_SESSION['iduser']."'"));
if (mysql_affected_rows()=="1")
{$r="ok";}
if ($qw['type']=="999" and $r=="ok")
{
//////////////////////////////////////////////////////
  if($_GET['act']=="")        
{

 echo "<div class='contur_rek'>
<div class='header_rek'>Управление гостевой</div></div>";
 echo "<div><a href='adguest.php?act='>Обновить</a><br /></div>";

      ///////////////////////////
  if(!$_GET['act'])        
{	    
  $count = mysql_num_rows($messages);

   while($massiv = mysql_fetch_array($messages)) 
{
	if ($i<=$page*10 & $i>=($page-1)*10)
	{ 
	
  	     echo "<div class='contur'><div class='contur'>
	<div class='header'>".$massiv['nik']." ".date("d-m-Y (H:i)", $massiv['time'])."";
  	     echo "</div></div>";
  	     
  	     	 echo "$massiv[text]";
  	     	 if (!empty($massiv['admin']))
    	     {
  	     echo "<br/><span style='color:red;'>Админ: $massiv[admin]</span>";
  	     	 }
  	            echo "<br/> $massiv[ip] - $massiv[browser][<a href='adguest.php?act=ans&amp;id=".$massiv['id']."'>отв</a>][<a href='adguest.php?act=del&amp;id=".$massiv['id']."'>удал</a>][<a href='adguest.php?act=ban&amp;id=".$massiv['id']."'>бан</a>]</div>";
  	         }
  	}
  	     	 ++$i;

} 
if ($count>10)
	{
	$next=$page+1;
	print "<div><a href='adguest.php?page=".$next."'>Вперёд</a></div>";
	}
	$prev=$page-1;
	if ($prev!=0)
	{print "<div><a href='adguest.php?page=".$prev."'>Назад</a></div>";
	}
    echo "<div>Сообщений: $count</div>";
     print "<div><a href='adguest.php?act=banlist'>Баннлист</a><br/><a href='adpanel.php'>В админку</a></div>";
}

//////////////////////////////////////
if ($_GET['act']=="ans")
{
$ans = mysql_query("select * from `guest` where `id`='".intval($_GET['id'])."';");
  $m = mysql_fetch_array($ans);
      echo "<div>Ваш ответ для сообщения с id:".intval($_GET['id'])."</div>";
echo   "<div><form action='adguest.php?act=send&amp;id=".intval($_GET['id'])."' method='post'>
<input type='text' name='otv' maxlength='500' value='$m[admin]' />\n";
      echo "<br />\n";
      echo "<input type='submit' value='ответить' />
  </form></div>";

  	  
  echo "<div><a href='adguest.php?act='>админ-guest</a></div>";
echo "<div><a href='./main.php'>В админку</a></div>";

}
/////////////////////////////////////
if($_GET['act']=="send")
{
$otv = str_replace("\n"," ",$_POST['otv']);
    $otv = str_replace("\r"," ",$otv);
   $sm1 = array(':-))',':-)',':-P','8-)',':-(',':-O',';-)',':roll:',':rf:','8-(','-(');
$sm2 = array("$s1","$s2","$s3","$s4","$s5","$s6","$s7","$s8","$s9","$s10","$s11");
$otv=str_replace($sm1,$sm2,$otv);
        mysql_query("update `guest` set admin='".$otv."' where id='".intval($_GET['id'])."';");
echo "<div>Ответ для сообщения id:".$_GET['id']." добавлен!<br /><a href='adguest.php?act='>админ-guest</a></div>";
 header ("Location: adguest.php");
echo "<div><a href='./main.php'>В админку</a></div>";
 
}
////////////////////////////////
  	if ($_GET['act']=="del")
   	{
if (mysql_query("delete from `guest` where `id`='".intval($_GET['id'])."';"))
	{
echo "<div>Сообщение удалено!<br /><a href='adguest.php?act='>админ-guest</a></div>";
 header ("Location: adguest.php");
    }
 }
   	 //////////////////////////////
   	 if($_GET['act']=="ban")
   	 {
 $banned=mysql_query("select * from `guest` where id='".intval($_GET['id'])."';");
 	$m = mysql_fetch_array($banned);			
mysql_query("insert into `bann` values('".$m['nik']."','".$m['ip']."','".trim($m['browser'])."','".$_SESSION['login']."', '".$realtime."');");
echo "<div>".$m['nik']." с IP: ".$m['ip']."";
echo "<br/>Забанен<br /><a href='adguest.php?act='>админ-guest</a></div>";
   	 }
   	  
   	  /////////////////////////////////
   	  if($_GET['act']=="banlist")
   	 {
 		$bannlist = mysql_query("select * from `bann`;");
 	$countbann = mysql_num_rows($bannlist);

   while($massiv = mysql_fetch_array($bannlist)) 
{
	if ($i<=$page*10 & $i>=($page-1)*10)
	{ 
	
  	     echo "<div class='contur'><div class='header'>$massiv[user] :: $massiv[ip] :: $massiv[browser] :: ".date("d-m-Y (H:i)", $massiv[time])."<br/> Забанил: ".$massiv['admin']." <a href='adguest.php?act=razban&amp;id=".$massiv[time]."'>Разбанить</a><br />";
  	     echo "</div></div>";
    	}
  	     	 ++$i;


} 
if ($countbann>10)
	{
	$next=$page+1;
	print "<div><a href='adguest.php?act=banlist&amp;page=".$next."'>Вперёд</a></div>";
	}
	$prev=$page-1;
	if ($prev!=0)
	{print "<div><a href='adguest.php?act=banlist&amp;page=".$prev."'>Назад</a></div>";
	}
    echo "<div>Забаннено: $countbann<br/><a href='adguest.php?act='>админ-guest</a></div>";
    	 }
    	 ////////////////////////////////
   	   if($act=="razban")
   	   {
mysql_query("delete from `bann` where time='".$id."';");
echo "<div>".$delstr." разбанен<br /><a href='adguest.php?act='>админ-guest</a></div>";  
 header ("Location: adguest.php");

}
///////////////////////////////////
}
include ("foot.php");
?>