Example #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;
}
Example #2
0
         $content = $zone > '' ? file($conf->path . idnToHost($_POST['sel'])) : array();
         $smarty->assign("method", "Select orphan file from list");
         break;
     case "text":
         $zone = isset($_POST['txt_domain']) && isset($_POST['txt']) ? $_POST['txt_domain'] : '';
         $content = $zone > '' ? explode("\n", $_POST['txt']) : array();
         $smarty->assign("method", "Write zone manually or pasted from clipboard");
         break;
     default:
         problem();
 }
 if (count($content) < 4) {
     problem("nocontent");
 }
 $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();
Example #3
0
 public function doSecure($zonedir, $zonesigner, $rollinit, $rollerconf)
 {
     if (!$this->is_complete()) {
         ob_start();
         var_dump($this->head);
         $this->err .= "Zone head is not complete" . "\n" . ob_get_clean();
         error_log($this->err);
         return false;
     }
     $err = $this->err;
     $param = $this->refresh_secure($zonedir) && $err == $this->err ? '' : ' -genkeys -usensec3';
     if ($err != $this->err) {
         return false;
     }
     $cmd = $zonesigner . $param . " -zone " . $this->head['name'] . " " . $zonedir . $this->head['name'] . " 2>/dev/stdout";
     unset($coutput);
     $currpath = getcwd();
     chdir($zonedir);
     exec($cmd, $coutput, $signexit);
     chdir($currpath);
     if ($signexit != 0) {
         $this->err .= "Zonesigner error (" . $signexit . "):\n" . implode("\n", $coutput);
         error_log($this->err);
         return false;
     } else {
         $this->msg .= "Zonesigner output (" . $signexit . "):\n  " . implode("\n  ", $coutput) . "\n";
     }
     if (!$this->refresh_secure($zonedir)) {
         return false;
     }
     $rollf = file($rollerconf, FILE_IGNORE_NEW_LINES);
     $noroll = false;
     foreach ($rollf as $row) {
         preg_match('/^\\s*roll\\s+"' . $this->head['name'] . '"\\s*/', $row, $match);
         $noroll = isset($match[0]) && $row == $match[0];
         if ($noroll) {
             break;
         }
     }
     if (!$noroll) {
         $cmd = $rollinit . " " . $this->head['name'] . " -zone " . $zonedir . $this->head['name'] . '.signed' . " -keyrec " . $zonedir . $this->head['name'] . ".krf " . " -directory " . $zonedir . " 2>/dev/stdout";
         unset($coutput);
         exec($cmd, $coutput, $exit);
         if ($exit != 0) {
             $this->err .= "Rollerd error(" . $exit . "):\n" . implode("\n  ", $coutput) . "\n";
             error_log($this->err);
             return false;
         } else {
             $fh = fopen($rollerconf, "a+");
             fwrite($fh, "\n# rollinit config for zone " . hostToIdn($this->head['name']) . ":\n" . implode("\n", $coutput) . "\n");
             fclose($fh);
             $this->msg .= "\n  Rollerd for zone " . hostToIdn($this->head['name']) . " is configured now\n";
         }
     } else {
         $this->msg .= "\n  Rollerd for zone " . hostToIdn($this->head['name']) . " has already set\n";
     }
     return true;
 }
Example #4
0
 *
 **********************************************************************
 *
 * Process the options form and save the changes
 *
 */
require_once "include.php";
if ($user->isAdmin()) {
    $allrec = array();
    foreach ($_POST as $key => $value) {
        $val = $value;
        switch ($key) {
            case 'master':
            case 'prins':
            case 'secns':
                $val = hostToIdn(preg_replace('/([\\s\\r\\n]+|\\.$)/', '', $value));
                break;
            case 'range':
                $val = intval($value) > 0 ? intval($value) : 10;
                break;
            case 'hostmaster':
                $val = preg_replace('/([\\s\\r\\n]+|\\.$)/', '', $value);
                break;
            default:
                $val = strtolower($value) == 'on' || strtolower($value) == 'off' ? strtolower($value) : 'off';
        }
        $allrec[$key] = $val;
    }
    foreach ($allrec as $key => $value) {
        $res = $db->query("UPDATE options SET prefval = '" . $value . "' " . "WHERE prefkey = '" . $key . "'");
    }