CLEANUP: working on database now a config.php option
authorArun Persaud <arun@nubati.net>
Sat, 28 Jul 2007 17:04:38 +0000 (10:04 -0700)
committerArun Persaud <arun@nubati.net>
Sat, 28 Jul 2007 17:04:38 +0000 (10:04 -0700)
moved error checking into a function and made working on the database a config.php
option

INSTALL
functions.php
index.php

diff --git a/INSTALL b/INSTALL
index 8cdf132fbd68a92a650d03565c0bb255f1c0cebb..bed28d57d550e1d9699da6596c206ba39516bff3 100644 (file)
--- 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 ;)
index af34345f6303a053c4f5705776a60097860d3c6a..6fe813734755166a63c1ac3a33918d751d50d794 100644 (file)
@@ -1,5 +1,54 @@
 <?php
 
+function config_check()
+{
+  global $EmailName,$EMAIL_REPLY,$ADMIN_NAME,$ADMIN_EMAIL,$DB_work;
+
+  /* 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 "<h1>Setup not completed</h1>";
+      echo "You need to set \$ADMIN_NAME in config.php.";
+      output_footer(); 
+      exit(); 
+    }    
+  if(!isset($ADMIN_EMAIL))
+    {
+      output_header();
+      echo "<h1>Setup not completed</h1>";
+      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 "<h1>Setup not completed</h1>";
+      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;
index fef72fdd78fc02bc20b62c04093e30cc6bb4afaf..8c34a2be61aa6aec92f6f83017b071c37e699421 100644 (file)
--- 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 "<h1>Setup not completed</h1>";
-    echo "You need to set \$ADMIN_NAME in config.php.";
-    output_footer(); 
-    exit(); 
-  }    
-if(!isset($ADMIN_EMAIL))
-  {
-    output_header();
-    echo "<h1>Setup not completed</h1>";
-    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)
   {