<?php

#############################################################################
#                              Site@School
# Site@School is a website management system designed for schools.
#
############################################################################
# standard 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:13 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>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> 
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $sas_lang['lang_charset']?>">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<?php

print "<title>$sitename - $pagetitle</title>
<link rel=\"StyleSheet\" href=\"$cmsdir/themes/$themelocation/style.css\" type=\"text/css\">";
?>
<style>
A:link, A:active
	{	text-decoration	:	none;
		color		:	#000000;
		background	:	transparent;
		}
A:visited {	color		:	#000000;
		background	:	transparent;
		text-decoration	:	none;
		}		
A:hover {	color		:	#000000;
		background	:	#transparent;
                text-decoration	:	none;
		}
.buttonlink {
	FONT-WEIGHT: normal; COLOR: #000000; FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial
}
.text {
	FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial
}
.colortext {
	FONT-WEIGHT: bold; COLOR: #638ab9; FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial
}
.link {
	FONT-WEIGHT: bold; COLOR: #638ab9; FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial
}
.bgout {
background-image: url(<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/button.gif);
}
.bgover {
background-image: url(<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/button1.gif);
}
.bgout2 {
background: #transparant;
}
.bgover2 {
background-image: url(<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/menu-bg2.gif);
}

</style>
<script language="javascript">
// if form exists , set cursor in first input field
function focusonform()
{
  if (document.forms[0])
    {document.forms[0].elements[0].focus();}
  else
    {window.focus();}
}
</script>
</head>
<body marginwidth="0" marginheight="0" rightmargin="0" topmargin="0" bottommargin="0" leftmargin="0" background="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/background.gif" style="font-family: Verdana, Arial, Helvetica; font-size: 10pt"link="#000000" vlink="#000000" alink="#466C9B">

<table border="0" cellpadding="0" cellspacing="0" width="100%" height="45" background="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/banner-bg.gif">
  <tr>
    <td width="5%" align="left">
    <img border="0" src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/banner-left.gif" width="1" height="45"></td>
    <td width="70%" align="center" valign="middle"><font face=verdana size=5 color=FFFFFF><b><?php echo $sitename ?></b></font><br>
    </td>
    <td align="right">
    <img border="0" src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/logo.gif"></td>
    <td width="5%">&nbsp;</td>
   </tr>
</table>
<table border="0" width="100%">
  <tr>
     <td width="160">&nbsp;</td>
     <td width="55%"><font face="Verdana" size="1">&nbsp;
<?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 "Location: $sectionname -> $pagetitle";

print "</font></td>
     <td align=\"right\">  
		  <font size=1> ";

if ($_SESSION['site'] == "protected")
{
	print "<a 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 href=\"index.php?section=$section&page=$page&logout=yes\">" . $sas_lang['logout'] . "&nbsp;&nbsp;&nbsp;&nbsp;</a>";
}
?>
		  </font>
		 </td>
   </tr>
</table>      
<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=0 cellPadding=0 width="100%"
background="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/bar-bg.gif" border=1>
  <TBODY>
  <TR>
    <TD align=left width="160"><font size="2">&nbsp;</font></TD>
    <TD>

    <table border="0" width="100%" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#F7F7F7">
      <tr>
<?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))
{
	print "<td width=\"160\" height=\"18\" align=\"center\" class=\"bgout\" onmouseover=\"this.className='bgover'\" onmouseout=\"this.className='bgout'\">
	      <span class=\"buttonlink\"><a href=index.php?section=$sectionmenu[0]&page=$sectionmenu[2]>$sectionmenu[1]</a></span></td>";
}
?>
    <td height="18" background="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/button.gif">&nbsp;</td>
        </tr>
    </table>

    </TD>
    </TR></TBODY></TABLE>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber3">
  <tr>
    <td width="160" bgcolor="#F7F7F7" valign="top">

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

$query1 = "SELECT id, name, module FROM $table_pages WHERE section=$section AND invisible != 'yes' ORDER BY sort";
$result1 = mysql_query($query1);
while ($sectionmenu = mysql_fetch_array($result1))
{
	if ($sectionmenu[0] == $page)
	{
		print "<tr height=\"25\"><td width=\"10%\" background=\"$cmsdir/themes/$themelocation/menu-bg2.gif\">&nbsp;</td>";
		print "<td width=\"80%\" background=\"$cmsdir/themes/$themelocation/menu-bg2.gif\"><font size=\"2\">";
		print "$sectionmenu[1]</font></td>";
		print "<td width=\"10%\" background=\"$cmsdir/themes/$themelocation/menu-bg2.gif\" align=\"left\"><img border=\"0\" src=\"$cmsdir/themes/$themelocation/triangle.gif\"width=\"12\" height=\"13\"></td></tr>";
	}
	elseif (substr($sectionmenu[2], 0, 5) == "file:")
	{
		$link = substr($sectionmenu[2], 7);
		print "<tr height=\"25\"><td width=\"10%\">&nbsp;</td>";
		print "<td width=\"80%\"><font size=\"2\">";
		print "<a href=\"javascript:void(0)\" OnClick=\"javascript:parent.location.href='$link'; return false;\" style=\"text-decoration:none; font-family:Verdana; font-size:10pt;\">$sectionmenu[1]</a></font></td>";
		print "<td width=\"10%\" align=\"left\"><img border=\"0\" src=\"$cmsdir/themes/$themelocation/triangle.gif\"width=\"12\" height=\"13\"></td></tr>";
	}
	elseif (substr($sectionmenu[2], 0, 5) == "http:")
	{
		print "<tr height=\"25\"><td width=\"10%\">&nbsp;</td>";
		print "<td width=\"80%\"><font size=\"2\">";
		print "<a href=$sectionmenu[2] target=\"_blank\" style=\"text-decoration:none; font-family:Verdana; font-size:10pt;\">$sectionmenu[1]</a></font></td>";
		print "<td width=\"10%\" align=\"left\"><img border=\"0\" src=\"$cmsdir/themes/$themelocation/triangle.gif\"width=\"12\" height=\"13\"></td></tr>";
	}
	else
	{
		print "<tr height=\"25\" class=\"bgout2\" onmouseover=\"this.className='bgover2'\" onmouseout=\"this.className='bgout2'\"><td width=\"10%\" >&nbsp;</td>";
		print "<td width=\"00%\"><font size=\"2\">";
		print "<a href=index.php?page=$sectionmenu[0]&section=$section>$sectionmenu[1]</a></font></td>";
		print "<td width=\"10%\" align=\"left\">
				 <img border=\"0\" src=\"$cmsdir/themes/$themelocation/triangle.gif\" width=\"12\" height=\"13\"></td></tr>";
	}
}
?>
</table>
   <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    </td>
    <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 != '')
{
	print "<table height=\"490\"  border=\"0\" cellpadding=\"10\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\">
	        <tr><td valign=\"top\" width=\"100%\">";

	include ("$cmsdir/modules/$module");
}
else
{
	print "<table height=\"490\" border=\"0\" cellpadding=\"10\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\">
	        <tr><td valign=\"top\" width=\"100%\">";
	$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";
}
print "</td></tr>";
$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);
print "
  <tr>
    <td align=\"center\"><font face=\"Verdana\" size=\"1\">&copy; $sitename , last changed on $date</font>&nbsp;";
foreach ($_GET as $key => $value)
{
	$parms .= $key . "=" . $value . "&";
}
$parms = substr($parms, 0, -1);

if ($site == "protected")
{
	print "<a href=\"index.php?$parms&print=yes&site=protected\">";
}
else
{
	print "<a href=\"index.php?$parms&print=yes\">";
}
print "<img src=$cmsdir/themes/$themelocation/print.gif border=\"0\"></a></td>
  </tr>
</table>

    </td>
    </table>
</body>
</html>";
?>