Esempio n. 1
0
function getorphan()
{
    global $conf;
    global $user;
    $files = ' ' . implode(' ', scandir($conf->Path)) . ' ';
    $mzones = $user->getMasters();
    $szones = $user->getSlaves();
    foreach ($mzones as $id) {
        $z = new masterZone(intval($id));
        $z->loadZoneHead();
        $zone = $z->getZoneHeadRaw();
        $files = str_replace(' ' . $zone['name'] . ' ', ' ', $files);
    }
    foreach ($szones as $id) {
        $z = new slaveZone(intval($id));
        $z->loadZoneHead();
        $zone = $z->getZoneHeadRaw();
        $files = str_replace(' ' . $zone['name'] . ' ', ' ', $files);
    }
    $vzf = array();
    foreach (explode(' ', trim($files)) as $entry) {
        if (is_file($conf->Path . $entry) && preg_replace('/\\.(signed|private|key|krf|jnl|bind)$/', '', $entry) == $entry) {
            if (checkZoneFile($conf->Path . $entry, $entry)) {
                $vzf[] = hostToIdn($entry);
            }
        }
    }
    return $vzf;
}
Esempio n. 2
0
<?php

require_once "include.php";
$znum = intval($_GET['i']) > 0 ? intval($_GET['i']) : NULL;
if ($znum) {
    if ($user->isOwned($znum, 'master', 'live')) {
        $zone = new masterZone(array('id' => $znum));
        $zone->loadZone();
        $zonerec = $zone->getZoneHead();
        $currpage = isset($_GET['page']) && intval($_GET['page']) > 0 ? $currpage = intval($_GET['page']) : 1;
        $allrec = $zone->getRecords(true);
        $count = sizeof($allrec);
        $fromto = makePart($count, $currpage);
        $rec = array();
        for ($i = $fromto[0]; $i < $fromto[1]; $i++) {
            $allrec[$i]['ttl'] = $allrec[$i]['ttl'] > 0 ? $allrec[$i]['ttl'] : '';
            $rec[] = $allrec[$i];
        }
        $users = $user->getAllusers();
        $types = $conf->parameters;
        $err = '';
        $err .= !is_array($zonerec) || !is_array($rec) ? $zone->getErr() : '';
        $err .= !is_array($users) ? $user->getErr() : '';
        $err .= !is_array($types) ? "Record types not foud\n" : '';
        if ($err > '') {
            $smarty->assign("popuperror", implode("<br />", explode("\n", $err)));
        }
        $smarty->assign("zone", $zonerec);
        $smarty->assign("pagetitle", "Editing master zone");
        $smarty->assign("rcount", sizeof($rec));
        $smarty->assign("record", $rec);
Esempio n. 3
0
<?php

require_once "include.php";
if ($user->isAdmin()) {
    $arr = array('name' => $_POST['name'], 'pri_dns' => $_POST['pri_dns'], 'sec_dns' => $_POST['sec_dns'], 'refresh' => $_POST['refresh'], 'retry' => $_POST['retry'], 'expire' => $_POST['expire'], 'ttl' => $_POST['ttl'], 'owner' => $_POST['owner']);
    $nz = new masterZone($arr);
    if (!$nz->loadZoneHead()) {
        $nz->setZoneHead($arr);
        $nz->saveZoneHead();
        $www = isset($_POST['www']) && $_POST['www'] > '' ? $_POST['www'] : NULL;
        if ($www) {
            $type = filter_var($www, FILTER_VALIDATE_IP) ? 'A' : 'CNAME';
            if ($type == 'A') {
                $nz->addRecord(array('host' => '@', 'type' => 'A', 'destination' => $www));
                $nz->addRecord(array('host' => 'www', 'type' => 'CNAME', 'destination' => '@'));
            } else {
                $nz->addRecord(array('host' => 'www', 'type' => 'CNAME', 'destination' => $www));
            }
        }
        $ftp = isset($_POST['ftp']) && $_POST['ftp'] > '' ? $_POST['ftp'] : NULL;
        if ($ftp) {
            $type = filter_var($ftp, FILTER_VALIDATE_IP) ? 'A' : 'CNAME';
            $nz->addRecord(array('host' => 'ftp', 'type' => $type, 'destination' => $ftp));
        }
        $mail = isset($_POST['mail']) && $_POST['mail'] > '' ? $_POST['mail'] : NULL;
        if ($mail) {
            $type = filter_var($mail, FILTER_VALIDATE_IP) ? 'A' : 'MX';
            $destination = $type == 'A' ? 'mail' : $mail;
            if ($type == 'A') {
                $nz->addRecord(array('host' => 'mail', 'type' => $type, 'destination' => $mail));
                $type = 'MX';
Esempio n. 4
0
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 *
 **********************************************************************
 *
 * Check what need to delete and provides info for confirmation
 *
 */
require_once "include.php";
$zoneid = intval($_GET['i']);
if ($zoneid > 0) {
    if ($user->isOwned($zoneid, 'master')) {
        $smarty->assign("pagetitle", "Delete master zone");
        $zone = new masterZone($zoneid);
        $zone->loadZoneHead();
        $res = $zone->getZoneHead();
        $smarty->assign("zone", $res['name']);
        $smarty->assign("zoneid", $zoneid);
        $smarty->assign("template", "deletezone.tpl");
        $smarty->assign("help", help("deletezone"));
        $smarty->assign("menu_button", menu_buttons());
        $smarty->display("main.tpl");
    } else {
        problem('notown');
    }
} else {
    problem();
}
Esempio n. 5
0
<?php

require_once "include.php";
$zones = $user->getMasters('live');
$count = sizeof($zones);
$maxitems = intval($conf->range);
$currpage = isset($_GET['page']) && intval($_GET['page']) > 0 ? $currpage = intval($_GET['page']) : 1;
$fromto = makePart($count, $currpage);
$buffer = array();
for ($i = $fromto[0]; $i < $fromto[1]; $i++) {
    $zone = new masterZone(array('id' => $zones[$i]));
    $zone->loadZoneHead();
    $buffer[] = $zone->getZoneHead();
    unset($zone);
}
$smarty->assign("zonelist", $buffer);
$smarty->assign("pagetitle", "Master zones");
$smarty->assign("template", "zoneread.tpl");
$smarty->assign("help", help("zoneread"));
$smarty->assign("menu_button", menu_buttons());
$smarty->assign("page_root", $src . "zonelist.php?");
$smarty->display("main.tpl");
Esempio n. 6
0
<?php

require_once "include.php";
$param = isset($_GET['i']) ? intval($_GET['i']) : 0;
if ($param > 0) {
    if ($user->isOwned($param, 'master')) {
        $smarty->assign("pagetitle", "Preview master zone");
        $zone = new masterZone(array('id' => $_GET['i']));
        $fname = tempnam($conf->Tmp_Path, "zone_");
        $zone->writeZone($fname, $conf->HostMaster);
        $head = $zone->getZoneHead();
        $name = $head['name'];
        $issec = $head['secured'] == "yes";
        $sec = $_GET['s'] == "1" && $issec;
        $zonetype = "master zone";
        $zonetype .= !$issec ? " not" : "";
        $zonetype .= " secured, displayed as plain";
        $ownerid = $head['owner'];
        $ouser = new User(array('id' => $ownerid));
        $owner = $ouser->getFullName();
        if (file_exists($fname)) {
            $lines = file($fname);
            $zonedef = implode("", $lines);
            unlink($fname);
        } else {
            $zonedef = NULL;
            $smarty->assign("popuperror", "There is a problem with this zone!");
        }
        $smarty->assign("zonename", $name);
        $smarty->assign("zonetype", $zonetype);
        $smarty->assign("owner", $owner);
Esempio n. 7
0
<?php

require_once "include.php";
$znum = intval($_GET['i']) > 0 ? intval($_GET['i']) : NULL;
if ($znum) {
    if ($user->isOwned($znum, 'master', 'live')) {
        $zone = new masterZone(array('id' => $znum));
        $zone->loadZone();
        $zonerec = $zone->getZoneHead();
        $zrec = array();
        foreach (array('refresh', 'expire', 'retry', 'ttl', 'secured', 'pri_dns', 'sec_dns', 'owner') as $key) {
            $zrec[$key] = (isset($_POST[$key]) and $_POST[$key] > '') ? $_POST[$key] : $zonerec[$key];
        }
        $zrec['valid'] = 'may';
        $zone->setZoneHead($zrec);
        $zone->saveZoneHead();
        $total = isset($_POST['total']) && $_POST['total'] > 0 ? $_POST['total'] : 0;
        for ($x = 0; $x < $total; $x++) {
            if (isset($_POST['delete'][$x])) {
                $zone->eraseRecord(intval($_POST['host_id'][$x]));
            } else {
                $nrec = array();
                foreach (array('host', 'ttl', 'type', 'pri', 'destination') as $key) {
                    $pkey = $key == 'ttl' ? 'rttl' : $key;
                    $nrec[$key] = isset($_POST[$pkey][$x]) ? $_POST[$pkey][$x] : '';
                    $nrec[$key] = $key == 'ttl' && $nrec[$key] == '' ? 0 : $nrec[$key];
                    $nrec[$key] = $key == 'pri' && $nrec[$key] == '' ? 10 : $nrec[$key];
                    $nrec[$key] = $key == 'host' && $nrec[$key] == '' ? '@' : $nrec[$key];
                    $nrec[$key] = $key == 'destination' && $nrec[$key] == '' ? '@' : $nrec[$key];
                }
                if ($nrec['host'] != $nrec['destination']) {
Esempio n. 8
0
<?php

require_once "include.php";
$param = isset($_GET['i']) ? intval($_GET['i']) : 0;
if ($param > 0) {
    if ($user->isOwned($param, 'master')) {
        $smarty->assign("pagetitle", "Dump master zone");
        $zone = new masterZone(array('id' => $_GET['i']));
        $zone->loadZoneHead();
        $head = $zone->getZoneHead();
        $headraw = $zone->getZoneHeadRaw();
        $name = $head['name'];
        $fname = $headraw['name'];
        $issec = $head['secured'] == "yes";
        $sec = $_GET['s'] == "1" && $issec;
        $zonetype = "master zone";
        $zonetype .= !$issec ? " not" : "";
        $zonetype .= " secured, displayed as ";
        $zonetype .= $sec ? "secured" : "plain";
        $fname .= $issec ? '.signed' : "";
        $ownerid = $head['owner'];
        $ouser = new User(array('id' => $ownerid));
        $owner = $ouser->getFullName();
        $filename = $conf->path . $fname;
        if (file_exists($filename)) {
            $lines = file($conf->path . $fname);
            $zonedef = '';
            foreach ($lines as $line) {
                $zonedef .= $line;
            }
        } else {
Esempio n. 9
0
 public function getMasters($type = 'all')
 {
     $out = array();
     if ($type == 'live') {
         foreach ($this->mzones as $zoneid) {
             $zone = new masterZone(array('id' => intval($zoneid)));
             $zone->loadZoneHead();
             $head = $zone->getZoneHeadRaw();
             if ($head['updated'] != 'del') {
                 $out[] = intval($zoneid);
             }
         }
     } else {
         $out = $this->mzones;
     }
     return $out;
 }
Esempio n. 10
0
<?php

require_once "include.php";
$param = isset($_GET['i']) ? intval($_GET['i']) : 0;
if ($user->isOwned($param, 'master')) {
    $zone = new masterZone(array('id' => $_GET['i']));
    $file = tempnam($conf->Tmp_Path, "zone_");
    $check = $zone->validateZone($file, $conf->HostMaster, $conf->NamedCheckZone);
    if (!$check[0]) {
        $smarty->assign("popuperror", $check[1]);
    }
    if (file_exists($file)) {
        unlink($file);
    }
} else {
    problem('notown');
}
Esempio n. 11
0
         fclose($fh);
         $check = checkZoneFile($temp, $zone);
         unlink($temp);
         if (!$check) {
             problem("nocontent");
         }
     }
     $mz = new masterZone($gzone);
     $sz = new slaveZone($gzone);
     if ($mz->loadZoneHead() || $sz->loadZoneHead()) {
         $mz = array();
         $sz = array();
         problem("existzone");
     }
     $smarty->assign("zone", $gzone);
     $nz = new masterZone();
     if ($nz->parseZone($content, $zone, $user->getId()) && $nz->getId() > 0) {
         $smarty->assign("pagetitle", "Review imported records");
         $smarty->assign("template", "uploadreview.tpl");
         $smarty->assign("output", explode("\n", $nz->getConf($conf->hostMaster)));
         $smarty->assign("help", help("uploadreview"));
         $smarty->assign("menu_button", menu_buttons());
     } else {
         $smarty->assign("problem", explode("\n", $nz->getErr()));
         $smarty->assign("pagetitle", "Import error");
         $smarty->assign("template", "uploadproblem.tpl");
         $smarty->assign("help", help("uploadproblem"));
         $smarty->assign("menu_button", menu_buttons());
     }
     $smarty->display("main.tpl");
 } else {
Esempio n. 12
0
<?php

require_once "include.php";
if ($user->isAdmin()) {
    $i = isset($_GET['i']) ? intval($_GET['i']) : 0;
    if ($i > 1) {
        $smarty->assign("pagetitle", "Viewing user");
        $smarty->assign("admin_array", array("yes", "no"));
        $xuser = new User($i);
        $data = $xuser->getUser();
        $smarty->assign("user", $data);
        $xuser->loadUserZones();
        $masters = $xuser->getMasters('live');
        $masterlist = array();
        foreach ($masters as $id) {
            $temp = new masterZone(intval($id));
            $temp->loadZoneHead();
            $head = $temp->getZoneHead();
            $temp = array();
            foreach (array('id', 'name', 'serial') as $key) {
                $temp[$key] = $head[$key];
            }
            $masterlist[] = $temp;
        }
        $slaves = $xuser->getSlaves('live');
        $slavelist = array();
        foreach ($slaves as $id) {
            $temp = new slaveZone(intval($id));
            $temp->loadZoneHead();
            $head = $temp->getZoneHead();
            $temp = array();
Esempio n. 13
0
    $err = $dsz->getErr();
    if ($err > '') {
        $errors .= "<u>" . $hd['name'] . ":</u> Error in deleting\n" . $err . '\\n\\n';
    } else {
        $deleteds .= "<u>" . $hd['name'] . "</u>: Deleting success.\n\n";
        $bind->eraseConfig($hdr['name']);
        $done++;
    }
}
$error .= $errors > '' ? $delm . $errors : '';
$deleted .= $deleteds > '' ? $delm . $deleteds : '';
$errors = '';
$comm = count($cmaster) > 0 ? "<strong>" . "Committing master records" . "</strong>\n\n" : '';
$mcomm = '';
foreach ($cmaster as $master) {
    $cmz = new masterZone(intval($master['id']));
    $cmz->loadZoneHead();
    $hd = $cmz->getZoneHead();
    $hdr = $cmz->getZoneHeadRaw();
    $cmz->writeZone($conf->path . $hdr['name'], $conf->hostMaster);
    $zarray = array('type' => 'master', 'file' => $hdr['name']);
    $zarray['file'] .= $hd['secured'] == 'yes' && $cmz->doSecure($conf->path, $conf->zoneSigner, $conf->rollInit, $conf->rollerConf) ? ".signed" : "";
    $cmz->doCommit();
    $err = $cmz->getErr();
    if ($err > '') {
        $errors .= "<u>" . $hd['name'] . ":</u> Error in committing\n" . $err . '\\n\\n';
    } else {
        $mcomm .= "<u>" . $hd['name'] . "</u>: Committing success.\n" . $cmz->getMsg() . "\n";
        $bind->addConfig($hdr['name'], $zarray);
        $done++;
    }
Esempio n. 14
0
<?php

require_once "include.php";
$zoneid = intval($_GET['i']);
if ($user->isOwned($zoneid, 'master')) {
    if ($zoneid > 0) {
        $zone = new masterZone($zoneid);
        $zone->loadZoneHead();
        $zone->setZoneHead(array('updated' => 'del'));
        $zone->saveZoneHead();
    } else {
        problem();
    }
} else {
    problem("notown");
}