54e2cb785c5e0297144d120b12e44a78dcdc0dad
[e-DoKo.git] / index.php
1 <?php
2 error_reporting(E_ALL);
3
4 include_once("config.php");                /* needs to be first in list, since other includes use this */
5 include_once("./include/output.php");      /* html output only */
6 include_once("./include/db.php");          /* database only */
7 include_once("./include/functions.php");   /* the rest */
8
9 /* make sure that user has set all variables in config.php */
10 config_check();
11
12 /* open the database */
13 if(DB_open()<0)
14   {
15     output_header();
16     echo "Database error, can't connect... Please wait a while and try again. ".
17       "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL.";
18     output_footer();
19     exit();
20   }
21
22 /* start a session, if it is not already running.
23  * This way people don't have to log in all the times. 
24  * The session variables can also be read out from different
25  * php scripts, so that the code can be easily split up across several files
26  */
27 session_start();
28
29 /* done major error checking, output header of HTML page */
30 output_header();
31
32 /* The rest of the file consists of handling user input.
33  * The user sends information via html GET and POST variables,
34  * the script checks if these are set via "myisset"
35  * which can check a list of variables.
36  */
37
38 /* does the user want to log out? */
39 if(myisset("logout"))
40   {
41     require './include/logout.php';
42   }
43 /* check if we want to start a new game */
44 else if(myisset("new"))
45   {
46     require './include/newgame.php';
47   }
48 /*check if everything is ready to set up a new game */
49 else if( myisset("PlayerA", "PlayerB","PlayerC","PlayerD","dullen","schweinchen","callrule" ))
50   {
51     require './include/newgameready.php';
52   }    
53 /* cancel a game, if nothing has happend in the last N minutes */
54 else if(myisset("cancel","me"))
55   {
56     require './include/cancelgame.php';
57   }
58 /* send out a reminder */
59 else if(myisset("remind","me"))
60   {
61     require './include/reminder.php';
62   }
63 /* handle request from one specific player for one game,
64  * (the hash is set on a per game base) */
65 else if(myisset("me"))
66   {
67     require './include/game.php';
68  }
69 /* user status page */
70 else if( myisset("email","password") || isset($_SESSION["name"]) )
71    {
72      require './include/user.php';
73    }
74 /* default login page */
75  else
76    {
77      require './include/welcome.php';
78    }
79
80 output_footer();
81
82 DB_close();
83
84 /*
85  *Local Variables:
86  *mode: php
87  *mode: hs-minor
88  *End:
89  */
90 ?>
91
92