diff --git a/common.inc.php b/common.inc.php index 8f8671c..b490d2b 100644 --- a/common.inc.php +++ b/common.inc.php @@ -51,7 +51,6 @@ else $sfiabversion=@file($prependdir."version.txt"); $config['version']=trim($sfiabversion[0]); - //make sure the data subdirectory is writable, if its not, then we're screwed, so make sure it is! if(!is_writable($prependdir."data")) { @@ -130,8 +129,7 @@ if(mysql_num_rows($q)<2) } else { - while($r=mysql_fetch_object($q)) - { + while($r=mysql_fetch_object($q)) { $config[$r->var]=$r->val; } } @@ -204,37 +202,48 @@ if($config['SFIABDIRECTORY'] == '') { } session_start(); +if(!$_SESSION['conferenceid']) { + $q=mysql_query("SELECT * FROM conferences WHERE status='running' ORDER BY name LIMIT 1"); + if($r=mysql_fetch_object($q)) { + $_SESSION['conferenceid']=$r->id; + } + else { + echo "No conferences defined!"; + } +} + //move the conference stuff before the configuration loading, so we can load the right configuration for the conference :) if(isset($_GET['switchconference'])) { //make sure its good $cid=intval($_GET['switchconference']); // echo "cid=$cid"; - if($cid==0) { - //default for old science fair system - $_SESSION['conferenceid']=0; - } - else { - $q=mysql_query("SELECT * FROM conferences WHERE id='$cid' AND status='running'"); - if($r=mysql_fetch_object($q)) { - $_SESSION['conferenceid']=$cid; - } + $q=mysql_query("SELECT * FROM conferences WHERE id='$cid' AND status='running'"); + if($r=mysql_fetch_object($q)) { + $_SESSION['conferenceid']=$cid; } } -if($_SESSION['conferenceid']) { +if(intval($_SESSION['conferenceid'])>0) { $q=mysql_query("SELECT * FROM conferences WHERE id='".$_SESSION['conferenceid']."'"); $conference=mysql_fetch_assoc($q); -} -else { - $conference['id']=0; - $conference['name']=$config['fairname']; - $conference['type']="sciencefair"; + + /* + ******* THIS IS TEMPORARY.. probably remove it in a year or so ******** + if the conference year is set, this is temporary for migratory purposes, so set the FAIRYEAR = confierence year - this will + gracefully handle the science fair parts that still rely on FAIRYEAR + + if conference year is NOT set, then make sure config['FAIRYEAR'] is NOT set, so we can weed out any code that relies on + FAIRYEAR from the conference system + */ + if($conference['year']) + $config['FAIRYEAR']=$conference['year']; + else + $config['FAIRYEAR']=NULL; } //now pull the rest of the configuration $q=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."'"); -while($r=mysql_fetch_object($q)) -{ +while($r=mysql_fetch_object($q)) { $config[$r->var]=$r->val; } @@ -518,15 +527,9 @@ echo "";