BUGFIX: some variables where not defined after moving some code around
[e-DoKo.git] / index.php
1 <?php
2 error_reporting(E_ALL);
3
4 /* start a session, if it is not already running.
5  * This way people don't have to log in all the times. 
6  * The session variables can also be read out from different
7  * php scripts, so that the code can be easily split up across several files
8  */
9 session_start();
10
11
12 include_once("config.php");                /* needs to be first in list, since other includes use this */
13 include_once("./include/output.php");      /* html output only */
14 include_once("./include/db.php");          /* database only */
15 include_once("./include/functions.php");   /* the rest */
16
17
18 /* make sure that user has set all variables in config.php */
19 config_check();
20
21 /* open the database */
22 if(DB_open()<0)
23   {
24     output_header();
25     echo "Database error, can't connect... Please wait a while and try again. ".
26       "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL.";
27     output_footer();
28     exit();
29   }
30
31 /* done major error checking, output header of HTML page */
32 output_header();
33
34 /* The rest of the file consists of handling user input.
35  * The user sends information via html GET and POST variables,
36  * and the action variable tells the prog what the user wants to do
37  */
38 if(myisset("action"))
39   $action=$_REQUEST['action'];
40 else
41   $action=""; /* so that we can use a default option below */
42
43 switch($action)
44   {
45   case 'new':
46     require './include/newgame.php';
47     break;
48   case 'cancel':
49     require './include/cancelgame.php';
50     break;
51   case 'reminder':
52     require './include/reminder.php';
53     break;
54   case 'logout':
55     require './include/logout.php'; 
56     require './include/welcome.php';
57     break;
58   case 'login':
59     require './include/login.php'; 
60     require './include/user.php';
61     break;
62   case 'register':
63     require './include/register.php';
64     break;
65   case 'prefs':
66     require './include/preferences.php';
67     break;
68   case 'game':
69     require './include/game.php';
70     break;
71   case 'stats':
72     if(isset($_SESSION["name"]))
73       require './include/stats.php';
74     else
75       require './include/welcome.php';
76     break;
77   default:
78     if(isset($_SESSION["name"]))
79       require './include/user.php';
80     else
81       require './include/welcome.php';
82   }
83
84 output_footer();
85
86 DB_close();
87
88 /*
89  *Local Variables:
90  *mode: php
91  *mode: hs-minor
92  *End:
93  */
94 ?>
95
96