[aur-dev] [PATCH] Call check_sid() from a central location
Instead of calling check_sid() from every single PHP script representing a web page, add the call to aur.inc.php which is sourced by all of them. Also, remove set_lang() calls from the scripts since these are also already included in aur.inc.php. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/account.php | 3 --- web/html/addvote.php | 2 -- web/html/comaintainers.php | 3 --- web/html/commentedit.php | 3 --- web/html/home.php | 3 --- web/html/login.php | 2 -- web/html/logout.php | 1 - web/html/packages.php | 2 -- web/html/passreset.php | 3 --- web/html/pkgbase.php | 2 -- web/html/pkgdel.php | 3 --- web/html/pkgdisown.php | 3 --- web/html/pkgflag.php | 3 --- web/html/pkgflagcomment.php | 3 --- web/html/pkgmerge.php | 3 --- web/html/pkgreq.php | 3 --- web/html/register.php | 3 --- web/html/tu.php | 2 -- web/lib/aur.inc.php | 2 ++ 19 files changed, 2 insertions(+), 47 deletions(-) diff --git a/web/html/account.php b/web/html/account.php index 549f852..c30a89a 100644 --- a/web/html/account.php +++ b/web/html/account.php @@ -5,9 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once('aur.inc.php'); # access AUR common functions include_once('acctfuncs.inc.php'); # access Account specific functions -set_lang(); # this sets up the visitor's language -check_sid(); # see if they're still logged in - $action = in_request("Action"); $need_userinfo = array( diff --git a/web/html/addvote.php b/web/html/addvote.php index d152941..3672c03 100644 --- a/web/html/addvote.php +++ b/web/html/addvote.php @@ -3,8 +3,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); -set_lang(); -check_sid(); $title = __("Add Proposal"); diff --git a/web/html/comaintainers.php b/web/html/comaintainers.php index 23d8d19..9733558 100644 --- a/web/html/comaintainers.php +++ b/web/html/comaintainers.php @@ -5,9 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); include_once("pkgbasefuncs.inc.php"); -set_lang(); -check_sid(); - if (!isset($base_id) || !has_credential(CRED_PKGBASE_EDIT_COMAINTAINERS, array(pkgbase_maintainer_uid($base_id)))) { header('Location: /'); exit(); diff --git a/web/html/commentedit.php b/web/html/commentedit.php index 2a0628e..53ec289 100644 --- a/web/html/commentedit.php +++ b/web/html/commentedit.php @@ -5,9 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); include_once("pkgbasefuncs.inc.php"); -set_lang(); -check_sid(); - $comment_id = intval($_REQUEST['comment_id']); list($user_id, $comment) = comment_by_id($comment_id); diff --git a/web/html/home.php b/web/html/home.php index 2675491..0ce89f4 100644 --- a/web/html/home.php +++ b/web/html/home.php @@ -3,9 +3,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); -set_lang(); -check_sid(); - include_once('stats.inc.php'); if (isset($_COOKIE["AURSID"])) { diff --git a/web/html/login.php b/web/html/login.php index 7345439..a55ce05 100644 --- a/web/html/login.php +++ b/web/html/login.php @@ -2,8 +2,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); -set_lang(); -check_sid(); $disable_http_login = config_get_bool('options', 'disable_http_login'); if (!$disable_http_login || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'])) { diff --git a/web/html/logout.php b/web/html/logout.php index 5e8e8f4..1402200 100644 --- a/web/html/logout.php +++ b/web/html/logout.php @@ -5,7 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); # access AUR common functions include_once("acctfuncs.inc.php"); # access AUR common functions - # if they've got a cookie, log them out - need to do this before # sending any HTML output. # diff --git a/web/html/packages.php b/web/html/packages.php index 7d5b207..db9606d 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -3,9 +3,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); # access AUR common functions -set_lang(); # this sets up the visitor's language include_once('pkgfuncs.inc.php'); # package specific functions -check_sid(); # see if they're still logged in # Retrieve package ID and name, unless initialized by the routing framework if (!isset($pkgid) || !isset($pkgname)) { diff --git a/web/html/passreset.php b/web/html/passreset.php index e89967d..9e7cee8 100644 --- a/web/html/passreset.php +++ b/web/html/passreset.php @@ -4,9 +4,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); # access AUR common functions -set_lang(); # this sets up the visitor's language -check_sid(); # see if they're still logged in - if (isset($_COOKIE["AURSID"])) { header('Location: /'); exit(); diff --git a/web/html/pkgbase.php b/web/html/pkgbase.php index a593af1..03b0eee 100644 --- a/web/html/pkgbase.php +++ b/web/html/pkgbase.php @@ -3,9 +3,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); -set_lang(); include_once('pkgfuncs.inc.php'); -check_sid(); /* * Retrieve package base ID and name, unless initialized by the routing diff --git a/web/html/pkgdel.php b/web/html/pkgdel.php index 591ccce..4620beb 100644 --- a/web/html/pkgdel.php +++ b/web/html/pkgdel.php @@ -5,9 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); include_once("pkgfuncs.inc.php"); -set_lang(); -check_sid(); - html_header(__("Package Deletion")); if (has_credential(CRED_PKGBASE_DELETE)): ?> diff --git a/web/html/pkgdisown.php b/web/html/pkgdisown.php index 036fe6d..4b04e85 100644 --- a/web/html/pkgdisown.php +++ b/web/html/pkgdisown.php @@ -5,9 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); include_once("pkgfuncs.inc.php"); -set_lang(); -check_sid(); - html_header(__("Disown Package")); $maintainer_uids = array(pkgbase_maintainer_uid($base_id)); diff --git a/web/html/pkgflag.php b/web/html/pkgflag.php index 25c8ccb..61346b9 100644 --- a/web/html/pkgflag.php +++ b/web/html/pkgflag.php @@ -5,9 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); include_once("pkgfuncs.inc.php"); -set_lang(); -check_sid(); - /* Grab the list of package base IDs to be operated on. */ $ids = array(); if (isset($_POST['IDs'])) { diff --git a/web/html/pkgflagcomment.php b/web/html/pkgflagcomment.php index 98680ef..c0363c8 100644 --- a/web/html/pkgflagcomment.php +++ b/web/html/pkgflagcomment.php @@ -5,9 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); include_once("pkgbasefuncs.inc.php"); -set_lang(); -check_sid(); - if (!isset($base_id)) { header('Location: /'); exit(); diff --git a/web/html/pkgmerge.php b/web/html/pkgmerge.php index e8e7ca9..6ee7423 100644 --- a/web/html/pkgmerge.php +++ b/web/html/pkgmerge.php @@ -5,9 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); include_once("pkgfuncs.inc.php"); -set_lang(); -check_sid(); - html_header(__("Package Merging")); if (has_credential(CRED_PKGBASE_DELETE)): ?> diff --git a/web/html/pkgreq.php b/web/html/pkgreq.php index f981c25..d2f9461 100644 --- a/web/html/pkgreq.php +++ b/web/html/pkgreq.php @@ -5,9 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); include_once("pkgfuncs.inc.php"); -set_lang(); -check_sid(); - if (isset($base_id)) { if (!has_credential(CRED_PKGREQ_FILE)) { header('Location: /'); diff --git a/web/html/register.php b/web/html/register.php index 843fea9..368999a 100644 --- a/web/html/register.php +++ b/web/html/register.php @@ -5,9 +5,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once('aur.inc.php'); # access AUR common functions include_once('acctfuncs.inc.php'); # access Account specific functions -set_lang(); # this sets up the visitor's language -check_sid(); # see if they're still logged in - if (isset($_COOKIE["AURSID"])) { header('Location: /'); exit(); diff --git a/web/html/tu.php b/web/html/tu.php index cc77d62..34e64ea 100644 --- a/web/html/tu.php +++ b/web/html/tu.php @@ -3,8 +3,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("aur.inc.php"); -set_lang(); -check_sid(); $title = __("Trusted User"); diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php index d58df40..063de8f 100644 --- a/web/lib/aur.inc.php +++ b/web/lib/aur.inc.php @@ -21,6 +21,8 @@ include_once("credentials.inc.php"); include_once('timezone.inc.php'); set_tz(); +check_sid(); + /** * Check if a visitor is logged in * -- 2.12.2
participants (1)
-
Lukas Fleischer