dennis: Modifications to allow installation on Windows servers.

This commit is contained in:
dennis 2011-02-05 22:35:44 +00:00
parent 9730d79ab6
commit b791499b18
4 changed files with 2002 additions and 1908 deletions

View File

@ -35,6 +35,21 @@ 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
// dspanogle 2011-02-04 Windows based servers use '\' in directories. This code works for WIN servers and or *nix servers.
if (stristr(substr(getcwd(),-9), '\\')) {
// Win
if(substr(getcwd(),-6)=="\\admin")
$prependdir="..\\";
else if(substr(getcwd(),-7)=="\\config")
$prependdir="..\\";
else if(substr(getcwd(),-3)=="\\db")
$prependdir="..\\";
else if(substr(getcwd(),-8)=="\\scripts")
$prependdir="..\\";
else
$prependdir="";
} else {
// Other
if(substr(getcwd(),-6)=="/admin")
$prependdir="../";
else if(substr(getcwd(),-7)=="/config")
@ -45,6 +60,8 @@ else if(substr(getcwd(),-8)=="/scripts")
$prependdir="../";
else
$prependdir="";
}
$sfiabversion=@file($prependdir."version.txt");
$config['version']=trim($sfiabversion[0]);
@ -694,7 +711,7 @@ function send_popup_header($title="")
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/theme/<?=$config['theme']?>/sfiab.css" type="text/css" media="all" />
<link media=all href="<?=$config['SFIABDIRECTORY']?>/tableeditor.css" type=text/css rel=stylesheet>
</head>
<body onload="window.focus()">
<body onLoad="window.focus()">
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/sfiab.js"></script>

View File

@ -1,9 +1,11 @@
<?
// dspanogle 2011-02-04 This is not required since we have removed the system("mysql".. calls to allow Windows servers installs
/*
if(!function_exists("system")) {
echo "DB Update requires php's system() function to be available\n";
exit;
}
*/
//include the config.inc.php
//so we have the db connection info
require("../data/config.inc.php");
@ -84,7 +86,32 @@ 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");
// dspanogle 2011-02-04 Use each section of the sql file instead of using system("sql" ...
// For windows ISP servers that do not provide "sql: executable - replace system call.
// system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME <db.update.$ver.sql");
$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
mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
// Reset temp variable to empty
$templine = '';
}
}
echo "<br />";
}
else
{

View File

@ -30,13 +30,14 @@ echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
<body>
<h1>SFIAB Installation - Step 2</h1>
<?
// dspanogle 2011-02-04 This is not required since we have removed the system("mysql".. calls to allow Windows servers installs
/*
if(!function_exists("system")) {
echo "<div class=\"error\">Installation requires php's system() function to be available</div>\n";
echo "</body></html>";
exit;
}
*/
if(!file_exists("data/config.inc.php"))
{
echo "<div class=\"error\">SFIAB Installation Step 1 is not yet complete.</div>";
@ -94,9 +95,33 @@ mysql_select_db($DBNAME);
echo "<b>db/db.full.$dbcodeversion.sql found</b><br />";
echo "Setting up database tables... ";
// dspanogle 2011-02-04 Use each section of the sql file instead of using system("sql" ...
// For windows ISP servers that do not provide "sql: executable - replace system call.
// system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME <db/db.full.$dbcodeversion.sql");
$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;
system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME <db/db.full.$dbcodeversion.sql");
// 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
mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
// Reset temp variable to empty
$templine = '';
}
}
echo "<br />";
echo "<b>Done! installed database version $dbcodeversion</b><br />\n";
//now update the db version in the database
@ -117,8 +142,32 @@ 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");
// dspanogle 2011-02-04 Use each section of the sql file instead of using system("sql" ...
// For windows ISP servers that do not provide "sql: executable - replace system call.
// system("mysql --default-character-set=latin1 -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME <db/db.full.$x.sql");
$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
mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
// Reset temp variable to empty
$templine = '';
}
}
echo "<br />";
echo "<b>Done! installed database version $x</b><br />\n";

View File

@ -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);
// DES dspanogle 2011-02-05 $_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\" />";