Skip to content

Commit

Permalink
Added euridEppCreateDomainRequest for .EU domain names
Browse files Browse the repository at this point in the history
  • Loading branch information
metaregistrar committed Jun 12, 2018
1 parent 973cb71 commit d247134
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Examples/registerdomain.php → Examples/createdomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

if ($argc <= 1)
{
echo "Usage: registerdomain.php <domainname>\n";
echo "Usage: createdomain.php <domainname>\n";
echo "Please enter the domain name to be created\n\n";
die();
}
Expand Down
3 changes: 2 additions & 1 deletion Protocols/EPP/eppData/eppContactHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class eppContactHandle {
const CONTACT_TYPE_ADMIN = 'admin';
const CONTACT_TYPE_TECH = 'tech';
const CONTACT_TYPE_BILLING = 'billing';
const CONTACT_TYPE_ONSITE = 'onsite'; //USED FOR .EU AND .BE ONLY
/**
* Registry handle of contact
* @var string
Expand Down Expand Up @@ -41,7 +42,7 @@ public function __construct($contactHandle, $contactType = null) {
if ($contactType) {
$this->setContactType($contactType);
}
if (($contactType != null) && ($contactType != self::CONTACT_TYPE_ADMIN) && ($contactType != self::CONTACT_TYPE_REGISTRANT) && ($contactType != self::CONTACT_TYPE_BILLING) && ($contactType != self::CONTACT_TYPE_TECH)) {
if (($contactType != null) && ($contactType != self::CONTACT_TYPE_ADMIN) && ($contactType != self::CONTACT_TYPE_REGISTRANT) && ($contactType != self::CONTACT_TYPE_BILLING) && ($contactType != self::CONTACT_TYPE_TECH) && ($contactType != self::CONTACT_TYPE_ONSITE)) {
throw new eppException('Invalid contact type: ' . $contactType);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class euridEppContact extends eppContact {
#

const CONTACT_EXT_TYPES = ['registrant', 'tech', 'onsite', 'reseller'];

const EURID_EXT_CONTACT_REGISTRANT = 'registrant';
const EURID_EXT_CONTACT_TECH = 'tech';
const EURID_EXT_CONTACT_ONSITE = 'onsite';
const EURID_EXT_CONTACT_RESELLER = 'reseller';

private $contactExtType;
private $contactExtLang = 'en';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
namespace Metaregistrar\EPP;

/*
<?xml version='1.0' encoding='UTF-8'?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<domain:create xmlns:domain='urn:ietf:params:xml:ns:domain-1.0'>
<domain:name>domainname.eu</domain:name>
<domain:ns>
<domain:hostAttr>
<domain:hostName>a.alpha.al</domain:hostName>
</domain:hostAttr>
<domain:hostAttr>
<domain:hostName>b.bravo.bb</domain:hostName>
</domain:hostAttr>
</domain:ns>
<domain:registrant>xxxxx</domain:registrant>
<domain:contact type='billing'>xxxxx</domain:contact>
</domain:create>
</create>
<extension>
<domain-ext:create xmlns:domain-ext='http://www.eurid.eu/xml/epp/domain-ext-2.1'>
<domain-ext:contact type='onsite'>xxxxx</domain-ext:contact>
<domain-ext:contact type='reseller'>xxxxx</domain-ext:contact>
</domain-ext:create>
</extension>
</command>
</epp>
*/

/**
* Class euridEppCreateDomainRequest
* @package Metaregistrar\EPP
*/
class euridEppCreateDomainRequest extends eppCreateDomainRequest {

function __construct(eppDomain $domain) {
parent::__construct($domain, true);
$this->addContacts($domain);
parent::addSessionId();

}

private function addContacts(eppDomain $domain) {
$created = false;
$create = $this->createElement('domain-ext:create');
$this->setNamespace('xmlns:domain','urn:ietf:params:xml:ns:domain-1.0',$create);
$this->setNamespace('xmlns:domain-ext','http://www.eurid.eu/xml/epp/domain-ext-2.1',$create);

foreach ($domain->getContacts() as $contact) {
/* @var $contact \Metaregistrar\EPP\eppContactHandle */
if (in_array($contact->getContactType(),['onsite','reseller'])) {
$c = $this->createElement('domain-ext:contact',$contact->getContactHandle());
$c->setAttribute('type',$contact->getContactType());
$create->appendChild($c);
$created = true;
}
}
if ($created) {
$this->getExtension()->appendChild($create);
}
}


}
4 changes: 3 additions & 1 deletion Protocols/EPP/eppExtensions/domain-ext-2.1/includes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
$this->addExtension('domain-ext', 'http://www.eurid.eu/xml/epp/domain-ext-2.1');

include_once(dirname(__FILE__) . '/eppRequests/euridEppTransferDomainRequest.php');
$this->addCommandResponse('Metaregistrar\EPP\euridEppTransferDomainRequest', 'Metaregistrar\EPP\eppTransferResponse');

$this->addCommandResponse('Metaregistrar\EPP\euridEppTransferDomainRequest', 'Metaregistrar\EPP\eppTransferResponse');
include_once(dirname(__FILE__) . '/eppRequests/euridEppCreateDomainRequest.php');
$this->addCommandResponse('Metaregistrar\EPP\euridEppCreateDomainRequest', 'Metaregistrar\EPP\eppCreateResponse');
8 changes: 5 additions & 3 deletions Protocols/EPP/eppRequests/eppCreateDomainRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function addSecdns($secdns) {
/**
*
* @param eppDomain $domain
* @return \DOMElement
* @return \DOMElement | null
* @throws eppException
*/
public function setDomain(eppDomain $domain) {
Expand Down Expand Up @@ -116,7 +116,9 @@ public function setDomain(eppDomain $domain) {
if ($domain->getContactLength() > 0) {
foreach ($contacts as $contact) {
/* @var $contact eppContactHandle */
$this->addDomainContact($this->domainobject, $contact->getContactHandle(), $contact->getContactType());
if (in_array($contact->getContactType(),[eppContactHandle::CONTACT_TYPE_ADMIN,eppContactHandle::CONTACT_TYPE_BILLING,eppContactHandle::CONTACT_TYPE_TECH])) {
$this->addDomainContact($this->domainobject, $contact->getContactHandle(), $contact->getContactType());
}
}
}
if (strlen($domain->getAuthorisationCode())) {
Expand All @@ -137,7 +139,7 @@ public function setDomain(eppDomain $domain) {
}
}
}
return;
return null;
}

/**
Expand Down

0 comments on commit d247134

Please sign in to comment.