Copyright (C) 2005 James Grant New functionality: Copyright (C) 2011 At Work Software Copyright (C) 2011 Dennis Spanogle 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 plug-in Installation (Evaluations)

SFIAB Evaluations Plug-in - Installation

"; if(file_exists("db/eval.code.version.txt")) { $evaldbcodeversion_file=file("db/eval.code.version.txt"); $evaldbcodeversion=trim($evaldbcodeversion_file[0]); } else { echo "ERROR: Couldnt load plugins/evaluations/db/eval.code.version.txt
"; exit; } echo "'Evaluations version $evaldbcodeversion
"; echo "Checking for existing 'Evaluations' database... "; $q=@mysql_query("SELECT db_version FROM eval_config"); $r=@mysql_fetch_object($q); $evaldbdbversion=$r->db_version; if($evaldbdbversion) { echo "Found version $evaldbdbversion
"; //lets see if they match if($evaldbcodeversion == $evaldbdbversion) echo "Your 'Evaluations' plug-in database is already setup with the required version\n"; else if($evaldbcodeversion<$evaldbdbversion) echo "ERROR: evaldbcodeversion$evaldbdbversion) echo "Your 'Evaluations' plug-in database needs to be updated. You should run the update script instead of this installer!\n"; exit; } else { echo "Installing 'Evaluations' plug-in database!
"; } $error_count = 0; echo "Checking for database installer for 'Evaluations' version $evaldbcodeversion... "; if(file_exists("db/db.eval.full.$evaldbcodeversion.sql")) { echo "db/db.eval.full.$evaldbcodeversion.sql found
"; echo "Setting up database tables... "; $exit_code = 0; $filename = 'db/db.eval.full.'.$evaldbcodeversion.'.sql'; // Temporary variable, used to store current query $templine = ''; // Read in entire file $lines = file($filename); // Loop through each line foreach ($lines as $line) { // Skip it if it's a comment if (substr($line, 0, 2) == '--' || $line == '') continue; // Add this line to the current segment $templine .= $line; // If it has a semicolon at the end, it's the end of the query if (substr(trim($line), -1, 1) == ';') { // Perform the query if(!mysql_query($templine)){ echo('
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 valuations' database version $dbcodeversion
\n"; echo "
"; echo "Done!
"; // Dennis allert if errors! if ($error_count > 0){ echo "THERE WERE ERRORS! The database was not created correctly!
"; } else{ echo "DATABASE CREATED SUCCESSFULLY!
"; } echo "Proceed to Evaluations setup
"; } else { echo "
Notice: Could not find db/db.eval.full.$evaldbcodeversion.sql
"; echo "Trying to find an older version...
"; for($x=$evaldbcodeversion;$x>0;$x--) { if(file_exists("db/db.eval.full.$x.sql")) { echo "Found db/db.eval.full.$x.sql!
"; echo "Setting up 'Evaluations' database tables... "; $exit_code = 0; $filename = 'db/db.eval.full.'.$x.'.sql'; // Temporary variable, used to store current query $templine = ''; // Read in entire file $lines = file($filename); // Loop through each line foreach ($lines as $line) { // Skip it if it's a comment if (substr($line, 0, 2) == '--' || $line == '') continue; // Add this line to the current segment $templine .= $line; // If it has a semicolon at the end, it's the end of the query if (substr(trim($line), -1, 1) == ';') { // Perform the query if(!mysql_query($templine)){ echo('
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 "Installed 'Evaluations' database version $x
\n"; echo "Attempting to update 'Evaluations' from $x to $evaldbcodeversion
"; echo "
Please scroll to the bottom of this page for the link to the next step of the installation process.
"; chdir ("db"); include "db_eval_update.php"; chdir ("../"); echo "
"; echo "Done!
"; // Dennis allert if errors! 2011-02-18 if ($error_count > 0){ echo "THERE WERE ERRORS! The 'Evaluations' database was not created correctly!
"; } else{ echo "DATABASE CREATED SUCCESSFULLY!
"; } echo "Proceed to Evaluations setup
"; break; } } } ?>