Файл: forum/index.php
Строк: 55
<?php
define('R', $_SERVER['DOCUMENT_ROOT']);
define('S', R.'/system');
require_once(R.'/system/kernel.php');
$tmp->header('forum');
$tmp->div('title', Language::config('forum'));
User::panel();
if(User::profile('level') >=3){
if(isset($_GET['r'])){
if(isset($_REQUEST['submit'])){
$name = $db->guard($_POST['name']);
$pos = $db->guard($_POST['pos']);
if(empty($name)){
$error .= Language::config('error');
}
if(empty($pos)){
$error .= Language::config('error');
}
if(!isset($error)){
$db->query("insert into `forum_razdel` set `name` = '".$name."', `pos` = '".$pos."' ");
header('location: /forum');
}
}
$tmp->div('menu', '<form method="POST" action="">
'.Language::config('name').':<br/>
<input type="text" name="name" value="'. out($_POST['name']) .'" /><br/>
'.Language::config('pos').':<br/>
<input type="text" name="pos" value="'. out($_POST['pos']) .'" /><br/>
<input type="submit" name="submit" value="'.Language::config('add').'" /></form>');
}
}
$count=$db->fass("SELECT COUNT(id) as count FROM `forum_razdel`");
$posts=$count['count'];
if($posts==0){
$tmp->div('block', Language::config('no_razdels'));
if(User::level()){
$tmp->div('block', '<a href="/forum?r">'.Language::config('add_razdel').'</a>');
}
$tmp->footer();
exit();
}
$total = (($posts-1)/$num)+1;
$total = intval($total);
$page = intval($page);
if(empty($page) or $page<0) $page=1;
if($page>$total) $page=$total;
$start=$page*$num-$num;
$f= $db->query("SELECT * FROM `forum_razdel` ORDER BY pos ASC LIMIT ".$start.", ".$num." ");
while($fo=$f->fetch_assoc())
{
$tmp->div('block', '<a href="/forum/'.$fo['id'].'">'.$fo['name'].'</a>');
}
if(User::profile('level') >=3){
$tmp->div('block', '<a href="/forum?r">'.Language::config('add_razdel').'</a>');
}
page('?');
$tmp->footer();
?>