From 41e0baca8444ae6c8c0fe367d429549e94ee1caf Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 3 Sep 2014 07:23:39 +0200 Subject: [PATCH] Throw exception instead of exit. --- .../API_key_management/API_key_management.php | 76 +++++++++---------- .../public_php/ams/func/activate_plugin.php | 6 +- code/web/public_php/ams/func/add_sgroup.php | 4 +- code/web/public_php/ams/func/add_user.php | 10 +-- .../ams/func/add_user_to_sgroup.php | 6 +- code/web/public_php/ams/func/change_info.php | 10 +-- code/web/public_php/ams/func/change_mail.php | 12 +-- .../public_php/ams/func/change_password.php | 12 +-- .../ams/func/change_receivemail.php | 10 +-- .../web/public_php/ams/func/create_ticket.php | 12 +-- .../public_php/ams/func/deactivate_plugin.php | 6 +- .../web/public_php/ams/func/delete_plugin.php | 6 +- .../public_php/ams/func/forgot_password.php | 4 +- .../public_php/ams/func/install_plugin.php | 24 +++--- code/web/public_php/ams/func/login.php | 6 +- .../ams/func/modify_email_of_sgroup.php | 6 +- .../public_php/ams/func/reply_on_ticket.php | 8 +- .../public_php/ams/func/reset_password.php | 4 +- .../web/public_php/ams/func/update_plugin.php | 2 +- .../public_php/ams/inc/change_permission.php | 8 +- code/web/public_php/ams/inc/createticket.php | 4 +- code/web/public_php/ams/inc/dashboard.php | 4 +- code/web/public_php/ams/inc/login.php | 2 +- code/web/public_php/ams/inc/plugins.php | 2 +- .../web/public_php/ams/inc/plugins_update.php | 2 +- .../web/public_php/ams/inc/reset_password.php | 2 +- code/web/public_php/ams/inc/settings.php | 4 +- code/web/public_php/ams/inc/sgroup_list.php | 6 +- code/web/public_php/ams/inc/show_queue.php | 6 +- code/web/public_php/ams/inc/show_reply.php | 4 +- code/web/public_php/ams/inc/show_sgroup.php | 8 +- code/web/public_php/ams/inc/show_ticket.php | 4 +- .../public_php/ams/inc/show_ticket_info.php | 4 +- .../public_php/ams/inc/show_ticket_log.php | 4 +- code/web/public_php/ams/inc/show_user.php | 4 +- code/web/public_php/ams/inc/syncing.php | 2 +- code/web/public_php/ams/inc/userlist.php | 2 +- code/web/public_php/ams/index.php | 9 ++- 38 files changed, 156 insertions(+), 149 deletions(-) diff --git a/code/web/private_php/ams/plugins/API_key_management/API_key_management.php b/code/web/private_php/ams/plugins/API_key_management/API_key_management.php index 27613e18b..cbe7fca6a 100644 --- a/code/web/private_php/ams/plugins/API_key_management/API_key_management.php +++ b/code/web/private_php/ams/plugins/API_key_management/API_key_management.php @@ -3,12 +3,12 @@ /** * Global and Local Hooks for the API key Management plugin * Global Hooks are defined with the prefix(name of the plugin) - * Local Hooks are defined with normal function name - * + * Local Hooks are defined with normal function name + * * All the Global Hooks are called during the page load * and Local Hooks are called according to conditions - * - * @author shubham meena mentored by Matthew Lagoe + * + * @author shubham meena mentored by Matthew Lagoe */ // Global variable to store the data which is @@ -27,7 +27,7 @@ function api_key_management_hook_display() global $return_set; // to display plugin name in menu bar $return_set['menu_display'] = 'API Key Management'; - } + } /** * Local Hook to validate the posted data @@ -37,12 +37,12 @@ function hook_validate( $var ) if ( isset( $var ) && !empty( $var ) ) { return true; - } + } else { return false; - } - } + } + } /** * Local Hook to set the POST variables and validate them @@ -51,7 +51,7 @@ function hook_variables() { global $var_set; global $return_set; - + if ( hook_validate( $_POST['expDate'] ) && hook_validate( $_POST['sp_name'] ) && hook_validate( $_POST['api_type'] ) && hook_validate( $_POST['character_name'] ) ) { @@ -63,12 +63,12 @@ function hook_variables() $var_set['AddedOn'] = date( "Y-m-d H:i:s" ); $var_set['Items'] = ''; $return_set['gen_key_validate'] = 'true'; - } + } else { $return_set['gen_key_validate'] = 'false'; - } - } + } + } /** * Global Hook to create table of the API_key_management @@ -108,12 +108,12 @@ function api_key_management_hook_create_tb() -- ALTER TABLE `ams_api_keys` ADD CONSTRAINT `ams_api_keys_ibfk_1` FOREIGN KEY (`User`) REFERENCES `ryzom_ams`.`ams_user` (`Login`);"; - + $dbl -> executeWithoutParams( $sql ); - } + } /** - * Hook to store data to database which is sent as post + * Hook to store data to database which is sent as post * method from the forms in this plugin * It also calls the local hook */ @@ -121,63 +121,63 @@ function api_key_management_hook_store_db() { global $var_set; global $return_set; - + // if the form been submited move forward if ( @hook_validate( $_POST['gen_key'] ) ) { - + // local hook to validate the POST variables hook_variables(); - + // if validation successfull move forward if ( $return_set['gen_key_validate'] == 'true' && $_GET['plugin_action'] == 'generate_key' ) { // this part generated the access token include 'generate_key.php'; $var_set['AccessToken'] = generate_key :: randomToken( 56, false, true, false ); - + // database connection $db = new DBLayer( 'lib' ); // insert the form data to the database $db -> insert( 'ams_api_keys', $var_set ); - + // redirect to the the main page with success code // 1 refers to the successfull addition of key to the database header( "Location: index.php?page=layout_plugin&&name=API_key_management&&success=1" ); - exit; - } - } - } + throw new SystemExit(); + } + } + } /** - * Global Hook to load the data from db and set it + * Global Hook to load the data from db and set it * into the global array to return it to the template */ function api_key_management_hook_load_db() { global $var_set; global $return_set; - + $db = new DBLayer( 'lib' ); - + if ( isset( $_SESSION['user'] ) ) { // returns the registered keys $sth = $db -> select( 'ams_api_keys', array( 'user' => $_SESSION['user'] ), 'User = :user' ); $row = $sth -> fetchAll(); $return_set['api_keys'] = $row; - + // fetch the character from the array to compare $com = array_column( $return_set['api_keys'], 'UserCharacter' ); - + // returns the characters with respect to the user id in the ring_tool->characters $db = new DBLayer( 'ring' ); $sth = $db -> selectWithParameter( 'char_name', 'characters' , array(), '1' ); $row = $sth -> fetch(); - + // loop through the character list and remove the character if already have an api key $return_set['characters'] = array_diff( $row, $com ); - } - } + } + } /** * Global Hook to update or delete the data from db @@ -186,24 +186,24 @@ function api_key_management_hook_update_db() { global $var_set; global $return_set; - + $db = new DBLayer( 'lib' ); if ( isset( $_GET['delete_id'] ) ) { // removes the registered key using get variable which contains the id of the registered key $db -> delete( 'ams_api_keys', array( 'SNo' => $_GET['delete_id'] ), 'SNo = :SNo' ); - + // redirecting to the API_key_management plugins template with success code // 2 refers to the succssfull delete condition header( "Location: index.php?page=layout_plugin&&name=API_key_management&&success=2" ); - exit; - } - } + throw new SystemExit(); + } + } /** * Global Hook to return global variables which contains * the content to use in the smarty templates - * + * * @return $return_set global array returns the template data */ function api_key_management_hook_return_global() diff --git a/code/web/public_php/ams/func/activate_plugin.php b/code/web/public_php/ams/func/activate_plugin.php index 6b12c8492..5d1d2b8fb 100644 --- a/code/web/public_php/ams/func/activate_plugin.php +++ b/code/web/public_php/ams/func/activate_plugin.php @@ -22,20 +22,20 @@ function activate_plugin() { { // if result is successfull it redirects and shows success message header( "Location: index.php?page=plugins&result=3" ); - die(); + throw new SystemExit(); } else { //if result is unsuccessfull it redirects and throws error header( "Location: index.php?page=plugins&result=4" ); - die(); + throw new SystemExit(); } } else { //if $_GET variable is not set it redirects and shows error header( "Location: index.php?page=plugins&result=4" ); - die(); + throw new SystemExit(); } } } diff --git a/code/web/public_php/ams/func/add_sgroup.php b/code/web/public_php/ams/func/add_sgroup.php index 610f2a2ad..c1823e2b0 100644 --- a/code/web/public_php/ams/func/add_sgroup.php +++ b/code/web/public_php/ams/func/add_sgroup.php @@ -41,12 +41,12 @@ function add_sgroup(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/add_user.php b/code/web/public_php/ams/func/add_user.php index 3418611ba..612b8bc88 100644 --- a/code/web/public_php/ams/func/add_user.php +++ b/code/web/public_php/ams/func/add_user.php @@ -30,13 +30,13 @@ function add_user(){ if(Helpers::check_if_game_client()){ //if registering ingame then we have to set the header and dont need to reload the template. header('Location: email_sent.php'); - die(); + throw new SystemExit(); } $pageElements['status'] = $status; $pageElements['no_visible_elements'] = 'TRUE'; $pageElements['ingame_webpath'] = $INGAME_WEBPATH; helpers :: loadtemplate( 'register_feedback', $pageElements); - die(); + throw new SystemExit(); }elseif (isset($_POST['page']) && $_POST['page']=="settings"){ // pass error and reload template accordingly $result['prevUsername'] = $_POST["Username"]; @@ -45,7 +45,7 @@ function add_user(){ $result['prevEmail'] = $_POST["Email"]; $result['no_visible_elements'] = 'TRUE'; helpers :: loadtemplate( 'settings', $result); - die(); + throw new SystemExit(); }else{ // pass error and reload template accordingly $result['prevUsername'] = $_POST["Username"]; @@ -55,7 +55,7 @@ function add_user(){ $result['no_visible_elements'] = 'TRUE'; $pageElements['ingame_webpath'] = $INGAME_WEBPATH; helpers :: loadtemplate( 'register', $result); - die(); + throw new SystemExit(); } } @@ -83,7 +83,7 @@ function write_user($newUser){ }catch (PDOException $e) { //go to error page or something, because can't access website db print_r($e); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/add_user_to_sgroup.php b/code/web/public_php/ams/func/add_user_to_sgroup.php index 1f6f7c90a..d797edf25 100644 --- a/code/web/public_php/ams/func/add_user_to_sgroup.php +++ b/code/web/public_php/ams/func/add_user_to_sgroup.php @@ -40,18 +40,18 @@ function add_user_to_sgroup(){ }else{ header("Location: ".$WEBPATH."?page=show_sgroup&id=".$id); } - die(); + throw new SystemExit(); }else{ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/change_info.php b/code/web/public_php/ams/func/change_info.php index 0fccbc315..f9534e93d 100644 --- a/code/web/public_php/ams/func/change_info.php +++ b/code/web/public_php/ams/func/change_info.php @@ -97,29 +97,29 @@ function change_info(){ global $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH; helpers :: loadtemplate( 'settings', $result); - die(); + throw new SystemExit(); }else{ //ERROR: permission denied! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: The form was not filled in correclty header("Location: index.php?page=settings"); - die(); + throw new SystemExit(); } }else{ //ERROR: user is not logged in header("Location: index.php"); - die(); + throw new SystemExit(); } }catch (PDOException $e) { //go to error page or something, because can't access website db print_r($e); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/change_mail.php b/code/web/public_php/ams/func/change_mail.php index 7c7cec1ad..14f0c5f4c 100644 --- a/code/web/public_php/ams/func/change_mail.php +++ b/code/web/public_php/ams/func/change_mail.php @@ -58,7 +58,7 @@ function change_mail(){ } } helpers :: loadtemplate( 'settings', $result); - die(); + throw new SystemExit(); }else{ $result['EMAIL'] = $reply; @@ -72,31 +72,31 @@ function change_mail(){ } } helpers :: loadtemplate( 'settings', $result); - die(); + throw new SystemExit(); } }else{ //ERROR: permission denied! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: The form was not filled in correclty header("Location: index.php?page=settings"); - die(); + throw new SystemExit(); } }else{ //ERROR: user is not logged in header("Location: index.php"); - die(); + throw new SystemExit(); } }catch (PDOException $e) { //go to error page or something, because can't access website db print_r($e); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/change_password.php b/code/web/public_php/ams/func/change_password.php index 4641e9a20..cc86462f5 100644 --- a/code/web/public_php/ams/func/change_password.php +++ b/code/web/public_php/ams/func/change_password.php @@ -47,7 +47,7 @@ function change_password(){ $succresult['username'] = $_SESSION['user']; $succresult['target_id'] = $_POST['target_id']; helpers :: loadtemplate( 'settings', $succresult); - die(); + throw new SystemExit(); }else{ @@ -65,31 +65,31 @@ function change_password(){ $result = array_merge($result,$settings); helpers :: loadtemplate( 'settings', $result); - die(); + throw new SystemExit(); } }else{ //ERROR: permission denied! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: The form was not filled in correclty header("Location: index.php?page=settings"); - die(); + throw new SystemExit(); } }else{ //ERROR: user is not logged in header("Location: index.php"); - die(); + throw new SystemExit(); } }catch (PDOException $e) { //go to error page or something, because can't access website db print_r($e); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/change_receivemail.php b/code/web/public_php/ams/func/change_receivemail.php index 895044997..0dc43d145 100644 --- a/code/web/public_php/ams/func/change_receivemail.php +++ b/code/web/public_php/ams/func/change_receivemail.php @@ -27,30 +27,30 @@ function change_receivemail(){ }else{ header("Location: ".$WEBPATH."?page=settings&id=".$user_id); } - die(); + throw new SystemExit(); }else{ //ERROR: permission denied! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: The form was not filled in correclty header("Location: index.php?page=settings"); - die(); + throw new SystemExit(); } }else{ //ERROR: user is not logged in header("Location: index.php"); - die(); + throw new SystemExit(); } }catch (PDOException $e) { //go to error page or something, because can't access website db print_r($e); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/create_ticket.php b/code/web/public_php/ams/func/create_ticket.php index a7d6df015..6b725387c 100644 --- a/code/web/public_php/ams/func/create_ticket.php +++ b/code/web/public_php/ams/func/create_ticket.php @@ -35,32 +35,32 @@ function create_ticket(){ }else{ header("Location: ".$WEBPATH."?page=show_ticket&id=".$ticket_id); } - die(); + throw new SystemExit(); }catch (PDOException $e) { //ERROR: LIB DB is not online! print_r($e); - die(); + throw new SystemExit(); header("Location: index.php"); - die(); + throw new SystemExit(); } }else{ //ERROR: permission denied! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: The form was not filled in correclty header("Location: index.php?page=create_ticket"); - die(); + throw new SystemExit(); } }else{ //ERROR: user is not logged in header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/deactivate_plugin.php b/code/web/public_php/ams/func/deactivate_plugin.php index 7e3277c0d..addb4d0ea 100644 --- a/code/web/public_php/ams/func/deactivate_plugin.php +++ b/code/web/public_php/ams/func/deactivate_plugin.php @@ -23,13 +23,13 @@ function deactivate_plugin() { { // if result is successfull it redirects and shows success message header( "Location: index.php?page=plugins&result=5" ); - die(); + throw new SystemExit(); } else { // if result is unsuccessfull it redirects and shows success message header( "Location: index.php?page=plugins&result=6" ); - die(); + throw new SystemExit(); } } @@ -37,7 +37,7 @@ function deactivate_plugin() { { //if $_GET variable is not set it redirects and shows error header( "Location: index.php?page=plugins&result=6" ); - die(); + throw new SystemExit(); } } } diff --git a/code/web/public_php/ams/func/delete_plugin.php b/code/web/public_php/ams/func/delete_plugin.php index fd36f418e..502f223fd 100644 --- a/code/web/public_php/ams/func/delete_plugin.php +++ b/code/web/public_php/ams/func/delete_plugin.php @@ -30,14 +30,14 @@ function delete_plugin() { //if result successfull redirect and show success message header( "Location: index.php?page=plugins&result=2" ); - die(); + throw new SystemExit(); } else { // if result unsuccessfull redirect and show error message header( "Location: index.php?page=plugins&result=0" ); - die(); + throw new SystemExit(); } } } @@ -45,7 +45,7 @@ function delete_plugin() { { // if result unsuccessfull redirect and show error message header( "Location: index.php?page=plugins&result=0" ); - die(); + throw new SystemExit(); } } } diff --git a/code/web/public_php/ams/func/forgot_password.php b/code/web/public_php/ams/func/forgot_password.php index 133d31106..936e6ed37 100644 --- a/code/web/public_php/ams/func/forgot_password.php +++ b/code/web/public_php/ams/func/forgot_password.php @@ -11,7 +11,7 @@ function forgot_password(){ $result['EMAIL_ERROR'] = 'TRUE'; $result['no_visible_elements'] = 'TRUE'; helpers :: loadtemplate( 'forgot_password', $result); - die(); + throw new SystemExit(); } $webUser = new WebUsers($target_id); $target_username = $webUser->getUsername(); @@ -44,7 +44,7 @@ function forgot_password(){ $result['prevEmail'] = $email; $result['no_visible_elements'] = 'TRUE'; helpers :: loadtemplate( 'forgot_password', $result); - die(); + throw new SystemExit(); } diff --git a/code/web/public_php/ams/func/install_plugin.php b/code/web/public_php/ams/func/install_plugin.php index 15d997905..d7b5755f0 100644 --- a/code/web/public_php/ams/func/install_plugin.php +++ b/code/web/public_php/ams/func/install_plugin.php @@ -59,17 +59,17 @@ function install_plugin() { if ( $x == '1' ) { echo "update found"; - die(); + throw new SystemExit(); } else if ( $x == '2' ) { echo "Plugin already exists with same name ."; - die(); + throw new SystemExit(); } else if ( $x == '3' ) { echo "Update info is not present in the update"; - die(); + throw new SystemExit(); } @@ -80,18 +80,18 @@ function install_plugin() { { if ( move_uploaded_file( $fileTmpLoc, $temp_path . "/" . $fileName ) ) { echo "$fileName upload is complete.
" . "
"; - die(); + throw new SystemExit(); } else { echo "Error in uploading file."; - die(); + throw new SystemExit(); } } else { echo "Please select a file with .zip extension to upload."; - die(); + throw new SystemExit(); } } else @@ -126,28 +126,28 @@ function install_plugin() { // if everything is successfull redirecting to the plugin template header( "Location: index.php?page=plugins&result=1" ); - die(); + throw new SystemExit(); } else { // file .info not exists rmdir( $target_path ); header( "Location: index.php?page=install_plugin&result=2" ); - die(); + throw new SystemExit(); } } else { // extraction failed header( "Location: index.php?page=install_plugin&result=0" ); - die(); + throw new SystemExit(); } } } else { echo "Please Browse for a file before clicking the upload button"; - die(); + throw new SystemExit(); } } } @@ -279,7 +279,7 @@ function checkForUpdate( $fileName, $findPath, $tempFile, $tempPath ) if ( pluginUpdateExists( $info['Id'], $tempPath . "/" . trim( $fileName, ".zip" ) . "_" . $result['Version'] . ".zip" ) ) { echo "Update already exists"; - die(); + throw new SystemExit(); } else { // removing the preivous update @@ -294,7 +294,7 @@ function checkForUpdate( $fileName, $findPath, $tempFile, $tempPath ) $update['UpdateInfo'] = json_encode( $result ); $dbr -> insert( "updates", $update ); header( "Location: index.php?page=plugins&result=7" ); - die(); + throw new SystemExit(); } } } diff --git a/code/web/public_php/ams/func/login.php b/code/web/public_php/ams/func/login.php index 8e24aea87..0e71d57ca 100644 --- a/code/web/public_php/ams/func/login.php +++ b/code/web/public_php/ams/func/login.php @@ -38,21 +38,21 @@ function login(){ }else{ header( 'Location: '. $WEBPATH . $GETString); } - die(); + throw new SystemExit(); }else{ //handle login failure $result = Array(); $result['login_error'] = 'TRUE'; $result['no_visible_elements'] = 'TRUE'; helpers :: loadtemplate( 'login', $result); - die(); + throw new SystemExit(); } }catch (PDOException $e) { //go to error page or something, because can't access website db print_r($e); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/modify_email_of_sgroup.php b/code/web/public_php/ams/func/modify_email_of_sgroup.php index 02e5e76f7..8ea3708f9 100644 --- a/code/web/public_php/ams/func/modify_email_of_sgroup.php +++ b/code/web/public_php/ams/func/modify_email_of_sgroup.php @@ -49,18 +49,18 @@ function modify_email_of_sgroup(){ }else{ header("Location: ".$WEBPATH."?page=show_sgroup&id=".$sgroupid); } - die(); + throw new SystemExit(); }else{ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/reply_on_ticket.php b/code/web/public_php/ams/func/reply_on_ticket.php index 181ddec56..2d625bf41 100644 --- a/code/web/public_php/ams/func/reply_on_ticket.php +++ b/code/web/public_php/ams/func/reply_on_ticket.php @@ -46,25 +46,25 @@ function reply_on_ticket(){ }else{ header("Location: ".$WEBPATH."?page=show_ticket&id=".$ticket_id); } - die(); + throw new SystemExit(); }catch (PDOException $e) { //ERROR: LIB DB is not online! print_r($e); //header("Location: index.php"); - die(); + throw new SystemExit(); } }else{ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/reset_password.php b/code/web/public_php/ams/func/reset_password.php index e0dbd946d..864cb3550 100644 --- a/code/web/public_php/ams/func/reset_password.php +++ b/code/web/public_php/ams/func/reset_password.php @@ -24,7 +24,7 @@ function reset_password(){ } $result['no_visible_elements'] = 'TRUE'; helpers :: loadtemplate( 'reset_success', $result); - die(); + throw new SystemExit(); } $GETString = ""; foreach($_GET as $key => $value){ @@ -38,7 +38,7 @@ function reset_password(){ $result['prevConfirmNewPass'] = $confirmpass; $result['no_visible_elements'] = 'TRUE'; helpers :: loadtemplate( 'reset_password', $result); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/func/update_plugin.php b/code/web/public_php/ams/func/update_plugin.php index 436272c3e..025dd8f7d 100644 --- a/code/web/public_php/ams/func/update_plugin.php +++ b/code/web/public_php/ams/func/update_plugin.php @@ -31,7 +31,7 @@ function update_plugin() { // if update is installed succesffully redirect to show success message header( "Location: index.php?page=plugins&result=8" ); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/change_permission.php b/code/web/public_php/ams/inc/change_permission.php index 4c07a4489..456c07ecf 100644 --- a/code/web/public_php/ams/inc/change_permission.php +++ b/code/web/public_php/ams/inc/change_permission.php @@ -27,7 +27,7 @@ function change_permission(){ }else{ header("Location: ".$WEBPATH."?page=show_user&id=".$user_id); } - die(); + throw new SystemExit(); }else{ @@ -37,21 +37,21 @@ function change_permission(){ }else{ header("Location: ".$WEBPATH."?page=show_user&id=".$user_id); } - die(); + throw new SystemExit(); } }else{ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } diff --git a/code/web/public_php/ams/inc/createticket.php b/code/web/public_php/ams/inc/createticket.php index cd4ca80ab..debf4f7e0 100644 --- a/code/web/public_php/ams/inc/createticket.php +++ b/code/web/public_php/ams/inc/createticket.php @@ -18,7 +18,7 @@ function createticket(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); }else{ //if user_id is given, then set it as the target_id @@ -48,7 +48,7 @@ function createticket(){ }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/dashboard.php b/code/web/public_php/ams/inc/dashboard.php index 5bba2b401..eb658a59c 100644 --- a/code/web/public_php/ams/inc/dashboard.php +++ b/code/web/public_php/ams/inc/dashboard.php @@ -30,14 +30,14 @@ function dashboard(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } diff --git a/code/web/public_php/ams/inc/login.php b/code/web/public_php/ams/inc/login.php index 823f2c838..9fff79fd6 100644 --- a/code/web/public_php/ams/inc/login.php +++ b/code/web/public_php/ams/inc/login.php @@ -22,7 +22,7 @@ function login() { } else { header('Location: ' . $WEBPATH); } - die(); + throw new SystemExit(); } } $pageElements['ingame_webpath'] = $INGAME_WEBPATH; diff --git a/code/web/public_php/ams/inc/plugins.php b/code/web/public_php/ams/inc/plugins.php index b7a0af6ac..87724b11e 100644 --- a/code/web/public_php/ams/inc/plugins.php +++ b/code/web/public_php/ams/inc/plugins.php @@ -33,7 +33,7 @@ function plugins() // ERROR: No access! $_SESSION['error_code'] = "403"; header( "Location: index.php?page=error" ); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/plugins_update.php b/code/web/public_php/ams/inc/plugins_update.php index 67357dc5c..c8dd669fd 100644 --- a/code/web/public_php/ams/inc/plugins_update.php +++ b/code/web/public_php/ams/inc/plugins_update.php @@ -31,6 +31,6 @@ function plugins_update() // ERROR: No access! $_SESSION['error_code'] = "403"; header( "Location: index.php?page=error" ); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/reset_password.php b/code/web/public_php/ams/inc/reset_password.php index b75a4af36..6a98d2ee8 100644 --- a/code/web/public_php/ams/inc/reset_password.php +++ b/code/web/public_php/ams/inc/reset_password.php @@ -26,6 +26,6 @@ function reset_password(){ global $WEBPATH; $_SESSION['error_code'] = "403"; header("Location: ".$WEBPATH."?page=error"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/settings.php b/code/web/public_php/ams/inc/settings.php index 62a2ef76b..8ce988e43 100644 --- a/code/web/public_php/ams/inc/settings.php +++ b/code/web/public_php/ams/inc/settings.php @@ -13,7 +13,7 @@ function settings(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); }else{ $webUser = new Webusers($_GET['id']); $result = $webUser->getInfo(); @@ -47,7 +47,7 @@ function settings(){ }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/sgroup_list.php b/code/web/public_php/ams/inc/sgroup_list.php index 86f8fdca9..dd1faa458 100644 --- a/code/web/public_php/ams/inc/sgroup_list.php +++ b/code/web/public_php/ams/inc/sgroup_list.php @@ -21,7 +21,7 @@ function sgroup_list(){ }else{ header("Location: ".$WEBPATH."?page=sgroup_list"); } - die(); + throw new SystemExit(); } if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){ $result['isAdmin'] = "TRUE"; @@ -34,12 +34,12 @@ function sgroup_list(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/show_queue.php b/code/web/public_php/ams/inc/show_queue.php index 658c14dce..64614b317 100644 --- a/code/web/public_php/ams/inc/show_queue.php +++ b/code/web/public_php/ams/inc/show_queue.php @@ -149,19 +149,19 @@ function show_queue(){ //ERROR: Doesn't exist! $_SESSION['error_code'] = "404"; header("Location: ams?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/show_reply.php b/code/web/public_php/ams/inc/show_reply.php index 864c4090d..2f05816f9 100644 --- a/code/web/public_php/ams/inc/show_reply.php +++ b/code/web/public_php/ams/inc/show_reply.php @@ -44,11 +44,11 @@ function show_reply(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/show_sgroup.php b/code/web/public_php/ams/inc/show_sgroup.php index fc3ca4bdf..74f73b8a3 100644 --- a/code/web/public_php/ams/inc/show_sgroup.php +++ b/code/web/public_php/ams/inc/show_sgroup.php @@ -25,7 +25,7 @@ function show_sgroup(){ }else{ header("Location: ".$WEBPATH."?page=show_sgroup&id=" . $result['target_id']); } - die(); + throw new SystemExit(); } @@ -65,19 +65,19 @@ function show_sgroup(){ //ERROR: No page specified! $_SESSION['error_code'] = "404"; header("Location: ams?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/show_ticket.php b/code/web/public_php/ams/inc/show_ticket.php index 383a7d4f7..459b7e0e6 100644 --- a/code/web/public_php/ams/inc/show_ticket.php +++ b/code/web/public_php/ams/inc/show_ticket.php @@ -83,11 +83,11 @@ function show_ticket(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/show_ticket_info.php b/code/web/public_php/ams/inc/show_ticket_info.php index b558d3c39..d5377fc39 100644 --- a/code/web/public_php/ams/inc/show_ticket_info.php +++ b/code/web/public_php/ams/inc/show_ticket_info.php @@ -50,11 +50,11 @@ function show_ticket_info(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/show_ticket_log.php b/code/web/public_php/ams/inc/show_ticket_log.php index 46c18634c..fd4a95188 100644 --- a/code/web/public_php/ams/inc/show_ticket_log.php +++ b/code/web/public_php/ams/inc/show_ticket_log.php @@ -68,11 +68,11 @@ function show_ticket_log(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/show_user.php b/code/web/public_php/ams/inc/show_user.php index d50f7756b..1128cd21e 100644 --- a/code/web/public_php/ams/inc/show_user.php +++ b/code/web/public_php/ams/inc/show_user.php @@ -42,11 +42,11 @@ function show_user(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } }else{ //ERROR: not logged in! header("Location: index.php"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/syncing.php b/code/web/public_php/ams/inc/syncing.php index 9f26ab90a..dff1d0402 100644 --- a/code/web/public_php/ams/inc/syncing.php +++ b/code/web/public_php/ams/inc/syncing.php @@ -31,6 +31,6 @@ function syncing(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/inc/userlist.php b/code/web/public_php/ams/inc/userlist.php index b38ce2f47..36d180fe1 100644 --- a/code/web/public_php/ams/inc/userlist.php +++ b/code/web/public_php/ams/inc/userlist.php @@ -31,6 +31,6 @@ function userlist(){ //ERROR: No access! $_SESSION['error_code'] = "403"; header("Location: index.php?page=error"); - die(); + throw new SystemExit(); } } diff --git a/code/web/public_php/ams/index.php b/code/web/public_php/ams/index.php index 7a7d77049..d4c43d018 100644 --- a/code/web/public_php/ams/index.php +++ b/code/web/public_php/ams/index.php @@ -14,10 +14,14 @@ // load required pages and turn error reporting on/off error_reporting( E_ALL ); ini_set( 'display_errors', 'on' ); + +class SystemExit extends Exception {} +try { + if (!file_exists( '../is_installed')) { header("Cache-Control: max-age=1"); header('Location: ../setup', true, 303); - die(); + throw new SystemExit(); } require( '../config.php' ); @@ -129,3 +133,6 @@ foreach( $hook_content as $key => $value ) // load the template with the variables in the $return array helpers :: loadTemplate( $page , $return ); + +} +catch (SystemExit $e) { /* do nothing */ }