MDL-15249 $_SERVER['HTTP_HOST'] not availabel in CLI script, replaced by parsing of wwwroot which should give the same info

This commit is contained in:
skodak
2009-05-25 20:55:27 +00:00
parent a600ad359a
commit aa282b10fb
4 changed files with 17 additions and 4 deletions
+1 -1
View 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',
+2 -2
View 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);
+13
View 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
*
+1 -1
View 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'));