Файл: profi_wm/modules/guest/mess.php
Строк: 94
<?php
include '../../system/core.php';
$num = 12;
if($_POST['page']) $_SESSION['page'] = (int)$_POST['page'];
if(!$_SESSION['page'] || $_SESSION['page'] == 1) $page = 0;
else
$page = $_SESSION['page'];
$posts = mysql_result(mysql_query("SELECT COUNT(*) FROM `guest`"), 0);
$total = intval(($posts - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
/*Если есть, выводим ошибку*/
if($_COOKIE['errors']) echo' <div><font color="red">'.$_COOKIE['errors'].'</font></div>';
/**/
$print = mysql_query("SELECT * FROM `guest` ORDER BY `id` DESC LIMIT ".$start.",".($num)."");
if (mysql_affected_rows() != 0)
{
while($arr = mysql_fetch_array($print))
{
echo '<div class="poste">';
if($_SESSION['id'] != $arr['user_id']) echo ''.uname($arr['user_id']).' ['.$arr['date'].'] <span style="cursor: pointer;" onClick="otv(''.mysql_result(mysql_query("SELECT `login` FROM `user` WHERE `id` = '".(int)$arr['user_id']."'"), 0).'')">[Отв]</span>';
else
echo uname($arr['user_id']).' ['.$arr['date'].'] ';
if($user['status'] >= 2) echo'<span style="cursor: pointer;" onClick="del_mess(''.$arr['id'].'')">[del]</span>';
echo'</div>';
echo '<div class="post1">
'.antispam(smiles(bbcode(nl2br($arr['content'])))).'
</div> ';
}
}
else
{
echo'Пока нет сообщений';
}
/*Постраничка*/
for ($v=0;$v<$total_pages;$v++){
$page_number=$v*$na_page;
if(!$page_number) $page_number = 1;
if ($page_number!=$page) {
echo "<span style='cursor: pointer;' onClick='nav($page_number)'>[".($v+1)."]</span> ";
} else {
echo '<b>['.($v+1).']</b>';
}
}
// Вывод меню
// Проверяем нужны ли стрелки назад
if ($page != 1) $pervpage = '<button onClick="nav(1)" class="button_navig"><<</button>
<button onClick="nav('. ($page - 1) .')" class="button_navig"><</button>';
// Проверяем нужны ли стрелки вперед
if ($page != $total) $nextpage = '<button onClick="nav('. ($page + 1) .')" class="button_navig">></button>
<button onClick="nav('.$total.')" class="button_navig">>></button>';
// Находим две ближайшие станицы с обоих краев, если они есть
if($page - 2 > 0) $page2left = '<button onClick="nav('. ($page - 2) .')" class="button_navig">'. ($page - 2) .'</button>';
if($page - 1 > 0) $page1left = '<button onClick="nav('. ($page - 1) .')" class="button_navig">'. ($page - 1) .'</button>';
if($page + 2 <= $total) $page2right = '<button onClick="nav('. ($page + 2) .')" class="button_navig">'. ($page + 2) .'</button>';
if($page + 1 <= $total) $page1right = '<button onClick="nav('. ($page + 1) .')" class="button_navig">'. ($page + 1) .'</button>';
echo'
<div class="tegi">
<center>
'.$pervpage.$page2left.$page1left.'<input value="'.$page.'" type="button" />'.$page1right.$page2right.$nextpage.'
</center>
</div>';
?>