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

print $sas_config['news_welcome_text'];

$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))
{
	print "<b>$category_list[1]</b>&nbsp;
		<IMG hspace=0 src=\"" . $cmsdir . "/modules/sn_news/templates/" . $sas_config['news_template'] . "/arrow.gif\" border=0 width=\"8\" height=\"8\">";

	print "<br>";

	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);
	$result3 = mysql_query("SELECT header FROM $news_categorytable WHERE id='$category_list[0]'");
	$cat_text = mysql_result($result3, 0, header);
	unset ($result3);
	print $cat_text;
	while ($article_list = mysql_fetch_array($result2))
	{
		print "<A name=\"$article_list[0]\"></a>
					  $article_list[1] &nbsp;&nbsp;  <font size=1>$article_list[2]</font><br>
					  $article_list[4]<br><br>";
	}
}
?>
