LAYOUT: make footer smaller
[e-DoKo.git] / index.php
1 <?php
2 /* Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 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 /* localization */
55 /* needs to be in front of output_header, but we don't know the users preferences at this time,
56  * so we go by the session variable or if language is set
57  */
58 if(myisset('language') || isset($_SESSION['language']))
59   {
60     $language = 'en';
61
62     if(myisset('language'))
63       $language = $_REQUEST['language'];
64     else if(isset($_SESSION['language']))
65       $language = $_SESSION['language'];
66
67     switch($language)
68       {
69       case 'de':
70         putenv("LC_ALL=de_DE");
71         setlocale(LC_ALL, "de_DE");
72         // Specify location of translation tables
73         bindtextdomain("edoko", "./locale");
74         // Choose domain
75         textdomain("edoko");
76         break;
77       default:
78         /* do nothing */
79       }
80   }
81
82 /* done major error checking, output header of HTML page */
83 output_header();
84
85 /* The rest of the file consists of handling user input.
86  * The user sends information via html GET and POST variables,
87  * and the action variable tells the prog what the user wants to do
88  */
89 if(myisset("action"))
90   $action=$_REQUEST['action'];
91 else
92   $action=""; /* so that we can use a default option below */
93
94 switch($action)
95   {
96   case 'new':
97     require './include/newgame.php';
98     break;
99   case 'cancel':
100     require './include/cancelgame.php';
101     break;
102   case 'reminder':
103     require './include/reminder.php';
104     break;
105   case 'logout':
106     require './include/logout.php';
107     require './include/welcome.php';
108     break;
109   case 'login':
110     require './include/login.php';
111     require './include/user.php';
112     break;
113   case 'register':
114     require './include/register.php';
115     break;
116   case 'prefs':
117     require './include/preferences.php';
118     break;
119   case 'game':
120     require './include/game.php';
121     break;
122   case 'about':
123     require './include/about.php';
124     break;
125   case 'stats':
126     if(isset($_SESSION["name"]))
127       require './include/stats.php';
128     else
129       require './include/welcome.php';
130     break;
131   default:
132     if(isset($_SESSION["name"]))
133       require './include/user.php';
134     else
135       require './include/welcome.php';
136   }
137
138 /* ask for login or display login info, needs to go at the end, so that we have the
139  * session-variable already set.
140  */
141 output_navbar();
142
143 output_footer();
144
145 DB_close();
146
147 /*
148  *Local Variables:
149  *mode: php
150  *mode: hs-minor
151  *End:
152  */
153 ?>