<?php
define('ROOT','../');
define('GCMS',true);
require_once (ROOT.'system/power.php');
if ($id) {
$type = $db -> query("SELECT `id` FROM `guest`");
if ($type -> num_rows > 0) $the = $type -> fetch_assoc(); else $the = false;
} else $the = false;
$diz -> head('Гостевая книга');
$diz -> title('Гостевая книга');
$count = $db -> dbcount('COUNT(`id`)','guest');
$num = isset($ya['num']) ? $ya['num'] : 10;
$total = intval(($count - 1) / $num) + 1; 
if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] < 1 )
{
$page = 1;
} elseif($_GET['page'] > $total)
{ $page = $total;
} else $page = (int)$_GET['page'];
$start = $page * $num - $num;
$posts = $db -> query("SELECT `id` FROM `guest`");
if ($posts -> num_rows > 0) {
$for = $db -> query("SELECT `id`,`uid`,`text`,`who`,`ip`,`browser`,`time` FROM `guest` ORDER BY `id` DESC LIMIT ".$start.",".$num);
while ($assoc = $for -> fetch_assoc()) {
$user = $assoc['uid'];
$arr = $db -> query("SELECT `login` FROM `users` WHERE `id` = '".$assoc['uid']."' LIMIT 1");
if ($arr -> num_rows > 0) {
$array['login'] = $func -> user($user);
} else {$array['login'] = 'Гость';}
$dop = null;
$otv = null;
if ($aut) {
if ($ya['id'] == $user) {
$dop = ' | <a href="del.php?id='.$assoc['id'].'">[Удал]</a>';
} 
elseif ($ya['level'] > 1) {
$dop = ' | <a href="del.php?id='.$assoc['id'].'">[Удал]</a>';
}
if ($ya['id'] != $user and $array['login'] != 'Гость') {
$otv = ' | <a href="post.php?sid='.$assoc['uid'].'&id='.$assoc['id'].'&page='.$page.'"> [Ответ]</a>';
} 
}
$msg .= '<div class="top">'.$array['login'].' ('.$func -> times(date('d m Y в H:i',$assoc['time'])).')'.$dop.' '.$otv.'</div>';
$msg .='<div class="fon">'.$func -> tags($func -> smiles($assoc['text'])).'</div>';
}
}else{$msg.='<div class="fon">Пока ни кто не отписался!</div>';}
$act = './?';
$msg .= ''.$func -> pagenav($act,$page,$total).'';

$msg .= '<div class="tochechki"><a href="post.php?page='.$page.'">Написать</a></div>';


$msg .= '<div class="levo">'.$diz -> img('home.png').'<a href="/index.php">На главную</a></div>';
#####Копирайт#######
require_once (ROOT.'system/kopy.php');
$diz -> out($msg);

?>