Location: PHPKode > projects > WeBBind Web Gui to Bind > webbind_0.98/writezone.php
<?
require("htmlcommon.php");
require("global.php");
require("locking.php");
require("clrzonesess.php");

$serverchoose = $servername[$idserver];

// INSERIRE CONTROLLO CONGRUENZA MINIMA DATI


if ( $serial != "" ) {
		$SERIAL = $serial ;
	}

if ( $nameservernew != "" ) {
		$NSnew = trim ($nameservernew) ;
	}

if ( $mailxvaluenew != "" && $mailxrecordnew != "" ) {
		$MXhostnew = $mailxhostnew ;
                $MXvaluenew = $mailxvaluenew ;
                $MXrecordnew = $mailxrecordnew ;
        }

if ( $ahostnew != "" && $aipnew != "" ) {
                $Ahostnew = $ahostnew ;
                $Aipnew = $aipnew ;
        }

if ( $cnamehostnew != "" && $cnamevaluenew != "" ) {
                $CNAMEhostnew = $cnamehostnew ;
                $CNAMEvaluenew = $cnamevaluenew ;
        }

if ( $delegationzonenew != "" && $delegationnsnew != "" ) {
                $DELEGATIONzonenew = $delegationzonenew ;
                $DELEGATIONnsnew = $delegationnsnew ;
        }

if ( $ptripnnew != "" && $ptrhostnnew != "" ) {
                $PTRipnew = $ptripnnew ;
                $PTRhostnew = $ptrhostnnew ;
        }


$SUFFIXZONENAME = explode("/", $filelocation);
 end($SUFFIXZONENAME);
$ZONENAME = ereg_replace("\.dns", "", current($SUFFIXZONENAME));
$TIMESTAMP = "Last modification on  ".date("Y/m/d H:i:s")."  by user: $username" ;


$zoneout .= ";\n";
$zoneout .= ";\t$TIMESTAMP\n";
$zoneout .= ";\n";
$zoneout .= ";\tDatabase file ".current($SUFFIXZONENAME)." for $ZONENAME zone.\n";
$zoneout .= ";\n";
$zoneout .= ";\n";
$zoneout .= "\$TTL 86400\n";
$zoneout .= "@\t\tIN\tSOA $serverchoose. postmaster.$serverchoose. (\n";
$zoneout .= "\t\t\t$oserial\t; serial number\n";
$zoneout .= "\t\t\t$refresh\t\t; refresh\n";
$zoneout .= "\t\t\t$retry\t\t; retry\n";
$zoneout .= "\t\t\t$expire\t\t; expire\n";
$zoneout .= "\t\t\t$ttl )\t\t; minimum TTL\n";
$zoneout .= ";\n";
$zoneout .= ";\n";
$zoneout .= ";\tZone NS records\n";
$zoneout .= ";\n";
$zoneout .= ";\n";
  for ($i = 0; $i < (count ($nameserver)); $i++) {
	if ($nameserver[$i]) {
		$zoneout .= "@\t\tNS\t$nameserver[$i]\n";
	}
  }
  if ($NSnew) {
	$zoneout .= "@\t\tNS\t$NSnew\n";
  }
$zoneout .= ";\n";
$zoneout .= ";\n";
$zoneout .= ";\tZone records\n";
$zoneout .= ";\n";
$zoneout .= ";\n";
    for ($i = 0; $i < (count ($mailxvalue)); $i++) {
	if ($mailxrecord[$i]) {
        	$zoneout .= "$mailxhost[$i]\t\tMX\t$mailxvalue[$i]\t$mailxrecord[$i]\n";
	}
  }
  if ($MXvaluenew) {
	$zoneout .= "$MXhostnew\t\tMX\t$MXvaluenew\t$MXrecordnew\n";
  }
$zoneout .= "\n";
$zoneout .= "\n";
    for ($i = 0; $i < (count ($ahost)); $i++) {
	if ($aip[$i]) {
        	$zoneout .= "$ahost[$i]\t\tA\t$aip[$i]\n";
	}
  }
  if ($Ahostnew) {
        $zoneout .= "$Ahostnew\t\tA\t$Aipnew\n";
  }
$zoneout .= "\n";
$zoneout .= "\n";
        for ($i = 0; $i < (count ($cnamehost)); $i++) {
        if ($cnamevalue[$i]) {
                $zoneout .= "$cnamehost[$i]\t\tCNAME\t$cnamevalue[$i]\n";
        }
  }
  if ($CNAMEhostnew) {
        $zoneout .= "$CNAMEhostnew\t\tCNAME\t$CNAMEvaluenew\n";
  }
  for ($i = 0; $i < (count ($ptrhost)); $i++) {
        if ($ptrhost[$i]) {
                $zoneout .= "$ptrip[$i]\t\tPTR\t$ptrhost[$i]\n";
			if ($ptrhostnew[$i]) { 
					$zoneout .= "\t\tPTR\t$ptrhostnew[$i]\n";
			}
        }
  }
  if ($PTRipnew) {
        $zoneout .= "$PTRipnew\t\tPTR\t$PTRhostnew\n";
  }

$zoneout .= ";\n";
$zoneout .= ";\n";
$zoneout .= ";\tDelegated sub-zone\n";
$zoneout .= ";\n";
$zoneout .= ";\n";
        for ($i = 0; $i < (count ($delegationzone)); $i++) {
        if ($delegationzone[$i]) {
                $zoneout .= "$delegationzone[$i]\t\tNS\t$delegationns[$i]\n";
        }
  }
  if ($DELEGATIONzonenew) {
        $zoneout .= "$DELEGATIONzonenew\t\tNS\t$DELEGATIONnsnew\n";
  }
$zoneout .= "\n";

// print $zoneout;

$fl=Filelock();
if ( $fl ) {

	// SALVA UNA COPIA DI BACKUP E MODIFICA LA ZONA //
	if (!copy($filelocation, $filelocation.'.backup')) {
		HTMLHeader();
		Banner("Fail to backup zonefile for $SUFFIXZONENAME<BR><BR><A HREF=\"$phpbindurl\">Back To Search Page</A>",$user,$server);
		die();
	}

	$fp = fopen ("$filelocation", "w+");
	fwrite ($fp, $zoneout);
	fclose ($fp);

fclose($fl);
}

// Need .rhosts in named home dir (SOLARIS) with client hostname and named as user

exec ("$remexec $ipbe[$idserver] $subin[$idserver]/ndc reload $ZONENAME", $result);

HTMLHeader();
Banner("$result[0]<BR><BR><A HREF=\"$phpbindurl\">Back To Search Page</A>",$user,$server);

ClrZoneSess($zonelock);

?>
Return current item: WeBBind Web Gui to Bind