<?php

#############################################################################
#                              Site@School
# Site@School is a website management system designed for schools.
#
# About Site@School:
# Original Idea: Mark de Haan (mark@starwave.nl)
# PHP coding & Design: Mark de Haan (mark@starwave.nl)
# Comissioned by: Stadsdeel de Baarsjes, Amsterdam, Netherlands
############################################################################
# frontpage.php: last changed 14/03/2006 , version: 2.4
#              by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: frontpage_cat.php,v 1.1 2006/10/03 09:38:29 fstuurman Exp $
############################################################################
#                        LICENSE INFORMATION
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
##############################################################################
if (!defined('IN_SAS'))
{
	die("Hacking attempt");
}
load_language($cmsdir . '/', 'sn_news'); //load language file

$query = "SELECT dbtables FROM $table_modules WHERE location='sn_news'"; // getting the table names
$result = mysql_query($query) or die_script($query, mysql_error());
$moduletables = mysql_result($result, 0);
unset ($query);
unset ($result);
$moduletables = explode(",", $moduletables);
$news_articletable = "$moduletables[0]";
$news_categorytable = "$moduletables[1]";

$result = mysql_query("SELECT id, header FROM $news_categorytable WHERE title='$pagetitle'");
$RecordCount = mysql_num_rows($result);
if ($RecordCount > 0)
{
	$cat_id = mysql_result($result, 0, 'id');
	$welcometext = mysql_result($result, 0, 'header');
	unset ($query);
	unset ($result);

	print $welcometext . "<br><br>";

	$query = "SELECT id, title, date, category, content FROM $news_articletable WHERE archive!=1 AND category = $cat_id 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;<FONT face=\"Arial,helvetica\" color=\"#000000\" size=\"2\"><A href=\"#$article_list[0]\"><b>$article_list[1]</b></a></font><br><br>";
	}

	print "<br>";
	$query = "SELECT id, title, date, category, content FROM $news_articletable where archive!=1 AND category = $cat_id ORDER BY id DESC";
	$result = mysql_query($query) or die_script($query, mysql_error());
	while ($article_list = mysql_fetch_array($result))
	{
		$article_list[4] = str_replace("\n", "<br>", $article_list[4]);
		print "<A name=\"$article_list[0]\"></a>
					   <FONT face=\"Arial,helvetica\" size=\"3\">
					   <B>$article_list[1] &nbsp;&nbsp;  <font size=1>$article_list[2]</B></font><br>
					   <FONT face=\"Arial,helvetica\" color=\"#000000\" size=\"2\">
					   $article_list[4]
					   </font><br><br>";
	}
}
else
{
	print $sas_lang['news_module_category_not_exists'];
}
?>
