Файл: apanel/news.php
Строк: 61
<?php
define('R', $_SERVER['DOCUMENT_ROOT']);
define('S', R.'/system');
require_once(R.'/system/kernel.php');
$tmp->header('news');
$tmp->div('title', Language::config('news'));
User::panel();
if(User::level() < 2)
{
header('location: /');
}
$count=$db->fass("SELECT COUNT(id) as count FROM `news`");
$posts=$count['count'];
$total = intval((($posts-1)/$num)+1);
if(empty($page) or $page<0) $page=1;
if($page>$total) $page=$total;
$start=$page*$num-$num;
$n=$db->query("select * from `news` ORDER BY time DESC LIMIT ".$start.", ".$num."");
if(isset($_GET['del']))
{
$del = $db->guard($_GET['del']);
$c=$db->fass("SELECT * FROM `news` where `id` ='".$del."'");
if(User::profile('level') >=3)
$db->query("DELETE FROM `news` where `id` ='".$del."'");
header('location: /apanel/news');
}
if(isset($_REQUEST['submit']))
{
$message = $db->guard($_POST['message']);
if(empty($_POST['message']) )
{
$error .= Language::config('error');
}
if( mb_strlen($_POST['message'], 'UTF-8')<2)
{
$error .= Language::config('error');
}
if(!isset($error))
{
$db->query("INSERT INTO `news` set `kto` = '".User::ID()."', `message` = '".$message."', `time` = '".time()."' ");
header('location: /apanel/news');
}
}
error($error);
$tmp->div('menu', '<form method="POST" action="">
'.Language::config('message').':<br/>
<textarea name="message"></textarea><br />
<input type="submit" name="submit" value="'.Language::config('send').'" /></form>');
if($posts==0)
{
$tmp->div('error', Language::config('no_news'));
}
else{
while($news=$n->fetch_assoc())
{
$tmp->div('block', nick($news['kto'], true).' '. times($news['time']). ((User::profile('level') >=3) ? ' <a href="./news/del'.$news['id'].'">['.Language::config('del').']</a>' : NULL) .' </br> '.bb(smile($news['message'])));
}
page('?');
}
$tmp->footer();
?>