From 5ea948224ea15ea53bd8167c78e331951d9e1ece Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 25 Nov 2016 20:41:09 -0800 Subject: [PATCH] web: make $master_url a global var --- html/inc/akismet.inc | 8 ++++---- html/inc/bootstrap.inc | 3 ++- html/inc/forum_email.inc | 11 +++++++---- html/inc/util.inc | 7 +++++-- html/user/download.php | 2 +- html/user/ffmail_form.php | 2 -- html/user/get_passwd.php | 2 +- html/user/get_project_config.php | 1 - html/user/logout.php | 1 - html/user/sample_index.php | 1 - html/user/site_search.php | 2 -- html/user/weak_auth.php | 2 -- 12 files changed, 20 insertions(+), 22 deletions(-) diff --git a/html/inc/akismet.inc b/html/inc/akismet.inc index b9f5bde9ca..cd435f7c24 100644 --- a/html/inc/akismet.inc +++ b/html/inc/akismet.inc @@ -17,15 +17,15 @@ // along with BOINC. If not, see . function akismet_check($user, $post) { + global $master_url; $config = get_config(); $key = parse_config($config, ""); if (!$key) { return true; } - $master_url = parse_config($config, ""); - $master_url = urlencode($master_url); - $response = akismet_request("key=$key&blog=$master_url", "rest.akismet.com", "/1.1/verify-key"); + $master_url_enc = urlencode($master_url); + $response = akismet_request("key=$key&blog=$master_url_enc", "rest.akismet.com", "/1.1/verify-key"); if ("valid" == $response[1] ) { $post = urlencode($post); $ip = urlencode($_SERVER['REMOTE_ADDR']); @@ -33,7 +33,7 @@ function akismet_check($user, $post) { $author = urlencode($user->name); $useragent = urlencode($_SERVER['HTTP_USER_AGENT']); - $request = "blog=$master_url"; + $request = "blog=$master_url_enc"; $request .= "&user_ip=$ip"; $request .= "&user_agent=$useragent"; $request .= "&referrer=$referrer"; diff --git a/html/inc/bootstrap.inc b/html/inc/bootstrap.inc index 6c9674fb49..5bfad436c4 100644 --- a/html/inc/bootstrap.inc +++ b/html/inc/bootstrap.inc @@ -140,7 +140,8 @@ function sample_navbar( $inverse=false // white on black? ) { - $master_url = parse_config(get_config(), ""); + global $master_url; + $brand = "".PROJECT.""; navbar_start($brand, $fixed, $inverse); diff --git a/html/inc/forum_email.inc b/html/inc/forum_email.inc index 4dcbf7efdb..bcb92fc0ed 100644 --- a/html/inc/forum_email.inc +++ b/html/inc/forum_email.inc @@ -60,7 +60,8 @@ function mail_report_list($forum, $subject, $body, $must_send=false) { //////////////////// post hidden/unhidden /////////// // function send_moderation_email($forum, $post, $thread, $explanation, $action) { - $master_url = parse_config(get_config(), ""); + global $master_url; + $moderator=get_logged_in_user(); $body = ""; $user = BoincUser::lookup_id($post->user); @@ -98,7 +99,8 @@ $body function send_thread_moderation_email( $forum, $thread, $message, $action_name, $explanation ) { - $master_url = parse_config(get_config(), ""); + global $master_url; + $moderator = get_logged_in_user(); $user = BoincUser::lookup_id($thread->owner); $body = ""; @@ -139,7 +141,8 @@ Do not reply to this message. //////////////////// a user clicks the red "x" to report a post /////////// // function send_report_post_email($user, $forum, $thread, $post, $message) { - $master_url = parse_config(get_config(), ""); + global $master_url; + $body = ""; $owner = BoincUser::lookup_id($post->user); @@ -194,7 +197,7 @@ because your postings have not followed our guidelines. //////////////////// a banishment vote has been started /////////// // function send_banish_vote_email($user, $duration, $reason, $end_time) { - $master_url = parse_config(get_config(), ""); + global $master_url; $now=time(); $subject = PROJECT." banishment vote underway"; $vote_url = $master_url."forum_banishment_vote.php"; diff --git a/html/inc/util.inc b/html/inc/util.inc index 20c8917839..472d75a835 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -31,6 +31,8 @@ require_once("../inc/translation.inc"); require_once("../inc/profile.inc"); require_once("../inc/bootstrap.inc"); +$master_url = parse_config(get_config(), ""); + // don't allow /... at the end of URL if (array_key_exists("PATH_INFO", $_SERVER)) { @@ -94,9 +96,10 @@ function url_base() { } function send_cookie($name, $value, $permanent, $ops=false) { + global $master_url; + // the following allows independent login for projects on the same server // - $master_url = parse_config(get_config(), ""); $url = parse_url($master_url); $path = $url['path']; if ($ops) { @@ -108,7 +111,7 @@ function send_cookie($name, $value, $permanent, $ops=false) { } function clear_cookie($name, $ops=false) { - $master_url = parse_config(get_config(), ""); + global $master_url; $url = parse_url($master_url); $path = $url['path']; if ($ops) { diff --git a/html/user/download.php b/html/user/download.php index 0fe3e9ab91..8f7e374079 100644 --- a/html/user/download.php +++ b/html/user/download.php @@ -27,7 +27,7 @@ require_once("../inc/util.inc"); // and optionally download the appropriate installer, // function concierge_url($user, $download) { - $master_url = parse_config(get_config(), ""); + global $master_url; $project_name = parse_config(get_config(), ""); $project_desc = parse_config(get_config(), ""); $project_inst = parse_config(get_config(), ""); diff --git a/html/user/ffmail_form.php b/html/user/ffmail_form.php index 61927a4d35..9b40573054 100644 --- a/html/user/ffmail_form.php +++ b/html/user/ffmail_form.php @@ -28,8 +28,6 @@ require_once("../inc/util.inc"); error_page("This feature is deprecated"); -$master_url = parse_config(get_config(), ""); - $user = get_logged_in_user(); page_head(tra("Tell your friends about %1", PROJECT)); diff --git a/html/user/get_passwd.php b/html/user/get_passwd.php index 00061ede1d..1f58f4ba15 100644 --- a/html/user/get_passwd.php +++ b/html/user/get_passwd.php @@ -35,7 +35,7 @@ function show_email_form() { } function show_auth_form() { - $master_url = parse_config(get_config(), ""); + global $master_url; $x = strstr($master_url, "//"); $x = substr($x, 2); $x = rtrim($x, "/"); diff --git a/html/user/get_project_config.php b/html/user/get_project_config.php index ac2df32bac..effa86e384 100644 --- a/html/user/get_project_config.php +++ b/html/user/get_project_config.php @@ -55,7 +55,6 @@ if (!$min_passwd_length) { $min_passwd_length = 6; } $disable_account_creation = parse_bool($config, "disable_account_creation"); -$master_url = parse_config($config, ""); echo " $long_name diff --git a/html/user/logout.php b/html/user/logout.php index 265dfa6b3c..389b276c37 100644 --- a/html/user/logout.php +++ b/html/user/logout.php @@ -27,7 +27,6 @@ if ($user) { check_tokens($user->authenticator); clear_cookie('auth'); $g_logged_in_user = null; - $master_url = parse_config(get_config(), ""); header("Location: $master_url"); page_head("Logged out"); echo "You are now logged out"; diff --git a/html/user/sample_index.php b/html/user/sample_index.php index 158c03983b..dd31322e22 100644 --- a/html/user/sample_index.php +++ b/html/user/sample_index.php @@ -33,7 +33,6 @@ require_once("../project/project.inc"); require_once("../inc/bootstrap.inc"); $config = get_config(); -$master_url = parse_config($config, ""); $no_computing = parse_config($config, ""); $no_web_account_creation = parse_bool($config, "no_web_account_creation"); diff --git a/html/user/site_search.php b/html/user/site_search.php index 110f355a90..9bab1b43ce 100644 --- a/html/user/site_search.php +++ b/html/user/site_search.php @@ -17,8 +17,6 @@ function search_form($url) { page_tail(); } -$master_url = parse_config(get_config(), ""); - search_form($master_url); ?> diff --git a/html/user/weak_auth.php b/html/user/weak_auth.php index f3e31b3744..75266224a1 100644 --- a/html/user/weak_auth.php +++ b/html/user/weak_auth.php @@ -19,8 +19,6 @@ require_once("../inc/util.inc"); require_once("../inc/user.inc"); -$master_url = parse_config(get_config(), ""); - $user = get_logged_in_user(); page_head(tra("Account keys"));