本文整理汇总了PHP中Domain::GetContactList方法的典型用法代码示例。如果您正苦于以下问题:PHP Domain::GetContactList方法的具体用法?PHP Domain::GetContactList怎么用?PHP Domain::GetContactList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domain
的用法示例。
在下文中一共展示了Domain::GetContactList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CreateDomain
/**
* Create domain and return transaction status
*
* @access public
* @param Domain $domain
* @param int $period Domain registration period
* @param array $extra Extra data
* @version v1000
* @return Domain
*/
public function CreateDomain(Domain $domain, $period, $extra = array())
{
// Validate contacts
$contact_list = $domain->GetContactList();
foreach (CONTACT_TYPE::GetKeys() as $contact_type) {
$config = $this->GetManifest()->GetContactConfig($contact_type);
if ($config instanceof SimpleXMLElement) {
if ((int) $config->attributes()->required && !$contact_list[$contact_type]) {
throw new Exception(sprintf(_('%s contact is required'), ucfirst($contact_type)));
}
}
}
//
$nameserver_list = $domain->GetNameserverList();
foreach ($nameserver_list as $ns) {
try {
try {
$can_create = $this->NameserverCanBeCreated($ns);
} catch (NotImplementedException $e) {
$can_create = true;
}
if ($can_create) {
$this->CreateNameserver($ns);
}
} catch (ObjectExistsException $e) {
// Ignore errors
} catch (NotImplementedException $e) {
// Ignore errors
}
}
$this->FireEvent('BeforeCreateDomain', $domain);
$Resp = $this->RegModule->CreateDomain($domain, $period, $extra);
$this->ValidateModuleResponse($Resp, 'CreateDomainResponse');
if ($Resp->IsFailed()) {
Log::Log(sprintf('CreateDomain failed. Registry error: %s', $Resp->ErrMsg), E_USER_ERROR);
throw new RegistryException($Resp->ErrMsg, $Resp->Code);
}
$domain->Period = $period;
$domain->AuthCode = $Resp->AuthCode;
$domain->CreateDate = $Resp->CreateDate;
$domain->ExpireDate = $Resp->ExpireDate;
$domain->Protocol = $Resp->Protocol;
$domain->Status = $Resp->Status == REGISTRY_RESPONSE_STATUS::PENDING ? DOMAIN_STATUS::REGISTRATION_PENDING : DOMAIN_STATUS::DELEGATED;
$domain->IncompleteOrderOperation = null;
if ($domain->Status == DOMAIN_STATUS::DELEGATED) {
$this->FireEvent('DomainOperation', $domain, self::OP_CREATE);
$this->FireEvent('DomainCreated', $domain);
} else {
if ($domain->Status == DOMAIN_STATUS::REGISTRATION_PENDING) {
$this->AddPendingOperation($domain, self::OP_CREATE, $Resp->OperationId);
}
}
$this->DBDomain->Save($domain);
// db operation
return $domain;
}
示例2: CreateDomain
public function CreateDomain(Domain $domain, $period, $extra = array())
{
$contacts = $domain->GetContactList();
$params = array(
"name" => $this->MakeNameIDNCompatible($domain->GetHostName()),
"registrant_id" => $contacts['registrant']->CLID,
"period" => $period,
"pw" => $domain->AuthCode ? $domain->AuthCode : rand(100000000, 999999999)
);
unset($contacts[CONTACT_TYPE::REGISTRANT]);
$params['contacts'] = '';
foreach ($contacts as $contact_type => $contact)
$params['contacts'] .= '<domain:contact type="'.$contact_type.'">'.$contact->CLID.'</domain:contact>';
$this->BeforeRequest('domain-create', $params, __METHOD__, $domain, $period, $extra);
$response = $this->Request("domain-create", $params);
$resp = new CreateDomainResponse(
$this->GetResponseStatusFromEPPResponse($response),
$response->ErrMsg, $response->Code
);
if ($response->Succeed)
{
// Fill response
$info = $response->Data->response->resData->children($this->XmlNamespaces['domain']);
$info = $info[0];
$resp->CreateDate = $this->StrToTime((string)$info->crDate[0]);
$resp->ExpireDate = $this->StrToTime((string)$info->exDate[0]);
$resp->AuthCode = (string)$params["pw"];
if ($nameservers = $domain->GetNameserverList())
{
// XXX AD and PIZDETS
// registration process in AFNIC contains 2 steps:
// 1. create domain without nameservers; epp code = 1000
// 2. update created domain with nameservers; epp code = 1001
$Changes = new Changelist(array(), $nameservers);
$UpdateResponse = $this->UpdateDomainNameservers($domain, $Changes);
if ($UpdateResponse->Pending())
{
// Need this to lock domain update
// before we recive operation result via poll message.
$domain->AddPendingOperation(Registry::OP_UPDATE);
}
}
}
return $resp;
}
示例3: Save
/**
* Save domain in database
*
* @param Domain $domain
* @return Domain
*/
public function Save(Domain $domain)
{
if (!$domain->ID) {
// check for duplicate domain
$duplicate = $this->DB->GetOne('SELECT COUNT(*) FROM domains WHERE name = ? AND TLD = ?', array($domain->Name, $domain->Extension));
if ($duplicate) {
throw new Exception(sprintf(_('Domain %s already exists in DB and could\'t be added twice'), $domain->GetHostName()));
}
}
// Properties data
$row = array();
foreach ($this->FieldPropertyMap as $field => $property) {
$row[$field] = $domain->{$property} !== null ? $domain->{$property} : "";
}
if ($domain->IncompleteOrderOperation === null) {
$row['incomplete_operation'] = null;
}
// Nameservers data
$nslist = $domain->GetNameserverList();
// If nameservers list smaller then size of db slots
for ($i = 2; $i > count($ns_list); $i--) {
$row['ns' . $i] = '';
}
$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
//.........这里部分代码省略.........
示例4: CreateDomain
/**
* Create domain and return transaction status
*
* Domain info is an array of the following structure:
* Fill domain Data with this values
*
* "crDate" => string Creation DateTime,
* "exDate" => Expiration DateTime,
* "status" => string Status code,
* "pw" => string Password generated by registry,
* "protocol" => string Protocol
*
* @access public
* @param Domain $domain Domain name without TLD
* @param array $owner_contact Domain Owner contact array
* @param array $admin_contact Domain Admin contact array
* @param array $tech_contact Domain Tech contact array
* @param array $billing_contact Domain Billing contact array
* @param array $extra Domain Billing contact array
* @param integer $period Registration period, years
* @param array $nameservers Array of strings containing nameservers hostnames
*
* @return CreateDomainResponse
*/
public function CreateDomain(Domain $domain, $period, $extra = array())
{
$contacts = $domain->GetContactList();
$nameservers = $domain->GetNameserverList();
$params = array(
"name" => $this->MakeNameIDNCompatible($domain->GetHostName()),
"registrant_id" => $contacts['registrant']->CLID,
"ns1" => $nameservers[0]->HostName,
"ns2" => $nameservers[1]->HostName,
"period" => $period,
"pw" => $domain->AuthCode ? $domain->AuthCode : rand(100000000, 999999999)
);
unset($contacts[CONTACT_TYPE::REGISTRANT]);
$params['contacts'] = '';
foreach ($contacts as $contact_type => $contact)
$params['contacts'] .= '<domain:contact type="'.$contact_type.'">'.$contact->CLID.'</domain:contact>';
$params['ns'] = count($nameservers) ? '<domain:ns>' . $this->GetNSXML($nameservers) . '</domain:ns>' : '';
$this->BeforeRequest('domain-create', $params, __METHOD__, $domain, $period, $extra);
$response = $this->Request("domain-create", $params);
if ($response->Code == RFC3730_RESULT_CODE::OK_PENDING)
$status = REGISTRY_RESPONSE_STATUS::PENDING;
elseif ($response->Succeed)
$status = REGISTRY_RESPONSE_STATUS::SUCCESS;
else
$status = REGISTRY_RESPONSE_STATUS::FAILED;
$resp = new CreateDomainResponse($status, $response->ErrMsg, $response->Code);
$resp->RawResponse = $response->Data;
if ($response->Succeed)
{
$info = $response->Data->response->resData->children($this->XmlNamespaces['domain']);
$info = $info[0];
if ($date = $this->StrToTime((string)$info->crDate[0]))
$resp->CreateDate = $date;
if ($date = $this->StrToTime((string)$info->exDate[0]))
$resp->ExpireDate = $date;
else
$resp->ExpireDate = strtotime("+{$period} year");
$resp->AuthCode = "{$info->authInfo->pw}" ? "{$info->authInfo->pw}" : (string)$params["pw"];
}
return $resp;
}
示例5: 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())
{
$contact_list = $domain->GetContactList();
$params = array("DOMAIN" => $domain->Name, "TLD" => $this->Extension, "CURRENT ADMIN EMAIL" => $extra["temail"], "AUTH_CODE" => $extra["pw"]);
foreach ($contact_list as $contacttype => $contact) {
$params[$this->ContacttypeSRSMap[$contacttype]] = $contact->CLID;
}
$Resp = $this->Request('REQUEST TRANSFER', $params);
$status = $Resp->Succeed && $Resp->Data['TRANSFERID'] ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED;
$Ret = new TransferRequestResponse($status, $Resp->ErrMsg);
$Ret->TransferID = (string) $Resp->Data['TRANSFERID'];
$Ret->Result = $Ret->Succeed();
return $Ret;
}
示例6: UpdateContactsAfterTransfer
public function UpdateContactsAfterTransfer(Domain $Domain, Domain $Saved)
{
$domainName = $this->MakeNameIDNCompatible($Saved->GetHostName());
// Flags, indicates that saved contact will be assigned to transferred domain.
$assignSavedContacts = array();
foreach (CONTACT_TYPE::GetKeys() as $ctype) {
$assignSavedContacts[$ctype] = 1;
}
if (in_array($this->Extension, array("be", "eu", "it", "nl"))) {
$GrdResponse = $this->GetRemoteDomain($Domain);
foreach (CONTACT_TYPE::GetKeys() as $ctype) {
$clid_property = ucfirst($ctype) . "Contact";
// ex: RegistrantContact
$clid = $GrdResponse->{$clid_property};
// clid started from domain TLD means native registry contact,
// which is unoperational by rrpproxy api.
// ex: be.tr55322
if (preg_match("/^{$this->Extension}/", $clid)) {
// Create dummy contact with non-strict fields and assign it to domain.
$Contact = $this->RegistryAccessible->NewContactInstance($ctype);
$Contact->CLID = $clid;
$Contact->SetFieldList(array("firstname" => $clid), 0);
$Domain->SetContact($Contact, $ctype);
}
// Контакты заданные при инициации трансфера не применяются к домену.
$assignSavedContacts[$ctype] = 0;
// Возможна ситуация когда среди нативных контактов попадаются rrpproxy-вые,
// они импортируются в БД ЕПП-ДРС.
// ex:
// property[billing contact][0] = eu.c89406
// property[owner contact][0] = eu.c10720031
// property[admin contact][0] = eu.c10720031
// property[tech contact][0] = P-JZW723
// P-JZW723 будет запрошен операцией GetRemoteContact аплевел кодом;
// для остальных контактов будут созданы заглушки.
}
} else {
if ("nu" == $this->Extension) {
// In .NU change registrant is a special operation that requires fax sending.
// Sync registrant contact, update admin, tech, billing
try {
$Registrant = $Domain->GetContact(CONTACT_TYPE::REGISTRANT);
$Registrant = $this->RegistryAccessible->GetRemoteContact($Registrant);
$Domain->SetContact($Registrant, CONTACT_TYPE::REGISTRANT);
$assignSavedContacts[CONTACT_TYPE::REGISTRANT] = 0;
} catch (Exception $e) {
throw new Exception("Cannot synchronize registrant contact with registry. {$e->getMessage()}");
}
$params = array('domain' => $domainName);
foreach (array("admin", "billing", "tech") as $ctype) {
$params["{$ctype}contact0"] = $Saved->GetContact($ctype)->CLID;
}
$response = $this->Request("ModifyDomain", $params);
} else {
// Default behaviour:
// Set new contacts in an atomic operation
$params = array('domain' => $domainName, 'ownercontact0' => $Saved->GetContact(CONTACT_TYPE::REGISTRANT)->CLID);
foreach (array("admin", "billing", "tech") as $ctype) {
$params["{$ctype}contact0"] = $Saved->GetContact($ctype)->CLID;
}
$response = $this->Request("ModifyDomain", $params);
}
}
// Set updated contacts to domain.
foreach ($Saved->GetContactList() as $ctype => $Contact) {
if ($assignSavedContacts[$ctype]) {
$Domain->SetContact($Contact, $ctype);
}
}
}