<?php
define('ROOT','../');
define('GCMS',true);
require_once (ROOT.'system/power.php');
$pav = $db -> query("SELECT `id`,`name`,`cat`,`user` FROM `albom_pav` where `id`='$id'")->fetch_assoc();
$cat = $db -> query("SELECT `id`,`name` FROM `albom_cat` where `id`='$pav[cat]'")->fetch_assoc();
$diz -> head('Фотоальбомы');
$diz -> title("<a href='./'>Фотоальбомы</a>/<a href='cat$cat[id]'>$cat[name]</a>/<b>".$pav['name']."</b>");
if($aut==true and ($ya['level']>1 or $pav['user']==$ya['id'])){
$msg.='<div class="tochechki">
'.$diz -> img('albom/delete.png').' <a href="./func.php?id='.$id.'&amp;mode=delal">Удалить альбом</a></br>
'.$diz -> img('albom/satting.png').' <a href="./func.php?id='.$id.'&amp;mode=redal">Редактировать альбом</a></div>';
}
////-------------------/////
$count = $db -> dbcount('COUNT(`id`)','albom_fotos',"`cat` = '".$id."'");
$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;
////------------------/////
$for = $db -> query("SELECT `id`,`name`,`url`,`text` FROM `albom_fotos` where `cat`='$id'");
if ($for -> num_rows > 0) {
while ($assoc = $for -> fetch_assoc()) {
$nst2 = $db -> dbcount('COUNT(*)','comes',"`idwh` = '".$assoc['id']."' and `where`='albom'");
if ($nst2==0)$nst2=NULL;
else $nst2='<span style="color:red">+'.$nst2.'</span>';
$kom = $db -> dbcount('COUNT(`id`)','comes',"`idwh` = '".$assoc['id']."' and `where`='albom'");  
$foto = ''.ROOT.'albom/'.$assoc['url'];                
$msg .= '<div class="post">
<TABLE> 
<TR> 
<TD ALIGN=RIGHT><img src="/system/resize.php?img='.$foto.'&width=48&height=48&i=0" alt=""/>
</TD> 
<TD ALIGN=LEFT>
<a href="foto'.$assoc['id'].'"> '.$assoc['name'].'</a> ('.$kom.''.$nst2.')</br>
<small>'.$assoc['text'].'</small></TD></TR></table></div>';
}
$act = 'cat.php?id='.$id;
$msg .= ''.$func -> pagenav($act,$page,$total).'';
} else {
$msg .= '<div class="fon">В данном фотоальбоме нет фотографий</div>';
}
$msg .= '<div class="levo">'.$diz -> img('home.png').'<a href="/">На главную</a></div>';
#####Копирайт#######
require_once ('../system/kopy.php');
$diz -> out($msg);
?>