BUGFIX: missing ul-tag in poverty check messed up layout
[e-DoKo.git] / index.php
1 <?php
2 /* Copyright 2006, 2007, 2008, 2009, 2010 Arun Persaud <arun@nubati.net>
3  *
4  *   This file is part of e-DoKo.
5  *
6  *   e-DoKo is free software: you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation, either version 3 of the License, or
9  *   (at your option) any later version.
10  *
11  *   e-DoKo is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with e-DoKo.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 error_reporting(E_ALL);
22
23 /* start a session, if it is not already running.
24  * This way people don't have to log in all the times.
25  * The session variables can also be read out from different
26  * php scripts, so that the code can be easily split up across several files
27  */
28 session_start();
29
30 include_once("config.php");                /* needs to be first in list, since other includes use this */
31 include_once("./include/output.php");      /* html output only */
32 include_once("./include/db.php");          /* database only */
33 include_once("./include/functions.php");   /* the rest */
34
35 /* make sure that user has set all variables in config.php */
36 config_check();
37
38 /* open the database */
39 $DBopen = DB_open();
40 if($DBopen<0)
41   {
42     output_header();
43
44     if($DBopen == -1)
45       echo "Database error, can't connect... Please wait a while and try again. ".
46         "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL.";
47     else if ($DBopen == -2)
48       echo "Wrong database version, please update your database using the update.php script.";
49
50     output_footer();
51     exit();
52   }
53
54 /* done major error checking, output5B header of HTML page */
55 output_header();
56
57 /* The rest of the file consists of handling user input.
58  * The user sends information via html GET and POST variables,
59  * and the action variable tells the prog what the user wants to do
60  */
61 if(myisset("action"))
62   $action=$_REQUEST['action'];
63 else
64   $action=""; /* so that we can use a default option below */
65
66 switch($action)
67   {
68   case 'new':
69     require './include/newgame.php';
70     break;
71   case 'cancel':
72     require './include/cancelgame.php';
73     break;
74   case 'reminder':
75     require './include/reminder.php';
76     break;
77   case 'logout':
78     require './include/logout.php';
79     require './include/welcome.php';
80     break;
81   case 'login':
82     require './include/login.php';
83     require './include/user.php';
84     break;
85   case 'register':
86     require './include/register.php';
87     break;
88   case 'prefs':
89     require './include/preferences.php';
90     break;
91   case 'game':
92     require './include/game.php';
93     break;
94   case 'stats':
95     if(isset($_SESSION["name"]))
96       require './include/stats.php';
97     else
98       require './include/welcome.php';
99     break;
100   default:
101     if(isset($_SESSION["name"]))
102       require './include/user.php';
103     else
104       require './include/welcome.php';
105   }
106
107 /* ask for login or display login info, needs to go at the end, so that we have the
108  * session-variable already set.
109  */
110 output_status();
111
112 output_footer();
113
114 DB_close();
115
116 /*
117  *Local Variables:
118  *mode: php
119  *mode: hs-minor
120  *End:
121  */
122 ?>
123
124