include("identify.php");
load_all("news");
$db = $main_settings->components[$main_settings->components_keys['Document Browser']]->db_name;
$doc_component_id = $main_settings->components[$main_settings->components_keys['Document Browser']]->id;
?>
echo "$main_settings->site_name"; ?> News
if (! isset($news_index)) {
$news_index = 0;
}
$temp_article = new article;
echo "";
echo "$main_settings->site_name News
";
if ($main_user->level == 10) {
echo "[Add new article]
";
}
if ( $main_user->id == 0 ) {
topheader();
echo "Login:";
botheader();
topcontent();
echo "";
$main_user->show_login_info();
echo "
";
botcontent();
echo "
";
}
$sql = "
SELECT COUNT(*)
FROM $db
";
$result = database_query($sql);
$row = mysql_fetch_array($result);
$article_count =$row['COUNT(*)'];
$sql = "
SELECT *
FROM $db\n";
if ( isset($_GET['category']) ) {
$sql .= "WHERE category = '{$_GET['category']}'\n";
}
$sql .= "ORDER BY id DESC\n";
if ( !isset($_GET['news_index']) ) {
$_GET['news_index'] = 0;
$next_index = $main_settings->articles_ppage;
} else {
$next_index = $_GET['news_index'] + $main_settings->articles_ppage;
$prev_index = $_GET['news_index'] - $main_settings->articles_ppage;
}
if ( !isset($_GET['tag']) ) {
$sql .= "LIMIT {$_GET['news_index']}, $main_settings->articles_ppage
";
}
$result = database_query($sql);
if ( isset($_GET['tag']) ) {
while ($row = mysql_fetch_array($result)) {
$news_id = $row['id'];
$test_list = comma_list("articles", "tags", $news_id);
for ($i = 0; $i < count($test_list); $i++) {
if ($test_list[$i] == $_GET['tag']) {
$temp_article->load($news_id);
$temp_article->show();
}
}
}
} else {
while ($row = mysql_fetch_array($result)) {
$news_id = $row['id'];
$temp_article->load($news_id);
$temp_article->show(true);
}
}
echo "\n";
if ($article_count > $main_settings->articles_ppage) {
echo "table_bottom_color\">[Older news] | \n";
}
if ($_GET['news_index'] >= $main_settings->articles_ppage) {
echo "table_bottom_color\">[Newer news] | \n";
}
echo "