Файл: profi_wm/modules/op/index.php
Строк: 15
<?php
include '../../system/core.php';
if(!$user['id']){
header('Location: /index.php'); exit;
}
switch($_GET['m']){
case 'clear':
$ops = mysql_result(mysql_query("SELECT COUNT(*) FROM `op` where `who` = '".$user['id']."'"),0);
mysql_query("DELETE FROM `op` WHERE `who`='".$user['id']."' limit $ops");
header('Location: /op'); exit;
break;
#Главная
default:
$_title = 'Оповещения';
include '../../system/header.php';
echo '<div class="s"><span><a href="/op?m=clear">Очистка</a><span></div>';
$cop = $user['on_page'];
$ca = mysql_result(mysql_query("SELECT COUNT(*) FROM `op` where `who` = '".$user['id']."'"),0);
$cp = ceil($ca/$cop);
if(isset($_GET['p']) && is_numeric($_GET['p'])){
$p = $_GET['p'];
if($_GET['p']>$cp) $p = $cp;
if($_GET['p']<1)$p = 1;
}else{
$p = 1;
}
$start = $p*$cop-$cop;
$op = mysql_query("SELECT * FROM `op` where `who` = '".$user['id']."' ORDER BY `id` DESC LIMIT $start,$cop");
while($op2 = mysql_fetch_assoc($op)){
$op2_ho = mysql_fetch_array(mysql_query('select * from `user` where `id` = '.$op2['ho'].''));
echo '<div class="post1"><a href="/us'.$op2['ho'].'">'.uname($op2_ho['id']).'</a> '.smiles(bbcode($op2['text'])).' ['.times($op2['time']).']';
if($op2['read'] == 0) echo ' <font color="red"><b>[new!]</b></font>';
echo '</div>';
mysql_query("UPDATE `op` SET `read`='1' WHERE `id`='".$op2['id']."' limit 1");
}
echo '<div class="levo">Стр. ';
if($p-2>0) echo '<a href="/op/p1"><<</a> ';
if($p-1>0) echo '<a href="/op/p'.($p-1).'"><</a> ';
if($p-3>0) echo '<a href="/op/p'.($p-3).'">'.($p-3).'</a> | ';
if($p-2>0) echo '<a href="/op/p'.($p-2).'">'.($p-2).'</a> | ';
if($p-1>0) echo '<a href="/op/p'.($p-1).'">'.($p-1).'</a> | ';
echo '<b>'.$p.'</b>';
if($p+1<=$cp) echo ' | <a href="/op/p'.($p+1).'">'.($p+1).'</a>';
if($p+2<=$cp) echo ' | <a href="/op/p'.($p+2).'">'.($p+2).'</a>';
if($p+3<=$cp) echo ' | <a href="/op/p'.($p+3).'">'.($p+3).'</a>';
if($p+1<=$cp) echo ' <a href="/op/p'.($p+1).'">></a>';
if($p+2<=$cp) echo ' <a href="/op/p'.ceil($ca/$cop).'">>></a>';
echo '</div></div>';
break;
}
include '../../system/footer.php';
?>