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"; $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 {
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; }
} 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++; } } $error .= $errors > '' ? $comm . $errors : ''; $commited .= $mcomm > '' ? $comm . $mcomm : '';