X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=index.php;h=f71643accab1699a62573e4b77ff67298729fc44;hp=54e2cb785c5e0297144d120b12e44a78dcdc0dad;hb=64586775883969c933517edc541b6f5a0878bd7d;hpb=09515348107d9aab7823a12d31b082a2ebb75555 diff --git a/index.php b/index.php index 54e2cb7..f71643a 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,32 @@ + * + * This file is part of e-DoKo. + * + * e-DoKo is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * e-DoKo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with e-DoKo. If not, see . + * + */ + error_reporting(E_ALL); +/* start a session, if it is not already running. + * This way people don't have to log in all the times. + * The session variables can also be read out from different + * php scripts, so that the code can be easily split up across several files + */ +session_start(); + include_once("config.php"); /* needs to be first in list, since other includes use this */ include_once("./include/output.php"); /* html output only */ include_once("./include/db.php"); /* database only */ @@ -10,72 +36,104 @@ include_once("./include/functions.php"); /* the rest */ config_check(); /* open the database */ -if(DB_open()<0) +$DBopen = DB_open(); +if($DBopen<0) { output_header(); - echo "Database error, can't connect... Please wait a while and try again. ". - "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL."; + + if($DBopen == -1) + echo "Database error, can't connect... Please wait a while and try again. ". + "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL."; + else if ($DBopen == -2) + echo 'Wrong database version, please update your database using the update.php script.'; + output_footer(); exit(); } -/* start a session, if it is not already running. - * This way people don't have to log in all the times. - * The session variables can also be read out from different - * php scripts, so that the code can be easily split up across several files +/**** localization ****/ +/* needs to be in front of output_header, but we don't know the users preferences at this time, + * so we go by the session variable or if language is set */ -session_start(); +/* set default */ +$language = detectlanguage(); + +/* check if default in array of supported languages, else default to english */ +$supported_languages = array ('en','de'); + +if ( !in_array($language, $supported_languages) ) + $language = 'en'; + +/* override with explicit request from user */ +if(myisset('language')) + $language = $_REQUEST['language']; +else if(isset($_SESSION['language'])) + $language = $_SESSION['language']; + +/* set it */ +set_language($language); +/**** end language ****/ /* done major error checking, output header of HTML page */ output_header(); /* The rest of the file consists of handling user input. * The user sends information via html GET and POST variables, - * the script checks if these are set via "myisset" - * which can check a list of variables. + * and the action variable tells the prog what the user wants to do */ +if(myisset("action")) + $action=$_REQUEST['action']; +else + $action=""; /* so that we can use a default option below */ -/* does the user want to log out? */ -if(myisset("logout")) - { - require './include/logout.php'; - } -/* check if we want to start a new game */ -else if(myisset("new")) +switch($action) { + case 'new': require './include/newgame.php'; - } -/*check if everything is ready to set up a new game */ -else if( myisset("PlayerA", "PlayerB","PlayerC","PlayerD","dullen","schweinchen","callrule" )) - { - require './include/newgameready.php'; - } -/* cancel a game, if nothing has happend in the last N minutes */ -else if(myisset("cancel","me")) - { + break; + case 'cancel': require './include/cancelgame.php'; - } -/* send out a reminder */ -else if(myisset("remind","me")) - { + break; + case 'reminder': require './include/reminder.php'; - } -/* handle request from one specific player for one game, - * (the hash is set on a per game base) */ -else if(myisset("me")) - { + break; + case 'logout': + require './include/logout.php'; + require './include/welcome.php'; + break; + case 'login': + require './include/login.php'; + require './include/user.php'; + break; + case 'register': + require './include/register.php'; + break; + case 'prefs': + require './include/preferences.php'; + break; + case 'game': require './include/game.php'; - } -/* user status page */ -else if( myisset("email","password") || isset($_SESSION["name"]) ) - { - require './include/user.php'; - } -/* default login page */ - else - { - require './include/welcome.php'; - } + break; + case 'about': + require './include/about.php'; + break; + case 'stats': + if(isset($_SESSION["name"])) + require './include/stats.php'; + else + require './include/welcome.php'; + break; + default: + if(isset($_SESSION["name"])) + require './include/user.php'; + else + require './include/welcome.php'; + } + +/* ask for login or display login info, needs to go at the end, so that we have the + * session-variable already set. + */ +output_navbar(); output_footer(); @@ -88,5 +146,3 @@ DB_close(); *End: */ ?> - -