<?php

#############################################################################
#                              Site@School
# Site@School is a website management system designed for 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)
############################################################################
# tv.php: last changed 20/08/2006  , version: 2.4.10
#            by Fred Stuurman  (fc.stuurman@hccnet.nl)
#$Id: tv.php,v 1.2 2006/10/15 19:08:54 fstuurman Exp $
############################################################################
#                        LICENSE INFORMATION
# Copyright (C) 2006 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.
##############################################################################
$cmsdir = "starnet";
$loc_id = 0;

if (IsSet ($_GET['loc_id']))
{
	$loc_id = intval($_GET['loc_id']);
}

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

$query = "SELECT config_value FROM $table_configuration WHERE config_key = 'language'";
$result = mysql_query($query);
$language = mysql_result($result, 0, 0);

if (file_exists("../languages/" . $language . "/sn_tvmodule/" . $language . ".php"))
{
	include ("../languages/" . $language . "/sn_tvmodule/" . $language . ".php");
}
else
{
	include ("../languages/EN/sn_tvmodule/EN.php");
}

$table_scripts = $dbprefix . "m_scripts";
$query = "SELECT script, welcome, id FROM $table_scripts WHERE active = 1 AND loc_id = '" . $loc_id . "'";

$result = mysql_query($query);

$RecordCount = mysql_num_rows($result);
if ($RecordCount > 0)
{
	$script_name = mysql_result($result, 0, 0);
	$script_welcome = mysql_result($result, 0, 1);
	$script_id = mysql_result($result, 0, 2);

	if ($script_welcome != "")
	{
		print $script_welcome;
	}

	include ($script_name);
}
else
{
	print $sas_lang['tv_module_not_found'];
}

//$query = "SELECT config_value FROM $table_configuration WHERE config_key = 'ip_tv_module'" ;
//$result = mysql_query($query) ;
//$ip_tv_module = mysql_result($result,0,0);
//$ip = $_SERVER["REMOTE_ADDR"];
//unset($query);
//unset($result);

//if($ip == $ip_tv_module)
//{
print "<iframe name=\"checker\" src=\"checker.php?loc_id=$_GET[loc_id]&id=$script_id\" width=\"0\" height=\"0\" scrolling=\"no\" frameborder=\"no\"></iframe>";
//}  
?>
