Rename util_show_error_page() to util_show_error_page_and_exit() and redirect() to util_redirect_and_exit()
so it is explicit that we exit in those functions that so we know it isn't necessary to put an exit after we call them
This commit is contained in:
@@ -519,7 +519,7 @@ class Application {
|
||||
|
||||
/* is this user supposed to view this version? */
|
||||
if(!$_SESSION['current']->canViewApplication($this))
|
||||
util_show_error_page("Something went wrong with the application or version id");
|
||||
util_show_error_page_and_exit("Something went wrong with the application or version id");
|
||||
|
||||
// show Vote Menu
|
||||
if($_SESSION['current']->isLoggedIn())
|
||||
|
||||
@@ -18,13 +18,13 @@ function filter_gpc()
|
||||
if(is_numeric($_REQUEST[$aKeys[$i]]))
|
||||
$aClean[$aKeys[$i]] = $_REQUEST[$aKeys[$i]];
|
||||
else
|
||||
util_show_error_page("Fatal error: ".$aKeys[$i]." should be a numeric value.");
|
||||
util_show_error_page_and_exit("Fatal error: ".$aKeys[$i]." should be a numeric value.");
|
||||
break;
|
||||
case "b": // boolean
|
||||
if($_REQUEST[$aKeys[$i]]=="true" || $_REQUEST[$aKeys[$i]]=="false")
|
||||
$aClean[$aKeys[$i]] = $_REQUEST[$aKeys[$i]];
|
||||
else
|
||||
util_show_error_page("Fatal error: ".$aKeys[$i]." should be a boolean value.");
|
||||
util_show_error_page_and_exit("Fatal error: ".$aKeys[$i]." should be a boolean value.");
|
||||
break;
|
||||
case "s": // string
|
||||
switch($aKeys[$i][1])
|
||||
@@ -39,11 +39,11 @@ function filter_gpc()
|
||||
break;
|
||||
case "a": // array
|
||||
if(!is_array($_REQUEST[$aKeys[$i]]))
|
||||
util_show_error_page("Fatal error: ".$aKeys[$i]." should be an array.");
|
||||
util_show_error_page_and_exit("Fatal error: ".$aKeys[$i]." should be an array.");
|
||||
break;
|
||||
default:
|
||||
if($aKeys[$i]!="whq_appdb" && $aKeys[$i]!="MAX_FILE_SIZE") // whq_appdb is the name of the session cookie
|
||||
util_show_error_page("Fatal error: type of variable ".$aKeys[$i]." is not recognized.");
|
||||
util_show_error_page_and_exit("Fatal error: type of variable ".$aKeys[$i]." is not recognized.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,16 +164,6 @@ function apidb_image($name)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* redirect to $url
|
||||
*/
|
||||
function redirect($url)
|
||||
{
|
||||
header("Location: ".$url);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* format a date as required for HTTP by RFC 2068 sec 3.3.1
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* display an error page
|
||||
*/
|
||||
function util_show_error_page($text = null, $message = null)
|
||||
function util_show_error_page_and_exit($text = null, $message = null)
|
||||
{
|
||||
if (!$text) {
|
||||
$text = "You must be logged in to perform that operation.";
|
||||
@@ -15,6 +15,15 @@ function util_show_error_page($text = null, $message = null)
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* redirect to $url
|
||||
*/
|
||||
function util_redirect_and_exit($url)
|
||||
{
|
||||
header("Location: ".$url);
|
||||
exit;
|
||||
}
|
||||
|
||||
function makeSafe($var)
|
||||
{
|
||||
/* Disable addslashes() until we can use more finely grained filtering on user input */
|
||||
|
||||
@@ -622,17 +622,17 @@ class Version {
|
||||
|
||||
/* is this user supposed to view this version? */
|
||||
if(!$_SESSION['current']->canViewVersion($this))
|
||||
util_show_error_page("Something went wrong with the application or version id");
|
||||
util_show_error_page_and_exit("Something went wrong with the application or version id");
|
||||
|
||||
$oApp = new Application($this->iAppId);
|
||||
|
||||
// Oops! application not found or other error. do something
|
||||
if(!$oApp->iAppId)
|
||||
util_show_error_page('Internal Database Access Error. No App found.');
|
||||
util_show_error_page_and_exit('Internal Database Access Error. No App found.');
|
||||
|
||||
// Oops! Version not found or other error. do something
|
||||
if(!$this->iVersionId)
|
||||
util_show_error_page('Internal Database Access Error. No Version Found.');
|
||||
util_show_error_page_and_exit('Internal Database Access Error. No Version Found.');
|
||||
|
||||
// header
|
||||
apidb_header("Viewing App- ".$oApp->sName." Version - ".$this->sName);
|
||||
|
||||
@@ -151,14 +151,14 @@ function vote_menu()
|
||||
function vote_update($vars)
|
||||
{
|
||||
if(!$_SESSION['current']->isLoggedIn())
|
||||
util_show_error_page("You must be logged in to vote");
|
||||
util_show_error_page_and_exit("You must be logged in to vote");
|
||||
|
||||
if( !is_numeric($vars['iAppId']) OR !is_numeric($vars['iSlot']))
|
||||
{
|
||||
if(is_numeric($vars['iAppId']))
|
||||
redirect(apidb_fullurl("appview.php?iAppId=".$vars["iAppId"]));
|
||||
util_redirect_and_exit(apidb_fullurl("appview.php?iAppId=".$vars["iAppId"]));
|
||||
else
|
||||
redirect(apidb_fullurl("index.php"));
|
||||
util_redirect_and_exit(apidb_fullurl("index.php"));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ function vote_update($vars)
|
||||
}
|
||||
}
|
||||
|
||||
redirect(apidb_fullurl("appview.php?iAppId=".$vars["iAppId"]));
|
||||
util_redirect_and_exit(apidb_fullurl("appview.php?iAppId=".$vars["iAppId"]));
|
||||
}
|
||||
|
||||
// tell us if there is a vote in a given slot so we don't
|
||||
|
||||
Reference in New Issue
Block a user