<?php 
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: 'easy-access'
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>
<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>
<div>
<!-- navigation level 1 -->
<?php
print "<ul id=\"sas_navi1\">";
$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 "<li><span>$sectionmenu[1]</span></li>
";
}
else {
print "<li><a href=\"index.php?section=$sectionmenu[0]&amp;page=$sectionmenu[2]\">$sectionmenu[1]</a></li>
";  }
}
print "</ul>"
?>
</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
{
print "&nbsp;Location: <em>$sectionname -> $category -> $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);
            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_list[1]</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_list[1]</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>$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]\">$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>
<div align="center" id="sas_footer">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;site=protected&amp;print=yes\">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>
</body></html>
