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

print "<font size=2>" . $sas_config['news_welcome_text'] . "</font><table cellspacing=\"0\" width=\"100%\" border=\"1\">";

$query = "SELECT id, title FROM $news_categorytable WHERE ispage= '0' ORDER BY id DESC";
$result = mysql_query($query) or die_script($query, mysql_error());

while ($category_list = mysql_fetch_array($result))
{
	$result3 = mysql_query("SELECT header FROM $news_categorytable WHERE id='$category_list[0]'");
	$cat_text = mysql_result($result3, 0, header);
	unset ($result3);

	print "<tr><td colspan=\"2\">&nbsp;</td></tr>
<tr><td colspan=\"2\"><b>$category_list[1]</b>&nbsp;<br>$cat_text</td></tr>";

	if (IsSet ($_SESSION['site'])) //are we on protected area
	{
		$query = "SELECT id, title, date, category, content 
			FROM $news_articletable WHERE (archive = 0 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 = 0 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 colspan=\"2\">&nbsp;</td></tr>";
			$column = 0;
		}
		else
		{
			print "<tr><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>";
			$column = 1;
		}

	}
}
print "</table>";
?>