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

$fqdn=ereg_replace("\.dns", "", $zonename);	// FQDN of zone to delete
$cc=count($servername);				//How many server we managed


/*
	Remove zone files from master and(?) slave
*/

if(file_exists($zonefile)) {
$fl=Filelock();
 if ($fl) {
	$fp = fopen ($zonefile, "r");
	while (!feof ($fp)) {
		$buffer = fgets($fp, 4096);
	
		if ( (substr ($buffer, 0, 1) != ";") && (substr ($buffer, 0, 1) == "@") && (ereg("NS", $buffer)) ) {
			$exprow = explode("NS", $buffer);
			$RECORD_NS=trim(end($exprow));
			for($i=1; $i<=$cc; $i++) {
				if ($RECORD_NS == "$servername[$i].") {
					$slavefile="$basemount/$servername[$i]/zones/$zonename.slavezone";
					if (file_exists($slavefile)) { rename($slavefile, "$slavefile.removed"); } //delete slave file zones
						$namedconfori="$basemount/$servername[$i]/etc/named.conf";
						$namedconfbak="$basemount/$servername[$i]/etc/named.conf.bak";
						rename($namedconfori, $namedconfbak);
						$sourcefile=fopen("$namedconfbak", "r");
						$destfile=fopen("$namedconfori", "w+");
						while (!feof ($sourcefile)) {
								$sbuffer=fgets($sourcefile, 4096);
								if( (substr($sbuffer, 0,4) == "zone") && (ereg($fqdn,$sbuffer)) ) {
									$startc=(strpos($sbuffer,"\""))+1;
									$endc=strlen($fqdn);
										if ( substr($sbuffer, $startc, $endc) == $fqdn) {
											while(substr ($sbuffer, 0, 2) != "};") {
												fwrite($destfile, "//$sbuffer");
												$sbuffer=fgets($sourcefile, 4096);
												}
											fwrite($destfile, "//$sbuffer\n");	
											$sbuffer=fgets($sourcefile, 4096);
											} else { fwrite($destfile, $sbuffer); }
								} else { fwrite($destfile, $sbuffer); }
						}
					fclose($sourcefile);
					fclose($destfile);
					exec ("$remexec $ipbe[$i] $subin[$i]/ndc reconfig , $resultA");
					$resultt .= $resultA;
					
				}
			}
		}
	}
 rename($zonefile, "$zonefile.removed");
 fclose($fl);
 }
}


HTMLHeader();
Banner("Zone Removed $resultt<BR><BR><A HREF=\"$phpbindurl\">Back To Search Page</A>",$REMOTE_USER,$servername[$idserver]);


?>
Return current item: WeBBind Web Gui to Bind