2013-06-17 06:13:38 +00:00
|
|
|
<?php
|
2013-09-13 22:39:03 +00:00
|
|
|
/**
|
|
|
|
* Core that runs the entire system.
|
|
|
|
* The index.php page handles:
|
|
|
|
* -# checks what page to load
|
|
|
|
* -# if a $_POST['function'] is set try to execute that function in the matching php file located in the func folder.
|
|
|
|
* -# else load the inc's folder matching function related to the page
|
|
|
|
* -# set the permission and other smarty related settings
|
|
|
|
* -# call the helper function to load the page.
|
|
|
|
* @author Daan Janssens, mentored by Matthew Lagoe
|
|
|
|
*/
|
|
|
|
|
|
|
|
//load required pages and turn error reporting on/off
|
2013-08-05 02:37:20 +00:00
|
|
|
error_reporting(E_ALL);
|
|
|
|
ini_set('display_errors', 'on');
|
2013-06-17 06:13:38 +00:00
|
|
|
require( '../config.php' );
|
|
|
|
require( '../../ams_lib/libinclude.php' );
|
2013-06-25 19:33:49 +00:00
|
|
|
session_start();
|
2013-06-15 14:01:11 +00:00
|
|
|
|
2013-06-25 19:33:49 +00:00
|
|
|
//Decide what page to load
|
2013-07-29 23:46:56 +00:00
|
|
|
if ( ! isset( $_GET["page"]) ){
|
|
|
|
if(isset($_SESSION['user'])){
|
2013-09-09 01:47:32 +00:00
|
|
|
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
2013-08-29 03:01:47 +00:00
|
|
|
$page = 'dashboard';
|
|
|
|
}else{
|
|
|
|
$page = 'show_user';
|
|
|
|
}
|
2013-07-29 23:46:56 +00:00
|
|
|
}else{
|
|
|
|
//default page
|
|
|
|
$page = 'login';
|
|
|
|
}
|
2013-06-25 19:33:49 +00:00
|
|
|
}else{
|
2013-09-20 03:33:39 +00:00
|
|
|
if(isset($_SESSION['user'])){
|
|
|
|
$page = $_GET["page"];
|
|
|
|
}else{
|
2013-09-20 21:36:19 +00:00
|
|
|
switch($_GET["page"]){
|
|
|
|
case 'register':
|
|
|
|
$page = 'register';
|
|
|
|
break;
|
|
|
|
case 'forgot_password':
|
|
|
|
$page = 'forgot_password';
|
|
|
|
break;
|
|
|
|
case 'reset_password':
|
|
|
|
$page = 'reset_password';
|
|
|
|
break;
|
|
|
|
case 'error':
|
|
|
|
$page = 'error';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$page = 'login';
|
|
|
|
break;
|
|
|
|
}
|
2013-09-20 03:33:39 +00:00
|
|
|
}
|
2013-06-25 19:33:49 +00:00
|
|
|
}
|
|
|
|
|
2013-09-17 02:24:57 +00:00
|
|
|
//check if ingame & page= register
|
|
|
|
//this is needed because the ingame register can't send a hidden $_POST["function"]
|
2013-09-17 02:35:37 +00:00
|
|
|
if ( Helpers::check_if_game_client() && ($page == "register")){
|
2013-09-17 02:24:57 +00:00
|
|
|
require( "func/add_user.php" );
|
|
|
|
$return = add_user();
|
|
|
|
}
|
|
|
|
|
2013-06-29 03:23:38 +00:00
|
|
|
//perform an action in case one is specified
|
|
|
|
//else check if a php page is included in the inc folder, else just set page to the get param
|
|
|
|
if ( isset( $_POST["function"] ) ){
|
|
|
|
require( "func/" . $_POST["function"] . ".php" );
|
|
|
|
$return = $_POST["function"]();
|
2013-07-29 23:46:56 +00:00
|
|
|
}else{
|
|
|
|
$filename = 'inc/' . $page . '.php';
|
2013-06-29 03:23:38 +00:00
|
|
|
if(is_file($filename)){
|
|
|
|
require_once($filename);
|
2013-07-29 23:46:56 +00:00
|
|
|
$return = $page();
|
2013-06-25 19:33:49 +00:00
|
|
|
}
|
2013-06-29 03:23:38 +00:00
|
|
|
}
|
|
|
|
|
2013-06-29 17:05:54 +00:00
|
|
|
//add username to the return array in case logged in.
|
|
|
|
if(isset($_SESSION['user'])){
|
|
|
|
$return['username'] = $_SESSION['user'];
|
2013-06-25 19:33:49 +00:00
|
|
|
}
|
2013-06-29 17:05:54 +00:00
|
|
|
|
|
|
|
|
2013-06-15 14:01:11 +00:00
|
|
|
|
2013-06-26 14:35:33 +00:00
|
|
|
|
2013-06-25 19:33:49 +00:00
|
|
|
//Set permission
|
2013-07-18 19:12:03 +00:00
|
|
|
if(isset($_SESSION['ticket_user'])){
|
2013-09-09 01:47:32 +00:00
|
|
|
$return['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
|
2013-06-25 19:33:49 +00:00
|
|
|
}else{
|
|
|
|
//default permission
|
|
|
|
$return['permission'] = 0;
|
2013-06-17 14:29:20 +00:00
|
|
|
}
|
2013-06-18 05:22:24 +00:00
|
|
|
|
2013-06-25 19:33:49 +00:00
|
|
|
|
|
|
|
//hide sidebar + topbar in case of login/register
|
2013-09-20 21:36:19 +00:00
|
|
|
if($page == 'login' || $page == 'register' || $page == 'logout' || $page == 'forgot_password' || $page == 'reset_password'){
|
2013-06-25 19:33:49 +00:00
|
|
|
$return['no_visible_elements'] = 'TRUE';
|
2013-06-18 05:22:24 +00:00
|
|
|
}else{
|
2013-06-25 19:33:49 +00:00
|
|
|
$return['no_visible_elements'] = 'FALSE';
|
2013-06-18 05:22:24 +00:00
|
|
|
}
|
2013-07-03 16:49:23 +00:00
|
|
|
|
|
|
|
//handle error page
|
|
|
|
if($page == 'error'){
|
|
|
|
$return['permission'] = 0;
|
|
|
|
$return['no_visible_elements'] = 'FALSE';
|
|
|
|
}
|
2013-08-25 04:27:44 +00:00
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//load the template with the variables in the $return array
|
2013-06-17 06:13:38 +00:00
|
|
|
helpers :: loadTemplate( $page , $return );
|