git.schokokeks.org
Repositories
Help
Report an Issue
webinterface.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
84e7f97
Branches
Tags
master
ticket
webinterface.git
modules
domains
include
domainapi.php
Ermögliche das Hinzufügen externer Domains
Bernd Wurst
commited
84e7f97
at 2018-02-20 11:35:38
domainapi.php
Blame
History
Raw
<?php /* This file belongs to the Webinterface of schokokeks.org Hosting Written 2008-2018 by schokokeks.org Hosting, namely Bernd Wurst <bernd@schokokeks.org> Hanno Böck <hanno@schokokeks.org> To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see http://creativecommons.org/publicdomain/zero/1.0/ Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code. */ require_once('inc/debug.php'); require_once('inc/api.php'); use_module('contacts'); require_once('contacts.php'); require_once('contactapi.php'); function api_download_domain($id) { $result = db_query("SELECT id, CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c, registrierungsdatum, kuendigungsdatum FROM kundendaten.domains WHERE id=?", array($id)); if ($result->rowCount() < 1) { system_failure('Domain nicht gefunden'); } $dom = $result->fetch(); $data = array("domainName" => $dom['fqdn']); $result = api_request('domainInfo', $data); if ($result['status'] != 'success') { system_failure("Abfrage nicht erfolgreich!"); } $apidomain = $result['response']; $apiowner = NULL; $apiadmin_c = NULL; foreach ($apidomain['contacts'] as $ac) { if ($ac['type'] == 'owner') { $apiowner = $ac['contact']; } if ($ac['type'] == 'admin') { $apiadmin_c = $ac['contact']; } } if (! $apiowner || !$apiadmin_c) { system_failure("Ungültige Daten erhalten!"); } $owner = download_contact($apiowner); $admin_c = $owner; if ($apiadmin_c != $apiowner) { $admin_c = download_contact($apiadmin_c); } if ($owner != $dom['owner'] || $admin_c != $dom['admin_c']) { db_query("UPDATE kundendaten.domains SET owner=?, admin_c=? WHERE id=?", array($owner, $admin_c, $id)); } } function api_upload_domain($fqdn) { $result = db_query("SELECT id,CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=?", array($fqdn)); if ($result->rowCount() < 1) { system_failure("Unbekannte Domain"); } $dom = $result->fetch(); $owner = get_contact($dom['owner']); if (! $owner['nic_id']) { upload_contact($owner); $owner = get_contact($dom['owner']); } $admin_c = get_contact($dom['admin_c']); if (! $admin_c['nic_id']) { upload_contact($admin_c); $admin_c = get_contact($dom['admin_c']); } $owner = $owner['nic_id']; $admin_c = $admin_c['nic_id']; $data = array("domainName" => $dom['fqdn']); $result = api_request('domainInfo', $data); if ($result['status'] != 'success') { system_failure("Abfrage nicht erfolgreich!"); } $apidomain = $result['response']; foreach ($apidomain['contacts'] as $key => $ac) { if ($ac['type'] == 'owner') { $apidomain['contacts'][$key]['contact'] = $owner; } if ($ac['type'] == 'admin') { $apidomain['contacts'][$key]['contact'] = $admin_c; } } $args = array("domain" => $apidomain); api_request('domainUpdate', $args); } function api_domain_available($domainname) { $args = array("domainNames" => array($domainname)); $result = api_request('domainStatus', $args); $resp = $result["responses"][0]; return $resp["status"]; /* alreadyRegistered You (or a sub account) already registered the domain registered Somebody else registered domain nameContainsForbiddenCharacter Domain name contains invalid characters available Domain is available for registration suffixDoesNotExist Domain suffix does not exist suffixCannotBeRegistered You are not allowed to register a domain with this suffix canNotCheck System is currently unable to check availability unknown Other problems or difficulties occured */ }