moved error checking into a function and made working on the database a config.php
option
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 ;)
<?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;
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)
{