Файл: faq.php
Строк: 76
<?
define('ROOT','./');
require_once (ROOT.'system/power.php');
switch($mode){
//информация
case 'view':
$sql = $db -> query("SELECT * FROM `faq` WHERE `id` = '".$sid."' and `type`='text' or `type`='page' and `id` = '".$sid."'");
if ($sql -> num_rows > 0) {
$menu = $sql -> fetch_assoc();
if($menu['if_dir']!=0)$dir = $db -> query("SELECT `name` from `faq` where `id`='".$menu['if_dir']."' and `type`='cat'")-> fetch_assoc();
$diz -> head($menu['name']);
$diz -> title($menu['name']);
if($menu['type']=='text')echo '<div class="fon">'.htmlspecialchars_decode($menu['text']).'</div>';
if($menu['type']=='page')require_once (ROOT.'pages/'.$menu['text']);
echo '<div class="levo"><a href="faq.php?sid='.$menu['if_dir'].'&page='.$page.'" class="levo_tuch">'.$diz -> icon('back.png').' '.language('Назад').'</a></div>';
} else header('Location: faq.php');
break;
//папки
default:
$dir_sql = $db -> query("SELECT `name` from `faq` where `id`='".$sid."' and `type`='cat'");
if($dir_sql->num_rows==0 and $sid!=null)header('Location: faq.php'); else $dir=$dir_sql-> fetch_assoc();
$count = $db -> dbcount('COUNT(`id`)','faq');
if($dir['name']==null)$dir['name']='Информация';
$diz -> head($dir['name']);
$diz -> title($dir['name']);
if($count!=0 && $sid!=0){
if($sid!=0){
$tree = array();
$dirid = $sid;
while ($dirid != '0' && $dirid != "") {
$dir_while = $db -> query("SELECT * FROM `faq` WHERE `id` = '".$dirid."' and `type`='cat' LIMIT 1")-> fetch_assoc();
$tree[] = '<a href="faq.php?sid='.$dirid.'">' . $dir_while['name']. '</a>';
$dirid = $dir_while['if_dir'];
}
krsort($tree);
$cdir = array_pop($tree);
echo '<div class="fon"><a href="faq.php?">'.language('Корневая').'</a> / ';
foreach ($tree as $value) {
echo $value . ' / ';
}
echo '<b>'.$dir['name'].'</b></div>';
}else echo '<div class="fon">'.language('Корневая').' /</div>';
}
$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;
$sql = $db -> query("SELECT * FROM `faq` where `if_dir`='".$sid."' ORDER BY `type` asc,`sid` desc LIMIT ".$start.",".$num);
if ($sql -> num_rows > 0) {
while ($faq = $sql -> fetch_assoc()) {
if($faq['type']=='cat'){
echo '<div class="menu"><a href="faq.php?sid='.$faq['id'].'" class="menutuch">'.$diz -> icon('cat.png').' '.$faq['name'].' </a></div>';
}else{
echo '<div class="menu"><a href="faq'.$faq['id'].'" class="menutuch">'.$diz -> icon('faq.png').' '.$faq['name'].' </a></div>';
}
}
echo $func -> pagenav('?',$page,$total);
}else echo '<div class="fon">'.language('Раздел пуст').'</div>';
}
echo '<div class="levo"><a href="'.ROOT.'" class="levo_tuch">'.$diz -> icon('home.png').' '.language('На главную').'</a></div>';
#####Копирайт#######
$diz -> out($msg);
?>