diff --git a/db/db.update.188.php b/db/db.update.188.php index ea70e32a..001a150c 100644 --- a/db/db.update.188.php +++ b/db/db.update.188.php @@ -20,8 +20,15 @@ function db_update_188_post() //now update a couple config options for now, until we cna do soemthing better, without theme and theme_icons //being fairyear independent, they wont get set at all so the page wont even load + mysql_query("UPDATE config SET year=0, category='Special' WHERE year='{$config['FAIRYEAR']}' AND var='theme'"); + if(!mysql_affected_rows()) { + mysql_query("UPDATE config SET year=0, category='Special' WHERE year='-1' AND var='theme'"); + } mysql_query("UPDATE config SET year=0, category='Special' WHERE year='{$config['FAIRYEAR']}' AND var='theme_icons'"); + if(!mysql_affected_rows()) { + mysql_query("UPDATE config SET year=0, category='Special' WHERE year='-1' AND var='theme_icons'"); + } mysql_query("DELETE FROM config WHERE year!=0 AND var='theme'"); mysql_query("DELETE FROM config WHERE year!=0 AND var='theme_icons'"); diff --git a/install2.php b/install2.php index 18228f8a..4e55f103 100644 --- a/install2.php +++ b/install2.php @@ -37,8 +37,7 @@ if(!function_exists("system")) { exit; } -if(!file_exists("data/config.inc.php")) -{ +if(!file_exists("data/config.inc.php")) { echo "
SFIAB Installation Step 1 is not yet complete.
"; echo "Go back to installation step 1
"; echo ""; @@ -51,13 +50,11 @@ mysql_select_db($DBNAME); echo "Getting database version requirements for code... "; - if(file_exists("db/db.code.version.txt")) - { + if(file_exists("db/db.code.version.txt")) { $dbcodeversion_file=file("db/db.code.version.txt"); $dbcodeversion=trim($dbcodeversion_file[0]); } - else - { + else { echo "ERROR: Couldnt load current db/db.code.version.txt
"; exit; } @@ -69,8 +66,7 @@ mysql_select_db($DBNAME); $r=@mysql_fetch_object($q); $dbdbversion=$r->val; - if($dbdbversion) - { + if($dbdbversion) { echo "ERROR: found version $dbdbversion
"; //lets see if they match @@ -82,14 +78,12 @@ mysql_select_db($DBNAME); echo "Your SFIAB database needs to be updated. You should run the update script instead of this installer!\n"; exit; } - else - { + else { echo "Not found (good!)
"; } echo "Checking for database installer for version $dbcodeversion... "; - if(file_exists("db/db.full.$dbcodeversion.sql")) - { + if(file_exists("db/db.full.$dbcodeversion.sql")) { echo "db/db.full.$dbcodeversion.sql found
"; echo "Setting up database tables... "; @@ -105,15 +99,12 @@ mysql_select_db($DBNAME); echo "Done!
"; echo "Proceed to installation step 3
"; } - else - { - echo "WARNING: Couldnt find db/db.full.$dbcodeversion.sql
"; + else { + echo "Couldnt find db/db.full.$dbcodeversion.sql
"; echo "Trying to find an older version...
"; - for($x=$dbcodeversion;$x>0;$x--) - { - if(file_exists("db/db.full.$x.sql")) - { + for($x=$dbcodeversion;$x>0;$x--) { + if(file_exists("db/db.full.$x.sql")) { echo "db/db.full.$x.sql found
"; echo "Setting up database tables... "; @@ -140,10 +131,8 @@ mysql_select_db($DBNAME); } } } - //only if this file was created will we go ahead with the rest //creating all the tables and such.. - ?> diff --git a/install3.php b/install3.php index f2d1b973..7c085e4a 100644 --- a/install3.php +++ b/install3.php @@ -30,8 +30,7 @@ echo "\n";

SFIAB Installation - Step 3

SFIAB Installation Step 1 is not yet complete."; echo "Go back to installation step 1
"; echo ""; @@ -45,25 +44,23 @@ require_once("committee.inc.php"); mysql_connect($DBHOST,$DBUSER,$DBPASS); mysql_select_db($DBNAME); - echo "Checking for SFIAB database... "; +echo "Checking for SFIAB database... "; - $q=@mysql_query("SELECT val FROM config WHERE var='DBVERSION' AND year='0'"); - $r=@mysql_fetch_object($q); - $dbdbversion=$r->val; +$q=@mysql_query("SELECT val FROM config WHERE var='DBVERSION' AND year='0'"); +$r=@mysql_fetch_object($q); +$dbdbversion=$r->val; - if(!$dbdbversion) - { - echo "
SFIAB Installation Step 2 is not yet complete.
"; - echo "Go back to installation step 2
"; - echo ""; - exit; - } +if(!$dbdbversion) { + echo "
SFIAB Installation Step 2 is not yet complete.
"; + echo "Go back to installation step 2
"; + echo ""; + exit; +} //a fresh install should ONLY have DBVERSION defined in the config table. If there are others (FAIRYEAR, SFIABDIRECTORY) then this is NOT fresh -$q=mysql_query("SELECT * FROM config WHERE year='0' AND ( var='DBVERSION' OR var='FAIRYEAR' OR var='SFIABDIRECTORY') "); +$q=mysql_query("SELECT * FROM config WHERE year='0' AND conferences_id='0' AND ( var='DBVERSION' OR var='FAIRYEAR' OR var='SFIABDIRECTORY') "); //we might get an error if the config table does not exist (ie, installer step 2 failed) -if(mysql_error()) -{ +if(mysql_error()) { //we say all tables, but really only we check for config where year=0; echo "
ERROR: No SFIAB tables detected, It seems like step 2 failed. Please go Back to Installation Step 2 and try again.
"; echo ""; @@ -71,8 +68,7 @@ if(mysql_error()) } //1 is okay (DBVERSION). More than 1 is bad (already isntalled) -if(mysql_num_rows($q)>1) -{ +if(mysql_num_rows($q)>1) { //we say all tables, but really only we check for config where year=0; echo "
ERROR: Detected existing table data, SFIAB Installation Step 3 requires a clean SFIAB database installation.
"; echo ""; @@ -80,35 +76,29 @@ if(mysql_num_rows($q)>1) } echo "Found!
"; -if($_POST['action']=="save") -{ +if($_POST['action']=="save") { $err=false; - if(!$_POST['fairyear']) - { + if(!$_POST['fairyear']) { echo "Fair Year is required"; $err=true; } - if(!$_POST['email']) - { + if(!$_POST['email']) { echo "Superuser email address is required"; $err=true; } - if(!( $_POST['pass1'] && $_POST['pass2'])) - { + if(!( $_POST['pass1'] && $_POST['pass2'])) { echo "Superuser password and password confirmation are required"; $err=true; } - if($_POST['pass1'] != $_POST['pass2']) - { + if($_POST['pass1'] != $_POST['pass2']) { echo "Password and Password confirmation do not match"; $err=true; } - if(!$err) - { - echo "Creating configuration settings..."; + if(!$err) { + echo "Creating configuration settings... "; mysql_query("INSERT INTO config (var,val,category,ord,year) VALUES ('FAIRYEAR','".$_POST['fairyear']."','Special','0','0')"); mysql_query("INSERT INTO config (var,val,category,ord,year) VALUES ('FISCALYEAR','".$_POST['fiscalyear']."','Special','0','0')"); mysql_query("INSERT INTO config (var,val,category,ord,year) VALUES ('SFIABDIRECTORY','".$_POST['sfiabdirectory']."','Special','','0')"); @@ -120,42 +110,38 @@ if($_POST['action']=="save") // Update some variables mysql_query("UPDATE config SET - val='".mysql_escape_string(stripslashes($_POST['fairname']))."' + val='".mysql_escape_string($_POST['fairname'])."' WHERE var='fairname' AND year='$year'"); mysql_query("UPDATE config SET - val='".mysql_escape_string(stripslashes($_POST['email']))."' + val='".mysql_escape_string($_POST['email'])."' WHERE var='fairmanageremail' AND year='$year'"); - $q=mysql_query("SELECT * FROM dates WHERE year='-1'"); - while($r=mysql_fetch_object($q)) - { - mysql_query("INSERT INTO dates (date,name,description,year) VALUES ('$r->date','$r->name','$r->description','".$_POST['fairyear']."')"); - } - //copy over the award_types defautls $q=mysql_query("SELECT * FROM award_types WHERE year='-1'"); - while($r=mysql_fetch_object($q)) - { + while($r=mysql_fetch_object($q)) { mysql_query("INSERT INTO award_types (id,type,`order`,year) VALUES ('$r->id','$r->type','$r->order','".$_POST['fairyear']."')"); } - echo "Done!
"; - echo "Creating superuser account..."; + echo "Creating a science fair conference... "; + mysql_query("INSERT INTO conferences (`name`,`type`,`status`) VALUES ('".mysql_real_escape_string($_POST['fairname'])."','sciencefair','running')"); + echo "Done!
"; + + echo "Creating superuser account... "; $u = user_create('committee',$_POST['email']); if($_POST['firstname'] && $_POST['lastname']) { - $u['firstname']=mysql_escape_string(stripslashes($_POST['firstname'])); - $u['lastname']=mysql_escape_string(stripslashes($_POST['lastname'])); + $u['firstname']=mysql_escape_string($_POST['firstname']); + $u['lastname']=mysql_escape_string($_POST['lastname']); } else { $u['firstname'] = 'Superuser'; $u['lastname'] = 'Account'; } - $u['emailprivate'] = mysql_escape_string(stripslashes($_POST['email'])); - $u['email'] = mysql_escape_string(stripslashes($_POST['email'])); - $u['username'] = mysql_escape_string(stripslashes($_POST['email'])); - $u['password'] = mysql_escape_string(stripslashes($_POST['pass1'])); + $u['emailprivate'] = mysql_escape_string($_POST['email']); + $u['email'] = mysql_escape_string($_POST['email']); + $u['username'] = mysql_escape_string($_POST['email']); + $u['password'] = mysql_escape_string($_POST['pass1']); $u['access_admin'] = 'yes'; $u['access_config'] = 'yes'; $u['access_super'] = 'yes';