3) accessDenied();
$output .= "
"._NEWS."
";
if(isset($_POST['submit'])) {
$title = addslashes(strip_tags(descript($_POST['title']), $allowed_tags));
$author = addslashes(strip_tags(descript($_POST['author']), $allowed_tags));
$story = addslashes(strip_tags(descript($_POST['story']), $allowed_tags));
if($_GET['form'] == "new") $result = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_news (title, author, story, time) VALUES ('$title', '$author', '$story', now())");
else $result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_news SET title = '$title', author = '$author', story = '$story' WHERE nid = '$_POST[nid]'");
if($result) {
$output .= write_message(_ACTIONSUCCESSFUL);
unset($_GET['form']);
}
else $output .= write_error(_ERROR." ".TRYAGAIN);
}
if(isset($_GET['delete']) && isNumber($_GET['delete'])) {
if($_GET['confirm'] == "yes") {
dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_news where nid = '".$_GET['delete']."'");
$output .= write_message(_ACTIONSUCCESSFUL);
}
else if ($_GET['confirm'] == "no") $output .= write_message(_ACTIONCANCELLED);
else {
$output .= write_message(_CONFIRMDELETE."
[ "._YES." | "._NO." ]");
}
}
else if(isset($_GET["form"])) {
if($_GET["form"] != "new" && isNumber($_GET["form"])) {
$result = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_news WHERE nid = '".$_GET['form']."' LIMIT 1");
$newsitem = dbassoc($result);
}
else $newsitem = array("title" => "", "author" => "", "story" => "");
$output .= "";
}
else {
$output .= ""._ADDNEWS."
";
$count = dbquery("SELECT COUNT(nid) FROM ".TABLEPREFIX."fanfiction_news");
list($numrows)= dbrow($count);
$result = dbquery("SELECT n.*, UNIX_TIMESTAMP(n.time) as date, count(c.cid) as comments FROM ".TABLEPREFIX."fanfiction_news as n LEFT JOIN ".TABLEPREFIX."fanfiction_comments as c ON n.nid = c.nid GROUP BY n.nid ORDER BY time DESC LIMIT $offset, $itemsperpage");
if(file_exists("$skindir/newsbox.tpl")) $news = new TemplatePower( "$skindir/newsbox.tpl" );
else $news = new TemplatePower( "default_tpls/newsbox.tpl" );
$news->prepare();
$count = 0;
while($stories = dbassoc($result)) {
$news->newBlock("newsbox");
//assign values
$news->assign("newstitle" , $stories['title'] );
$news->assign("newsstory" , $stories['story'] );
$news->assign("newsauthor", $stories['author'] );
$news->assign("newsdate", date("$dateformat $timeformat", $stories['date']) );
$news->assign("oddeven", ($count % 2 ? "even" : "odd"));
if($newscomments == "1")
$news->assign("newscomments", "".$stories['comments']." "._COMMENTS."");
if(isADMIN)
$news->assign("adminoptions", ""._EDIT." | "._DELETE."");
$count++;
}
$news->gotoBlock("_ROOT");
$output .= $news->getOutputContent( );
if($numrows > $itemsperpage) $output .= build_pagelinks("admin.php?action=news&", $numrows, $offset);
}
?>