function createdomain($conn, $domainname, $registrant, $admincontact, $techcontact, $billingcontact, $nameservers)
{
    try {
        $domain = new Metaregistrar\EPP\eppDomain($domainname, $registrant);
        $reg = new Metaregistrar\EPP\eppContactHandle($registrant);
        $domain->setRegistrant($reg);
        $admin = new Metaregistrar\EPP\eppContactHandle($admincontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_ADMIN);
        $domain->addContact($admin);
        $tech = new Metaregistrar\EPP\eppContactHandle($techcontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_TECH);
        $domain->addContact($tech);
        $billing = new Metaregistrar\EPP\eppContactHandle($billingcontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_BILLING);
        $domain->addContact($billing);
        $domain->setAuthorisationCode($domain->generateRandomString(12));
        if (is_array($nameservers)) {
            foreach ($nameservers as $nameserver) {
                $host = new Metaregistrar\EPP\eppHost($nameserver);
                $domain->addHost($host);
            }
        }
        $create = new Metaregistrar\EPP\eppLaunchCreateDomainRequest($domain);
        $create->setLaunchPhase('claims', 'application');
        if (($response = $conn->writeandread($create)) instanceof Metaregistrar\EPP\eppLaunchCreateDomainResponse && $response->Success()) {
            /* @var Metaregistrar\EPP\eppLaunchCreateDomainResponse $response */
            echo "Domain " . $response->getDomainName() . " created on " . $response->getDomainCreateDate() . ", expiration date is " . $response->getDomainExpirationDate() . "\n";
            echo "Registration phase: " . $response->getLaunchPhase() . " and Application ID: " . $response->getLaunchApplicationID() . "\n";
        } else {
            var_dump($response);
        }
    } catch (Metaregistrar\EPP\eppException $e) {
        echo $e->getMessage() . "\n";
        return false;
    }
}
 /**
  * Test update of hosts on a domain name
  * Expects a standard result for a free domainname
  */
 public function testUpdateDomainHostAttr()
 {
     $domainname = self::randomstring(30) . '.frl';
     $domain = new Metaregistrar\EPP\eppDomain($domainname);
     $add = null;
     $del = new Metaregistrar\EPP\eppDomain($domainname);
     $d1 = new Metaregistrar\EPP\eppHost('ns1.metaregistrar.nl');
     $d2 = new Metaregistrar\EPP\eppHost('ns2.metaregistrar.nl');
     $del->addHost($d1);
     $del->addHost($d2);
     $mod = new Metaregistrar\EPP\eppDomain($domainname);
     $h1 = new Metaregistrar\EPP\eppHost('ns1.metaregistrar.nl');
     $h2 = new Metaregistrar\EPP\eppHost('ns2.metaregistrar.nl');
     $mod->addHost($h1);
     $mod->addHost($h2);
     $update = new Metaregistrar\EPP\eppUpdateDomainRequest($domain, $add, $del, $mod, true);
     //echo $update->saveXML();
     $this->setExpectedException('Metaregistrar\\EPP\\eppException', "Error 2001: Command syntax error; value:line: 2 column: 851 cvc-complex-type.2.4.a: Invalid content was found starting with element 'domain:ns'. One of '{\"urn:ietf:params:xml:ns:domain-1.0\":registrant, \"urn:ietf:params:xml:ns:domain-1.0\":authInfo}' is expected.");
     $response = $this->conn->writeandread($update);
     $this->assertFalse($response->Success());
 }
示例#3
0
function modifydomain($conn, $domainname, $registrant = null, $admincontact = null, $techcontact = null, $billingcontact = null, $nameservers = null)
{
    try {
        $domain = new Metaregistrar\EPP\eppDomain($domainname);
        // First, retrieve the current domain info. Nameservers can be unset and then set again.
        $del = null;
        $info = new Metaregistrar\EPP\eppInfoDomainRequest($domain);
        if (($response = $conn->writeandread($info)) instanceof Metaregistrar\EPP\eppInfoDomainResponse && $response->Success()) {
            // If new nameservers are given, get the old ones to remove them
            if (is_array($nameservers)) {
                /* @var Metaregistrar\EPP\eppInfoDomainResponse $response */
                $oldns = $response->getDomainNameservers();
                if (is_array($oldns)) {
                    if (!$del) {
                        $del = new Metaregistrar\EPP\eppDomain($domainname);
                    }
                    foreach ($oldns as $ns) {
                        $del->addHost($ns);
                    }
                }
            }
        }
        // In the UpdateDomain command you can set or add parameters
        // - Registrant is always set (you can only have one registrant)
        // - Admin, Tech, Billing contacts are Added (you can have multiple contacts, don't forget to remove the old ones)
        // - Nameservers are Added (you can have multiple nameservers, don't forget to remove the old ones
        $mod = null;
        if ($registrant) {
            $mod = new Metaregistrar\EPP\eppDomain($domainname);
            $reg = new Metaregistrar\EPP\eppContactHandle($registrant);
            $mod->setRegistrant($reg);
        }
        $add = null;
        if ($admincontact) {
            if (!$add) {
                $add = new Metaregistrar\EPP\eppDomain($domainname);
            }
            $admin = new Metaregistrar\EPP\eppContactHandle($admincontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_ADMIN);
            $add->addContact($admin);
        }
        if ($techcontact) {
            if (!$add) {
                $add = new Metaregistrar\EPP\eppDomain($domainname);
            }
            $tech = new Metaregistrar\EPP\eppContactHandle($techcontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_TECH);
            $add->addContact($tech);
        }
        if ($billingcontact) {
            if (!$add) {
                $add = new Metaregistrar\EPP\eppDomain($domainname);
            }
            $billing = new Metaregistrar\EPP\eppContactHandle($billingcontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_BILLING);
            $add->addContact($billing);
        }
        if (is_array($nameservers)) {
            if (!$add) {
                $add = new Metaregistrar\EPP\eppDomain($domainname);
            }
            foreach ($nameservers as $nameserver) {
                $host = new Metaregistrar\EPP\eppHost($nameserver);
                $add->addHost($host);
            }
        }
        $update = new Metaregistrar\EPP\eppUpdateDomainRequest($domain, $add, $del, $mod);
        if (($response = $conn->writeandread($update)) instanceof Metaregistrar\EPP\eppUpdateResponse && $response->Success()) {
            /* @var Metaregistrar\EPP\eppUpdateResponse $response */
            echo $response->getResultMessage() . "\n";
        }
    } catch (Metaregistrar\EPP\eppException $e) {
        echo $e->getMessage() . "\n";
        if ($response instanceof Metaregistrar\EPP\eppUpdateResponse) {
            echo $response->textContent . "\n";
        }
    }
}
/**
 * @param Metaregistrar\EPP\eppConnection $conn
 * @param string $domainname
 * @param Metaregistrar\TMCH\tmchClaimData $claim
 * @param string $registrant
 * @param string $admincontact
 * @param string $techcontact
 * @param string $billingcontact
 * @param array $nameservers
 */
function createclaimeddomain($conn, $domainname, $claim, $registrant, $admincontact, $techcontact, $billingcontact, $nameservers)
{
    try {
        $domain = new Metaregistrar\EPP\eppDomain($domainname, $registrant);
        $domain->setPeriod(1);
        $reg = new Metaregistrar\EPP\eppContactHandle($registrant);
        $domain->setRegistrant($reg);
        if ($admincontact) {
            $admin = new Metaregistrar\EPP\eppContactHandle($admincontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_ADMIN);
            $domain->addContact($admin);
        }
        if ($techcontact) {
            $tech = new Metaregistrar\EPP\eppContactHandle($techcontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_TECH);
            $domain->addContact($tech);
        }
        if ($billingcontact) {
            $billing = new Metaregistrar\EPP\eppContactHandle($billingcontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_BILLING);
            $domain->addContact($billing);
        }
        $domain->setAuthorisationCode($domain->generateRandomString(8));
        if (is_array($nameservers)) {
            foreach ($nameservers as $nameserver) {
                $host = new Metaregistrar\EPP\eppHost($nameserver);
                $domain->addHost($host);
            }
        }
        $create = new Metaregistrar\EPP\eppLaunchCreateDomainRequest($domain);
        $create->setLaunchPhase('claims');
        //$create->setLaunchCodeMark($domainname.';'.base64_encode(hash('sha512',$domainname.'MetaregistrarRocks!',true)),'Metaregistrar');
        $create->addLaunchClaim('tmch', $claim['noticeid'], $claim['notafter'], $claim['confirmed']);
        echo $create->saveXML();
        if (($response = $conn->writeandread($create)) instanceof Metaregistrar\EPP\eppLaunchCreateDomainResponse && $response->Success()) {
            /* @var Metaregistrar\EPP\eppLaunchCreateDomainResponse $response */
            echo $response->saveXML();
            echo "Domain " . $response->getDomainName() . " created on " . $response->getDomainCreateDate() . ", expiration date is " . $response->getDomainExpirationDate() . "\n";
            //echo "Registration phase: ".$response->getLaunchPhase()." and Application ID: ".$response->getLaunchApplicationID()."\n";
        }
    } catch (Metaregistrar\EPP\eppException $e) {
        echo $e->getMessage() . "\n";
    }
}
示例#5
0
function createdomain($conn, $domainname, $registrant, $admincontact, $techcontact, $billingcontact, $nameservers)
{
    /* @var $conn Metaregistrar\EPP\eppConnection */
    try {
        $domain = new Metaregistrar\EPP\eppDomain($domainname, $registrant);
        $reg = new Metaregistrar\EPP\eppContactHandle($registrant);
        $domain->setRegistrant($reg);
        $admin = new Metaregistrar\EPP\eppContactHandle($admincontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_ADMIN);
        $domain->addContact($admin);
        $tech = new Metaregistrar\EPP\eppContactHandle($techcontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_TECH);
        $domain->addContact($tech);
        $billing = new Metaregistrar\EPP\eppContactHandle($billingcontact, Metaregistrar\EPP\eppContactHandle::CONTACT_TYPE_BILLING);
        $domain->addContact($billing);
        $domain->setAuthorisationCode('rand0m');
        if (is_array($nameservers)) {
            foreach ($nameservers as $nameserver) {
                $host = new Metaregistrar\EPP\eppHost($nameserver);
                $domain->addHost($host);
            }
        }
        $create = new Metaregistrar\EPP\eppCreateDomainRequest($domain, true);
        if (($response = $conn->writeandread($create)) instanceof Metaregistrar\EPP\eppCreateResponse && $response->Success()) {
            /* @var $response Metaregistrar\EPP\eppCreateResponse */
            echo "Domain " . $response->getDomainName() . " created on " . $response->getDomainCreateDate() . ", expiration date is " . $response->getDomainExpirationDate() . "\n";
        }
    } catch (Metaregistrar\EPP\eppException $e) {
        echo $e->getMessage() . "\n";
    }
}
示例#6
0
function updatedomainremovehost($conn, $domainname, $hosts)
{
    try {
        $domain = new Metaregistrar\EPP\eppDomain($domainname);
        $remove = new Metaregistrar\EPP\eppDomain($domainname);
        foreach ($hosts as $host) {
            $h = new Metaregistrar\EPP\eppHost($host);
            $remove->addHost($h);
        }
        $up = new Metaregistrar\EPP\eppUpdateRequest($domain, null, $remove, null);
        if (($response = $conn->writeandread($up)) instanceof Metaregistrar\EPP\eppUpdateResponse && $response->Success()) {
            echo "Domain {$domainname} updated, infoing\n";
            infodomain($conn, $domainname);
        }
    } catch (Metaregistrar\EPP\eppException $e) {
        echo $e->getMessage() . "\n";
    }
}