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

SFIAB Installation - Step 3

SFIAB Installation Step 1 is not yet complete."; echo "Go back to installation step 1
"; echo ""; exit; } require_once("data/config.inc.php"); mysql_connect($DBHOST,$DBUSER,$DBPASS); mysql_select_db($DBNAME); 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; 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'"); //we might get an error if the config table does not exist (ie, installer step 2 failed) 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 ""; exit; } //1 is okay (DBVERSION). More than 1 is bad (already isntalled) 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 ""; exit; } echo "Found!
"; if($_POST['action']=="save") { $err=false; if(!$_POST['fairyear']) { echo "Fair Year is required"; $err=true; } if(!$_POST['email']) { echo "Superuser email address is required"; $err=true; } if(!( $_POST['pass1'] && $_POST['pass2'])) { echo "Superuser password and password confirmation are required"; $err=true; } if($_POST['pass1'] != $_POST['pass2']) { echo "Password and Password confirmation do not match"; $err=true; } 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 ('SFIABDIRECTORY','".$_POST['sfiabdirectory']."','Special','','0')"); //copy over the config defautls $q=mysql_query("SELECT * FROM config WHERE year='-1'"); while($r=mysql_fetch_object($q)) { //add the actual fair name, and just insert the defaults of everything else if($r->var=="fairname") mysql_query("INSERT INTO config (var,val,description,category,ord,year) VALUES ('$r->var','".mysql_escape_string(stripslashes($_POST['fairname']))."','".mysql_escape_string($r->description)."','".mysql_escape_string($r->category)."','$r->ord','".$_POST['fairyear']."')"); //add the fair manager as well else if($r->var=="fairmanager") mysql_query("INSERT INTO config (var,val,description,category,ord,year) VALUES ('$r->var','".mysql_escape_string(stripslashes($_POST['email']))."','".mysql_escape_string($r->description)."','".mysql_escape_string($r->category)."','$r->ord','".$_POST['fairyear']."')"); else mysql_query("INSERT INTO config (var,val,description,category,ord,year) VALUES ('$r->var','$r->val','".mysql_escape_string($r->description)."','".mysql_escape_string($r->category)."','$r->ord','".$_POST['fairyear']."')"); } //copy over the dates defautls $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)) { 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..."; mysql_query("INSERT INTO committees_members (email,emailprivate,password,access_admin,access_config,access_super) VALUES ('".$_POST['email']."','".$_POST['email']."','".$_POST['pass1']."','Y','Y','Y')"); echo mysql_error(); echo "Done!
"; echo "Installation is now complete! You can now proceed to the following location:
"; echo "    Your SFIAB main page
"; echo ""; exit; } } echo "
"; echo "Please enter the following options
"; echo "
"; $month=date("m"); if($month>4) $fairyearsuggest=date("Y")+1; else $fairyearsuggest=date("Y"); $directorysuggest=substr($_SERVER['REQUEST_URI'],0,-13); echo "

Options

"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Fair NameThe name of the fair you are installing SFIAB to run
Fair YearThe year of the fair you are installing SFIAB to run
DirectoryThe directory of this SFIAB installation as seen by the web browser
"; echo "
"; echo "

Superuser Account

"; echo "Please choose your superuser account which is required to login to SFIAB and configure the system, as well as to add other users.
"; echo ""; echo ""; echo ""; echo ""; echo "
Superuser Email Address
Superuser Password
Superuser Password (Confirm)
"; echo "
"; echo ""; echo "
"; ?>