From d1b7fb23067f6f55168c6a1d794d2a4dceba383e Mon Sep 17 00:00:00 2001 From: dennis Date: Thu, 24 Feb 2011 18:12:03 +0000 Subject: [PATCH] Dennis. Changes allow 'installation' in windows servers (and others) Complete functionality in windows servers still 'in work' --- common.inc.php | 13 +++--- db/db_update.php | 45 +++++++++++++++++++- install.php | 29 ++++++++++++- install2.php | 108 ++++++++++++++++++++++++++++++++++++++++++++--- install3.php | 5 ++- 5 files changed, 184 insertions(+), 16 deletions(-) diff --git a/common.inc.php b/common.inc.php index cb8150a..d637936 100644 --- a/common.inc.php +++ b/common.inc.php @@ -35,13 +35,17 @@ error_reporting(E_ALL ^ E_NOTICE); define('REQUIREDFIELD','*'); //figure out the directory to prepend to directoroy names, depending on if we are in a subdirectory or not -if(substr(getcwd(),-6)=="/admin") +// Dennis Fix so works in windows servers. +// Windows based servers use '\' in directories. This code works for WIN servers and or *nix servers. +if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-6)=="\\admin") $prependdir="../"; -else if(substr(getcwd(),-7)=="/config") +else if(substr(getcwd(),-6)=="/super" || substr(getcwd(),-6)=="\\super") $prependdir="../"; -else if(substr(getcwd(),-3)=="/db") +else if(substr(getcwd(),-7)=="/config" || substr(getcwd(),-7)=="\\config") $prependdir="../"; -else if(substr(getcwd(),-8)=="/scripts") +else if(substr(getcwd(),-3)=="/db" || substr(getcwd(),-3)=="\\db") + $prependdir="../"; +else if(substr(getcwd(),-8)=="/scripts" || substr(getcwd(),-8)=="\\scripts") $prependdir="../"; else $prependdir=""; @@ -49,7 +53,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")) { diff --git a/db/db_update.php b/db/db_update.php index 64b3f6e..b6154ca 100644 --- a/db/db_update.php +++ b/db/db_update.php @@ -84,7 +84,50 @@ if($dbcodeversion && $dbdbversion) echo "db.update.$ver.sql detected - running...\n"; readfile("db.update.$ver.sql"); echo "\n"; - system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME
** db_update USING system('mysql ..) on this server!
"; + system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME Error performing query!
'.$templine.'
mysqlerror: '.mysql_error().'

'); + $error_count += 1; + $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 "
ERROR in db_update: Failed to execute query(s) without error!
"; + echo "Update scripts bad or system('mysql' .. ) call failed!


"; + } } else { diff --git a/install.php b/install.php index e4f2221..1307c8c 100644 --- a/install.php +++ b/install.php @@ -38,8 +38,35 @@ if(file_exists("data/config.inc.php")) exit; } ?> +Warning: Function 'system' is not available in this server! Installation may not work!

"; +} +if(!function_exists("exec")) { + echo "Warning: Function 'exec' is not available in this server! Installation may not work!

"; +} +else { + $status = 99; + exec("mysql -q --help", $output, $status); + if(!$status == 0){ + echo "Warning: Functions 'system' and 'exec' are available but 'mysql.exe' is not setup for use in system() calls
Install on this server may not have full funtionality!

"; + } + $status = 99; + exec("php -v",$output,$status); + if ($status == 0){ + //echo "Good: php is callable from exec and system!
"; + } + else{ + echo "Warning: Functions 'system' and 'exec' are available but 'php.exe' is not setup for use in system() calls
Install on this server may not have full funtionality!

"; + } +} +// This check can be eliminated after all pdf reports are converted to tcpdf +if (!function_exists("pdf_new")){ +echo "Warning: pdflib is not installed on this server! Most pdf reports will fail!

"; +} - +?> "; 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")) { @@ -87,16 +90,55 @@ mysql_select_db($DBNAME); { echo "Not found (good!)
"; } - + // Dennis count the errors here and in db_update + $error_count = 0; 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... "; - - system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME
** USING system('mysql ..) on this server!
"; + system("mysql --default-character-set=latin1 -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 @@ -104,6 +146,13 @@ mysql_select_db($DBNAME); 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 installation step 3
"; } else @@ -117,9 +166,47 @@ mysql_select_db($DBNAME); { echo "db/db.full.$x.sql found
"; echo "Setting up database tables... "; - - system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME
** USING system('mysql ..) on this server!
"; + system("mysql --default-character-set=latin1 -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 @@ -136,6 +223,13 @@ mysql_select_db($DBNAME); 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; } diff --git a/install3.php b/install3.php index d86b8c5..e322f56 100644 --- a/install3.php +++ b/install3.php @@ -181,8 +181,9 @@ else $fairyearsuggest=date("Y"); if($month>6) $fiscalyearsuggest=date("Y")+1; else $fiscalyearsuggest=date("Y"); - -$directorysuggest=substr($_SERVER['REQUEST_URI'],0,-13); +// Dennis $_SERVER['REQUEST_URI'] is not available on many Windows servers +//$directorysuggest = substr($_SERVER['REQUEST_URI'],0,-13); +$directorysuggest = substr(getenv("SCRIPT_NAME"),0,-13); echo "

Options

"; echo "
"; echo "";