Rename errorpage() to util_show_error_page() and move util_show_error_page() into include/util.php

This commit is contained in:
Jonathan Ernst
2006-06-29 16:13:35 +00:00
committed by WineHQ
parent 6b89df82a5
commit 6d019b918a
38 changed files with 68 additions and 72 deletions

View File

@@ -2,7 +2,6 @@
/********************************************/ /********************************************/
/* Account Login / Logout Handler for AppDB */ /* Account Login / Logout Handler for AppDB */
/********************************************/ /********************************************/
include("path.php"); include("path.php");
require(BASE."include/incl.php"); require(BASE."include/incl.php");
require(BASE."include/mail.php"); require(BASE."include/mail.php");
@@ -61,7 +60,7 @@ function do_account($cmd = null)
exit; exit;
} }
//not valid command, display error page //not valid command, display error page
errorpage("Internal Error","This module was called with incorrect parameters"); util_show_error_page("Internal Error","This module was called with incorrect parameters");
exit; exit;
} }

View File

@@ -28,7 +28,7 @@ if(!$_SESSION['current']->isLoggedIn())
if( !is_numeric($aClean['versionId']) ) if( !is_numeric($aClean['versionId']) )
{ {
errorpage('Internal Database Access Error'); util_show_error_page('Internal Database Access Error');
exit; exit;
} }

View File

@@ -26,7 +26,7 @@ $appId = $oRow->appId;
//check for admin privs //check for admin privs
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isMaintainer($aClean['versionId']) && !$_SESSION['current']->isSuperMaintainer($aClean['appId'])) if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isMaintainer($aClean['versionId']) && !$_SESSION['current']->isSuperMaintainer($aClean['appId']))
{ {
errorpage("Insufficient Privileges!"); util_show_error_page("Insufficient Privileges!");
exit; exit;
} }

View File

@@ -13,7 +13,7 @@ $aClean['submit'] = makeSafe($_REQUEST['submit']);
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage(); util_show_error_page();
exit; exit;
} }
$oCat = new Category($aClean['catId']); $oCat = new Category($aClean['catId']);

View File

@@ -21,7 +21,7 @@ $aClean['reject'] = makeSafe($_REQUEST['reject']);
// deny access if not admin or at least some kind of maintainer // deny access if not admin or at least some kind of maintainer
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isMaintainer()) if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isMaintainer())
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }

View File

@@ -133,7 +133,7 @@ function display_move_test_to_versions_table($aVersionsIds,$icurrentVersionId)
//deny access if not logged in or not a super maintainer of any applications //deny access if not logged in or not a super maintainer of any applications
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isSuperMaintainer()) if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isSuperMaintainer())
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }
$oTest = new testData($aClean['iTestingId']); $oTest = new testData($aClean['iTestingId']);
@@ -145,7 +145,7 @@ if ($aClean['sub'])
/* make sure the user is authorized to view this application request */ /* make sure the user is authorized to view this application request */
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }
@@ -165,7 +165,7 @@ if ($aClean['sub'])
$oVersion = new Version($aClean['versionId']); $oVersion = new Version($aClean['versionId']);
if(!$_SESSION['current']->hasAppVersionModifyPermission($oVersion)) if(!$_SESSION['current']->hasAppVersionModifyPermission($oVersion))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }
} else } else

View File

@@ -23,7 +23,7 @@ $aClean['page'] = makeSafe($_REQUEST['page']);
// deny access if not logged in // deny access if not logged in
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }

View File

@@ -21,7 +21,7 @@ $aClean['replyText'] = makeSafe( $_REQUEST['replyText'] );
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }
@@ -42,7 +42,7 @@ if ($aClean['sub'])
else else
{ {
//error no Id! //error no Id!
errorpage("<p><b>QueueId Not Found!</b></p>"); util_show_error_page("<p><b>QueueId Not Found!</b></p>");
} }
//process according to which request was submitted and optionally the sub flag //process according to which request was submitted and optionally the sub flag

View File

@@ -17,7 +17,7 @@ $aClean['maintainerId'] = makeSafe($_REQUEST['maintainerId']);
// deny access if not logged in // deny access if not logged in
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }

View File

@@ -22,7 +22,7 @@ $aClean['versionId'] = makeSafe($_REQUEST['versionId']);
// deny access if not admin // deny access if not admin
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }
/* /*

View File

@@ -22,7 +22,7 @@ if ($aClean['sub'])
$oVersion = new Version($oTest->iVersionId); $oVersion = new Version($oTest->iVersionId);
if(!($_SESSION['current']->hasAppVersionModifyPermission($oVersion))) if(!($_SESSION['current']->hasAppVersionModifyPermission($oVersion)))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }

View File

@@ -19,7 +19,7 @@ apidb_header("Admin Users Management");
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }

View File

@@ -29,7 +29,7 @@ if($aClean['confirmed'] != "yes")
// //
// perhaps we can do this with some javascript, popup // perhaps we can do this with some javascript, popup
errorpage("Not confirmed"); util_show_error_page("Not confirmed");
} }
if($aClean['what']) if($aClean['what'])
@@ -40,7 +40,7 @@ if($aClean['what'])
// delete category and the apps in it // delete category and the apps in it
$oCategory = new Category($aClean['catId']); $oCategory = new Category($aClean['catId']);
if(!$oCategory->delete()) if(!$oCategory->delete())
errorpage(); util_show_error_page();
else else
redirect(BASE."appbrowse.php"); redirect(BASE."appbrowse.php");
break; break;
@@ -48,14 +48,14 @@ if($aClean['what'])
// delete app family & all its versions // delete app family & all its versions
$oApp = new Application($aClean['appId']); $oApp = new Application($aClean['appId']);
if(!$oApp->delete()) if(!$oApp->delete())
errorpage(); util_show_error_page();
else else
redirect(BASE."appbrowse.php"); redirect(BASE."appbrowse.php");
break; break;
case "appVersion": case "appVersion":
$oVersion = new Version($aClean['versionId']); $oVersion = new Version($aClean['versionId']);
if(!$oVersion->delete()) if(!$oVersion->delete())
errorpage(); util_show_error_page();
else else
redirect(BASE."appview.php?appId=".$aClean['appId']); redirect(BASE."appview.php?appId=".$aClean['appId']);
break; break;

View File

@@ -17,13 +17,13 @@ $aClean['submit'] = makeSafe($_REQUEST['submit']);
if(!is_numeric($aClean['appId'])) if(!is_numeric($aClean['appId']))
{ {
errorpage("Wrong ID"); util_show_error_page("Wrong ID");
exit; exit;
} }
if(!($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isSuperMaintainer($aClean['appId']))) if(!($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isSuperMaintainer($aClean['appId'])))
{ {
errorpage("Insufficient Privileges!"); util_show_error_page("Insufficient Privileges!");
exit; exit;
} }
@@ -42,7 +42,7 @@ else
if(!$oApp) if(!$oApp)
{ {
errorpage('Application does not exist'); util_show_error_page('Application does not exist');
} }
if($_SESSION['current']->showDebuggingInfos()) { echo "<p align=center><b>appName:</b> $oApp->sName </p>"; } if($_SESSION['current']->showDebuggingInfos()) { echo "<p align=center><b>appName:</b> $oApp->sName </p>"; }

View File

@@ -20,7 +20,7 @@ $aClean['versionId'] = makeSafe($_REQUEST['versionId']);
if(!is_numeric($aClean['noteId'])) if(!is_numeric($aClean['noteId']))
{ {
errorpage('Wrong note ID'); util_show_error_page('Wrong note ID');
exit; exit;
} }
@@ -30,7 +30,7 @@ $oNote = new Note($aClean['noteId']);
/* Check for privs */ /* Check for privs */
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isMaintainer($oNote->iVersionId) && !$_SESSION['current']->isSuperMaintainer($oNote->iAppId)) if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isMaintainer($oNote->iVersionId) && !$_SESSION['current']->isSuperMaintainer($oNote->iAppId))
{ {
errorpage("Insufficient Privileges!"); util_show_error_page("Insufficient Privileges!");
exit; exit;
} }

View File

@@ -13,14 +13,14 @@ $aClean['submit'] = makeSafe($_REQUEST['submit']);
if(!is_numeric($aClean['appId']) OR !is_numeric($aClean['versionId'])) if(!is_numeric($aClean['appId']) OR !is_numeric($aClean['versionId']))
{ {
errorpage("Wrong ID"); util_show_error_page("Wrong ID");
exit; exit;
} }
/* Check for admin privs */ /* Check for admin privs */
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isMaintainer($aClean['versionId']) && !$_SESSION['current']->isSuperMaintainer($aClean['appId'])) if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isMaintainer($aClean['versionId']) && !$_SESSION['current']->isSuperMaintainer($aClean['appId']))
{ {
errorpage("Insufficient Privileges!"); util_show_error_page("Insufficient Privileges!");
exit; exit;
} }

View File

@@ -5,7 +5,7 @@ include(BASE."include/"."incl.php");
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage(); util_show_error_page();
exit; exit;
} }

View File

@@ -10,7 +10,7 @@ $aClean['Submit'] = makeSafe($_REQUEST['Submit']);
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }

View File

@@ -11,7 +11,7 @@ $aClean['sWebpage'] = makeSafe($_REQUEST['sWebpage']);
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage(); util_show_error_page();
exit; exit;
} }

View File

@@ -13,14 +13,14 @@ $aClean['action'] = makeSafe($_REQUEST['action']);
if(!is_numeric($aClean['appId']) OR !is_numeric($aClean['versionId'])) if(!is_numeric($aClean['appId']) OR !is_numeric($aClean['versionId']))
{ {
errorpage("Wrong ID"); util_show_error_page("Wrong ID");
exit; exit;
} }
/* Check for admin privs */ /* Check for admin privs */
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage("Insufficient Privileges!"); util_show_error_page("Insufficient Privileges!");
exit; exit;
} }

View File

@@ -32,7 +32,7 @@ if( empty( $aClean['catId'] ) )
if( !is_numeric($aClean['catId']) ) if( !is_numeric($aClean['catId']) )
{ {
errorpage("Something went wrong with the category ID"); util_show_error_page("Something went wrong with the category ID");
exit; exit;
} }

View File

@@ -21,7 +21,7 @@ header("Pragma: ");
/* display an error message and exit */ /* display an error message and exit */
if(!$_SESSION['current']->canViewImage($aClean['id'])) if(!$_SESSION['current']->canViewImage($aClean['id']))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }
@@ -30,7 +30,7 @@ if ($aClean['REQUEST_METHOD']='HEAD')
/* WARNING! optimization of logic in include/screenshots.php */ /* WARNING! optimization of logic in include/screenshots.php */
if (sscanf($aClean['id'],"%d", &$iId) < 1) if (sscanf($aClean['id'],"%d", &$iId) < 1)
{ {
errorpage("Bad parameter"); util_show_error_page("Bad parameter");
exit; exit;
} }
$hResult = query_parameters("SELECT id, url FROM appData $hResult = query_parameters("SELECT id, url FROM appData

View File

@@ -66,7 +66,7 @@ function newSubmition($errors)
//deny access if not logged on //deny access if not logged on
if(!$_SESSION['current']->isLoggedIn()) if(!$_SESSION['current']->isLoggedIn())
{ {
errorpage("Insufficient privilages to create application. Are you sure you are logged in?"); util_show_error_page("Insufficient privilages to create application. Are you sure you are logged in?");
exit; exit;
} }
@@ -91,7 +91,7 @@ if ($aClean['sub'])
(($oApp->queued=="false")?true:false) && (($oApp->queued=="false")?true:false) &&
!$_SESSION['current']->isVersionSubmitter($oApp->AppId)) !$_SESSION['current']->isVersionSubmitter($oApp->AppId))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }
@@ -111,7 +111,7 @@ if ($aClean['sub'])
(($oVersion->queued=="false")?true:false) && (($oVersion->queued=="false")?true:false) &&
!$_SESSION['current']->isVersionSubmitter($oVersion->versionId)) !$_SESSION['current']->isVersionSubmitter($oVersion->versionId))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }
} }

View File

@@ -133,7 +133,7 @@ function show_note($sType,$oData)
if(!is_numeric($aClean['appId']) && !is_numeric($aClean['versionId'])) if(!is_numeric($aClean['appId']) && !is_numeric($aClean['versionId']))
{ {
errorpage("Something went wrong with the application or version id"); util_show_error_page("Something went wrong with the application or version id");
exit; exit;
} }
@@ -207,7 +207,7 @@ if($aClean['appId'])
} else } else
{ {
// Oops! Called with no params, bad llamah! // Oops! Called with no params, bad llamah!
errorpage('Page Called with No Params!'); util_show_error_page('Page Called with No Params!');
exit; exit;
} }

View File

@@ -23,7 +23,7 @@ apidb_header("Comments");
if(!is_numeric($aClean['appId']) OR !is_numeric($aClean['versionId']) OR (!empty($aClean['threadId']) AND !is_numeric($aClean['threadId']))) if(!is_numeric($aClean['appId']) OR !is_numeric($aClean['versionId']) OR (!empty($aClean['threadId']) AND !is_numeric($aClean['threadId'])))
{ {
errorpage("Wrong IDs"); util_show_error_page("Wrong IDs");
exit; exit;
} }

View File

@@ -25,7 +25,7 @@ if (!$_SESSION['current']->hasPriv("admin")
&& !$_SESSION['current']->isMaintainer($oComment->iVersionId) && !$_SESSION['current']->isMaintainer($oComment->iVersionId)
&& !$_SESSION['current']->isSuperMaintainer($oComment->iAppId)) && !$_SESSION['current']->isSuperMaintainer($oComment->iAppId))
{ {
errorpage('You don\'t have sufficient privileges to delete this comment.'); util_show_error_page("You don't have sufficient privileges to delete this comment.");
exit; exit;
} }

View File

@@ -21,7 +21,7 @@ if ($aClean['sub'])
{ {
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }

View File

@@ -530,7 +530,7 @@ class Application {
/* is this user supposed to view this version? */ /* is this user supposed to view this version? */
if(!$_SESSION['current']->canViewApplication($this)) if(!$_SESSION['current']->canViewApplication($this))
{ {
errorpage("Something went wrong with the application or version id"); util_show_error_page("Something went wrong with the application or version id");
exit; exit;
} }

View File

@@ -164,23 +164,6 @@ function apidb_image($name)
} }
/**
* display an error page
*/
function errorpage($text = null, $message = null)
{
if (!$text) {
$text = "You must be logged in to perform that operation.";
}
header("HTTP/1.0 404 Object not found or user is not logged in");
apidb_header("Oops");
echo "<div align=center><font color=red><b>$text</b></font></div>\n";
echo "<p>$message</p>\n";
apidb_footer();
}
/** /**
* redirect to $url * redirect to $url
*/ */

View File

@@ -1,4 +1,18 @@
<?php <?php
/**
* display an error page
*/
function util_show_error_page($text = null, $message = null)
{
if (!$text) {
$text = "You must be logged in to perform that operation.";
}
header("HTTP/1.0 404 Object not found or user is not logged in");
apidb_header("Oops");
echo "<div align=center><font color=red><b>$text</b></font></div>\n";
echo "<p>$message</p>\n";
apidb_footer();
}
function makeSafe($var) function makeSafe($var)
{ {

View File

@@ -623,7 +623,7 @@ class Version {
/* is this user supposed to view this version? */ /* is this user supposed to view this version? */
if(!$_SESSION['current']->canViewVersion($this)) if(!$_SESSION['current']->canViewVersion($this))
{ {
errorpage("Something went wrong with the application or version id"); util_show_error_page("Something went wrong with the application or version id");
exit; exit;
} }
@@ -631,14 +631,14 @@ class Version {
if(!$oApp->iAppId) if(!$oApp->iAppId)
{ {
// Oops! application not found or other error. do something // Oops! application not found or other error. do something
errorpage('Internal Database Access Error. No App found.'); util_show_error_page('Internal Database Access Error. No App found.');
exit; exit;
} }
if(!$this->iVersionId) if(!$this->iVersionId)
{ {
// Oops! Version not found or other error. do something // Oops! Version not found or other error. do something
errorpage('Internal Database Access Error. No Version Found.'); util_show_error_page('Internal Database Access Error. No Version Found.');
exit; exit;
} }

View File

@@ -152,7 +152,7 @@ function vote_update($vars)
{ {
if(!$_SESSION['current']->isLoggedIn()) if(!$_SESSION['current']->isLoggedIn())
{ {
errorpage("You must be logged in to vote"); util_show_error_page("You must be logged in to vote");
return; return;
} }

View File

@@ -20,7 +20,7 @@ $aClean['superMaintainer'] = makeSafe($_POST['superMaintainer']);
if(!$_SESSION['current']->isLoggedIn()) if(!$_SESSION['current']->isLoggedIn())
{ {
errorpage("You need to be logged in to resign from being a maintainer."); util_show_error_page("You need to be logged in to resign from being a maintainer.");
exit; exit;
} }

View File

@@ -45,7 +45,7 @@ function checkAppMaintainerInput( $maintainReason )
if(!$_SESSION['current']->isLoggedIn()) if(!$_SESSION['current']->isLoggedIn())
{ {
errorpage("You need to be logged in to apply to be a maintainer."); util_show_error_page("You need to be logged in to apply to be a maintainer.");
exit; exit;
} }
@@ -71,7 +71,7 @@ if( $aClean['maintainReason'] )
$errors = checkAppMaintainerInput($aClean['maintainReason']); $errors = checkAppMaintainerInput($aClean['maintainReason']);
if(!empty($errors)) if(!empty($errors))
{ {
errorpage("We found the following errors:","<ul>$errors</ul><br />Please go back and correct them."); util_show_error_page("We found the following errors:","<ul>$errors</ul><br />Please go back and correct them.");
exit; exit;
} }

View File

@@ -33,7 +33,7 @@ while(list($key, $value) = each($_REQUEST))
if(!$_SESSION['current']->isLoggedIn()) if(!$_SESSION['current']->isLoggedIn())
{ {
errorpage("You must be logged in to edit preferences"); util_show_error_page("You must be logged in to edit preferences");
exit; exit;
} }

View File

@@ -81,7 +81,7 @@ if ($aClean['sub'])
!$_SESSION['current']->hasAppVersionModifyPermission($oVersion)&& !$_SESSION['current']->hasAppVersionModifyPermission($oVersion)&&
!(($_SESSION['current']->iUserId == $oTest->iSubmitterId) && !($oTest->sQueued == 'false'))) !(($_SESSION['current']->iUserId == $oTest->iSubmitterId) && !($oTest->sQueued == 'false')))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} else } else
$oVersion = new version($oTest->iVersionId); $oVersion = new version($oTest->iVersionId);

View File

@@ -21,7 +21,7 @@ if ($aClean['sub'])
{ {
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
errorpage("Insufficient privileges."); util_show_error_page("Insufficient privileges.");
exit; exit;
} }

View File

@@ -14,7 +14,7 @@ $aClean['bug_id'] = makeSafe($_REQUEST['bug_id']);
if( !is_numeric($aClean['bug_id'])) if( !is_numeric($aClean['bug_id']))
{ {
errorpage("Something went wrong with the bug ID"); util_show_error_page("Something went wrong with the bug ID");
exit; exit;
} }
{ {