<?PHP

#############################################################################
#                              Site@School
# Site@School is a website management system designed for schools.
#
# About Site@School:
# Original Idea: Mark de Haan (mark@starwave.nl)
# PHP coding & Design: Mark de Haan (mark@starwave.nl)
# Comissioned by: Stadsdeel de Baarsjes, Amsterdam, Netherlands
############################################################################
# scroll_page.php: last changed 07/09/2005  , version: 2.4                                      
#              by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: scroll_page.php,v 1.2 2006/10/15 19:08:54 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 you want to refresh the script automatically , you must add following line to the head section: 
	<meta http-equiv="refresh" content="50; url=scroll_page.php?page=<?php echo $page ?>">  */

$loc_id = 0;
$page = 0;

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

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

$scripts_table = $dbprefix . "m_scripts";

if ((IsSet ($_GET['page'])) AND (!IsSet ($_GET['loc_id'])))
{
	$page = intval($_GET['page']);
}
else
{
	$query = "SELECT value1 FROM $scripts_table WHERE active = '1' AND loc_id = '$loc_id'";
	$result = mysql_query($query) or die_script(mysql_error());
	$page = mysql_result($result, 0, 0); //get the page to display
	unset ($query);
	unset ($result);
}

if (IsSet ($_GET['speed']))
{
	$speed = $_GET['speed'];
}
else
{
	$query = "SELECT value2 FROM $scripts_table WHERE active = '1' AND loc_id = '$loc_id'";
	$result = mysql_query($query) or die_script(mysql_error());
	$RecordCount = mysql_num_rows($result);
	if ($RecordCount > 0)
	{
		$speed = mysql_result($result, 0, 0); //get the speed
	}
	else
	{
		$speed = 1;
	}
	unset ($query);
	unset ($result);
}

$query = "SELECT config_value FROM $table_configuration WHERE config_key = 'sitename'";
$result = mysql_query($query) or die_script(mysql_error());
$site_name = mysql_result($result, 0);
$query = "SELECT config_value FROM $table_configuration WHERE config_key = 'dateformat'";
$result = mysql_query($query) or die_script(mysql_error());
$date_format = mysql_result($result, 0);
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title><?php echo $site_name ?></title>
<STYLE type="text/css">
  <!--
   BODY {
    scrollbar-face-color:#808080;
    scrollbar-arrow-color:#FF00FF;
    scrollbar-highlight-color:#000000;
    scrollbar-3dlight-color:#000000;
    scrollbar-shadow-color:#000000;
    scrollbar-darkshadow-color:#000000;
    scrollbar-track-color:#000000;
   }
  -->
</STYLE>


<script language="javascript1.2">
<!--
//change 1 to another integer to alter the scroll speed. Greater is faster
var speed=<?PHP echo $speed; ?> 
var currentpos=0,alt=1,curpos1=0,curpos2=-1
function initialize(){
startit()
}

function scrollwindow(){
if (document.all)
temp=document.body.scrollTop
else
temp=window.pageYOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
currentpos=document.body.scrollTop+speed
else
currentpos=window.pageYOffset+speed
window.scroll(0,currentpos)
}
else{
currentpos=0
window.scroll(0,currentpos)
}
}

function startit(){
setInterval("scrollwindow()",50)
}
window.onload=initialize
//-->
</script>

</head>
<?PHP


print "
<body bgcolor=\"#000000\" text=\"#FFFFFF\" link=\"#FFFFFF\" vlink=\"#FFFFFF\" alink=\"#FFFFFF\" leftmargin=\"0\" topmargin=\"3\">

<table width=\"100%\"  border=\"0\" align=\"center\" cellpadding=\"4\" cellspacing=\"4\" bordercolor=\"#111111\" bgcolor=\"660066\" style=\"border-collapse: collapse\">
  <tr> 
    <td width=\"100%\" valign=\"top\" bgcolor=\"#000000\"> <font face=\"Arial, Helvetica, sans-serif\">";

print "<table  cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\">";
$query = "SELECT content FROM $table_pages WHERE id = '".$page."'";
$result = mysql_query($query) or die_script(mysql_error());
$content = mysql_result($result, 0);
unset ($query);
unset ($result);
$content = str_replace("../", "", $content);
print $content;

print "</td>
</table>";

print "</div> 
		</body>
		</html>";
?>
