-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathcreatelaunchdomain.php
80 lines (70 loc) · 3.07 KB
/
createlaunchdomain.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
require('../autoloader.php');
use Metaregistrar\EPP\eppConnection;
use Metaregistrar\EPP\eppException;
use Metaregistrar\EPP\eppDomain;
use Metaregistrar\EPP\eppContactHandle;
use Metaregistrar\EPP\eppHost;
use Metaregistrar\EPP\eppLaunchCreateDomainRequest;
/*
* This sample script registers a domain name within your account for a specific launch phase
*
* The nameservers of metaregistrar are used as nameservers
* In this scrips, the same contact id is used for registrant, admin-contact, tech-contact and billing contact
* Recommended usage is that you use a tech-contact and billing contact of your own, and set registrant and admin-contact to the domain name owner or reseller.
*/
if ($argc <= 1) {
echo "Usage: createlaunchdomain.php <domainname>\n";
echo "Please enter the domain name to be created\n\n";
die();
}
$domainname = $argv[1];
echo "Registering $domainname\n";
try {
// Please enter your own settings file here under before using this example
if ($conn = eppConnection::create('')) {
// Connect to the EPP server
if ($conn->login()) {
$contactid = 'mrg54b6560e01ddf';
$techcontact = $contactid;
$billingcontact = $contactid;
if ($contactid) {
createdomain($conn, $domainname, $contactid, $contactid, $techcontact, $billingcontact, array('ns1.metaregistrar.nl', 'ns2.metaregistrar.nl'));
}
$conn->logout();
}
}
} catch (eppException $e) {
echo "ERROR: " . $e->getMessage() . "\n\n";
}
/**
* @param $conn eppConnection
* @param $domainname string
* @param $registrant string
* @param $admincontact string
* @param $techcontact string
* @param $billingcontact string
* @param $nameservers array
* @return bool
*/
function createdomain($conn, $domainname, $registrant, $admincontact, $techcontact, $billingcontact, $nameservers) {
$domain = new eppDomain($domainname, $registrant);
$domain->setRegistrant(new eppContactHandle($registrant));
$domain->addContact(new eppContactHandle($admincontact, eppContactHandle::CONTACT_TYPE_ADMIN));
$domain->addContact(new eppContactHandle($techcontact, eppContactHandle::CONTACT_TYPE_TECH));
$domain->addContact(new eppContactHandle($billingcontact, eppContactHandle::CONTACT_TYPE_BILLING));
$domain->setAuthorisationCode($domain->generateRandomString(12));
if (is_array($nameservers)) {
foreach ($nameservers as $nameserver) {
$domain->addHost(new eppHost($nameserver));
}
}
$create = new eppLaunchCreateDomainRequest($domain);
$create->setLaunchPhase('claims', 'application');
if ($response = $conn->request($create)) {
/* @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";
}
return null;
}