Throw exception instead of exit.

This commit is contained in:
kaetemi 2014-09-03 07:23:39 +02:00
parent a43ff6e64e
commit 3f3319c40e
38 changed files with 156 additions and 149 deletions

View file

@ -143,7 +143,7 @@ function api_key_management_hook_store_db()
// 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();
}
}
}
@ -196,7 +196,7 @@ function api_key_management_hook_update_db()
// 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();
}
}

View file

@ -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();
}
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}
}

View file

@ -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();
}
}
}

View file

@ -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();
}

View file

@ -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.</br>" . "<button type='submit' class='btn btn-primary' style='margin-left:5px; margin-top:10px;' name='install_plugin'>Install Plugin</button></br>";
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();
}
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}

View file

@ -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();
}
}

View file

@ -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();
}

View file

@ -22,7 +22,7 @@ function login() {
} else {
header('Location: ' . $WEBPATH);
}
die();
throw new SystemExit();
}
}
$pageElements['ingame_webpath'] = $INGAME_WEBPATH;

View file

@ -33,7 +33,7 @@ function plugins()
// ERROR: No access!
$_SESSION['error_code'] = "403";
header( "Location: index.php?page=error" );
die();
throw new SystemExit();
}
}

View file

@ -31,6 +31,6 @@ function plugins_update()
// ERROR: No access!
$_SESSION['error_code'] = "403";
header( "Location: index.php?page=error" );
die();
throw new SystemExit();
}
}

View file

@ -26,6 +26,6 @@ function reset_password(){
global $WEBPATH;
$_SESSION['error_code'] = "403";
header("Location: ".$WEBPATH."?page=error");
die();
throw new SystemExit();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -31,6 +31,6 @@ function syncing(){
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
die();
throw new SystemExit();
}
}

View file

@ -31,6 +31,6 @@ function userlist(){
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
die();
throw new SystemExit();
}
}

View file

@ -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 */ }