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 2

Installation requires php's system() function to be available\n"; echo ""; exit; } // Dennis see if mysql is available from cli $exec_sqlstatus = 99; // will be set to 0 if following works. I test this prior to system("mysql...) calls exec("mysql -q --help", $outputnotused, $exec_sqlstatus); if(!file_exists("data/config.inc.php")) { echo "
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 "Getting database version requirements for code... "; if(file_exists("db/db.code.version.txt")) { $dbcodeversion_file=file("db/db.code.version.txt"); $dbcodeversion=trim($dbcodeversion_file[0]); } else { echo "ERROR: Couldnt load current db/db.code.version.txt
"; exit; } echo "version $dbcodeversion
"; echo "Checking for existing SFIAB database... "; $q=@mysql_query("SELECT val FROM config WHERE var='DBVERSION' AND conferences_id='0'"); $r=@mysql_fetch_object($q); $dbdbversion=$r->val; if($dbdbversion) { echo "ERROR: found version $dbdbversion
"; //lets see if they match if($dbcodeversion == $dbdbversion) echo "Your SFIAB database is already setup with the required version\n"; else if($dbcodeversion<$dbdbversion) echo "ERROR: dbcodeversion$dbdbversion) echo "Your SFIAB database needs to be updated. You should run the update script instead of this installer!\n"; exit; } else { echo "Not found (good!)
"; } echo "Checking for database installer for version $dbcodeversion... "; if(file_exists("db/db.full.$dbcodeversion.sql")) { echo "db/db.full.$dbcodeversion.sql found
"; echo "Setting up database tables... "; // Dennis If 'system' and 'mysql' do not exist use each section of the sql files not system("sql" ... // i.e. for windows ISP servers that do not provide system and sql.exe executable if(function_exists("system") and $exec_sqlstatus == 0 ) { echo "
** USING system('mysql ..) on this server!
"; system("mysql --default-character-set=utf8 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME Error performing query!
'.$templine.'
mysqlerror: '.mysql_error().'

'); $exit_code = -1; // do we bail out here or keep going? keep going for now, get all errors } // Reset temp variable to empty $templine = ''; } } echo "

"; } if($exit_code != 0) { /* mysql failed!, what now? */ $error_count += 1; echo "
mysql failed to execute query(s) without error!
"; } echo "Done! installed database version $dbcodeversion
\n"; //now update the db version in the database mysql_query("UPDATE config SET val='$dbcodeversion' WHERE var='DBVERSION' AND conferences_id='0'"); echo "
"; echo "Done!
"; // Dennis Allert if errors! 2011-02-18 if ($error_count > 0){ echo "THERE WERE ERRORS! The database was not created correctly!
"; } else{ echo "DATABASE CREATED SUCCESSFULLY!
"; } echo "Proceed to installation step 3
"; } 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")) { echo "db/db.full.$x.sql found
"; echo "Setting up database tables... "; // Dennis If 'system' and 'mysql' do not exist use each section of the sql files not system("sql" ... // i.e. for windows ISP servers that do not provide system and sql.exe executable if(function_exists("system") and $exec_sqlstatus == 0 ) { echo "
** USING system('mysql ..) on this server!
"; system("mysql --default-character-set=utf8 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME Error performing query!
'.$templine.'
mysqlerror: '.mysql_error().'

'); $exit_code = -1; // do we bail out here or keep going? keep going for now, get all errors } // Reset temp variable to empty $templine = ''; } } echo "

"; } if($exit_code != 0) { /* mysql failed!, what now? */ $error_count += 1; echo "
mysql failed to execute query(s) without error!
"; } echo "Done! installed database version $x
\n"; //now update the db version in the database mysql_query("UPDATE config SET val='$x' WHERE var='DBVERSION' AND conferences_id='0'"); echo "Attempting to update database using standard update script to update from $x to $dbcodeversion
"; echo "
Please scroll to the bottom of this page for the link to the next step of the installation process.
"; chdir ("db"); /* Update the database, but don't update the config variables yet, because * We haven't set the conference id */ $db_update_skip_variables = true; include "db_update.php"; chdir ("../"); echo "
"; echo "Done!
"; // Dennis Allert if errors! 2011-02-18 if ($error_count > 0){ echo "THERE WERE ERRORS! The database was not created correctly!
"; } else{ echo "DATABASE CREATED SUCCESSFULLY!
"; } echo "Proceed to installation step 3
"; break; } } } //only if this file was created will we go ahead with the rest //creating all the tables and such.. ?>