<?php

#############################################################################
#           			                   Site@School
# Site@School is a website management system designed for primary schools.
#
# About Site@School:
# Comissioned by: City District 'de Baarsjes', Amsterdam, Netherlands
# Original idea, coding (version 1.0) and design : Mark de Haan (mark@starwave.nl)
# Ideas, improvements, expansions (version 1.1 - 2.4): Fred Stuurman 
# Current coder & maintainer: Fred Stuurman (fc.stuurman@hccnet.nl)
############################################################################
# pag_modbrowser.inc.php: last changed 20/08/2006  , version: 2.4.10
#                         by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: pag_modbrowser.inc.php,v 1.2 2006/10/15 19:08:53 fstuurman Exp $
############################################################################
#                        LICENSE INFORMATION
# Copyright (C) 2002 - 2005 Municipality of Amsterdam, City District
#  'de Baarsjes', Amsterdam, the Netherlands.
#
# 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.
##############################################################################
define('IN_SAS', true);

include ("../configuration/database.inc.php"); // connecting to database
mysql_connect("$db_server", "$db_username", "$db_password");
mysql_select_db("$db_name");

require ("../core/session.php"); //build a session

$query = "SELECT config_value FROM $table_configuration WHERE config_key='sessioncode'";
if ($result = mysql_query($query))
{
	$check_sessioncode = mysql_result($result, 0);
	unset ($query);
	unset ($result);
}
if ($_SESSION['sessioncode'] != "$check_sessioncode")
{
	//if we don't have a session present the login screen
	Header("Location: ../index.php");
	exit;
}

$query = "SELECT config_value FROM $table_configuration WHERE config_key = 'language'"; // getting the language
$result = mysql_query($query) or die_script($query, mysql_error());
$language = mysql_result($result, 0);
include ("../languages/$language/$language.php"); // including language file
unset ($query);
unset ($result);

if (IsSet ($_GET['module']))
{
	if (!get_magic_quotes_gpc())
	{
		$module = intval(addslashes($_GET['module']));
	}
	else
	{
		$module = intval($_GET['module']);
	}
}
else
{
	unset ($module);
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $sas_lang['lang_charset'] ?>"> 
<title>Site@School</title>
<STYLE>
A:link {
	BACKGROUND: none transparent scroll repeat 0% 0%; COLOR: #000000; TEXT-DECORATION: none
}
A:active {
	BACKGROUND: none transparent scroll repeat 0% 0%; COLOR: #000000; TEXT-DECORATION: none
}
A:visited {
	BACKGROUND: none transparent scroll repeat 0% 0%; COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
	BACKGROUND: none transparent scroll repeat 0% 0%; COLOR: #FF0000; TEXT-DECORATION: none
}

.link {
	FONT-WEIGHT: bold; COLOR: #0000CC; FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial
}
.text {
	FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial
}

input.backbutton {
background-image: url(../graphics/button_back.png);
background-repeat: no-repeat;
background-position: left center;
background-color: ButtonFace;
border : 1px outset ButtonFace
}

</STYLE>
</head>
<body marginheight="0" marginwidth="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin=""0" style="font-family: Verdana, Arial, Helvetica; font-size: 10pt" bgcolor="#F7F7F7">

<?php

print "
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"27\" bgcolor=\"#13528c\">
  <tr>
    <td width=\"100%\" align=\"right\"><b><font face=\"Verdana\" color=\"#FFFFFF\" size=\"4\">" . $sas_lang['modulebrowser'] . "&nbsp;&nbsp;</font></b></td>
  </tr>
</table>";
print "<table id=AutoNumber3 cellSpacing=0 cellPadding=0 width=\"100%\" height=\"373\" border=0>
  <tbody>
  <tr>
    <td width=1 bgcolor=\"#ffffff\">&nbsp;</td>
    <td vAlign=\"top\" width=\"258\" bgColor=\"#f7f7f7\">
      <table>
        <tbody>
        <tr><td>" . $sas_lang['module_name'] . "</td></tr>
        <tr>
          <td>";

$query = "SELECT id, name FROM $table_modules WHERE options != ''"; // getting module list
$result = mysql_query($query) or die_script($query, mysql_error());
while ($module_list = mysql_fetch_array($result))
{
	print "<span class=\"link\"><a href=\"pag_modbrowser.inc.php?module=$module_list[0]\">$module_list[1]</a></span><br>";
}
print " </td>
        </tr>
      </tbody>
     </table>
    </td>
    <td width=1 bgColor=#e5e5e5><IMG height=1 src=\"\" width=1 border=0></td>
    <td vAlign=top>
    <table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" width=\"100%\" height=\"100%\" id=\"AutoNumber4\">
      <tr>
        <td width=\"100%\" valign=\"top\">";
if (!IsSet ($module))
{
	print "<span class=text>" . $sas_lang['modbrowser_introduction'] . "</span>";
}
else
{
	$query = "SELECT location, options FROM $table_modules WHERE id='" . $module . "'"; // getting the location
	$result = mysql_query($query) or die_script($query, mysql_error());
	$modlocation = mysql_result($result, 0, 0);
	$options = mysql_result($result, 0, 1);
	unset ($query);
	unset ($result);
	$options = explode(",", $options);
	$optioncounter = 2;
	print $sas_lang[module_script] . "<p>";
	foreach ($options as $optionitem)
	{
		if ($optioncounter == "1")
		{
			print $optionitem . "</a></span><br>";
			$optioncounter = "2";
		}
		else
		{
			print "<span class=link><a href=\"#\" OnClick=\"opener.document.form.module.value = '$modlocation/$optionitem'; self.close();\">";
			$optioncounter = "1";
		}
	}
}

print "</td></tr>
      <tr>
       <td width=\"100%\" align=\"right\" valign=\"bottom\">";
print "<input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['close'] . "\" name=\"closebutton\" 
		onClick=\"javascript:self.close();\" class=\"backbutton\">&nbsp;
        </td>
      </tr>
    </table>
    </td>
  </tr>
 </tbody>
</table>
</body>
</html>";
?>
