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

if (IsSet ($_GET['article']))
{
	$article = $_GET['article'];
}

print "<span class=colortext><b>" . $sas_config['news_archive_welcome_text'] . "</b></span><br><br>";

if (IsSet ($_GET[article]))
{
	$query = "SELECT id, title, date, category, content FROM $news_articletable WHERE id = '$article'";
	$result = mysql_query($query) or die_script($query, mysql_error());
	while ($article_list = mysql_fetch_array($result))
	{
		print "<A name=\"$article_list[0]\"></a>
				<b>$article_list[1] &nbsp;&nbsp;$article_list[2]</b><br>
				$article_list[4]<br><br>";
	}
	print "<span class=text><a href=\"index.php?section=$section&page=$page\"><< " . $sas_lang['news_module_backtoarchive'] . "</a></span>";
}
else
{
	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 ) ORDER BY id DESC";
	}
	else
	{
		$query = "SELECT id, title, date, category, content FROM $news_articletable 
					WHERE (archive = 1 AND public = 0 ) ORDER BY id DESC";
	}
	$result = mysql_query($query) or die_script($query, mysql_error());
	while ($article_list = mysql_fetch_array($result))
	{
		print "<IMG hspace=0 src=\"" . $cmsdir . "/modules/sn_news/templates/" . $sas_config['news_template'] . "/arrow.gif\" border=0 width=\"8\" height=\"8\">
					   &nbsp;<A href=\"index.php?section=$section&page=$page&article=$article_list[0]\">
					   $article_list[2] - $article_list[1]<br>";
	}
}
?>
