View file admin/chat.php

File size: 3.52Kb
<? $page_name="Админ-меню"; $dir='../'; include("../include/1.php"); require "../include/avto.php";

if(!isset($_SESSION['user_id']) or $me['admin']!=2)exit("Нету доступа!");




echo '<a href=../page/tag.html>Тэги</a> | <a href=../page/smile.html>Смайлы</a><br><form action="../chat/post.php" method="post"><textarea name="text" cols="20" rows="2"></textarea><br><input name="" type="submit" value="Написать"><br><br></form>';

$date=date("Y.m.d");

//////////////////////////////////////////
$num = 5;
@$page = $_GET['page'];
$result00 = mysql_query("SELECT COUNT(*) FROM `shurik_chat` LIMIT 200");
if (mysql_num_rows($result00) == 0) {exit("Сообщений нет!");}
$temp = mysql_fetch_array($result00);
$posts = $temp[0];
$total = (($posts - 1) / $num) + 1;
$total =  intval($total);
$page = intval($page);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
///////////////////////////////////////////

$chat_post1=mysql_query("select * from `shurik_chat` order by `time2` desc limit $start,$num");
if(@mysql_num_rows($chat_post1)>0){$chat_post2=mysql_fetch_array($chat_post1);
echo mysql_error();

do{$login_avtor=$chat_post2['avtor'];$user_avtor=mysql_fetch_array(mysql_query("select id, login, echologin, online from `shurik_users` where login='$login_avtor'"));

$date=date("ndHis");
$time=$user_avtor['online'];
if ($time+45 > $date) $st_on = "<span style='color:green'>[ON]</span>";
else $st_on = "<span style='color:red'>[OFF]</span>";

echo"<div class=aa><small><a href=chat2.php?edit=$chat_post2[id]>[ред]</a> <a href=chat2.php?del=$chat_post2[id]>[удал]</a> </small><br/><a href=../user/$user_avtor[id]>$user_avtor[echologin]</a> $st_on | $chat_post2[time]<br><small>$chat_post2[text]</small></div><hr style=color:white>";}
while($chat_post2=mysql_fetch_array($chat_post1));

}
else echo "Тут ничего не написали";
//////////////////////////
$url_for_pstr="chat.php?page=";
if($page - 5 > 0) $page5left = ' <a href='.$url_for_pstr.($page - 5) .'>'. ($page - 5) .'</a> | ';
if($page - 4 > 0) $page4left = ' <a href='.$url_for_pstr.($page - 4) .'>'. ($page - 4) .'</a> | ';
if($page - 3 > 0) $page3left = ' <a href='.$url_for_pstr.($page - 3) .'>'. ($page - 3) .'</a> | ';
if($page - 2 > 0) $page2left = ' <a href='.$url_for_pstr.($page - 2) .'>'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = ' <a href='.$url_for_pstr.($page - 1) .'>'. ($page - 1) .'</a> | ';

if($page + 5 <= $total) $page5right = ' | <a href='.$url_for_pstr.($page + 5) .'>'. ($page + 5) .'</a>';
if($page + 4 <= $total) $page4right = ' | <a href='.$url_for_pstr.($page + 4) .'>'. ($page + 4) .'</a>';
if($page + 3 <= $total) $page3right = ' | <a href='.$url_for_pstr.($page + 3) .'>'. ($page + 3) .'</a>';
if($page + 2 <= $total) $page2right = ' | <a href='.$url_for_pstr.($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href='.$url_for_pstr.($page + 1) .'>'. ($page + 1) .'</a>';

if($page - 1 > 0) $nazad = '<a href='.$url_for_pstr.($page - 1) .'>Назад</a>';
if($page + 1 <= $total) $vpered = '<a href='.$url_for_pstr.($page + 1) .'>Далее</a>';

// Вывод меню если страниц больше одной

if ($total > 1)
{
Error_Reporting(E_ALL & ~E_NOTICE);
echo $pervpage.$page5left.$page4left.$page3left.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$page3right.$page4right.$page5right.$nextpage.'<br>'.$nazad.' | '.$vpered;
}
////////////////////////////







echo "<br><br/><a href=index.php>В админ-меню</a>";
include("../include/2.php"); ?>