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. */ ?> SFIAB ERROR"; echo "

Science Fair In A Box - ERROR

"; echo "SFIAB database and code are mismatched"; echo "
"; echo "Please run the db_update.php script in order to update"; echo "
"; echo "your database to the same version as the code"; echo "
"; echo "
"; echo "
"; echo "

Details

"; echo "Current SFIAB codebase requires DB version: ".$dbcodeversion[0]; echo "
"; echo "Current SFIAB database is detected as version: ".$dbdbversion[0]; echo "
"; echo ""; exit; } require_once("config.inc.php"); require_once("committee_auth.php"); mysql_connect($DBHOST,$DBUSER,$DBPASS); mysql_select_db($DBNAME); session_start(); //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; } //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; } //now pull the dates $q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."'"); while($r=mysql_fetch_object($q)) { $config['dates'][$r->name]=$r->date; } //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,$type="normal") { if($type=="normal") return "
$str

"; else if($type=="inline") return "$str
"; } function notice($str,$type="normal") { if($type=="normal") return "
$str

"; else if($type=="inline") return "$str
"; } function happy($str,$type="normal") { if($type=="normal") return "
$str

"; else if($type=="inline") 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() { global $config; ?>
\n"; ?> <?=i18n($title)?> ".i18n($title).""; } function send_popup_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_date_selector($name,$selected="") { if($selected) { list($year,$month,$day)=split("-",$selected); } echo ""; echo ""; echo "
"; emit_year_selector($name."_year",$year); echo ""; emit_month_selector($name."_month",$month); echo ""; emit_day_selector($name."_day",$day); echo "
"; } function emit_hour_selector($name,$selected="") { if($selected!="") $selected=(int)$selected; echo "\n"; } function emit_minute_selector($name,$selected="") { $mins=array("00","05","10","15","20","25","30","35","40","45","50","55"); echo "\n"; } function emit_time_selector($name,$selected="") { if($selected) { list($hour,$minute,$second)=split(":",$selected); } echo ""; echo ""; echo "
"; emit_hour_selector($name."_hour",$hour); echo ""; emit_minute_selector($name."_minute",$minute); echo "
"; } function emit_province_selector($name,$selected="",$extra="") { $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; } function email_send($val,$to,$sub_subject=array(),$sub_body=array()) { $q=mysql_query("SELECT * FROM emails WHERE val='$val'"); if($r=mysql_fetch_object($q)) { $subject=i18n($r->subject); $body=i18n($r->body); if(count($sub_subject)) { foreach($sub_subject AS $sub_k=>$sub_v) { $subject=ereg_replace("\[$sub_k\]",$sub_v,$subject); } } if(count($sub_body)) { foreach($sub_body AS $sub_k=>$sub_v) { $body=ereg_replace("\[$sub_k\]",$sub_v,$body); } } //now word-wrap the body to 79 chars //hmm forget the wordwrap for now, its not really needed, but could be done later if need be. //i'll leave in the start of the function, but its not nearly complete /* $MAXCHARS=79; $c=0; $lastspace=0; for($x=0;$x$MAXCHARS) { } } */ mail($to,$subject,$body,"From: $r->from\r\nReply-To: $r->from"); } else { echo error(i18n("CRITICAL ERROR: email '%1' not found",array($val))); } } ?>