/*
 *   Author: Tobias Rahm
 *   Date:   2015-11-28
 */
echo PHP_EOL;
if (count($argv) < 3) {
    echo 'Err: 3 arguments required.' . PHP_EOL;
    echo 'php php_glesys_zone_import.php <DNS zone file> <api user> <api key>' . PHP_EOL;
    exit;
}
$file = $argv[1];
$api_user = $argv[2];
$api_key = $argv[3];
$api_url = 'https://api.glesys.com/';
$parser = new File_DNS();
$domain = $parser->getDomain($file);
if ($domain == null) {
    if (isset($argv[4])) {
        $domain = $argv[4];
        echo 'Log: Retrieving domain from argument list: ' . $argv[4] . PHP_EOL;
    } else {
        echo "Log: Domain not found. Create manually? (y/n) ";
        $handle = fopen("php://stdin", "r");
        $line = fgets($handle);
        if (trim($line) == 'y') {
            echo "Write domain name: ";
            $handle = fopen("php://stdin", "r");
            $line = fgets($handle);
            if (trim($line)) {
                $domain = trim($line);
Exemple #2
0
<?php

/**
 * The File_DNS example code.
 *
 * PHP versions 5
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to license@php.net so we can mail you a copy immediately.
 *
 * @category  File
 * @package   File_DNS
 * @author    Cipriano Groenendal <*****@*****.**>
 * @copyright 2004-2005 Cipriano Groenendal <*****@*****.**>
 * @license   http://www.php.net/license/3_0.txt PHP License 3.0
 * @version   CVS: $Id$
 * @link      http://pear.php.net/package/File_DNS
 */
require_once 'File/DNS.php';
$zone = new File_DNS();
$load = $zone->load('example.net', 'example.net');
$zone->setName('www2', 'www', 'a');
$zone->setDomainName('example.org');
$zone->setValue('127.0.0.1', '');
echo $zone->toString();