<?php
include '../system/bd.php';
include '../system/cook.php';
include ("../system/gzip.php");
if(isset($_SESSION['auth']) && $_SESSION['auth']==1){
include '../system/head.php';
include '../system/head1.php';
$req = mysql_query("SELECT * FROM `user` WHERE `id` = '$user[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto=="0"){
echo'Ошибка 1';
include 'inc/nogi.php';
exit;
}
$us = mysql_fetch_array($req);
if(empty($us[clan])){
echo' <div class="title">Ошибка</div>
<div class="empty_block item_center"> Вы не состоите в банде! </div>';
echo'<div class="block_link">';
echo"<a href='../index.php'> <img src ='../img/images/arrow.png'> Вернуться</a></div>";
include '../system/foot.php';
exit;}
/////////////

if($us[clan]!="$clans[id]"){

$req = mysql_query("SELECT * FROM `clans` where `id`='$us[clan]' or `leader`='$us[clan]' ");

$req = mysql_query("SELECT * FROM `clans` where `id`='$us[clan]' or `leader`='$us[clan]' ");

$avto=mysql_num_rows($req);
if($avto==1){
$clan1 = mysql_fetch_array($req);
$req = mysql_query("SELECT `id` FROM `user` where `clan`='$clan1[id]'");



////////////////////////////
$kk=mysql_num_rows($req);


echo '' ;

switch($_GET[mod]){
default:

echo" <div class='title'>
Журнал клана </div>";

$cop=5;
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `clans_journal` WHERE `clan`='$user[clan]' "),0);
$cp=ceil($ca/$cop);
if(isset($_GET['page']) && is_numeric($_GET['page'])){
$page = $_GET['page'];
if($_GET['page']>$cp) $page=$cp;
if($_GET['page']<1)$page=1;
}else{
$page=1;
}
$start=$page*$cop-$cop;
$dlist = 'list1';
$req = mysql_query("SELECT * FROM `clans_journal` WHERE `clan`='$user[clan]' ORDER by `id` DESC LIMIT $start,$cop  ");
$avto=mysql_num_rows($req);
if($avto==0){
echo" <div class='empty_block item_center'>
 Нет истории </div>";

}else{
while($chat = mysql_fetch_array($req))
{



$d = time()-$chat['time'];
echo"
<div class='block'>

$chat[msg] 

</br><span class='role0'> (".sec2day($d)." назад)</span>
</div> ";
}
echo '
<div class="empty_block top pagi item_center">';
if($page-1>0){
echo '<a href="?&page='.($page-1).'">&lt;</a> ';
}
if($page-1>0){
echo '<a href="?&page='.($page-1).'">'.($page-1).'</a> ';
}
echo '<b>'.$page.'</b>';
if($page+1<=$cp){
echo ' <a href="?&page='.($page+1).'">'.($page+1).'</a>';
}
if($page+1<=$cp){
echo ' <a href="?&page='.($page+1).'">&gt;</a>';
}
echo "</div>";
}

   
break;



             //////////




}
} else{
echo"Ошибка 3";
include '../system/foot.php';
exit;}
}
//////////////////

}else{
header ("Location: index.php"); exit;
}
include '../system/foot.php';
?>
