<?php 
#############################################################################
#                              Site@School
# Site@School is a website management system designed for schools.
#
############################################################################
# schoolyard 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:18 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.
##############################################################################
print '<?xml version="1.0" encoding="ISO-8859-1" ?>'; 

if ( !defined('IN_SAS') )
{
	die("Hacking attempt");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php
print "<title>$sitename - $pagetitle</title>";
?>

<!-- Site@School CMS licensed under GNU/GPL
http://siteatschool.sourceforge.net
Template name: 'schoolyard'
Design: David Prousch, d.prousch@gmx.de
May 2006
-->
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="Site@School" />
<meta name="description" content="Site@School. Content management system for schools." />
<meta name="keywords" content="Site@School, CMS for Schools" />
<style type="text/css" media="screen">@import url( <?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/style.css );</style>
</head>
<body>
<table class="sas_pageframe" width="100%" cellpadding="0" cellspacing="0"><tr><td>
<div id="sas_header1">
<!-- Logo of the website. -->
<a href="index.php"><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/sas_logo.png" alt="The logo of the website. Click here to go to the startpage of the website." border="0" /></a>
</div>
<div id="sas_header2">
&nbsp;<?PHP print "$sitename" ?>
</div>
<!-- navigation level 1 -->
<div id="sas_navi1">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="<?php echo $cmsdir ?>/themes/<?php echo $themelocation ?>/spacer.png" width="20" height="1" alt="spacer" /></td>
<?php
$query = "SELECT id, name, frontpage FROM $table_sections WHERE invisible != 'yes' ORDER BY sort";
$result = mysql_query($query);
while ($sectionmenu = mysql_fetch_array($result))
{
	if (!IsSet($category))
	{
	$query1 = "SELECT category FROM $table_pages WHERE section = '$section' AND id = '$page'"; // getting category of section startpage
	$result1 = mysql_query($query1) or die_script($query1,mysql_error());
	$category = mysql_result($result1,0,0);
	}
	if($sectionmenu[0] == $section)
	{
	print "<td class=\"sas_tableft\">&nbsp;</td><td class=\"sas_active\" nowrap=\"nowrap\"><a href=\"index.php?section=$sectionmenu[0]&amp;page=$sectionmenu[2]\">$sectionmenu[1]</a></td><td class=\"sas_tabright\">&nbsp;</td>
	<td>&nbsp;&nbsp;</td>
	";
	}
	else
	{
	print "<td class=\"sas_tableft2\">&nbsp;</td><td class=\"sas_mainmenu\" nowrap=\"nowrap\">&nbsp;<a href=\"index.php?section=$sectionmenu[0]&amp;page=$sectionmenu[2]\">$sectionmenu[1]</a>&nbsp;</td><td class=\"sas_tabright2\">&nbsp;</td>
	<td>&nbsp;&nbsp;</td>
	";
	}
}
?>
</tr>
</table>
</div>
<div class="sas_bar1">&nbsp;</div>
<div id="sas_info">
<?php
$query = "SELECT name FROM $table_sections WHERE id = '$section'";    // getting the section name
$result = mysql_query($query);
$sectionname = mysql_result($result,0);
unset($query);
unset($result);
if(!empty($category))    //only print category when not empty
{
$category1 = substr($category, 0); //Skip the first characters of the categorie name: Type a number >0.
print "&nbsp;Location: <em>$sectionname -> $category1 -> $pagetitle</em>"; }
else
{
print "&nbsp;Location: <em>$sectionname -> $pagetitle</em>"; }
?>
&nbsp;|&nbsp;
<?php
$newstable = $dbprefix."m_news_articles" ;
$query = "SELECT title,date FROM $newstable ORDER BY id DESC LIMIT 1";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0) {
//$newstitle = mysql_result($result,0);
$newstitle = mysql_result($result,0,0);
$datetext = mysql_result($result,0,1);
print "<a href=\"index.php?section=1&amp;category=&amp;page=1\">News:&nbsp;<strong>$newstitle</strong></a>" ;}
?>
</div>
<div>
<!-- navigation level 2 and 3 -->
<?php
print "<ul id=\"sas_navi2\">";
$query = "SELECT id, name FROM $table_sections WHERE invisible != 'yes' ORDER BY sort";
$result = mysql_query($query);
while ($sectionmenu = mysql_fetch_array($result))
{
        if($sectionmenu[0] == $section)
          {
            $query1 = "SELECT id, category FROM $table_pages WHERE section = '$section' GROUP BY category";             // getting catlist
            $result1 = mysql_query($query1);
            while ($cat_list = mysql_fetch_array($result1))
                  {
            $category1 = htmlspecialchars(rawurlencode($cat_list[1])) ;
            if(!empty($cat_list[1]))    //only display when category has no blanks
            {
            $query2 = "SELECT id FROM $table_pages WHERE category = '$cat_list[1]' and section = '$section' and invisible != 'yes' ORDER BY sort";      // getting starpage category
            $result2 = mysql_query($query2);
            $startpage = mysql_result($result2,0,0);
	   $cat_stripped = substr($cat_list[1],0) ; //Skip the first characters of the categorie name: Type a number >0.
            if($cat_list[1] == $category)
			{
            print "<li><strong><a href=\"index.php?section=$sectionmenu[0]&amp;category=$category1&amp;page=$startpage\">
			<img src=\"$cmsdir/themes/$themelocation/arrow2.png\" alt=\"arrow down: this categorie is open\" border=\"0\" />&nbsp;$cat_stripped</a></strong></li>";
			}
            else
			{
            print "<li><strong><a href=\"index.php?section=$sectionmenu[0]&amp;category=$category1&amp;page=$startpage\">
			<img src=\"$cmsdir/themes/$themelocation/arrow1.png\" alt=\"arrow right: this categorie is closed\" border=\"0\" />&nbsp;$cat_stripped</a></strong></li>";}
            }
             if($cat_list[1] == $category)
             {
              $query2 = "SELECT id, name, module, invisible FROM $table_pages WHERE category = '$category' and section = '$section' and invisible != 'yes' ORDER BY sort";      //getting pagelist
              $result2 = mysql_query($query2);
              while ($page_list = mysql_fetch_array($result2))     //loop through pages
              {
              if ($pagetitle == $page_list[1])
	     {
	     print "<li><span><img src=\"$cmsdir/themes/$themelocation/pointactive.png\" alt=\"current page\" border=\"0\" />&nbsp;$page_list[1]</span></li>";
	     }
              elseif(substr($page_list[2],0,5) == "http:") {
              print "<li><a href=$page_list[2] target=\"_blank\">$page_list[1]</a></li>"; }
              elseif (substr($page_list[2],0,5) == "file:"){
              $link = substr($page_list[2],7)  ;
              print "<li><a href=$link target=\"_blank\">$page_list[1]</a></li>";
              }
              else {
              print "<li><a href=\"index.php?section=$sectionmenu[0]&amp;category=$category1&amp;page=$page_list[0]\"><img src=\"$cmsdir/themes/$themelocation/point.png\" alt=\"menupoint\" border=\"0\" />&nbsp;$page_list[1]</a></li>";
              }
              }
             }
           }
          }
}
         print "</ul>" ;
?>
</div>
<!-- content -->
<div id="sas_content">
<?php
$query = "SELECT module FROM $table_pages WHERE id='$page'";
$result = mysql_query($query);
$module = mysql_result($result,0);
unset($query);
unset($result);
if($module != '')
{
 print "<div id=\"sas_module\">";
 include("starnet/modules/$module");
 print "</div>";
}
else
{
 $query = "SELECT content FROM $table_pages WHERE id='$page'";
 $result = mysql_query($query);
 $content = mysql_result($result,0);
 unset($query);
 unset($result);
 $content = str_replace("../","",$content);
 print "$content";
}
?>
<div id="sas_info2"><?PHP
$query = "SELECT UNIX_TIMESTAMP(lastupdate) FROM $table_pages where id='$page'";
 $result = mysql_query($query);
 $date = mysql_result($result,0);
 unset($query);
 unset($result);
$query = "SELECT config_value FROM $table_configuration where config_key='dateformat'";
$result = mysql_query($query);
$date_format = mysql_result($result,0);
unset($query);
unset($result);
$date = strftime($date_format,$date);
?>--- <br />last changed on: <?PHP print "$date"; ?></div>
</div>
<!-- Site footer -->
<div align="center" class="sas_bar2">Powered by <a href="http://siteatschool.sourceforge.net/" target="_blank">Site@School</a>&nbsp;&nbsp;&copy;&nbsp;<?PHP print "$sitename" ?>
&nbsp;|&nbsp;<?php
foreach($_GET as $key => $value)
{
$parms .=  $key."=".$value."&amp;" ;
}
$parms = substr($parms,0,-1) ;

if($site == "protected")
{
print "<a href=\"index.php?$parms&amp;print=yes&amp;site=protected\">print page</a>";
}
else
{
print "<a href=\"index.php?$parms&amp;print=yes\" target=\"_blank\">print page</a>";
}
?>&nbsp;|&nbsp;
<?PHP
if(IsSet($HTTP_SESSION_VARS['userid']))
{
print "&nbsp;-&nbsp;<a href=\"index.php?section=$section&amp;page=$page&amp;logout=yes\">".$sas_lang['logout']."</a>";
}
?>
</div>
</td></tr></table>
</body>
</html>