Файл: modules/forum/section.php
Строк: 145
<?php
define('R', $_SERVER['DOCUMENT_ROOT']);
define('S', R.'/system');
require_once(R.'/system/kernel.php');
$tmp->header('forum');
$id = $db->guard($_GET['id']);
$p=$db->fass("select * from `forum_section` where `id` = '".$id."' ");
$r=$db->fass("select * from `forum_razdel` where `id` = '".$p['razdel']."'");
$tmp->title('title', Language::config('forum').' / '.$r['name'].' / '.$p['name']. (User::level() >= 3 ? '<a href="/forum/'.$p['razdel'].'/'.$id.'?edit">'.img('edit_c.png').'</a><a href="/forum/'.$p['razdel'].'/'.$id.'?d">'.img('del_c.png').'</a>' : NULL));
User::panel();
if(!$p){
$tmp->div('error', Language::config('error'));
$tmp->div('menu', '<a href="/">'.img('link.png').' '.Language::config('home').'</a>');
$tmp->footer();
exit();
}
if(User::level() >=3){
if(isset($_GET['edit'])){
if(isset($_REQUEST['submit'])){
$name = $db->guard($_POST['name']);
$pos = $db->guard($_POST['pos']);
if(empty($name) || empty($pos)) $error .= Language::config('error');
if(!isset($error)) {
$db->query("update `forum_section` set `name` = '".$name."', `pos` = '".$pos."' where `id` = '".$id."' ");
header('location: /forum/'.$p['razdel'].'/'.$p['id']);
}
}
error($error);
$tmp->div('main', '<form method="POST" action="">
'.Language::config('name').': <br/>
<input type="text" name="name" value="'. $p['name'] .'" /><br/>
'.Language::config('pos').':<br/>
<input type="text" name="pos" value="'.$p['pos'].'" style="width: 60px" /><br/>
<input type="submit" name="submit" value="'.Language::config('save').'" /></form>');
$tmp->div('menu', '<hr><a href="/forum/'.$p['razdel'].'/'.$p['id'].'">'.img('link.png').' '.Language::config('back').'</a>');
$tmp->footer();
exit();
}
if(isset($_GET['d'])) {
if(isset($_GET['yes'])){
$db->query("DELETE FROM `forum_section` where `id` = '".$id."' limit 1");
$db->query("DELETE FROM `forum_topic` where `section` = '".$id."'");
$db->query("DELETE FROM `forum_message` where `section` = '".$id."'");
header('location: /forum/'.$p['razdel']);
}
$tmp->del_sure($p['name'], 'd&yes');
$tmp->footer();
exit();
}
}
if(isset($_GET['nt'])){
if(isset($_REQUEST['submit'])){
$name = $db->guard($_POST['name']);
$message = $db->guard($_POST['message']);
if(empty($name) || empty($message)) $error .= Language::config('error_strlen');
if(!isset($error)){
$db->query("insert into `forum_topic` set `razdel` = '".$p['razdel']."', `section` = '".$p['id']."', `kto` = '".User::ID()."', `name` = '".$name."', `time` = '".time()."', `last_message_time` = '".time()."' ");
$lid = $db->insert_id();
$db->query("insert into `forum_message` set `razdel` = '".$p['razdel']."', `section` = '".$p['id']."', `topic` = '".$lid."', `kto` = '".User::ID()."', `message` = '".$message."', `time` = '".time()."' ");
header('location: /forum/topic'.$lid);
}
}
error($error);
$tmp->div('main', '<form method="POST" action="">
'.Language::config('name').':<br/>
<input type="text" name="name" value="'.out($_POST['name']) .'" /><br/>
'.Language::config('message').':<br/>
<textarea name="message">'.out($_POST['message']).'</textarea><br />
<input type="submit" name="submit" value="'.Language::config('add').'" /></form>');
$tmp->div('menu', '<hr><a href="/forum/'.$p['razdel'].'/'.$p['id'].'">'.img('link.png').' '.Language::config('back').'</a>');
$tmp->footer();
exit();
}
$posts=$db->fass_c("SELECT COUNT(*) as count FROM `forum_topic` where `section` = '".$id."' ");
if($posts==0){
$tmp->div('main', Language::config('no_topics'));
if(User::aut()){
$tmp->div('menu', '<a class="items" href="/forum/'.$p['razdel'].'/'.$p['id'].'?nt">'.img('new_topic.png').' '.Language::config('new_topic').'</a>');
}
$tmp->div('menu', '<a href="/forum/'.$p['razdel'].'">'.img('link.png').' '.Language::config('back').'</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_topic` where `section` = '".$id."' ORDER BY id and `is_top_topic` = '1' desc LIMIT ".$start.", ".$num." ");
if(User::aut()){
$tmp->div('menu', '<a class="items" href="/forum/'.$p['razdel'].'/'.$p['id'].'?nt">'.img('new_topic.png').' '.Language::config('new_topic').'</a>');
}
echo '<div class="menu">';
while($fo=$f->fetch_assoc()) {
if($fo['is_close_topic'] == 1){
$icon = img('forum_close.png');
}elseif($fo['is_top_topic'] == 1){
$icon = img('forum_pin.png');
} else {
$icon = img('forum_topic.png');
}
$c=$db->fass_c("SELECT COUNT(*) as count FROM `forum_message` where `topic` = '".$fo['id']."'");
echo '<hr><a href="/forum/topic'.$fo['id'].'">'.$icon.' '.$fo['name'].' <span>'.$c.'</span></a>';
}
echo '</div>';
page('?');
$tmp->div('menu', '<hr><a href="/forum/'.$p['razdel'].'">'.img('link.png').' '.Language::config('back').'</a>');
$tmp->footer();
?>