web: make $master_url a global var

This commit is contained in:
David Anderson 2016-11-25 20:41:09 -08:00
parent 7be1f5d894
commit 5ea948224e
12 changed files with 20 additions and 22 deletions

View File

@ -17,15 +17,15 @@
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
function akismet_check($user, $post) {
global $master_url;
$config = get_config();
$key = parse_config($config, "<akismet_key>");
if (!$key) {
return true;
}
$master_url = parse_config($config, "<master_url>");
$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";

View File

@ -140,7 +140,8 @@ function sample_navbar(
$inverse=false
// white on black?
) {
$master_url = parse_config(get_config(), "<master_url>");
global $master_url;
$brand = "<a class=\"navbar-brand\" href=$master_url>".PROJECT."</a>";
navbar_start($brand, $fixed, $inverse);

View File

@ -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(), "<master_url>");
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(), "<master_url>");
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(), "<master_url>");
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(), "<master_url>");
global $master_url;
$now=time();
$subject = PROJECT." banishment vote underway";
$vote_url = $master_url."forum_banishment_vote.php";

View File

@ -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(), "<master_url>");
// 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(), "<master_url>");
$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(), "<master_url>");
global $master_url;
$url = parse_url($master_url);
$path = $url['path'];
if ($ops) {

View File

@ -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(), "<master_url>");
global $master_url;
$project_name = parse_config(get_config(), "<long_name>");
$project_desc = parse_config(get_config(), "<project_desc>");
$project_inst = parse_config(get_config(), "<project_inst>");

View File

@ -28,8 +28,6 @@ require_once("../inc/util.inc");
error_page("This feature is deprecated");
$master_url = parse_config(get_config(), "<master_url>");
$user = get_logged_in_user();
page_head(tra("Tell your friends about %1", PROJECT));

View File

@ -35,7 +35,7 @@ function show_email_form() {
}
function show_auth_form() {
$master_url = parse_config(get_config(), "<master_url>");
global $master_url;
$x = strstr($master_url, "//");
$x = substr($x, 2);
$x = rtrim($x, "/");

View File

@ -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, "<master_url>");
echo "<project_config>
<name>$long_name</name>

View File

@ -27,7 +27,6 @@ if ($user) {
check_tokens($user->authenticator);
clear_cookie('auth');
$g_logged_in_user = null;
$master_url = parse_config(get_config(), "<master_url>");
header("Location: $master_url");
page_head("Logged out");
echo "You are now logged out";

View File

@ -33,7 +33,6 @@ require_once("../project/project.inc");
require_once("../inc/bootstrap.inc");
$config = get_config();
$master_url = parse_config($config, "<master_url>");
$no_computing = parse_config($config, "<no_computing>");
$no_web_account_creation = parse_bool($config, "no_web_account_creation");

View File

@ -17,8 +17,6 @@ function search_form($url) {
page_tail();
}
$master_url = parse_config(get_config(), "<master_url>");
search_form($master_url);
?>

View File

@ -19,8 +19,6 @@
require_once("../inc/util.inc");
require_once("../inc/user.inc");
$master_url = parse_config(get_config(), "<master_url>");
$user = get_logged_in_user();
page_head(tra("Account keys"));