2004-11-10 13:52:01 +00:00
|
|
|
<?
|
2005-01-24 18:00:03 +00:00
|
|
|
/*
|
|
|
|
This file is part of the 'Science Fair In A Box' project
|
|
|
|
SFIAB Website: http://www.sfiab.ca
|
|
|
|
|
|
|
|
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
|
|
|
Copyright (C) 2005 James Grant <james@lightbox.org>
|
|
|
|
|
|
|
|
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, version 2.
|
|
|
|
|
|
|
|
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; see the file COPYING. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
?>
|
|
|
|
<?
|
2004-11-10 13:52:01 +00:00
|
|
|
require("config.inc.php");
|
2004-11-30 17:46:39 +00:00
|
|
|
mysql_connect($DBHOST,$DBUSER,$DBPASS);
|
|
|
|
mysql_select_db($DBNAME);
|
|
|
|
|
2004-11-30 18:34:25 +00:00
|
|
|
session_start();
|
|
|
|
|
2004-11-30 19:06:35 +00:00
|
|
|
//find out the fair year and any other 'year=0' configuration parameters (things that dont change as the years go on)
|
|
|
|
$q=mysql_query("SELECT * FROM config WHERE year='0'");
|
|
|
|
while($r=mysql_fetch_object($q))
|
|
|
|
{
|
|
|
|
$config[$r->var]=$r->val;
|
|
|
|
}
|
2004-11-30 18:34:25 +00:00
|
|
|
|
|
|
|
//now pull the rest of the configuration
|
2004-11-30 19:06:35 +00:00
|
|
|
$q=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."'");
|
2004-11-30 18:34:25 +00:00
|
|
|
while($r=mysql_fetch_object($q))
|
|
|
|
{
|
|
|
|
$config[$r->var]=$r->val;
|
|
|
|
}
|
|
|
|
|
2004-12-20 16:36:25 +00:00
|
|
|
//detect the browser first, so we know what icons to use - we store this in the config array as well
|
|
|
|
//even though its not configurable by the fair
|
|
|
|
if(stristr($_SERVER['HTTP_USER_AGENT'],"MSIE"))
|
|
|
|
$config['icon_extension']="gif";
|
|
|
|
else
|
|
|
|
$config['icon_extension']="png";
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-11-30 18:34:25 +00:00
|
|
|
//now get the languages, and make sure we have at least one active language
|
|
|
|
$q=mysql_query("SELECT * FROM languages WHERE active='Y' ORDER BY langname");
|
|
|
|
if(mysql_num_rows($q)==0)
|
|
|
|
{
|
|
|
|
echo "No active languages defined, defaulting to English";
|
|
|
|
$config['languages']['en']="English";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while($r=mysql_fetch_object($q))
|
|
|
|
{
|
|
|
|
$config['languages'][$r->lang]=$r->langname;
|
|
|
|
}
|
|
|
|
}
|
2004-11-30 18:52:31 +00:00
|
|
|
//now if no language has been set yet, lets set it to the default language
|
|
|
|
if(!$_SESSION['lang'])
|
|
|
|
{
|
|
|
|
//first try the default language, if that doesnt work, use "en"
|
|
|
|
if($config['default_language'])
|
|
|
|
$_SESSION['lang']=$config['default_language'];
|
|
|
|
else
|
|
|
|
$_SESSION['lang']="en";
|
|
|
|
}
|
|
|
|
|
2004-11-30 18:34:25 +00:00
|
|
|
|
|
|
|
//if the user has switched languages, go ahead and switch the session variable
|
|
|
|
if($_GET['switchlanguage'])
|
|
|
|
{
|
|
|
|
//first, make sure its a valid language:
|
|
|
|
if($config['languages'][$_GET['switchlanguage']])
|
|
|
|
{
|
|
|
|
$_SESSION['lang']=$_GET['switchlanguage'];
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//invalid language, dont do anything
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-30 17:46:39 +00:00
|
|
|
|
2004-11-30 22:59:27 +00:00
|
|
|
function i18n($str,$args=array())
|
2004-11-30 17:46:39 +00:00
|
|
|
{
|
|
|
|
if(!$str)
|
|
|
|
return "";
|
|
|
|
|
|
|
|
if($_SESSION['lang'])
|
|
|
|
{
|
|
|
|
if($_SESSION['lang']=="en")
|
2004-11-30 22:59:27 +00:00
|
|
|
{
|
|
|
|
for($x=1;$x<=count($args);$x++)
|
|
|
|
{
|
|
|
|
$str=str_replace("%$x",$args[$x-1],$str);
|
|
|
|
}
|
2004-11-30 17:46:39 +00:00
|
|
|
return $str;
|
2004-11-30 22:59:27 +00:00
|
|
|
}
|
2004-11-30 17:46:39 +00:00
|
|
|
else
|
|
|
|
{
|
2004-11-30 18:34:25 +00:00
|
|
|
$q=mysql_query("SELECT * FROM translations WHERE lang='".$_SESSION['lang']."' AND strmd5='".md5($str)."'");
|
2004-11-30 17:46:39 +00:00
|
|
|
if($r=@mysql_fetch_object($q))
|
|
|
|
{
|
|
|
|
if($r->val)
|
2004-11-30 22:59:27 +00:00
|
|
|
{
|
|
|
|
$ret=$r->val;
|
|
|
|
|
|
|
|
for($x=1;$x<=count($args);$x++)
|
|
|
|
{
|
|
|
|
$ret=str_replace("%$x",$args[$x-1],$ret);
|
|
|
|
}
|
|
|
|
return $ret;
|
|
|
|
}
|
2004-11-30 17:46:39 +00:00
|
|
|
else
|
|
|
|
{
|
2004-11-30 22:59:27 +00:00
|
|
|
for($x=1;$x<=count($args);$x++)
|
|
|
|
{
|
|
|
|
$str=str_replace("%$x",$args[$x-1],$str);
|
|
|
|
}
|
2004-12-02 17:40:37 +00:00
|
|
|
return "<font color=red>$str</font>";
|
2004-11-30 17:46:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-11-30 18:34:25 +00:00
|
|
|
mysql_query("INSERT INTO translations (lang,strmd5,str) VALUES ('".$_SESSION['lang']."','".md5($str)."','".mysql_escape_string($str)."')");
|
2004-11-30 22:59:27 +00:00
|
|
|
for($x=1;$x<=count($args);$x++)
|
|
|
|
{
|
|
|
|
$str=str_replace("%$x",$args[$x-1],$str);
|
|
|
|
}
|
2004-12-03 04:30:50 +00:00
|
|
|
return "<font color=red>$str</font>";
|
2004-11-30 17:46:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//no language set, assume english
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-30 22:59:27 +00:00
|
|
|
function error($str)
|
|
|
|
{
|
2004-12-02 23:15:42 +00:00
|
|
|
return "<div class=\"error\">$str</div><br />";
|
2004-11-30 22:59:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function notice($str)
|
|
|
|
{
|
2004-12-02 23:15:42 +00:00
|
|
|
return "<div class=\"notice\">$str</div><br />";
|
2004-11-30 22:59:27 +00:00
|
|
|
}
|
2004-11-10 13:52:01 +00:00
|
|
|
|
2004-12-08 20:34:02 +00:00
|
|
|
function happy($str)
|
|
|
|
{
|
|
|
|
return "<div class=\"happy\">$str</div><br />";
|
|
|
|
}
|
|
|
|
|
2004-11-30 22:59:27 +00:00
|
|
|
$HEADER_SENT=false;
|
2004-11-10 13:52:01 +00:00
|
|
|
function send_header($title="")
|
|
|
|
{
|
2004-11-30 22:59:27 +00:00
|
|
|
global $HEADER_SENT;
|
2004-11-30 18:34:25 +00:00
|
|
|
global $config;
|
2004-11-30 22:59:27 +00:00
|
|
|
|
|
|
|
//do this so we can use send_header() a little more loosly and not worry about it being sent more than once.
|
|
|
|
if($HEADER_SENT) return;
|
|
|
|
else $HEADER_SENT=true;
|
2004-11-30 18:34:25 +00:00
|
|
|
|
2004-12-02 19:03:53 +00:00
|
|
|
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
|
2004-11-10 13:52:01 +00:00
|
|
|
?>
|
2004-11-10 15:31:30 +00:00
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2004-11-30 17:46:39 +00:00
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
|
2004-11-30 22:59:27 +00:00
|
|
|
<head><title><?=i18n($title)?></title>
|
2004-11-30 19:06:35 +00:00
|
|
|
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/sfiab.css" type="text/css" />
|
2004-11-10 15:31:30 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2004-12-06 21:37:49 +00:00
|
|
|
<script language="javascript" type="text/javascript">
|
|
|
|
//useful function that we'll be using throughout
|
|
|
|
function confirmClick(msg)
|
|
|
|
{
|
|
|
|
var okay=confirm(msg);
|
|
|
|
if(okay)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
</script>
|
2004-11-30 17:46:39 +00:00
|
|
|
|
|
|
|
<div id="header">
|
|
|
|
<?
|
2004-11-30 19:06:35 +00:00
|
|
|
echo "<h1>".i18n($config['fairname'])."</h1>";
|
2004-11-30 17:46:39 +00:00
|
|
|
?>
|
2004-11-10 15:31:30 +00:00
|
|
|
<hr />
|
2004-11-30 17:46:39 +00:00
|
|
|
</div>
|
2004-11-10 13:52:01 +00:00
|
|
|
|
2004-11-30 17:46:39 +00:00
|
|
|
<div id="left">
|
|
|
|
<ul class="mainnav">
|
2004-12-07 14:20:42 +00:00
|
|
|
<li><a href="<?=$config['SFIABDIRECTORY']?>/index.php"><?=i18n("Home Page")?></a></li>
|
2004-11-30 19:06:35 +00:00
|
|
|
<li><a href="<?=$config['SFIABDIRECTORY']?>/register_participants.php"><?=i18n("Participant Registration")?></a></li>
|
|
|
|
<li><a href="<?=$config['SFIABDIRECTORY']?>/register_judges.php"><?=i18n("Judges Registration")?></a></li>
|
2004-11-30 17:46:39 +00:00
|
|
|
</ul>
|
|
|
|
<br />
|
|
|
|
<ul class="mainnav">
|
2004-11-30 19:06:35 +00:00
|
|
|
<li><a href="<?=$config['SFIABDIRECTORY']?>/admin/"><?=i18n("Fair Administration")?></a></li>
|
|
|
|
<li><a href="<?=$config['SFIABDIRECTORY']?>/config/"><?=i18n("SFIAB Configuration")?></a></li>
|
2004-11-30 17:46:39 +00:00
|
|
|
</ul>
|
2004-11-30 18:34:25 +00:00
|
|
|
|
2004-11-30 18:52:31 +00:00
|
|
|
<div class="aligncenter">
|
2004-11-30 18:34:25 +00:00
|
|
|
|
|
|
|
<?
|
|
|
|
|
|
|
|
if(count($config['languages'])>1)
|
|
|
|
{
|
2004-11-30 18:52:31 +00:00
|
|
|
echo "<br />";
|
|
|
|
echo "<form name=\"languageselect\" method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
|
|
|
|
echo "<select name=\"switchlanguage\" onchange=\"document.forms.languageselect.submit()\">\n";
|
2004-11-30 18:34:25 +00:00
|
|
|
foreach($config['languages'] AS $key=>$val)
|
|
|
|
{
|
2004-11-30 18:52:31 +00:00
|
|
|
if($_SESSION['lang']==$key) $selected="selected=\"selected\""; else $selected="";
|
2004-11-30 18:34:25 +00:00
|
|
|
|
|
|
|
echo "<option $selected value=\"$key\">$val</option>";
|
|
|
|
}
|
|
|
|
echo "</select>";
|
|
|
|
echo "</form>";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
<a href="http://www.sfiab.ca/"><?=i18n("Return to SFIAB Development Page")?></a>
|
2004-12-02 23:15:42 +00:00
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<? include "http://counter.lightbox.org/?user=sfiab&name=testsite&addr=".$_SERVER['REMOTE_ADDR']; ?>
|
2004-11-30 18:52:31 +00:00
|
|
|
</div>
|
2004-12-02 23:15:42 +00:00
|
|
|
|
2004-11-30 17:46:39 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div id="main">
|
2004-11-10 13:52:01 +00:00
|
|
|
<?
|
2004-11-30 18:55:39 +00:00
|
|
|
if($title)
|
2004-11-30 22:59:27 +00:00
|
|
|
echo "<h2>".i18n($title)."</h2>";
|
2004-11-10 13:52:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function send_footer()
|
|
|
|
{
|
|
|
|
?>
|
2004-11-30 17:46:39 +00:00
|
|
|
</div>
|
|
|
|
<div id="footer">
|
2004-11-30 22:59:27 +00:00
|
|
|
<? print_r($_SESSION); ?>
|
2004-11-30 17:46:39 +00:00
|
|
|
</div>
|
|
|
|
|
2004-11-10 15:31:30 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
2004-11-10 13:52:01 +00:00
|
|
|
|
|
|
|
<?
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-03 04:28:18 +00:00
|
|
|
function emit_month_selector($name,$selected="")
|
|
|
|
{
|
|
|
|
echo "<select name=\"$name\">\n";
|
|
|
|
$months=array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
|
|
|
|
echo "<option value=\"\">".i18n("Month")."</option>\n";
|
|
|
|
for($x=1;$x<=12;$x++)
|
|
|
|
{
|
|
|
|
if($x==$selected)
|
|
|
|
$s="selected=\"selected\"";
|
|
|
|
else
|
|
|
|
$s="";
|
|
|
|
echo "<option $s value=\"$x\">".$months[$x]."</option>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "</select>\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function emit_day_selector($name,$selected="")
|
|
|
|
{
|
|
|
|
echo "<select name=\"$name\">\n";
|
|
|
|
echo "<option value=\"\">".i18n("Day")."</option>\n";
|
|
|
|
|
|
|
|
for($x=1;$x<=31;$x++)
|
|
|
|
echo "<option value=\"".($x<10?"0":"")."$x\" ".($selected==$x?"selected=\"selected\"":"").">$x</option>\n";
|
|
|
|
|
|
|
|
echo "</select>\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function emit_year_selector($name,$selected="",$min=0,$max=0)
|
|
|
|
{
|
|
|
|
$curyear=date("Y");
|
|
|
|
echo "<select name=\"$name\">\n";
|
|
|
|
echo "<option value=\"\">".i18n("Year")."</option>\n";
|
|
|
|
|
|
|
|
if($min&&$max)
|
|
|
|
{
|
|
|
|
for($x=$min;$x<=$max;$x++)
|
|
|
|
echo "<option value=\"$x\" ".($selected==$x?"selected=\"selected\"":"").">$x</option>\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//if we arent given a min and max, lets show current year + 5
|
|
|
|
for($x=$curyear;$x<$curyear+5;$x++)
|
|
|
|
echo "<option value=\"$x\" ".($selected==$x?"selected=\"selected\"":"").">$x</option>\n";
|
|
|
|
}
|
|
|
|
echo "</select>\n";
|
|
|
|
}
|
|
|
|
|
2005-01-05 16:23:11 +00:00
|
|
|
function emit_province_selector($name,$selected="")
|
|
|
|
{
|
|
|
|
$q=mysql_query("SELECT * FROM provinces ORDER BY province");
|
|
|
|
if(mysql_num_rows($q)==1)
|
|
|
|
{
|
|
|
|
$r=mysql_fetch_object($q);
|
|
|
|
echo "<input type=\"hidden\" name=\"$name\" value=\"$r-code\">";
|
|
|
|
echo i18n($r->province);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "<select name=\"$name\">\n";
|
2005-01-05 16:28:42 +00:00
|
|
|
echo "<option value=\"\">".i18n("Select a Province")."</option>\n";
|
2005-01-05 16:23:11 +00:00
|
|
|
while($r=mysql_fetch_object($q))
|
|
|
|
{
|
|
|
|
if($r->code == $selected) $sel="selected=\"selected\""; else $sel="";
|
|
|
|
|
|
|
|
echo "<option $sel value=\"$r->code\">".i18n($r->province)."</option>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "</select>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2004-12-03 04:28:18 +00:00
|
|
|
|
|
|
|
|
2004-12-19 23:16:46 +00:00
|
|
|
function outputStatus($status)
|
|
|
|
{
|
|
|
|
$ret="";
|
|
|
|
switch($status)
|
|
|
|
{
|
|
|
|
case 'incomplete':
|
|
|
|
$ret.="<div class=\"incomplete\">";
|
|
|
|
$ret.= i18n("Incomplete");
|
|
|
|
$ret.= "</div>";
|
|
|
|
break;
|
|
|
|
case 'complete':
|
|
|
|
$ret.= "<div class=\"complete\">";
|
|
|
|
$ret.= i18n("Complete");
|
|
|
|
$ret.= "</div>";
|
|
|
|
break;
|
|
|
|
case 'empty':
|
|
|
|
$ret.="<div class=\"incomplete\">";
|
|
|
|
$ret.= i18n("Empty");
|
|
|
|
$ret.= "</div>";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$ret.=i18n("Unknown");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
2004-12-03 04:28:18 +00:00
|
|
|
|
|
|
|
|
2004-11-10 13:52:01 +00:00
|
|
|
?>
|