Skip to content

Commit

Permalink
MDL-16286 Change flow of bootstrap to remove hanging indent
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbulmer committed Sep 1, 2008
1 parent ea87ed5 commit aada58e
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions mnet/peer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,57 +45,57 @@ function bootstrap($wwwroot, $pubkey = null, $application) {
$wwwroot = substr($wwwroot, 0, -1);
}

if ( ! $this->set_wwwroot($wwwroot) ) {
$hostname = mnet_get_hostname_from_uri($wwwroot);
// If a peer record already exists for this address,
// load that info and return
if ($this->set_wwwroot($wwwroot)) {
return true;
}

// Get the IP address for that host - if this fails, it will
// return the hostname string
$ip_address = gethostbyname($hostname);
$hostname = mnet_get_hostname_from_uri($wwwroot);
// Get the IP address for that host - if this fails, it will return the hostname string
$ip_address = gethostbyname($hostname);

// Couldn't find the IP address?
if ($ip_address === $hostname && !preg_match('/^\d+\.\d+\.\d+.\d+$/',$hostname)) {
$this->error[] = array('code' => 2, 'text' => get_string("noaddressforhost", 'mnet'));
return false;
}
// Couldn't find the IP address?
if ($ip_address === $hostname && !preg_match('/^\d+\.\d+\.\d+.\d+$/',$hostname)) {
$this->error[] = array('code' => 2, 'text' => get_string("noaddressforhost", 'mnet'));
return false;
}

$this->name = $wwwroot;
$this->name = $wwwroot;

// TODO: In reality, this will be prohibitively slow... need another
// default - maybe blank string
$homepage = download_file_content($wwwroot);
if (!empty($homepage)) {
$count = preg_match("@<title>(.*)</title>@siU", $homepage, $matches);
if ($count > 0) {
$this->name = $matches[1];
}
// TODO: In reality, this will be prohibitively slow... need another
// default - maybe blank string
$homepage = download_file_content($wwwroot);
if (!empty($homepage)) {
$count = preg_match("@<title>(.*)</title>@siU", $homepage, $matches);
if ($count > 0) {
$this->name = $matches[1];
}
}

$this->wwwroot = $wwwroot;
$this->ip_address = $ip_address;
$this->deleted = 0;
$this->wwwroot = $wwwroot;
$this->ip_address = $ip_address;
$this->deleted = 0;

$this->application = $DB->get_record('mnet_application', array('name'=>$application));
if (empty($this->application)) {
$this->application = $DB->get_record('mnet_application', array('name'=>'moodle'));
}
$this->application = $DB->get_record('mnet_application', array('name'=>$application));
if (empty($this->application)) {
$this->application = $DB->get_record('mnet_application', array('name'=>'moodle'));
}

$this->applicationid = $this->application->id;
$this->applicationid = $this->application->id;

if(empty($pubkey)) {
$this->public_key = clean_param(mnet_get_public_key($this->wwwroot, $this->application), PARAM_PEM);
} else {
$this->public_key = clean_param($pubkey, PARAM_PEM);
}
$this->public_key_expires = $this->check_common_name($this->public_key);
$this->last_connect_time = 0;
$this->last_log_id = 0;
if ($this->public_key_expires == false) {
$this->public_key == '';
return false;
}
if(empty($pubkey)) {
$this->public_key = clean_param(mnet_get_public_key($this->wwwroot, $this->application), PARAM_PEM);
} else {
$this->public_key = clean_param($pubkey, PARAM_PEM);
}
$this->public_key_expires = $this->check_common_name($this->public_key);
$this->last_connect_time = 0;
$this->last_log_id = 0;
if ($this->public_key_expires == false) {
$this->public_key == '';
return false;
}

return true;
}

function delete() {
Expand Down

0 comments on commit aada58e

Please sign in to comment.