<?php
################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- #
## --------------------------------------------------------------------------- #
## ApPHP AdminPanel Pro #
## Developed by: ApPHP <hide@address.com> #
## License: GNU LGPL v.3 #
## Site: http://www.apphp.com/php-adminpanel/ #
## Copyright: ApPHP AdminPanel (c) 2006-2011. All rights reserved. #
## #
################################################################################
header("content-type: text/html; charset=utf-8");
// Initialize the session.
session_start();
define("AP_PATH", "../");
require_once(AP_PATH."inc/settings.inc.php");
require_once(AP_PATH."inc/languages/".$SETTINGS['site_language'].".php");
if(!module_istalled('news_events')) redirect_to(AP_PATH."html/404.html");
$news_id = isset($_GET['nid']) ? (int)$_GET['nid'] : "";
$sql = "SELECT
id, header, body, date_published
FROM ".TABLE_NEWS."
WHERE
".(!empty($news_id) ? "id = ".$news_id." AND " : "")."
is_active = 1
ORDER BY date_published DESC
LIMIT 0, 1000";
$db->Query($sql);
$output = "<table width='90%' align='center' border='0' cellspacing='0' cellpadding='0'>";
$output .= "<caption align='left'><h2>".lang('news')."</h2></caption>";
if($db->RowCount() <= 0){
$output .= "<tr valign='top'><td>".draw_message("error", "<b>There are no news found!</b>", false, "100%", "../", true)."</td></tr>";
}else{
while($row = $db->FetchAssoc()){
if(empty($news_id)){
$output .= "<tr valign='top'><td><a href='news.php?nid=".(int)$row['id']."'><b>".$row['header']."</b></a></td></tr>";
$output .= "<tr valign='top'><td>Published at: ".date("F d, Y h:i A", strtotime($row['date_published']))."</td></tr>";
$output .= "<tr valign='middle'><td><br /></td></tr>";
$output .= "<tr valign='top'><td>".substr(str_replace("\\n", "", $row['body']), 0, 255)."...</td></tr>";
}else{
$output .= "<tr valign='top'><td><b>".$row['header']."</b></td></tr>";
$output .= "<tr valign='top'><td>Published at: ".date("F d, Y g:i A", strtotime($row['date_published']))."</td></tr>";
$output .= "<tr valign='middle'><td><br /></td></tr>";
$output .= "<tr valign='top'><td>".str_replace("\\n", "", $row['body'])."</td></tr>";
}
$output .= "<tr valign='middle'><td><hr /><br /></td></tr>";
}
}
$output .= "</table>";
$template = get_include_contents("templates/news.tpl");
$template = str_replace("{SITE_NAME}", $SETTINGS['site_name'], $template);
$template = str_replace("{TITLE}", lang('news'), $template);
$template = str_replace("{STYLE}", "../styles/".$SETTINGS['css_style']."/style.css", $template);
$template = str_replace("{NEWS}", $output, $template);
echo $template;
?>