(→Authcode abrufen) |
|||
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 68: | Zeile 68: | ||
== Transfersperre / Verlängerung / WHOIS-Privacy == | == Transfersperre / Verlängerung / WHOIS-Privacy == | ||
− | . | + | Das Setzen der Transfersperre, von Verlängerungsoptionen und WHOIS-Privacy erfolgt über die Methode <code>changeValues($domain, $status = false, $renew = true, $privacy = false)</code>. Dabei stellen die drei Booleans folgende Werte dar: |
+ | |||
+ | * <code>$status</code> aktiviert die Transfersperre | ||
+ | * <code>$renew</code> aktiviert die automatische Verlängerung | ||
+ | * <code>$privacy</code> aktiviert WHOIS-Privacy | ||
== Domain löschen / in den Transit geben == | == Domain löschen / in den Transit geben == | ||
− | . | + | Um eine Domain zu löschen oder in den Transit zu geben, nutzen Sie die Methode <code>deleteDomain($domain, $transit = 0)</code>. Hierbei ist die Belegung von <code>$transit</code> wie folgt möglich: |
+ | |||
+ | * <code>0</code> - Domain löschen | ||
+ | * <code>1</code> - Konnektierter Transit | ||
+ | * <code>2</code> - Dekonnektierter Transit | ||
== Domain-Synchronisation == | == Domain-Synchronisation == | ||
− | ... | + | Domains werden periodisch synchronisiert, dazu wird die Methode <code>syncDomain($domain, $kkSync = false)</code> aufgerufen. Ist <code>$kkSync</code> auf <code>true</code> gesetzt, befindet sich die Domain noch im Transfer-Status. Sofern die Domain noch nicht transferiert wurde, ist <code>Array("status" => "waiting_kk")</code> zurückzugegeben. |
− | + | Die erwartete Rückgabe für eine registrierte Domain ist ein Array mit den folgenden Schlüsseln: | |
− | + | ||
− | + | * <code>auto_renew</code> - Boolean, der den Status der automatischen Verlängerung zurückgibt | |
− | + | * <code>expiration</code> - Datum des Domainablaufs im Format YYYY-MM-DD | |
+ | * <code>status</code> - Boolean, der den Status der Domain (aktiv/nicht aktiv) zurückgibt | ||
+ | * <code>transfer_lock</code> - Boolean, der angibt, ob die Transfer-Sperre aktiviert ist | ||
+ | * <code>privacy</code> - Boolean, der den Status der WHOIS-Privacy angibt | ||
== Beispiel-Code == | == Beispiel-Code == | ||
− | ... | + | <source lang="php"> |
+ | <?php | ||
+ | |||
+ | class InterNetWorX extends DomainRegistrar { | ||
+ | protected $short = "inwx"; | ||
+ | protected $name = "InterNetWorX"; | ||
+ | protected $version = "1.0"; | ||
+ | |||
+ | public function getSettings() { | ||
+ | return Array( | ||
+ | "api_user" => Array("type" => "text", "name" => "Benutzername"), | ||
+ | "api_password" => Array("type" => "password", "name" => "Passwort"), | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | public function availibilityStatus($domain) { | ||
+ | if (!function_exists('xmlrpc_encode_request')) { | ||
+ | return null; | ||
+ | } | ||
+ | |||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] == "1000") { | ||
+ | $res = $domrobot->call("domain", "check", Array("domain" => $domain), $this); | ||
+ | } | ||
+ | |||
+ | if (!isset($res['resData']['domain'][0]['avail']) || $res['resData']['domain'][0]['avail'] === null) { | ||
+ | return null; | ||
+ | } | ||
+ | |||
+ | $domrobot->logout(); | ||
+ | |||
+ | return (bool) $res['resData']['domain'][0]['avail']; | ||
+ | } | ||
+ | |||
+ | public function registerDomain($domain, $owner, $admin, $tech, $zone, $ns, $privacy = false) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | $arr = Array("owner", "admin", "tech", "zone"); | ||
+ | |||
+ | foreach ($arr as $t) { | ||
+ | $i = $$t; | ||
+ | |||
+ | $i[7] = str_replace(Array(" ", "-", "/"), "", $i[7]); | ||
+ | $i[8] = str_replace(Array(" ", "-", "/"), "", $i[8]); | ||
+ | |||
+ | $res = $domrobot->call("contact", "create", Array( | ||
+ | "type" => empty($i[2]) ? "PERSON" : "ORG", | ||
+ | "name" => $i[0] . " " . $i[1], | ||
+ | "org" => $i[2], | ||
+ | "street" => str_replace(Array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), Array("ae", "oe", "ue", "ss", "Ae", "Oe", "Ue"), $i[3]), | ||
+ | "city" => $i[6], | ||
+ | "pc" => $i[5], | ||
+ | "cc" => $i[4], | ||
+ | "voice" => $i[7], | ||
+ | "fax" => $i[8], | ||
+ | "email" => $i[9], | ||
+ | ), $this, $domain); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | $$t = $res['resData']['id']; | ||
+ | } | ||
+ | |||
+ | $res = $domrobot->call("domain", "create", Array( | ||
+ | "domain" => $domain, | ||
+ | "registrant" => $owner, | ||
+ | "admin" => $admin, | ||
+ | "tech" => $tech, | ||
+ | "billing" => $zone, | ||
+ | "ns" => $ns, | ||
+ | "renewalMode" => "AUTOEXPIRE", | ||
+ | ), $this); | ||
+ | |||
+ | if ($res['code'] != "1000" && $res['code'] != "1001") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | $domrobot->logout(); | ||
+ | return true; | ||
+ | } | ||
+ | |||
+ | public function transferDomain($domain, $owner, $admin, $tech, $zone, $authCode, $ns, $privacy = false) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | $arr = Array("owner", "admin", "tech", "zone"); | ||
+ | |||
+ | foreach ($arr as $t) { | ||
+ | $i = $$t; | ||
+ | |||
+ | $i[7] = str_replace(Array(" ", "-", "/"), "", $i[7]); | ||
+ | $i[8] = str_replace(Array(" ", "-", "/"), "", $i[8]); | ||
+ | |||
+ | $res = $domrobot->call("contact", "create", Array( | ||
+ | "type" => empty($i[2]) ? "PERSON" : "ORG", | ||
+ | "name" => $i[0] . " " . $i[1], | ||
+ | "org" => $i[2], | ||
+ | "street" => str_replace(Array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), Array("ae", "oe", "ue", "ss", "Ae", "Oe", "Ue"), $i[3]), | ||
+ | "city" => $i[6], | ||
+ | "pc" => $i[5], | ||
+ | "cc" => $i[4], | ||
+ | "voice" => $i[7], | ||
+ | "fax" => $i[8], | ||
+ | "email" => $i[9], | ||
+ | ), $this, $domain); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | $$t = $res['resData']['id']; | ||
+ | } | ||
+ | |||
+ | $res = $domrobot->call("domain", "transfer", Array( | ||
+ | "domain" => $domain, | ||
+ | "registrant" => $owner, | ||
+ | "admin" => $admin, | ||
+ | "tech" => $tech, | ||
+ | "billing" => $zone, | ||
+ | "ns" => $ns, | ||
+ | "renewalMode" => "AUTOEXPIRE", | ||
+ | "authCode" => $authCode, | ||
+ | ), $this); | ||
+ | |||
+ | if ($res['code'] != "1000" && $res['code'] != "1001") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | $domrobot->logout(); | ||
+ | return true; | ||
+ | } | ||
+ | |||
+ | public function deleteDomain($domain, $transit = 0) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | if ($transit == 0) { | ||
+ | $res = $domrobot->call("domain", "delete", Array( | ||
+ | "domain" => $domain, | ||
+ | ), $this); | ||
+ | } else { | ||
+ | $res = $domrobot->call("domain", "push", Array( | ||
+ | "domain" => $domain, | ||
+ | ), $this); | ||
+ | } | ||
+ | |||
+ | if ($res['code'] != "1000" && $res['code'] != "1001") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | return true; | ||
+ | } | ||
+ | |||
+ | public function getAuthCode($domain) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | ||
+ | $count = mb_strlen($chars); | ||
+ | for ($i = 0, $pwd = ''; $i < 12; $i++) { | ||
+ | $index = rand(0, $count - 1); | ||
+ | $pwd .= mb_substr($chars, $index, 1); | ||
+ | } | ||
+ | |||
+ | $res = $domrobot->call("domain", "update", Array( | ||
+ | "domain" => $domain, | ||
+ | "authCode" => $pwd, | ||
+ | ), $this); | ||
+ | |||
+ | if ($res['code'] != "1000" && $res['code'] != "1001") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | return "AUTH:" . $pwd; | ||
+ | } | ||
+ | |||
+ | public function changeNameserver($domain, $ns) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | $res = $domrobot->call("domain", "update", Array( | ||
+ | "domain" => $domain, | ||
+ | "ns" => $ns, | ||
+ | ), $this); | ||
+ | |||
+ | if ($res['code'] != "1000" && $res['code'] != "1001") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | return true; | ||
+ | } | ||
+ | |||
+ | public function changeContact($domain, $owner, $admin, $tech, $zone) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | $arr = Array("owner", "admin", "tech", "zone"); | ||
+ | |||
+ | foreach ($arr as $t) { | ||
+ | $i = $$t; | ||
+ | |||
+ | $i[7] = str_replace(Array(" ", "-", "/"), "", $i[7]); | ||
+ | $i[8] = str_replace(Array(" ", "-", "/"), "", $i[8]); | ||
+ | |||
+ | $res = $domrobot->call("contact", "create", Array( | ||
+ | "type" => empty($i[2]) ? "PERSON" : "ORG", | ||
+ | "name" => $i[0] . " " . $i[1], | ||
+ | "org" => $i[2], | ||
+ | "street" => str_replace(Array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), Array("ae", "oe", "ue", "ss", "Ae", "Oe", "Ue"), $i[3]), | ||
+ | "city" => $i[6], | ||
+ | "pc" => $i[5], | ||
+ | "cc" => $i[4], | ||
+ | "voice" => $i[7], | ||
+ | "fax" => $i[8], | ||
+ | "email" => $i[9], | ||
+ | ), $this, $domain); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | $$t = $res['resData']['id']; | ||
+ | } | ||
+ | |||
+ | $res = $domrobot->call("domain", "update", Array( | ||
+ | "domain" => $domain, | ||
+ | "registrant" => $owner, | ||
+ | "admin" => $admin, | ||
+ | "tech" => $tech, | ||
+ | "billing" => $zone, | ||
+ | ), $this); | ||
+ | |||
+ | if ($res['code'] != "1000" && $res['code'] != "1001") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | return true; | ||
+ | } | ||
+ | |||
+ | public function setRegLock($domain, $status = false, $error = false) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | $res = $domrobot->call("domain", "update", Array( | ||
+ | "domain" => $domain, | ||
+ | "transferLock" => $status, | ||
+ | ), $this); | ||
+ | |||
+ | if ($res['code'] != "1000" && $res['code'] != "1001") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | return true; | ||
+ | } | ||
+ | |||
+ | public function changeAll($domain, $owner, $admin, $tech, $zone, $ns, $status = false, $renew = true, $privacy = false) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | $arr = Array("owner", "admin", "tech", "zone"); | ||
+ | |||
+ | foreach ($arr as $t) { | ||
+ | $i = $$t; | ||
+ | |||
+ | if (count($i) == 0) { | ||
+ | $r = $this->syncDomain($domain); | ||
+ | if (empty($r) || !is_array($r) || empty($r['ownerc'])) { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | $$t = $r['ownerc']; | ||
+ | } else { | ||
+ | $i[7] = str_replace(Array(" ", "-", "/"), "", $i[7]); | ||
+ | $i[8] = str_replace(Array(" ", "-", "/"), "", $i[8]); | ||
+ | |||
+ | $res = $domrobot->call("contact", "create", Array( | ||
+ | "type" => empty($i[2]) ? "PERSON" : "ORG", | ||
+ | "name" => $i[0] . " " . $i[1], | ||
+ | "org" => $i[2], | ||
+ | "street" => str_replace(Array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), Array("ae", "oe", "ue", "ss", "Ae", "Oe", "Ue"), $i[3]), | ||
+ | "city" => $i[6], | ||
+ | "pc" => $i[5], | ||
+ | "cc" => $i[4], | ||
+ | "voice" => $i[7], | ||
+ | "fax" => $i[8], | ||
+ | "email" => $i[9], | ||
+ | ), $this, $domain); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | $$t = $res['resData']['id']; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | $res = $domrobot->call("domain", "update", Array( | ||
+ | "domain" => $domain, | ||
+ | "registrant" => $owner, | ||
+ | "admin" => $admin, | ||
+ | "tech" => $tech, | ||
+ | "billing" => $zone, | ||
+ | "transferLock" => $status, | ||
+ | "renewalMode" => $renew ? "AUTORENEW" : "AUTOEXPIRE", | ||
+ | "ns" => $ns, | ||
+ | ), $this); | ||
+ | |||
+ | if ($res['code'] != "1000" && $res['code'] != "1001") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | return true; | ||
+ | } | ||
+ | |||
+ | public function syncDomain($domain, $kkSync = false) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return "Login failure"; | ||
+ | } | ||
+ | |||
+ | $res = $domrobot->call("domain", "info", Array( | ||
+ | "domain" => $domain, | ||
+ | ), $this); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | if ($kkSync) { | ||
+ | return ["status" => "waiting_kk"]; | ||
+ | } | ||
+ | |||
+ | return false; | ||
+ | } | ||
+ | |||
+ | return Array( | ||
+ | "auto_renew" => $res['resData']['renewalMode'] == "AUTORENEW", | ||
+ | "expiration" => date("Y-m-d", $res['resData']['exDate']->timestamp), | ||
+ | "status" => $res['resData']['status'] == "OK", | ||
+ | "transfer_lock" => (bool) $res['resData']['transferLock'], | ||
+ | "ownerc" => $res['resData']['contact']['registrant']['id'], | ||
+ | "privacy" => false, | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | public function trade($domain, $owner, $admin, $tech, $zone) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | $arr = Array("owner", "admin", "tech", "zone"); | ||
+ | |||
+ | foreach ($arr as $t) { | ||
+ | $i = $$t; | ||
+ | |||
+ | $i[7] = str_replace(Array(" ", "-", "/"), "", $i[7]); | ||
+ | $i[8] = str_replace(Array(" ", "-", "/"), "", $i[8]); | ||
+ | |||
+ | $res = $domrobot->call("contact", "create", Array( | ||
+ | "type" => empty($i[2]) ? "PERSON" : "ORG", | ||
+ | "name" => $i[0] . " " . $i[1], | ||
+ | "org" => $i[2], | ||
+ | "street" => str_replace(Array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), Array("ae", "oe", "ue", "ss", "Ae", "Oe", "Ue"), $i[3]), | ||
+ | "city" => $i[6], | ||
+ | "pc" => $i[5], | ||
+ | "cc" => $i[4], | ||
+ | "voice" => $i[7], | ||
+ | "fax" => $i[8], | ||
+ | "email" => $i[9], | ||
+ | ), $this, $domain); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | $$t = $res['resData']['id']; | ||
+ | } | ||
+ | |||
+ | $res = $domrobot->call("domain", "trade", Array( | ||
+ | "domain" => $domain, | ||
+ | "registrant" => $owner, | ||
+ | "admin" => $admin, | ||
+ | "tech" => $tech, | ||
+ | "billing" => $zone, | ||
+ | ), $this); | ||
+ | |||
+ | if ($res['code'] != "1000" && $res['code'] != "1001") { | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | return true; | ||
+ | } | ||
+ | |||
+ | public function changeValues($domain, $status = false, $renew = true, $privacy = false) { | ||
+ | require_once __DIR__ . "/domrobot.class.php"; | ||
+ | $addr = "https://api.domrobot.com/xmlrpc/"; | ||
+ | $domrobot = new domrobot($addr); | ||
+ | $domrobot->setDebug(false); | ||
+ | $domrobot->setLanguage('en'); | ||
+ | $res = $domrobot->login($this->options->api_user, $this->options->api_password); | ||
+ | |||
+ | if ($res['code'] != "1000") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | $res = $domrobot->call("domain", "update", Array( | ||
+ | "domain" => $domain, | ||
+ | "renewalMode" => $renew ? "AUTORENEW" : "AUTOEXPIRE", | ||
+ | "transferLock" => $status, | ||
+ | ), $this); | ||
+ | |||
+ | if ($res['code'] != "1000" && $res['code'] != "1001") { | ||
+ | return $res; | ||
+ | } | ||
+ | |||
+ | return true; | ||
+ | } | ||
+ | } | ||
+ | </source> |
Aktuelle Version vom 12. Oktober 2018, 22:03 Uhr
Sie können an sourceDESK eigene Domain-Registrare anbinden, um Domains über diese zu registrieren und zu verwalten.
Dateistruktur
Ein Registrar-Modul bekommt ein eigenes Verzeichnis unter modules/domain. In diesem Verzeichnis muss sich eine PHP-Datei mit dem gleichen Namen wie das Verzeichnis und der Endung .php befinden. In dieser PHP-Datei wird eine Klasse definiert, die von der Klasse DomainRegistrar erbt.
Attribute
Es werden mehrere Attribute innerhalb der erstellten Klasse benötigt, die höchstens protected sein dürfen:
- $name gibt einen Anzeigenamen für das Modul an
- $short gibt den Kurznamen des Moduls an, das entspricht dem Verzeichnis- bzw. Dateinamen
- $version gibt die Versionsnummer des Moduls an
Einstellungen
Sie können über die Methode getSettings() definieren, welche Einstellungen der Administrator für das Modul durchführen können soll. Ein Beispiel:
public function getSettings() { return Array( "api_url" => Array("type" => "text", "name" => "API-URL", "default" => "https://gateway.autodns.com"), "api_user" => Array("type" => "text", "name" => "API-Benutzer"), "api_password" => Array("type" => "password", "name" => "API-Passwort"), ); }
Auf die definierten Einstellungen können Sie innerhalb der Modul-Klasse bspw. mit dem Aufruf $this->options->api_url zugreifen.
Domain-Verfügbarkeit
Über die Methode availibilityStatus($domain)
wird die Verfügbarkeit der Domain $domain
geprüft. Folgende Rückgabewerte sind möglich:
-
true
, wenn die Domain verfügbar ist -
false
, wenn die Domain bereits registriert ist -
null
, falls die Domain nicht geprüft werden konnte / nicht registriert werden kann
Domain registrieren / transferieren
Die Registrierung erfolgt über die Methode registerDomain($domain, $owner, $admin, $tech, $zone, $ns, $privacy = false)
. Die Signatur der Methode zum Transfer lautet transferDomain($domain, $owner, $admin, $tech, $zone, $authCode, $ns, $privacy = false)
. Die Belegung der Variablen:
-
$domain
- der Domain-Name -
$owner, $admin, $tech, $zone
- Handle-Daten als Array- Vorname
- Nachname
- Firma
- Straße
- Land
- Postleitzahl
- Stadt
- Telefon
- Telefax
- Notizen
-
$authCode
- Auth-Code (nur bei Transfer) -
$ns
- Array mit Nameservern -
$privacy
- Boolean, der angibt, ob WHOIS-Privacy aktiviert ist
Als Rückgabe wird im Erfolgsfall true
erwartet, im Fehlerfall eine Fehlermeldung als String.
Nameserver ändern
Über die Methode changeNameserver($domain, $ns)
können die Nameserver der Domain $domain
geändert werden. Hierbei wird ein Array mit Nameserver-Hostnamen als $ns
übergeben.
Kontakte ändern
Die Methode changeContact($domain, $owner, $admin, $tech, $zone)
ändert die Kontakte der Domain $domain
.
Sonderfall: Trade
Der kostenpflichtige Kontaktwechsel (Trade) wird über die Methode trade($domain, $owner, $admin, $tech, $zone)
initiiert.
Authcode abrufen
Der automatische Abruf des Authcodes erfolgt über die Methode getAuthCode($domain)
. Als Rückgabewert ist im Fehlerfall false
zulässig, im Erfolgsfall ist der Authcode zurückgegeben, wobei vor diesen AUTH:
geschrieben werden muss.
Transfersperre / Verlängerung / WHOIS-Privacy
Das Setzen der Transfersperre, von Verlängerungsoptionen und WHOIS-Privacy erfolgt über die Methode changeValues($domain, $status = false, $renew = true, $privacy = false)
. Dabei stellen die drei Booleans folgende Werte dar:
-
$status
aktiviert die Transfersperre -
$renew
aktiviert die automatische Verlängerung -
$privacy
aktiviert WHOIS-Privacy
Domain löschen / in den Transit geben
Um eine Domain zu löschen oder in den Transit zu geben, nutzen Sie die Methode deleteDomain($domain, $transit = 0)
. Hierbei ist die Belegung von $transit
wie folgt möglich:
-
0
- Domain löschen -
1
- Konnektierter Transit -
2
- Dekonnektierter Transit
Domain-Synchronisation
Domains werden periodisch synchronisiert, dazu wird die Methode syncDomain($domain, $kkSync = false)
aufgerufen. Ist $kkSync
auf true
gesetzt, befindet sich die Domain noch im Transfer-Status. Sofern die Domain noch nicht transferiert wurde, ist Array("status" => "waiting_kk")
zurückzugegeben.
Die erwartete Rückgabe für eine registrierte Domain ist ein Array mit den folgenden Schlüsseln:
-
auto_renew
- Boolean, der den Status der automatischen Verlängerung zurückgibt -
expiration
- Datum des Domainablaufs im Format YYYY-MM-DD -
status
- Boolean, der den Status der Domain (aktiv/nicht aktiv) zurückgibt -
transfer_lock
- Boolean, der angibt, ob die Transfer-Sperre aktiviert ist -
privacy
- Boolean, der den Status der WHOIS-Privacy angibt
Beispiel-Code
<?php class InterNetWorX extends DomainRegistrar { protected $short = "inwx"; protected $name = "InterNetWorX"; protected $version = "1.0"; public function getSettings() { return Array( "api_user" => Array("type" => "text", "name" => "Benutzername"), "api_password" => Array("type" => "password", "name" => "Passwort"), ); } public function availibilityStatus($domain) { if (!function_exists('xmlrpc_encode_request')) { return null; } require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] == "1000") { $res = $domrobot->call("domain", "check", Array("domain" => $domain), $this); } if (!isset($res['resData']['domain'][0]['avail']) || $res['resData']['domain'][0]['avail'] === null) { return null; } $domrobot->logout(); return (bool) $res['resData']['domain'][0]['avail']; } public function registerDomain($domain, $owner, $admin, $tech, $zone, $ns, $privacy = false) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return $res; } $arr = Array("owner", "admin", "tech", "zone"); foreach ($arr as $t) { $i = $$t; $i[7] = str_replace(Array(" ", "-", "/"), "", $i[7]); $i[8] = str_replace(Array(" ", "-", "/"), "", $i[8]); $res = $domrobot->call("contact", "create", Array( "type" => empty($i[2]) ? "PERSON" : "ORG", "name" => $i[0] . " " . $i[1], "org" => $i[2], "street" => str_replace(Array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), Array("ae", "oe", "ue", "ss", "Ae", "Oe", "Ue"), $i[3]), "city" => $i[6], "pc" => $i[5], "cc" => $i[4], "voice" => $i[7], "fax" => $i[8], "email" => $i[9], ), $this, $domain); if ($res['code'] != "1000") { return $res; } $$t = $res['resData']['id']; } $res = $domrobot->call("domain", "create", Array( "domain" => $domain, "registrant" => $owner, "admin" => $admin, "tech" => $tech, "billing" => $zone, "ns" => $ns, "renewalMode" => "AUTOEXPIRE", ), $this); if ($res['code'] != "1000" && $res['code'] != "1001") { return $res; } $domrobot->logout(); return true; } public function transferDomain($domain, $owner, $admin, $tech, $zone, $authCode, $ns, $privacy = false) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return $res; } $arr = Array("owner", "admin", "tech", "zone"); foreach ($arr as $t) { $i = $$t; $i[7] = str_replace(Array(" ", "-", "/"), "", $i[7]); $i[8] = str_replace(Array(" ", "-", "/"), "", $i[8]); $res = $domrobot->call("contact", "create", Array( "type" => empty($i[2]) ? "PERSON" : "ORG", "name" => $i[0] . " " . $i[1], "org" => $i[2], "street" => str_replace(Array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), Array("ae", "oe", "ue", "ss", "Ae", "Oe", "Ue"), $i[3]), "city" => $i[6], "pc" => $i[5], "cc" => $i[4], "voice" => $i[7], "fax" => $i[8], "email" => $i[9], ), $this, $domain); if ($res['code'] != "1000") { return $res; } $$t = $res['resData']['id']; } $res = $domrobot->call("domain", "transfer", Array( "domain" => $domain, "registrant" => $owner, "admin" => $admin, "tech" => $tech, "billing" => $zone, "ns" => $ns, "renewalMode" => "AUTOEXPIRE", "authCode" => $authCode, ), $this); if ($res['code'] != "1000" && $res['code'] != "1001") { return $res; } $domrobot->logout(); return true; } public function deleteDomain($domain, $transit = 0) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return false; } if ($transit == 0) { $res = $domrobot->call("domain", "delete", Array( "domain" => $domain, ), $this); } else { $res = $domrobot->call("domain", "push", Array( "domain" => $domain, ), $this); } if ($res['code'] != "1000" && $res['code'] != "1001") { return false; } return true; } public function getAuthCode($domain) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return false; } $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $count = mb_strlen($chars); for ($i = 0, $pwd = ''; $i < 12; $i++) { $index = rand(0, $count - 1); $pwd .= mb_substr($chars, $index, 1); } $res = $domrobot->call("domain", "update", Array( "domain" => $domain, "authCode" => $pwd, ), $this); if ($res['code'] != "1000" && $res['code'] != "1001") { return false; } return "AUTH:" . $pwd; } public function changeNameserver($domain, $ns) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return false; } $res = $domrobot->call("domain", "update", Array( "domain" => $domain, "ns" => $ns, ), $this); if ($res['code'] != "1000" && $res['code'] != "1001") { return false; } return true; } public function changeContact($domain, $owner, $admin, $tech, $zone) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return false; } $arr = Array("owner", "admin", "tech", "zone"); foreach ($arr as $t) { $i = $$t; $i[7] = str_replace(Array(" ", "-", "/"), "", $i[7]); $i[8] = str_replace(Array(" ", "-", "/"), "", $i[8]); $res = $domrobot->call("contact", "create", Array( "type" => empty($i[2]) ? "PERSON" : "ORG", "name" => $i[0] . " " . $i[1], "org" => $i[2], "street" => str_replace(Array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), Array("ae", "oe", "ue", "ss", "Ae", "Oe", "Ue"), $i[3]), "city" => $i[6], "pc" => $i[5], "cc" => $i[4], "voice" => $i[7], "fax" => $i[8], "email" => $i[9], ), $this, $domain); if ($res['code'] != "1000") { return false; } $$t = $res['resData']['id']; } $res = $domrobot->call("domain", "update", Array( "domain" => $domain, "registrant" => $owner, "admin" => $admin, "tech" => $tech, "billing" => $zone, ), $this); if ($res['code'] != "1000" && $res['code'] != "1001") { return false; } return true; } public function setRegLock($domain, $status = false, $error = false) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return $res; } $res = $domrobot->call("domain", "update", Array( "domain" => $domain, "transferLock" => $status, ), $this); if ($res['code'] != "1000" && $res['code'] != "1001") { return $res; } return true; } public function changeAll($domain, $owner, $admin, $tech, $zone, $ns, $status = false, $renew = true, $privacy = false) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return $res; } $arr = Array("owner", "admin", "tech", "zone"); foreach ($arr as $t) { $i = $$t; if (count($i) == 0) { $r = $this->syncDomain($domain); if (empty($r) || !is_array($r) || empty($r['ownerc'])) { return false; } $$t = $r['ownerc']; } else { $i[7] = str_replace(Array(" ", "-", "/"), "", $i[7]); $i[8] = str_replace(Array(" ", "-", "/"), "", $i[8]); $res = $domrobot->call("contact", "create", Array( "type" => empty($i[2]) ? "PERSON" : "ORG", "name" => $i[0] . " " . $i[1], "org" => $i[2], "street" => str_replace(Array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), Array("ae", "oe", "ue", "ss", "Ae", "Oe", "Ue"), $i[3]), "city" => $i[6], "pc" => $i[5], "cc" => $i[4], "voice" => $i[7], "fax" => $i[8], "email" => $i[9], ), $this, $domain); if ($res['code'] != "1000") { return $res; } $$t = $res['resData']['id']; } } $res = $domrobot->call("domain", "update", Array( "domain" => $domain, "registrant" => $owner, "admin" => $admin, "tech" => $tech, "billing" => $zone, "transferLock" => $status, "renewalMode" => $renew ? "AUTORENEW" : "AUTOEXPIRE", "ns" => $ns, ), $this); if ($res['code'] != "1000" && $res['code'] != "1001") { return $res; } return true; } public function syncDomain($domain, $kkSync = false) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return "Login failure"; } $res = $domrobot->call("domain", "info", Array( "domain" => $domain, ), $this); if ($res['code'] != "1000") { if ($kkSync) { return ["status" => "waiting_kk"]; } return false; } return Array( "auto_renew" => $res['resData']['renewalMode'] == "AUTORENEW", "expiration" => date("Y-m-d", $res['resData']['exDate']->timestamp), "status" => $res['resData']['status'] == "OK", "transfer_lock" => (bool) $res['resData']['transferLock'], "ownerc" => $res['resData']['contact']['registrant']['id'], "privacy" => false, ); } public function trade($domain, $owner, $admin, $tech, $zone) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return false; } $arr = Array("owner", "admin", "tech", "zone"); foreach ($arr as $t) { $i = $$t; $i[7] = str_replace(Array(" ", "-", "/"), "", $i[7]); $i[8] = str_replace(Array(" ", "-", "/"), "", $i[8]); $res = $domrobot->call("contact", "create", Array( "type" => empty($i[2]) ? "PERSON" : "ORG", "name" => $i[0] . " " . $i[1], "org" => $i[2], "street" => str_replace(Array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"), Array("ae", "oe", "ue", "ss", "Ae", "Oe", "Ue"), $i[3]), "city" => $i[6], "pc" => $i[5], "cc" => $i[4], "voice" => $i[7], "fax" => $i[8], "email" => $i[9], ), $this, $domain); if ($res['code'] != "1000") { return false; } $$t = $res['resData']['id']; } $res = $domrobot->call("domain", "trade", Array( "domain" => $domain, "registrant" => $owner, "admin" => $admin, "tech" => $tech, "billing" => $zone, ), $this); if ($res['code'] != "1000" && $res['code'] != "1001") { return false; } return true; } public function changeValues($domain, $status = false, $renew = true, $privacy = false) { require_once __DIR__ . "/domrobot.class.php"; $addr = "https://api.domrobot.com/xmlrpc/"; $domrobot = new domrobot($addr); $domrobot->setDebug(false); $domrobot->setLanguage('en'); $res = $domrobot->login($this->options->api_user, $this->options->api_password); if ($res['code'] != "1000") { return $res; } $res = $domrobot->call("domain", "update", Array( "domain" => $domain, "renewalMode" => $renew ? "AUTORENEW" : "AUTOEXPIRE", "transferLock" => $status, ), $this); if ($res['code'] != "1000" && $res['code'] != "1001") { return $res; } return true; } }