本文整理汇总了PHP中Domain::GetHostName方法的典型用法代码示例。如果您正苦于以下问题:PHP Domain::GetHostName方法的具体用法?PHP Domain::GetHostName怎么用?PHP Domain::GetHostName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domain
的用法示例。
在下文中一共展示了Domain::GetHostName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Run
/**
* Executor
*
* @throws UpdateDomainContactTask_Exception
*/
public function Run($userid = null)
{
try {
$Factory = RegistryModuleFactory::GetInstance();
$Registry = $Factory->GetRegistryByExtension($this->Domain->Extension);
$Manifest = $Registry->GetManifest();
if ($userid && $this->Domain->UserID != $userid) {
throw new UpdateDomainContactAction_Exception(_("You don't have permissions for manage this domain"), UpdateDomainContactAction_Exception::DOMAIN_NOT_BELONGS_TO_USER);
}
$OldContact = $this->Domain->GetContact($this->contact_type);
if ($this->NewContact && $this->NewContact->UserID != $this->Domain->UserID) {
throw new UpdateDomainContactAction_Exception(_("You don't have permissions for using this contact"), UpdateDomainContactAction_Exception::CONTACT_NOT_BELONGS_TO_USER);
}
$trade = $Manifest->GetRegistryOptions()->ability->trade == '1';
if ($this->contact_type != CONTACT_TYPE::REGISTRANT || !$trade) {
try {
$Registry->UpdateDomainContact($this->Domain, $this->contact_type, $OldContact, $this->NewContact);
return $this->Domain->HasPendingOperation(Registry::OP_UPDATE) ? UpdateDomainContactAction_Result::PENDING : UpdateDomainContactAction_Result::OK;
} catch (Exception $e) {
throw new UpdateDomainContactAction_Exception(sprintf(_("Cannot change contact. Reason: %s"), $e->getMessage()));
}
} else {
// Execute trade when:
// - Trade invoice is paid
// - Previous trade failed
if ($this->Domain->IncompleteOrderOperation == INCOMPLETE_OPERATION::DOMAIN_TRADE || $this->Invoice && $this->Invoice->Status == INVOICE_STATUS::PAID) {
$this->Domain->SetContact($this->NewContact, CONTACT_TYPE::REGISTRANT);
$this->Domain->IncompleteOrderOperation = null;
$extra["requesttype"] = "ownerChange";
try {
$trade = $Registry->ChangeDomainOwner($this->Domain, 1, $extra);
return $this->Domain->HasPendingOperation(Registry::OP_TRADE) ? UpdateDomainContactAction_Result::PENDING : UpdateDomainContactAction_Result::OK;
} catch (Exception $e) {
$this->Domain->IncompleteOrderOperation = INCOMPLETE_OPERATION::DOMAIN_TRADE;
if ($this->Invoice) {
$this->Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED;
$this->Invoice->ActionFailReason = $e->getMessage();
}
throw new UpdateDomainContactAction_Exception(sprintf(_("Cannot change contact. Reason: %s"), $e->getMessage()));
}
} else {
// Issue an invoice for trade operation
$invoiceid = $this->Db->GetOne("SELECT * FROM invoices WHERE status=? AND itemid=? AND purpose=?", array(INVOICE_STATUS::PENDING, $this->Domain->ID, INVOICE_PURPOSE::DOMAIN_TRADE));
if (!$invoiceid) {
$this->Domain->SetExtraField("NewRegistrantCLID", $this->NewContact->CLID);
DBDomain::GetInstance()->Save($this->Domain);
$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_TRADE, $this->Domain->ID, $userid);
$Invoice->Description = sprintf(_("%s domain name trade"), $this->Domain->GetHostName());
$Invoice->Save();
$this->Invoice = $Invoice;
return UpdateDomainContactAction_Result::INVOICE_GENERATED;
} else {
throw new UpdateDomainContactAction_Exception(_("Another domain trade is already initiated"));
}
}
}
} catch (Exception $e) {
throw new UpdateDomainContactAction_Exception($e->getMessage());
}
}
示例2: UpdateDomainFlags
/**
* Update domain flags (options such as clientUpdateProhibited, clientDeleteProhibited)
*
* @param Domain $domain
* @param IChangelist $changes flags changes
* @version v1000
*/
public function UpdateDomainFlags(Domain $domain, IChangelist $changes)
{
$params = array("name" => $this->MakeNameIDNCompatible($domain->GetHostName()));
list($added, $removed) = $this->FixTransferLonelyFlag($domain, $changes);
if ($added) {
$params['add'] = '<domain:add>' . $this->GetFlagsXML($added) . '</domain:add>';
} else {
$params['add'] = '';
}
if ($removed) {
$params['rem'] = '<domain:rem>' . $this->GetFlagsXML($removed) . '</domain:rem>';
} else {
$params['rem'] = '';
}
$response = $this->Request("domain-update-flags", $params);
if ($response->Code == RFC3730_RESULT_CODE::OK_PENDING) {
$status = REGISTRY_RESPONSE_STATUS::PENDING;
} elseif ($response->Code == RFC3730_RESULT_CODE::OK) {
$status = REGISTRY_RESPONSE_STATUS::SUCCESS;
} else {
$status = REGISTRY_RESPONSE_STATUS::FAILED;
}
$ret = new UpdateDomainFlagsResponse($status, $response->ErrMsg, $response->Code);
$ret->Result = $status != REGISTRY_RESPONSE_STATUS::FAILED;
return $ret;
}
示例3: OnDomainCreated
public function OnDomainCreated(Domain $domain)
{
if ($domain->IsManagedDNSEnabled) {
$userinfo = $this->DB->GetRow("SELECT * FROM users WHERE id=?", array($domain->UserID));
$SOA_owner = str_replace("@", ".", $userinfo["email"]);
$this->DB->Execute("INSERT INTO zones (\t`zone`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_owner`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_ttl`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_parent`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_serial`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_refresh`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_retry`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_expire`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`min_ttl`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`isupdated`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t )\r\n\t \t\t\t\t\t\t\t\t VALUES (?,?,'14400',?,?,'14400','7200','3600000','86400',0)", array($domain->GetHostName(), $SOA_owner, CONFIG::$NS1, date("Ymd") . "01"));
$zoneid = $this->DB->Insert_ID();
$this->DB->Execute("INSERT INTO records (id, zoneid, rtype, ttl, rpriority, rvalue, rkey) \r\n\t\t\t\t\t\t\t SELECT null, '{$zoneid}', rtype, ttl, rpriority, rvalue, rkey FROM records \r\n\t\t\t\t\t\t\t WHERE zoneid='0'\r\n\t\t\t\t\t\t\t ");
}
}
示例4: 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()));
}
}
示例5: Delete
public function Delete(Domain $domain)
{
$this->DB->BeginTrans();
try {
$this->DB->Execute('DELETE FROM domains WHERE id = ?', array($domain->ID));
$this->DB->Execute('DELETE FROM domains_data WHERE domainid = ?', array($domain->ID));
$this->DB->Execute('DELETE FROM domains_flags WHERE domainid = ?', array($domain->ID));
$this->DB->Execute("UPDATE zones SET isdeleted = '1' WHERE zone=?", array($domain->GetHostName()));
$purposes = implode(',', array($this->DB->qstr(INVOICE_PURPOSE::DOMAIN_CREATE), $this->DB->qstr(INVOICE_PURPOSE::DOMAIN_RENEW), $this->DB->qstr(INVOICE_PURPOSE::DOMAIN_TRANSFER), $this->DB->qstr(INVOICE_PURPOSE::DOMAIN_TRADE)));
$this->DB->Execute("UPDATE invoices SET itemid=0, status=IF(status = 0, 2, status) WHERE itemid=? AND purpose IN ({$purposes})", array($domain->ID));
$this->DBNameserverHost->DeleteList($domain->ID);
$domain->ID = null;
} catch (Exception $e) {
$this->DB->RollbackTrans();
Log::Log(sprintf("DBDomain::Delete failed. %s", $e->getMessage()), E_ERROR);
throw new ApplicationException($e->getMessage(), $e->getCode());
}
$this->DB->CompleteTrans();
// Remove it from loaded objects storage
unset($this->LoadedObjects[$domain->ID]);
}
示例6: OnDomainCreated
public function OnDomainCreated (Domain $Domain)
{
if ($this->once_run)
{
return;
}
$this->once_run = true;
////
// 3. CREATE 2 child name servers of newly created domain
//
try
{
$ns1 = new NameserverHost('ns1.' . $Domain->GetHostName(), gethostbyname('hostdad.com'));
$ns2 = new NameserverHost('ns2.' . $Domain->GetHostName(), gethostbyname('hostdad.com'));
$this->Registry->CreateNameserverHost($ns1);
$this->Registry->CreateNameserverHost($ns2);
$this->TestCase->assertTrue(true, 'Create nameservers');
}
catch (Exception $e)
{
return $this->TestCase->fail('Create nameservers. Error: ' . $e->getMessage());
}
////
// 4. UPDATE Domain to attach child name servers to domain
//
try
{
$nslist = $Domain->GetNameserverChangelist();
$nslist->Add($ns1);
$nslist->Add($ns2);
$this->Registry->UpdateDomainNameservers($Domain, $nslist);
$this->TestCase->assertTrue(
count($Domain->GetNameserverList()) == 4,
'Attach nameservers to domain'
);
}
catch (Exception $e)
{
return $this->TestCase->fail('Attach nameservers to domain. Error: ' . $e->getMessage());
}
////
// Create tech contact
//
try
{
$Tech = $this->Registry->NewContactInstance(CONTACT_TYPE::TECH);
$Tech->SetFieldList($this->contact_fields);
$this->Registry->CreateContact($Tech);
$this->TestCase->assertTrue(true, 'Create another contact');
}
catch (Exception $e)
{
return $this->TestCase->fail('Create another contact. Error: ' . $e->getMessage());
}
////
// Update domain contact
try
{
$this->Registry->UpdateDomainContact($Domain, CONTACT_TYPE::TECH, null, $Tech);
$this->TestCase->assertTrue(true, 'Attach contact to domain');
}
catch (Exception $e)
{
return $this->TestCase->fail('Attach contact to domain. Error: ' . $e->getMessage());
}
////
// 6. Perform an INFO command on the domain to verify update
//
try
{
$RDomain = $this->Registry->NewDomainInstance();
$RDomain->Name = $Domain->Name;
$RDomain = $this->Registry->GetRemoteDomain($RDomain);
$this->TestCase->assertTrue(
$RDomain->Name == $Domain->Name &&
date('Ymd', $RDomain->CreateDate) == date('Ymd', $Domain->CreateDate) &&
date('Ymd', $RDomain->ExpireDate) == date('Ymd', $Domain->ExpireDate) &&
count($RDomain->GetNameserverList()) == count($Domain->GetNameserverList()) &&
$RDomain->GetContact(CONTACT_TYPE::TECH)->CLID == $Tech->CLID,
'Get remote domain'
//.........这里部分代码省略.........
示例7: HandleImpendingExpiration
public function HandleImpendingExpiration(Domain $domain)
{
// http://bugzilla.webta.net/show_bug.cgi?id=210
// Prevent domain expiration
$Config = $this->GetManifest()->GetSectionConfig();
$days = $Config->domain->xpath("//renewal/notifications/period");
$last_notification_period = (int) end($days);
$last_renewal_date = $domain->RenewalDate ? $domain->RenewalDate : $domain->ExpireDate;
$days_before_expire = (int) ceil(($last_renewal_date - time()) / 86400);
if ($days_before_expire <= $last_notification_period) {
if ($days_before_expire < 0) {
// Today will expire... OMG!
$days_before_expire = 0;
}
// Set renew period
$period = (int) $Config->domain->renewal->min_period;
$domain->Period = $period;
// Copypasta from class.RenewProcess.php
// Issue invoice for renew and send notification to client.
$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $domain, $domain->UserID);
$Invoice->Description = sprintf(_("%s domain name renewal for %s years"), $domain->GetHostName(), $period);
$Invoice->Save();
if ($Invoice->Status == INVOICE_STATUS::PENDING) {
$userinfo = $this->DB->GetRow("SELECT * FROM users WHERE id=?", array($domain->UserID));
$args = array("domain_name" => $domain->Name, "extension" => $domain->Extension, "invoice" => $Invoice, "expDays" => $days_before_expire, "client" => $userinfo, "renewal_date" => $domain->RenewalDate);
mailer_send("renew_notice.eml", $args, $userinfo["email"], $userinfo["name"]);
Application::FireEvent('DomainAboutToExpire', $domain, $days_before_expire);
}
}
}
示例8: RenewDomain
/**
* This method request registry to renew domain
*
* @param string $domain Domain
* @param array $extradata Extra fields
* @return RenewDomainResponse
*/
public function RenewDomain(Domain $domain, $extra = array())
{
$params = array('name' => $domain->GetHostName());
$response = $this->Request("domain-undelete", $params);
$status = $response->Succeed ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED;
$ret = new RenewDomainResponse($status, $response->ErrMsg, $response->Code);
if ($ret->Succeed()) {
$ret->ExpireDate = $domain->ExpireDate + $domain->Period * 86400 * 365;
}
return $ret;
}
示例9: UpdateDomainContact
public function UpdateDomainContact(Domain $domain, $contactType, Contact $oldContact, Contact $newContact)
{
if (!$newContact && !$oldContact)
throw new Exception("At leat one contact (\$newContact or \$oldContact) must be passed into UpdateDomainContact");
if ($contactType == CONTACT_TYPE::TECH &&
preg_match('/^\d+/', $domain->GetContact(CONTACT_TYPE::REGISTRANT)->CLID))
{
throw new Exception("Domain transfer from SWITCH was buggy. You must update registrant contact first");
}
$params = array(
"name" => $this->MakeNameIDNCompatible($domain->GetHostName()),
"change" => "",
"add" => "",
"rem" => ""
);
if ($contactType == CONTACT_TYPE::REGISTRANT)
$params["change"] = "<domain:chg><domain:registrant>{$newContact->CLID}</domain:registrant></domain:chg>";
else
{
if ($newContact)
$params['add'] = '<domain:add><domain:contact type="'.$contactType.'">'.$newContact->CLID.'</domain:contact></domain:add>';
if ($oldContact && !preg_match('/^\d+/', $oldContact->CLID))
$params['rem'] = '<domain:rem><domain:contact type="'.$contactType.'">'.$oldContact->CLID.'</domain:contact></domain:rem>';
}
$response = $this->Request("domain-update-contact", $params);
$status = ($response->Succeed) ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED;
// Hack for bad transferred from SWITCH
if ($response->Succeed && preg_match('/^\d+/', $oldContact->CLID) && $contactType == CONTACT_TYPE::REGISTRANT)
{
$domain->SetContact(null, CONTACT_TYPE::TECH);
}
return new UpdateDomainContactResponse($status, $response->ErrMsg, $response->Code);
}
示例10: OnDomainTransferFailed
public function OnDomainTransferFailed(Domain $domain)
{
var_dump('transfer failed: ' . $domain->GetHostName());
}
示例11: OnDomainDeleted
public function OnDomainDeleted(Domain $domain)
{
$id = $this->Db->GetOne("\r\n\t\t\t\tSELECT domain_key FROM whois_domain \r\n\t\t\t\tWHERE domain = ?", array($domain->GetHostName()));
if ($id) {
$this->Db->Execute("\r\n\t\t\t\t\tDELETE FROM whois_nameserver WHERE domain_fkey = ?", array($id));
$this->Db->Execute("\r\n\t\t\t\t\tDELETE FROM whois_domain \r\n\t\t\t\t\tWHERE domain = ?", array($domain->GetHostName()));
}
}
示例12: PollTransfer
public function PollTransfer(Domain $domain)
{
$params = array('name' => $this->MakeNameIDNCompatible($domain->GetHostName()), 'pw' => $this->EscapeXML($domain->AuthCode));
$Resp = $this->Request('domain-info', $params);
if ($Resp->Succeed) {
$infData = $Resp->Data->response->resData->children("urn:ietf:params:xml:ns:domain-1.0");
$infData = $infData[0];
// transfer complete when trDate node exists.
$ok = $infData->trDate->getName() != '';
$trStatus = $ok ? TRANSFER_STATUS::APPROVED : TRANSFER_STATUS::PENDING;
$respStatus = $trStatus != TRANSFER_STATUS::PENDING ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::PENDING;
$Ret = new PollTransferResponse($respStatus, $Resp->ErrMsg, $Resp->Code);
$Ret->HostName = $domain->GetHostName();
$Ret->TransferStatus = $trStatus;
return $Ret;
} else {
return new PollTransferResponse(REGISTRY_RESPONSE_STATUS::FAILED, $Resp->ErrMsg, $Resp->Code);
}
}
示例13: TransferRequest
/**
* This method request registry to transfer domain
* In order to pending operation, response must have status REGISTRY_RESPONSE_STATUS::PENDING
*
* @param string $domain Domain
* @param array $extradata Extra fields
* @return TransferRequestResponse
*/
public function TransferRequest(Domain $domain, $extra = array())
{
$params = array('name' => $domain->GetHostName(), 'pw' => $this->EscapeXML($extra["pw"]), 'type' => $this->GetDomainType());
$response = $this->Request('domain-trans-request', $params);
$status = $response->Succeed ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED;
$ret = new TransferRequestResponse($status, $response->ErrMsg, $response->Code);
$ret->Result = $response->Succeed;
return $ret;
}
示例14: OnDomainTransferRequested
function OnDomainTransferRequested(Domain $domain)
{
$ops = $this->RegistryAccessible->GetPendingOperationList(Registry::OBJ_DOMAIN, $domain->ID);
foreach ($ops as $op) {
if ($op->Type == Registry::OP_TRANSFER) {
$resp = new PollTransferResponse();
$resp->HostName = $domain->GetHostName();
$resp->TransferStatus = TRANSFER_STATUS::APPROVED;
$this->RegistryAccessible->DispatchPollTransfer($resp);
$this->RegistryAccessible->RemovePendingOperation($op->ID);
break;
}
}
}
示例15: MarkAsExpired
private function MarkAsExpired (Domain $Domain)
{
$db = Core::GetDBInstance();
//Set to domain 'Expired'
Log::Log(sprintf("Mark domain '%s' as expired", $Domain->GetHostName()), E_USER_NOTICE);
$db->Execute("UPDATE domains SET status = ? WHERE id = ?", array(DOMAIN_STATUS::EXPIRED, $Domain->ID));
// Mark invoice as 'Failed'
$db->Execute("UPDATE invoices SET status = ? WHERE itemid = ? AND status = ? AND purpose = ?",
array(INVOICE_STATUS::FAILED, $Domain->ID, INVOICE_STATUS::PENDING, INVOICE_PURPOSE::DOMAIN_RENEW));
$userinfo = $db->GetRow("SELECT * FROM users WHERE id = ?", array($Domain->UserID));
// Send domain expired notice
$args = array
(
"login" => $userinfo["login"],
"domain_name" => $Domain->Name,
"extension" => $Domain->Extension,
"client" => $userinfo
);
mailer_send("expired_notice.eml", $args, $userinfo["email"], $userinfo["name"]);
}