Файл: users/my_diary.php
Строк: 62
<?
include('../core/core.php');
include(MAINDIR.'style/head.php');
if(is_user()){
$my = DB::run() -> queryFetch("SELECT * FROM `users` WHERE `login`=? LIMIT 1",array(check($_COOKIE['login'])));
$admin = $users['status'];
$login = check($_GET['login']);
if($login == NULL){$login = $my['login'];} else { $login = $login; }
title('Дневники пользователей!');
switch ($mode):
case 'index':
$myz = DB::run() -> queryFetch("SELECT * FROM `users` WHERE `login`=? LIMIT 1",array($login));
if(!empty($myz['login'])){
if($login == $_COOKIE['login']){echo '<div class="title">Мои Дневники</div>';} else {echo '<div class="title">Дневники '.$login.'</div>';}
define('TOPAGE',10); $num = TOPAGE;
$links = '?mode=index&page=';
$page = intval($_GET['page']);
$posts = DB::run() -> query("SELECT * FROM `diary_cat` WHERE `login`=?",array($login)) -> rowCount();
$total = intval(($posts - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$themes = DB::run()->query("SELECT * FROM `diary_cat` WHERE `login`=? ORDER BY `id` DESC LIMIT $start,".TOPAGE."",array($login));
$themes = $themes -> fetchAll();
foreach($themes AS $u){
echo'<div class="menu">';
echo'<a href="/diary/?mode=see&id='.$u['id'].'">'.$u['name'].'</a> ['.count_all('diary_note','id_diary_cat',$u['id']).'] ';
if(is_admin(array(101, 102))){echo'[<a href="/diary/?mode=ful_dell_diary">X</a>]';}
echo'<br />
Автор: <a href="/profile/'.$u['login'].'">'.$u['login'].'</a><br />
Дата: '.$u['data'].'';
echo'</div>';
}
if ($page != 1) $pervpage = '<a href= '.$links.'1><<</a> <a href= '.$links.''. ($page - 1) .'><</a> ';
if ($page != $total) $nextpage = ' <a href= '.$links.''. ($page + 1) .'>></a> <a href= '.$links.'' .$total. '>>></a>';
if($page - 2 > 0) $page2left = ' <a href= '.$links.''. ($page - 2) .'>'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = '<a href= '.$links.''. ($page - 1) .'>'. ($page - 1) .'</a> | ';
if($page + 2 <= $total) $page2right = ' | <a href= '.$links.''. ($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href= '.$links.''. ($page + 1) .'>'. ($page + 1) .'</a>';
if($posts == 0){ echo'<div class="menu">Дневники не были созданы!</div>'; } else {echo '<div class="menu_2">'.$pervpage.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$nextpage.'</div>'; }
} else {echo'<div class="menu">Пользователя не существует!</div>'; }
break;
default:
header ('location: ?mode=index');
endswitch;
} else {
title('Ошибка!');
echo'<div class="title">Ошибка!</div>';
echo'<div class="error">';
echo'Доступ разрешен только авторизованым!';
echo'</div>';
}
include(MAINDIR.'style/foot.php');
?>