]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15249 $_SERVER['HTTP_HOST'] not availabel in CLI script, replaced by parsing...
authorskodak <skodak>
Mon, 25 May 2009 20:55:27 +0000 (20:55 +0000)
committerskodak <skodak>
Mon, 25 May 2009 20:55:27 +0000 (20:55 +0000)
admin/settings/server.php
lib/db/install.php
lib/moodlelib.php
mod/chat/settings.php

index 8bdaa938a7bbd8bc94d51300aabb975549d3c3f0..6336c771b314def1d962f0f4d207aa30eccc2d68 100644 (file)
@@ -22,7 +22,7 @@ $temp->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'ad
 $temp->add(new admin_setting_configtext('smtpuser', get_string('smtpuser', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
 $temp->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'admin'), get_string('configsmtpuser', 'admin'), ''));
 $temp->add(new admin_setting_configtext('smtpmaxbulk', get_string('smtpmaxbulk', 'admin'), get_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT));
-$temp->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'admin'), get_string('confignoreplyaddress', 'admin'), 'noreply@' . $_SERVER['HTTP_HOST'], PARAM_NOTAGS));
+$temp->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'admin'), get_string('confignoreplyaddress', 'admin'), 'noreply@' . get_host_from_url($CFG->wwwroot), PARAM_NOTAGS));
 $temp->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'admin'), get_string('configdigestmailtime', 'admin'), 17, array('00' => '00',
                                                                                                                                                           '01' => '01',
                                                                                                                                                           '02' => '02',
index 7c441bf0a2b0a11fcac00041774f67487228878d..b0e092cc9373faafb3a8173118f5db81350e91c1 100644 (file)
@@ -51,7 +51,7 @@ function xmldb_main_install() {
         'template'              => 'default',
         'theme'                 => 'standardwhite',
         'filter_multilang_converted' => 1,
-        'siteidentifier'        => random_string(32).$_SERVER['HTTP_HOST'],
+        'siteidentifier'        => random_string(32).get_host_from_url($CFG->wwwroot),
         'backup_version'        => 2008111700,
         'backup_release'        => '2.0 dev',
         'blocks_version'        => 2007081300, // might be removed soon
@@ -158,7 +158,7 @@ function xmldb_main_install() {
     $admin->lang         = $CFG->lang;
     $admin->maildisplay  = 1;
     $admin->timemodified = time();
-    $admin->lastip       = getremoteaddr(); // installation hijacking prevention
+    $admin->lastip       = CLI_SCRIPT ? '0.0.0.0' : getremoteaddr(); // installation hijacking prevention
     $admin->id = $DB->insert_record('user', $admin);
 
 
index 664d8bf8f5ea1ebd256f5778d8742e9f443df88b..8ea7e01f063a76e565ca01ce14148379d241a28f 100644 (file)
@@ -661,6 +661,19 @@ function is_number($value) {
     }
 }
 
+/**
+ * Returns host part from url
+ * @param string $url full url
+ * @return string host, null if not found
+ */
+function get_host_from_url($url) {
+    preg_match('|^[a-z]+://([a-zA-Z0-9-.]+)|i', $url, $matches);
+    if ($matches) {
+        return $matches[1];
+    }
+    return null;
+}
+
 /**
  * Tests whether anything was returned by text editor
  *
index 7769d5af797a222281ebd2e9603673fc7287bbed..46f8b6d7d9183d2917aa5fff1765ce93251c638e 100644 (file)
@@ -33,7 +33,7 @@ $settings->add(new admin_setting_heading('chat_daemon_heading', get_string('meth
                    get_string('explainmethoddaemon', 'chat')));
 
 $settings->add(new admin_setting_configtext('chat_serverhost', get_string('serverhost', 'chat'),
-                   get_string('configserverhost', 'chat'), $_SERVER['HTTP_HOST']));
+                   get_string('configserverhost', 'chat'), get_host_from_url($CFG->wwwroot)));
 
 $settings->add(new admin_setting_configtext('chat_serverip', get_string('serverip', 'chat'),
                    get_string('configserverip', 'chat'), '127.0.0.1'));