CLEANUP: moved register.php to the include directory
[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  * 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 'game':
64     require './include/game.php';
65     break;
66   default:
67     if(isset($_SESSION["name"]))
68       require './include/user.php';
69     else
70       require './include/welcome.php';
71   }
72
73 output_footer();
74
75 DB_close();
76
77 /*
78  *Local Variables:
79  *mode: php
80  *mode: hs-minor
81  *End:
82  */
83 ?>
84
85