<?php
if (!defined('IN_SAS'))
{
	die("Hacking attempt");
}

print $sas_config['news_archive_welcome_text'] . "<table cellspacing=\"0\" width=\"100%\">";

$query = "SELECT id, title FROM $news_categorytable";
$result = mysql_query($query) or die_script($query, mysql_error());

while ($category_list = mysql_fetch_array($result))
{
	print "<tr><td>&nbsp;</td></tr><tr><td colspan=\"2\"><b>$category_list[1]</b>&nbsp;</td></tr>";

	if (IsSet ($_SESSION['site'])) //are we on protected area
	{
		$query = "SELECT id, title, date, category, content FROM $news_articletable 
			WHERE (archive = 1 AND public = 1 AND category = $category_list[0]) ORDER BY id DESC";
	}
	else
	{
		$query = "SELECT id, title, date, category, content FROM $news_articletable 
					  WHERE (archive = 1 AND public = 0 AND category = $category_list[0]) ORDER BY id DESC";
	}
	$result2 = mysql_query($query);
	while ($article_list = mysql_fetch_array($result2))
	{
		if ($column == 1)
		{
			print "<td width=\"50%\" valign=\"top\"><A name=\"$article_list[0]\"></a>
					<b>$article_list[1] &nbsp;&nbsp; $article_list[2]</b><br>
					$article_list[4]</td></tr><tr><td>&nbsp;</td></tr>";
			$column = 0;
		}
		else
		{
			print "<tr><td width=\"50%\" valign=\"top\"><A name=\"$article_list[0]\">
					<b>$article_list[1] &nbsp;&nbsp; $article_list[2]</b><br>$article_list[4]</td>";
			$column = 1;
		}
	}
}
print "</table>";
?>
