Esempio n. 1
0
//  agreement (EULA).  In such event, licensee  agrees to return licensor
//  or  destroy all copies  of  software  upon termination of the license
include 'config.php';
include 'PowerDNS.php';
header('Content-Type: text/plain');
$PowerDNS = new PowerDNS($db['host'], $db['user'], $db['pass'], $db['name'], $db['port']);
$output = json_encode(array("status" => "error", "msg" => "Unauthorized"));
// Verifiy API Key
if ($_GET['key'] == $api['key']) {
    // Default Output
    $output = json_encode(array("status" => "error", "msg" => "Action not defined."));
    // Add Domain
    if ($_GET['action'] == 'add_domain') {
        if (!empty($_GET['domain'])) {
            if ($PowerDNS->isValidDomain($_GET['domain']) && count(explode(".", $_GET['domain'])) > 1) {
                $response = $PowerDNS->addDomain($_GET['domain'], $_GET['solusvm_cid']);
                $output = json_encode($response);
            } else {
                $output = json_encode(array("status" => "error", "msg" => "Invalid Domain."));
            }
        } else {
            $output = json_encode(array("status" => "error", "msg" => "Missing data for add_domain."));
        }
    }
    // Delete Domain
    if ($_GET['action'] == 'delete_domain') {
        if (!empty($_GET['domain_id'])) {
            $response = $PowerDNS->deleteDomain($_GET['domain_id']);
            $output = json_encode($response);
        } else {
            $output = json_encode(array("status" => "error", "msg" => "Missing data for delete_domain."));