Copyright (C) 2005 James Grant 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. */ ?> var]=$r->val; } //now pull the rest of the configuration $q=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."'"); while($r=mysql_fetch_object($q)) { $config[$r->var]=$r->val; } //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"; //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; } } //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"; } //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 } } function i18n($str,$args=array()) { if(!$str) return ""; if($_SESSION['lang']) { if($_SESSION['lang']=="en") { for($x=1;$x<=count($args);$x++) { $str=str_replace("%$x",$args[$x-1],$str); } return $str; } else { $q=mysql_query("SELECT * FROM translations WHERE lang='".$_SESSION['lang']."' AND strmd5='".md5($str)."'"); if($r=@mysql_fetch_object($q)) { if($r->val) { $ret=$r->val; for($x=1;$x<=count($args);$x++) { $ret=str_replace("%$x",$args[$x-1],$ret); } return $ret; } else { for($x=1;$x<=count($args);$x++) { $str=str_replace("%$x",$args[$x-1],$str); } return "$str"; } } else { mysql_query("INSERT INTO translations (lang,strmd5,str) VALUES ('".$_SESSION['lang']."','".md5($str)."','".mysql_escape_string($str)."')"); for($x=1;$x<=count($args);$x++) { $str=str_replace("%$x",$args[$x-1],$str); } return "$str"; } } } else { //no language set, assume english return $str; } } function error($str) { return "
$str

"; } function notice($str) { return "
$str

"; } function happy($str) { return "
$str

"; } $HEADER_SENT=false; function send_header($title="") { global $HEADER_SENT; global $config; //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; echo "\n"; ?> <?=i18n($title)?>

1) { echo "
"; echo "
"; echo ""; echo "
"; } ?>

".i18n($title).""; } function send_footer() { ?>
\n"; $months=array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); echo "\n"; for($x=1;$x<=12;$x++) { if($x==$selected) $s="selected=\"selected\""; else $s=""; echo "\n"; } echo "\n"; } function emit_day_selector($name,$selected="") { echo "\n"; } function emit_year_selector($name,$selected="",$min=0,$max=0) { $curyear=date("Y"); echo "\n"; } 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 ""; echo i18n($r->province); } else { echo "\n"; } } function outputStatus($status) { $ret=""; switch($status) { case 'incomplete': $ret.="
"; $ret.= i18n("Incomplete"); $ret.= "
"; break; case 'complete': $ret.= "
"; $ret.= i18n("Complete"); $ret.= "
"; break; case 'empty': $ret.="
"; $ret.= i18n("Empty"); $ret.= "
"; break; default: $ret.=i18n("Unknown"); break; } return $ret; } ?>