<?php

#############################################################################
#                              Site@School
# Site@School is a website management system designed for schools.
#
############################################################################
# blue theme
# main.inc.php: last changed 13/06/2005
#            by F.C. Stuurman (fc.stuurman@hccnet.nl)
#$Id: main.inc.php,v 1.1 2006/10/03 11:13:14 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");
}
?>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $sas_lang[lang_charset]?>">
<?php


print "<title>$sitename - $pagetitle</title>";
?>
<link rel="StyleSheet" href="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/style.css" type="text/css"></head><body>
<table border="0" class="pageframe" width="100%" cellpadding="0" cellspacing="0"><tr><td>
<table border="0" width="100%" cellpadding="0" cellspacing="1"><tr><td>
<table border="0" class="pagespacer" width="100%" cellpadding="0" cellspacing="0"><tr><td>
<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="73" width="150">&nbsp;</td>
<td>
<?php


print "<h1>&nbsp;$sitename</h1>";
?>
</td>
<td width="150">&nbsp;</td>
</tr>
</table>
</td>
<td rowspan="6" align="right">&nbsp;</td>
</tr>
<tr>
<td bgcolor="#006699"><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/b.gif" height="1" alt=""></td>
</tr>
<tr>
<td background="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/statbg.gif" height="15" class="mainmenu">

<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>
<td width="125">&nbsp;</td>
<?php


$query = "SELECT name FROM $table_sections WHERE id = $section"; // getting the section name
$result = mysql_query($query) or die_script($query, mysql_error());
$sectionname = mysql_result($result, 0);
unset ($query);
unset ($result);
print "<td class=\"userstatus\">Location: $sectionname -> $pagetitle";

print "</td><td>&nbsp;</td><td align=\"right\">";

if ($_SESSION['site'] == "protected")
{
	print "<a class=\"conferr\" href=\"index.php?section=$_SESSION[section_came_from]&page=$_SESSION[page_came_from]&site=public\">" . $sas_lang['public_area'] . "&nbsp;/</a>";
}

if (IsSet ($_SESSION['userid']))
{
	print "<a class=\"conferr\" href=\"index.php?section=$section&page=$page&logout=yes\">" . $sas_lang['logout'] . "&nbsp;&nbsp;&nbsp;&nbsp;</a>";
}
?>
</td></tr></table></td>
</tr>
<tr>
<td bgcolor="#006699"><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/b.gif" height="1" alt=""></td>
</tr>
<tr><td>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="65%">&nbsp;</td>
<td bgcolor="#ffffff" height="21">
<?php


$newstable = $dbprefix . "m_news_articles";
if ($_SESSION['site'] == "protected")
{
	$query = "SELECT title,date FROM $newstable WHERE public = 1 AND archive = 0 ORDER BY id DESC LIMIT 1";
}
else
{
	$query = "SELECT title,date FROM $newstable WHERE public = 0 AND archive = 0 ORDER BY id DESC LIMIT 1";
}

$result = mysql_query($query) or die_script($query, mysql_error());
if (mysql_num_rows($result) > 0)
{
	$newstitle = mysql_result($result, 0);
	print "<a class=\"mainmenu\" href=\"index.php?section=2\">Latest news: <b>$newstitle</b></a>";
}
?>
<script language="Javascript">
<?php


echo "newstext = \"$newstitle\";";
echo "datetext = \"$datetext\";";
?>
</script>
</td></tr></table>
</td>
</tr>
</table>
</td></tr>
<tr><td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td bgcolor="#a0c7df"><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/b.gif" height="2" alt=""></td>
<td><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/midbar.gif" width="56" height="2" alt=""></td>
<td bgcolor="#6699cc"><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/b.gif" height="2" alt=""></td></tr>
<tr>
<td height="18"><table border="0" cellpadding="0" cellspacing="0"><tr valign="middle"><td>
<img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/b.gif" width="25" height="1" alt=""></td>
<?php


$query = "SELECT id, name, frontpage FROM $table_sections WHERE invisible != 'yes' ORDER BY sort";
$result = mysql_query($query) or die_script($query, mysql_error());
while ($sectionmenu = mysql_fetch_array($result))
{
	if ($sectionmenu[0] == $section)
	{
		print "<td class=\"active\" nowrap=\"nowrap\"><a href=\"index.php?section=$sectionmenu[0]&page=$sectionmenu[2]\">$sectionmenu[1]</a></td>
					<td class=\"active\">&nbsp;</td>
					<td class=\"active\" align=\"center\"><img src=\"$cmsdir/themes/$themelocation/menupoint.gif\" width=\"6\" height=\"6\" alt=\"\"></td>
					<td>&nbsp;&nbsp;&nbsp;</td>";
	}
	else
	{
		print "<td class=\"mainmenu\" nowrap=\"nowrap\"><a href=\"index.php?section=$sectionmenu[0]&page=$sectionmenu[2]\">$sectionmenu[1]</a></td>
					<td>&nbsp;</td>
					<td align=\"center\"><img src=\"$cmsdir/themes/$themelocation/menupoint.gif\" width=\"6\" height=\"6\" alt=\"\"></td>
					<td>&nbsp;&nbsp;&nbsp;</td>";
	}
}
?>
</tr></table></td><td><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/ferde.gif" width="56" height="18" alt=""></td>
<td background="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/barbg.gif" width="99%" height="18"><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/b.gif" height="18" alt=""></td></tr>
<tr>
<td bgcolor="#6699cc"><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/b.gif" height="10" alt=""></td>
<td><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/barbott.gif" width="56" height="10" alt=""></td>
<td><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/b.gif" height="10" alt=""></td></tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="white">
<tr><td colspan="3">&nbsp;</td></tr>
<tr>
<td width="130" valign="top">
<table border="0" cellpadding="0" cellspacing="0">
<?php


$query1 = "SELECT id, name, module FROM $table_pages WHERE section='$section' AND invisible != 'yes' ORDER BY sort";
$result1 = mysql_query($query1) or die_script($query1, mysql_error());
while ($sectionmenu = mysql_fetch_array($result1))
{
	if ($sectionmenu[0] == $page)
	{
		print "<tr><td colspan=\"5\">&nbsp;</td></tr>
						 <tr><td>&nbsp;</td>
						 <td align=\"center\"><img src=\"$cmsdir/themes/$themelocation/orange.gif\" alt=\"\"></td>
						 <td>&nbsp;</td>
						 <td class=\"mainmenu\" nowrap=\"nowrap\">$sectionmenu[1]</td>
						 <td>&nbsp;</td>
						 </tr>";
	}
	elseif (substr($sectionmenu[2], 0, 5) == "http:")
	{
		print "<tr><td colspan=\"5\">&nbsp;</td></tr>
						 <tr><td>&nbsp;</td><td align=\"center\"><img src=\"$cmsdir/themes/$themelocation/menupoint.gif\" alt=\"\"></td>
						 <td>&nbsp;</td>
						 <td width=\"100\" class=\"mainmenu\" nowrap=\"nowrap\"><a href=\"$sectionmenu[2]\" target=\"_blank\">$sectionmenu[1]</a></td>
						 <td>&nbsp;</td>
						 </tr>";
	}
	elseif (substr($sectionmenu[2], 0, 5) == "file:")
	{
		$link = substr($sectionmenu[2], 7);
		print "<tr><td colspan=\"5\">&nbsp;</td></tr>
						 <tr><td>&nbsp;</td><td align=\"center\"><img src=\"$cmsdir/themes/$themelocation/menupoint.gif\" alt=\"\"></td>
						 <td>&nbsp;</td>
						 <td width=\"100\" class=\"mainmenu\" nowrap=\"nowrap\"><a href=\"$link\" target=\"_blank\">$sectionmenu[1]</a></td>
						 <td>&nbsp;</td>
						 </tr>";
	}
	else
	{
		print "<tr><td colspan=\"5\">&nbsp;</td></tr>
						 <tr><td>&nbsp;</td><td align=\"center\"><img src=\"$cmsdir/themes/$themelocation/menupoint.gif\" alt=\"\"></td>
						 <td>&nbsp;</td>
						 <td class=\"mainmenu\" nowrap=\"nowrap\"><a href=\"index.php?page=$sectionmenu[0]&section=$section\">$sectionmenu[1]</a></td>
						 <td>&nbsp;</td>
						 </tr>";
	}
}
?>
</table></td>
<td bgcolor="#E8F3FF" width="30">&nbsp;</td>
<td valign="top"><table border="0" cellpadding="0" cellspacing="0" height="400" width="650" bgcolor="#E8F3FF">
<tr><td valign="top">
<?php


$query = "SELECT module FROM $table_pages WHERE id='$page'";
$result = mysql_query($query) or die_script($query, mysql_error());
$module = mysql_result($result, 0);
unset ($query);
unset ($result);
if ($module != '')
{
	include ("$cmsdir/modules/$module");
}
else
{
	$query = "SELECT content FROM $table_pages WHERE id='$page'";
	$result = mysql_query($query) or die_script($query, mysql_error());
	$content = mysql_result($result, 0);
	unset ($query);
	unset ($result);
	$content = str_replace("../", "", $content);
	print "$content";
}
?>
</td><td bgcolor="#E8F3FF" width="30">&nbsp;</td></tr></table></td></tr>
</td></tr>
</table>
</td></tr>

</td></tr></table>
</td></tr></table>
</td></tr></table>
</td></tr></table>
<?php


$query = "SELECT UNIX_TIMESTAMP(lastupdate) FROM $table_pages where id='$page'";
$result = mysql_query($query) or die_script($query, mysql_error());
$date = mysql_result($result, 0);
unset ($query);
unset ($result);

$date = strftime($sas_config['dateformat'], $date);
?>
<center><span class="footer">&copy; <?php echo $sitename ?>, last changed on <?php echo $date ?></span>
</center></body></html>