LAYOUT: fixed overflow of comment area (issue #28)
[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 include_once("config.php");                /* needs to be first in list, since other includes use this */
12 include_once("./include/output.php");      /* html output only */
13 include_once("./include/db.php");          /* database only */
14 include_once("./include/functions.php");   /* the rest */
15
16 /* make sure that user has set all variables in config.php */
17 config_check();
18
19 /* open the database */
20 if(DB_open()<0)
21   {
22     output_header();
23     echo "Database error, can't connect... Please wait a while and try again. ".
24       "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL.";
25     output_footer();
26     exit();
27   }
28
29 /* done major error checking, output5B 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  * and the action variable tells the prog what the user wants to do
35  */
36 if(myisset("action"))
37   $action=$_REQUEST['action'];
38 else
39   $action=""; /* so that we can use a default option below */
40
41 switch($action)
42   {
43   case 'new':
44     require './include/newgame.php';
45     break;
46   case 'cancel':
47     require './include/cancelgame.php';
48     break;
49   case 'reminder':
50     require './include/reminder.php';
51     break;
52   case 'logout':
53     require './include/logout.php'; 
54     require './include/welcome.php';
55     break;
56   case 'login':
57     require './include/login.php'; 
58     require './include/user.php';
59     break;
60   case 'register':
61     require './include/register.php';
62     break;
63   case 'prefs':
64     require './include/preferences.php';
65     break;
66   case 'game':
67     require './include/game.php';
68     break;
69   case 'stats':
70     if(isset($_SESSION["name"]))
71       require './include/stats.php';
72     else
73       require './include/welcome.php';
74     break;
75   default:
76     if(isset($_SESSION["name"]))
77       require './include/user.php';
78     else
79       require './include/welcome.php';
80   }
81
82 /* ask for login or display login info, needs to go at the end, so that we have the
83  * session-variable already set.
84  */
85 output_status();
86
87 output_footer();
88
89 DB_close();
90
91 /*
92  *Local Variables:
93  *mode: php
94  *mode: hs-minor
95  *End:
96  */
97 ?>
98
99