本文整理汇总了PHP中Domain::GetNameserverHostList方法的典型用法代码示例。如果您正苦于以下问题:PHP Domain::GetNameserverHostList方法的具体用法?PHP Domain::GetNameserverHostList怎么用?PHP Domain::GetNameserverHostList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domain
的用法示例。
在下文中一共展示了Domain::GetNameserverHostList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Run
public function Run($userid)
{
try {
$Factory = RegistryModuleFactory::GetInstance();
$Registry = $Factory->GetRegistryByExtension($this->Domain->Extension);
$host_as_attr = (bool) $Registry->GetManifest()->GetRegistryOptions()->ability->hostattr;
} catch (Exception $e) {
throw new UpdateDomainNameserversAction_Exception(sprintf(_("Cannot change nameservers. Reason: %s"), $e->getMessage()));
}
// Check that all nameserver hosts are registered
foreach ($this->nslist as &$NS) {
$glue_record = preg_match("/^(.*)\\.{$this->Domain->GetHostName()}\$/", $NS->HostName, $matches);
if ($glue_record) {
$known_ns = $this->Db->GetRow("SELECT * FROM nhosts WHERE hostname=? AND domainid=?", array($matches[1], $this->Domain->ID));
if (!$known_ns) {
if ($host_as_attr) {
// No need to register nameserver hosts
$this->Db->Execute("INSERT INTO nhosts SET domainid = ?, hostname = ?, ipaddr = ?", array($this->Domain->ID, $matches[1], $NS->IPAddr));
} else {
throw new UpdateDomainNameserversAction_Exception(sprintf(_("Nameserver %s does not exist"), $NS->HostName), UpdateDomainNameserversAction_Exception::NAMESERVERHOST_NOT_REGISTERED);
}
} else {
$NS = new NameserverHost($NS->HostName, $host_as_attr ? $NS->IPAddr : $known_ns['ipaddr']);
$NS->ID = $known_ns['id'];
}
}
}
// Perform nameservers update
try {
$Changes = new Changelist($this->Domain->GetNameserverList(), $this->nslist);
$Registry->UpdateDomainNameservers($this->Domain, $Changes);
$DBNSHost = DBNameserverHost::GetInstance();
$DBNSHost->SaveList($this->Domain->GetNameserverHostList(), $this->Domain->ID);
return $this->Domain->HasPendingOperation(Registry::OP_UPDATE) ? UpdateDomainNameserversAction_Result::PENDING : UpdateDomainNameserversAction_Result::OK;
} catch (Exception $e) {
throw new UpdateDomainNameserversAction_Exception(sprintf(_("Cannot change nameservers. Reason: %s"), $e->getMessage()));
}
}
示例2: Save
//.........这里部分代码省略.........
}
$ns_n = array();
foreach (array_values($nslist) as $i => $ns) {
if ($i < 2) {
$row['ns' . ($i + 1)] = $ns->HostName;
} else {
$ns_n[] = $ns->HostName;
}
}
$row['ns_n'] = join(';', $ns_n);
// Contacts data
$contact_list = $domain->GetContactList();
foreach ($this->ContactFieldTypeMap as $field => $contact_type) {
$contact = $contact_list[$contact_type];
// Add/Remove references to contact
$row[$field] = $contact ? $contact->CLID : '';
}
// Domain extra fields
$extra_fields = array();
foreach ($domain->GetConfig()->xpath('registration/extra_fields/field') as $field) {
settype($field, "array");
$field = $field["@attributes"];
if (isset($domain->{$field['name']})) {
$extra_fields[$field['name']] = $domain->{$field['name']};
}
}
foreach ((array) $domain->ExtraFields as $k => $v) {
$extra_fields[$k] = $v;
}
// Prepare data for DB
$row["start_date"] = $row["start_date"] ? date("Y-m-d H:i:s", $row["start_date"]) : '0000-00-00 00:00:00';
$row["end_date"] = $row["end_date"] ? date("Y-m-d H:i:s", $row["end_date"]) : '0000-00-00 00:00:00';
$row['dtTransfer'] = $row['dtTransfer'] ? date("Y-m-d H:i:s", $row["dtTransfer"]) : '0000-00-00 00:00:00';
$row["islocked"] = (int) (bool) $row["islocked"];
$row['managed_dns'] = (int) (bool) $row['managed_dns'];
$row['period'] = (int) $row['period'];
$row['delete_status'] = (int) $row['delete_status'];
$row['renew_disabled'] = (int) (bool) $row['renew_disabled'];
// Save it!
//if ($domain->ID)
unset($row['id']);
// Prepare SQL statement
$set = array();
$bind = array();
foreach ($row as $field => $value) {
$set[] = "`{$field}` = ?";
$bind[] = $value;
}
$set = join(', ', $set);
$this->DB->BeginTrans();
try {
if ($domain->ID) {
// Perform Update
$bind[] = $domain->ID;
$this->DB->Execute("UPDATE domains SET {$set} WHERE id = ?", $bind);
} else {
// Perform Insert
$this->DB->Execute("INSERT INTO domains SET {$set}", $bind);
$domain->ID = $this->DB->Insert_ID();
}
// Save extra data
$this->DB->Execute('DELETE FROM domains_data WHERE domainid = ?', array($domain->ID));
foreach ($extra_fields as $name => $value) {
$this->DB->Execute('INSERT INTO domains_data SET `domainid` = ?, `key` = ?, `value` = ?', array($domain->ID, $name, $value));
}
// Save flags
$this->DB->Execute('DELETE FROM domains_flags WHERE domainid = ?', array($domain->ID));
$flag_list = $domain->GetFlagList();
foreach ($flag_list as $flag) {
$this->DB->Execute('INSERT INTO domains_flags SET domainid = ?, flag = ?', array($domain->ID, $flag));
}
// Save contacts
foreach ($contact_list as $contact) {
if (!$contact->UserID) {
$contact->UserID = $domain->UserID;
}
$this->DBContact->Save($contact);
}
// Save nameserver hosts
$ns_list = $domain->GetNameserverHostList();
foreach ($ns_list as $ns) {
$ns_id = $this->DB->GetOne('SELECT id FROM nhosts WHERE domainid=? AND hostname=?', array($domain->ID, $ns->GetBaseName()));
if ($ns_id) {
$this->DB->Execute('UPDATE nhosts SET ipaddr=? WHERE hostname=? AND domainid=?', array($ns->IPAddr, $ns->GetBaseName(), $domain->ID));
} else {
$this->DB->Execute('INSERT INTO nhosts SET domainid=?, hostname=?, ipaddr=?', array($domain->ID, $ns->GetBaseName(), $ns->IPAddr));
$ns_id = $this->DB->Insert_ID();
}
$ns->ID = $ns_id;
}
//$this->DBNameserverHost->SaveList($ns_list, $domain->ID);
} catch (Exception $e) {
$this->DB->RollbackTrans();
throw new ApplicationException($e->getMessage(), $e->getCode());
}
$this->DB->CompleteTrans();
// Update domain in loaded objects storage
$this->LoadedObjects[$domain->ID] = clone $domain;
return $domain;
}