forked from science-ation/science-ation
Dennis. Changes allow 'installation' in windows servers (and others) Complete functionality in windows servers still 'in work'
This commit is contained in:
parent
947a11ca1c
commit
d1b7fb2306
@ -35,13 +35,17 @@ error_reporting(E_ALL ^ E_NOTICE);
|
||||
define('REQUIREDFIELD','<span class="requiredfield">*</span>');
|
||||
|
||||
//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"))
|
||||
{
|
||||
|
@ -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.$ver.sql");
|
||||
// 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
|
||||
exec("mysql -q --help", $outputnotused, $exec_sqlstatus);
|
||||
if(function_exists("system") and $exec_sqlstatus == 0 ) {
|
||||
// echo "<b><br />** db_update USING system('mysql ..) on this server!<b><br />";
|
||||
system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME <db.update.$ver.sql", $exit_code);
|
||||
}
|
||||
else{
|
||||
// Dennis 'system and 'mysql' not available on this server. loop thru all sections of .sql files
|
||||
$exit_code = 0; // assume no errors for now
|
||||
$filename = 'db.update.'.$ver.'.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('<br/>Error performing query!<br/>'.$templine.'<br/> mysqlerror: '.mysql_error().'<br /><br />');
|
||||
$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 "<br />";
|
||||
}
|
||||
if($exit_code != 0) {
|
||||
/* mysql failed!, what now? */
|
||||
$error_count += 1;
|
||||
echo "<br /><b>ERROR in db_update: Failed to execute query(s) without error!<br />";
|
||||
echo "Update scripts bad or system('mysql' .. ) call failed!</b><br /><br />";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
29
install.php
29
install.php
@ -38,8 +38,35 @@ if(file_exists("data/config.inc.php"))
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
// Dennis 2011-02-21 Added all these checks prior to install
|
||||
if(!function_exists("system")) {
|
||||
echo "<br />Warning: Function 'system' is not available in this server! Installation may not work!<br /><br />";
|
||||
}
|
||||
if(!function_exists("exec")) {
|
||||
echo "Warning: Function 'exec' is not available in this server! Installation may not work!<br /><br />";
|
||||
}
|
||||
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<br />Install on this server may not have full funtionality!<br /><br />";
|
||||
}
|
||||
$status = 99;
|
||||
exec("php -v",$output,$status);
|
||||
if ($status == 0){
|
||||
//echo "Good: php is callable from exec and system!<br />";
|
||||
}
|
||||
else{
|
||||
echo "Warning: Functions 'system' and 'exec' are available but 'php.exe' is not setup for use in system() calls<br />Install on this server may not have full funtionality!<br /><br />";
|
||||
}
|
||||
}
|
||||
// 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!<br /><br />";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<?
|
||||
$showform=true;
|
||||
|
||||
|
108
install2.php
108
install2.php
@ -36,6 +36,9 @@ if(!function_exists("system")) {
|
||||
echo "</body></html>";
|
||||
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 "<b>Not found (good!)</b><br />";
|
||||
}
|
||||
|
||||
// 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 "<b>db/db.full.$dbcodeversion.sql found</b><br />";
|
||||
|
||||
echo "Setting up database tables... ";
|
||||
|
||||
system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME <db/db.full.$dbcodeversion.sql");
|
||||
|
||||
// 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 "<b><br />** USING system('mysql ..) on this server!<b><br />";
|
||||
system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME <db/db.full.$dbcodeversion.sql, $exit_code");
|
||||
}
|
||||
else // 'system' and 'mysql' not available. Try to break up the query and just do each part.
|
||||
{
|
||||
$exit_code = 0;
|
||||
$filename = 'db/db.full.'.$dbcodeversion.'.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('<br/>Error performing query!<br/>'.$templine.'<br/> mysqlerror: '.mysql_error().'<br /><br />');
|
||||
$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 "<br/><br />";
|
||||
}
|
||||
if($exit_code != 0) {
|
||||
/* mysql failed!, what now? */
|
||||
$error_count += 1;
|
||||
echo "<br /><b>mysql failed to execute query(s) without error!<b><br />";
|
||||
}
|
||||
echo "<b>Done! installed database version $dbcodeversion</b><br />\n";
|
||||
|
||||
//now update the db version in the database
|
||||
@ -104,6 +146,13 @@ mysql_select_db($DBNAME);
|
||||
|
||||
echo "<br />";
|
||||
echo "<b>Done!</b><br />";
|
||||
// Dennis allert if errors!
|
||||
if ($error_count > 0){
|
||||
echo "<b>THERE WERE ERRORS! The database was not created correctly!</b><br />";
|
||||
}
|
||||
else{
|
||||
echo "<b>DATABASE CREATED SUCCESSFULLY!</b><br />";
|
||||
}
|
||||
echo "<a href=\"install3.php\">Proceed to installation step 3</a><br />";
|
||||
}
|
||||
else
|
||||
@ -117,9 +166,47 @@ mysql_select_db($DBNAME);
|
||||
{
|
||||
echo "<b>db/db.full.$x.sql found</b><br />";
|
||||
echo "Setting up database tables... ";
|
||||
|
||||
system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME <db/db.full.$x.sql");
|
||||
|
||||
// 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 "<b><br />** USING system('mysql ..) on this server!<b><br />";
|
||||
system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME <db/db.full.$x.sql", $exit_code);
|
||||
}
|
||||
else // 'system' and 'mysql' not available. Try to break up the query and just do each part.
|
||||
{
|
||||
$exit_code = 0;
|
||||
$filename = 'db/db.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('<br/>Error performing query!<br/>'.$templine.'<br/> mysqlerror: '.mysql_error().'<br /><br />');
|
||||
$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 "<br/><br />";
|
||||
}
|
||||
if($exit_code != 0) {
|
||||
/* mysql failed!, what now? */
|
||||
$error_count += 1;
|
||||
echo "<br/><b>mysql failed to execute query(s) without error!<b><br/>";
|
||||
}
|
||||
echo "<b>Done! installed database version $x</b><br />\n";
|
||||
|
||||
//now update the db version in the database
|
||||
@ -136,6 +223,13 @@ mysql_select_db($DBNAME);
|
||||
|
||||
echo "<br />";
|
||||
echo "<b>Done!</b><br />";
|
||||
// Dennis allert if errors! 2011-02-18
|
||||
if ($error_count > 0){
|
||||
echo "<b>THERE WERE ERRORS! The database was not created correctly!</b><br />";
|
||||
}
|
||||
else{
|
||||
echo "<b>DATABASE CREATED SUCCESSFULLY!</b><br />";
|
||||
}
|
||||
echo "<a href=\"install3.php\">Proceed to installation step 3</a><br />";
|
||||
break;
|
||||
}
|
||||
|
@ -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 "<h3>Options</h3>";
|
||||
echo "<form method=\"post\" action=\"install3.php\">";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />";
|
||||
|
Loading…
Reference in New Issue
Block a user