if ($argc <= 1) { echo "Usage: registerdomain.php <domainname>\n"; echo "Please enter the domain name to be created\n\n"; die; } $domainname = $argv[1]; echo "Registering {$domainname}\n"; $conn = new Metaregistrar\EPP\metaregEppConnection(); // Connect to the EPP server if ($conn->connect()) { if (login($conn)) { if (!checkhosts($conn, array('ns1.metaregistrar.nl'))) { createhost($conn, 'ns1.metaregistrar.nl'); } if (!checkhosts($conn, array('ns5.metaregistrar.nl'))) { createhost($conn, 'ns2.metaregistrar.nl'); } $nameservers = array('ns1.metaregistrar.nl', 'ns2.metaregistrar.nl'); $contactid = createcontact($conn, '*****@*****.**', '+31.61234567890', 'Person name', null, 'Address 1', '12345', 'City', 'NL'); if ($contactid) { createdomain($conn, $domainname, $contactid, $contactid, $contactid, $contactid, $nameservers); } logout($conn); } } function checkcontact($conn, $contactid) { /* @var $conn Metaregistrar\EPP\eppConnection */ try { $contactinfo = new Metaregistrar\EPP\eppContactHandle($contactid); $check = new Metaregistrar\EPP\eppCheckRequest($contactinfo);
use Metaregistrar\EPP\eppConnection; use Metaregistrar\EPP\eppException; use Metaregistrar\EPP\eppHost; use Metaregistrar\EPP\eppCreateHostRequest; if ($argc <= 1) { echo "Usage: createhost.php <hostname>\n"; echo "Please a host name to create\n\n"; die; } $hostname = $argv[1]; 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()) { createhost($conn, $hostname); $conn->logout(); } } } catch (eppException $e) { echo "ERROR: " . $e->getMessage() . "\n\n"; } /** * @param $conn eppConnection * @param $hostname string * @return null */ function createhost($conn, $hostname) { $create = new eppCreateHostRequest(new eppHost($hostname)); if ($response = $conn->request($create)) {
function checkandcreatehosts($conn, $hosts) { try { foreach ($hosts as $host) { $checkhost[] = new Metaregistrar\EPP\eppHost($host); } $check = new Metaregistrar\EPP\eppCheckRequest($checkhost); if (($response = $conn->writeandread($check)) instanceof Metaregistrar\EPP\eppCheckResponse && $response->Success()) { $checks = $response->getCheckedHosts(); foreach ($checks as $hostname => $check) { echo "{$hostname} " . ($check ? 'does not exist' : 'exists') . "\n"; if ($check) { if ($hostname == '') { $ipaddress[] = '81.4.97.131'; //$ipaddress[] = 'fe80:0:0:0:200:f8ff:fe21:67cf'; } else { $ipaddress[] = '188.93.148.99'; //$ipaddress[] = '2a00:4e40:1:1:0:5:3'; } echo "Creating host {$hostname} \n"; createhost($conn, $hostname, $ipaddress); } } } } catch (Metaregistrar\EPP\eppException $e) { echo $e->getMessage() . "\n"; } }