diff --git a/common.inc.php b/common.inc.php index e9b2d88..c64775b 100644 --- a/common.inc.php +++ b/common.inc.php @@ -24,6 +24,24 @@ SFIAB ERROR"; + echo "

Science Fair In A Box - ERROR

"; + echo "data/ subdirectory is not writable by the web server"; + echo "
"; + echo "

Details

"; + echo "The data/ subdirectory is used to store files uploaded through the SFIAB software. The web server must have write access to this directory in order to function properly. Please contact your system administrator (if you are the system administrator, chown/chmod the data directory appropriately)."; + echo "
"; + echo ""; + exit; +} + + + + //first things first - make sure our DB version matches our CODE version $dbcodeversion=@file("db/db.code.version.txt"); $dbdbversion=@file("db/db.db.version.txt"); @@ -47,11 +65,42 @@ if($dbcodeversion[0]!=$dbdbversion[0]) echo ""; exit; } +if(file_exists("data/config.inc.php")) +{ + require_once("data/config.inc.php"); +} +else +{ + echo "SFIAB"; + echo "

Science Fair In A Box - Installation

"; + echo "It looks like this is a new installation of SFIAB, and the database has not yet been configured. Please choose from the following options:
"; + echo "
"; + echo "Proceed with Fresh SFIAB Installation"; + echo "
"; + echo ""; + exit; +} -require_once("config.inc.php"); require_once("committee_auth.php"); -mysql_connect($DBHOST,$DBUSER,$DBPASS); -mysql_select_db($DBNAME); + +if(!mysql_connect($DBHOST,$DBUSER,$DBPASS)) +{ + echo "SFIAB ERROR"; + echo "

Science Fair In A Box - ERROR

"; + echo "Cannot connect to database!"; + echo ""; + exit; +} + +if(!mysql_select_db($DBNAME)) +{ + echo "SFIAB ERROR"; + echo "

Science Fair In A Box - ERROR

"; + echo "Cannot select database!"; + echo ""; + exit; +} + session_start(); diff --git a/db/db_update.php b/db/db_update.php index 122c38b..99aca90 100644 --- a/db/db_update.php +++ b/db/db_update.php @@ -32,6 +32,7 @@ if($dbcodeversion && $dbdbversion) else if($dbcodeversion<$dbdbversion) { echo "ERROR: dbcodeversion$dbdbversion) @@ -39,29 +40,39 @@ if($dbcodeversion && $dbdbversion) echo "DB update requirements detected\n"; echo "Current DB Version: $dbdbversion\n"; echo "Current CODE Version: $dbcodeversion\n"; - echo "Updating database from $dbdbversion to $dbcodeversion\n"; - //include the config.inc.php - //so we have the db connection info - require("../config.inc.php"); - - for($ver=$dbdbversion+1;$ver<=$dbcodeversion;$ver++) + //first, make sure we have write access to the db.db.version.txt + //otherwise, we will not be able to save the new version number + //which would screw things up. + if(is_writable("db.db.version.txt")) { - if(file_exists("db.update.$ver.sql")) + echo "Updating database from $dbdbversion to $dbcodeversion\n"; + //include the config.inc.php + //so we have the db connection info + require("../data/config.inc.php"); + + for($ver=$dbdbversion+1;$ver<=$dbcodeversion;$ver++) { - echo "db.update.$ver.sql detected - running...\n"; - readfile("db.update.$ver.sql"); - echo "\n"; - system("mysql -h$DBHOST -u$DBUSER -p$DBPASS $DBNAME + 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 is already installed"; + echo ""; + exit; +} +?> + +

SFIAB Installation

+ +Database connection successful!"; + echo "
"; + echo "Storing database connection information... "; + if($fp=fopen("data/config.inc.php","w")) + { + fputs($fp,"\n"); + fclose($fp); + echo "Done!"; + } + else + { + echo "
Cannot write to data/config.inc.php. Make sure the web server has write access to the data/ subdirectory
"; + + } + + } + else + { + echo "
Connected, but cannot select database. Make sure Database Name is correct, and that the user '".$_POST['dbuser']."' has access to it
"; + } + + + } + else + { + echo "
Cannot connect to database. Make sure Host, User and Pass are correct
"; + } + echo "
"; +} + + +if($showform) +{ +?> +SFIAB requires a MySQL database to store all of its information. Please enter your MySQL database connection info for your database to continue. The database must already exist and the user/password you specify must have access to the database. + +
+
+
+ + + + + + +
Database Host
Database User
Database Pass
Database Name
+
+ + + + +