<?php
$t = "Помощь";
$biglogo = 1;
include_once '../core/core.php';
if ($id != 0 && $db->Count("help","WHERE `qid` = '".$id."'") != 0 && $act=="view"){
	$c = $db->getObject("SELECT * FROM `help` WHERE `qid` = '".$id."'");
	$t = $c->title." - Помощь";
	include_once '../core/head.php';
	echo '<div class="title">'.$c->title.'</div>';
	echo '<div class="text">'.$core->drawString($c->sms).'</div>';
	echo b("?id=".$c->hid);
	echo ($user->auth()?hcp():h());
	include_once '../core/foot.php';
	die();
} elseif ($id != 0 && $db->Count("help_categories","WHERE `hid` = '".$id."'") != 0){
	$c = $db->getObject("SELECT * FROM `help_categories` WHERE `hid` = '".$id."'");
	$t = $c->name." - Помощь";
	include_once '../core/head.php';
	echo '<div class="title">'.$c->name.'</div>';
	if ($db->Count("help","WHERE `hid` = '".$id."'") == 0){
		echo '<div class="error">Информации пока что нету</div>';
	}

	$max = 10;
	$k_post = $db->Count("help","WHERE `hid` = '".$id."'");
	$k_page = $core->k_page($k_post,$max);
	$page = $core->page($k_page);
	$start = $max*$page-$max;
	$_tmp = $db->Query("SELECT * FROM `help` WHERE `hid` = '".$id."' ORDER BY `hid` ASC LIMIT $start, $max"); 
	while ($data = mysqli_fetch_assoc($_tmp)){
		echo l("?id=".$data["qid"]."&act=view",$data["title"],$data["icons"],"link",false,mb_strimwidth($data["sms"],0,60,"..."),1);
	}
	if($k_page>1) echo $core->str('?id='.$id.'&',$k_page,$page);
	echo b('?');
	echo ($user->auth()?hcp():h());
	include_once '../core/foot.php';
	die();
}
include_once '../core/head.php';
echo '<div class="title">Разделы помощи</div>';
$max = 10;
$k_post = $db->Count("help_categories");
$k_page = $core->k_page($k_post,$max);
$page = $core->page($k_page);
$start = $max*$page-$max;
$_tmp = $db->Query("SELECT * FROM `help_categories` ORDER BY `hid` ASC LIMIT $start, $max"); 
while ($data = mysqli_fetch_assoc($_tmp)){
	echo l("?id=".$data["hid"],$data["name"],$data["icons"],"link",$db->Count("help","WHERE `hid` = '".$data["hid"]."'"),$data["descriptor"],1);

}
if($k_page>1) echo $core->str('?',$k_page,$page);
echo ($user->auth()?hcp():h());
include_once '../core/foot.php';
?>