From b29ab3c07ebe1667e852457f22f6f51193970c1b Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 28 Jul 2007 10:04:38 -0700 Subject: [PATCH] CLEANUP: working on database now a config.php option moved error checking into a function and made working on the database a config.php option --- INSTALL | 46 +++++++++++++++++++++++++++------------------- functions.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 36 +----------------------------------- 3 files changed, 77 insertions(+), 54 deletions(-) diff --git a/INSTALL b/INSTALL index 8cdf132..bed28d5 100644 --- a/INSTALL +++ b/INSTALL @@ -3,40 +3,48 @@ Installation 0) get files -get all files from + get all files from -http://svn.nubati.net/emaildoko/trunk + http://nubati.net/git/e-DoKo 1) create database -create a mysql database using the provided file + create a mysql database using the provided file -mysql < create_database.sql + mysql < create_database.sql -use user, password, database and host option of mysql as needed + use user, password, database and host option of mysql as needed 2) create a config.php file that defines the following variables: -$host : for example "http://localhost/index.php", note: include the index.php here + $host: for example "http://localhost/index.php", note: include the index.php here -database info: + database info: -$DB_host -$DB_user -$DB_password -$DB_database + $DB_host + $DB_user + $DB_password + $DB_database -you can also turn the debug mode on by defining: -$debug=1; + working on the database: + in case you need to work on the database for some reason, you can suspend the game + by setting $DB_work to 1 -this will give some extra output and won't send out emails, but display them in the browser + debug mode: + you can also turn the debug mode on by defining: + $debug=1; -If you hvae problem with the timezone, that is an older PHP version, try adding this in config.php + this will give some extra output and won't send out emails, but + display them in the browser -function date_default_timezone_set($zone) -{ - return; -} + timezone problem: + If you hvae problem with the timezone, that is an older PHP version, + try adding this in config.php + + function date_default_timezone_set($zone) + { + return; + } 3) log in and enjoy ;) diff --git a/functions.php b/functions.php index af34345..6fe8137 100644 --- a/functions.php +++ b/functions.php @@ -1,5 +1,54 @@ Setup not completed"; + echo "You need to set \$ADMIN_NAME in config.php."; + output_footer(); + exit(); + } + if(!isset($ADMIN_EMAIL)) + { + output_header(); + echo "

Setup not completed

"; + echo "You need to set \$ADMIN_EMAIL in config.php. ". + "If something goes wrong an email will be send to this address."; + output_footer(); + exit(); + } + if(!isset($DB_work)) + { + output_header(); + echo "

Setup not completed

"; + echo "You need to set \$DB_work in config.php. ". + "If this is set to 1, the game will be suspended and one can work safely on the database.". + "The default should be 0 for the game to work."; + output_footer(); + exit(); + } + if($DB_work) + { + output_header(); + echo "Working on the database...please check back later."; + output_footer(); + exit(); + } + + return; +} + function mymail($To,$Subject,$message,$header="") { global $debug; diff --git a/index.php b/index.php index fef72fd..8c34a2b 100644 --- a/index.php +++ b/index.php @@ -6,41 +6,7 @@ include_once("output.php"); /* html output only */ include_once("db.php"); /* database only */ include_once("functions.php"); /* the rest */ -/* check if some variables are set in the config file, else set defaults */ -if(!isset($EmailName)) - $EmailName="[DoKo] "; -if(isset($EMAIL_REPLY)) - { - ini_set("sendmail_from",$EMAIL_REPLY); - } -if(!isset($ADMIN_NAME)) - { - output_header(); - echo "

Setup not completed

"; - echo "You need to set \$ADMIN_NAME in config.php."; - output_footer(); - exit(); - } -if(!isset($ADMIN_EMAIL)) - { - output_header(); - echo "

Setup not completed

"; - echo "You need to set \$ADMIN_EMAIL in config.php. ". - "If something goes wrong an email will send to this address."; - output_footer(); - exit(); - } - -/* in case work has to be done on the database or other section we can - * shut down the server and tell people to come back later - */ -if(0) - { - output_header(); - echo "Working on the database...please check back in a few mintues"; - output_footer(); - exit(); - } +config_check(); if(DB_open()<0) { -- 2.17.1