Файл: modules/news/index.php
Строк: 71
<?php
switch ($act) {
default:
$total = DB::run()->querySingle("select count(`id`) from `news`;");
if ($total)
{
require_once 'core/navsetvars.php';
$query = DB::run()->query("select * from `news` ORDER BY `time` DESC LIMIT $start, $config[ipp];");
}
$config['newtitle'] = $lang['News'];
if (access('news_add') or access(2)) $tpl['title'] = $lang['News'].' (<a href="/news/add">'.$lang['Add'].'</a>)';
$tpl['file'] = 'news';
require_once 'core/header.php';
break;
case 'view':
$news = DB::run()->queryFetch("select * from `news` where `id` = ?;", array($id));
if ($news)
{
$config['newtitle'] = $news['subject'];
$tpl['title'] = '<a href="/news">'.$lang['News'].'</a> » '.$news['subject'];
$tpl['file'] = 'news_view';
require_once 'core/header.php';
}
else
{
redirect(HTTPHOME.'news/');
}
break;
case 'add':
if (access('news_add') or access(2))
{
$subject = isset($_POST['subject']) ? check($_POST['subject']) : FALSE;
$message = isset($_POST['message']) ? check($_POST['message']) : FALSE;
if ($subject && $message)
{
DB::run()->query("insert into `news` set `subject` = ?, `message` = ?, `time` = ?;", array($subject, $message, TIME));
$newsid = DB::run()->lastinsertid();
redirect('/news/'.$newsid);
}
$config['newtitle'] = $lang['Add'];
$tpl['title'] = '<a href="/news">'.$lang['News'].'</a> » '.$lang['Add'];
$tpl['file'] = 'news_add';
require_once 'core/header.php';
}
else
{
redirect('/news');
}
break;
case 'edit':
if (access('news_editpost') or access(2))
{
$news = DB::run()->queryFetch("select * from `news` where `id` = ?;", array($id));
if ($news)
{
$subject = isset($_POST['subject']) ? check($_POST['subject']) : FALSE;
$message = isset($_POST['message']) ? check($_POST['message']) : FALSE;
if ($subject && $message)
{
DB::run()->query("update `news` set `subject` = ?, `message` = ? where `id` = ?;", array($subject, $message, $id));
redirect('/news/'.$news['id']);
}
$config['newtitle'] = $lang['Edit'];
$tpl['title'] = '<a href="/news">'.$lang['News'].'</a> » '.$lang['Edit'];
$tpl['file'] = 'news_edit';
require_once 'core/header.php';
}
else
{
redirect('/news');
}
}
else
{
redirect(HTTPHOME);
}
break;
case 'del':
$module = 'news';
require_once 'core/delpost.php';
break;
}