<?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';
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; }
<?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");
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; }
$gzone = $zone; $zone = hostToIdn($zone); if ($method != 'list') { $temp = tempnam($conf->tmp_path, "{$zone}"); $fh = fopen($temp, "w"); fwrite($fh, implode("\n", $content)); 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");
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(); foreach (array('id', 'name', 'master') as $key) {
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++; } }