"Fossies" - the Fresh Open Source Software Archive

Member "webbind_0.98/removezone.php" (5 Jan 2002, 2119 Bytes) of package /linux/misc/dns/old/WeBBind_0.98.tar:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?
    2 require("global.php");
    3 require("htmlcommon.php");
    4 require("locking.php");
    5 
    6 $fqdn=ereg_replace("\.dns", "", $zonename); // FQDN of zone to delete
    7 $cc=count($servername);             //How many server we managed
    8 
    9 
   10 /*
   11     Remove zone files from master and(?) slave
   12 */
   13 
   14 if(file_exists($zonefile)) {
   15 $fl=Filelock();
   16  if ($fl) {
   17     $fp = fopen ($zonefile, "r");
   18     while (!feof ($fp)) {
   19         $buffer = fgets($fp, 4096);
   20     
   21         if ( (substr ($buffer, 0, 1) != ";") && (substr ($buffer, 0, 1) == "@") && (ereg("NS", $buffer)) ) {
   22             $exprow = explode("NS", $buffer);
   23             $RECORD_NS=trim(end($exprow));
   24             for($i=1; $i<=$cc; $i++) {
   25                 if ($RECORD_NS == "$servername[$i].") {
   26                     $slavefile="$basemount/$servername[$i]/zones/$zonename.slavezone";
   27                     if (file_exists($slavefile)) { rename($slavefile, "$slavefile.removed"); } //delete slave file zones
   28                         $namedconfori="$basemount/$servername[$i]/etc/named.conf";
   29                         $namedconfbak="$basemount/$servername[$i]/etc/named.conf.bak";
   30                         rename($namedconfori, $namedconfbak);
   31                         $sourcefile=fopen("$namedconfbak", "r");
   32                         $destfile=fopen("$namedconfori", "w+");
   33                         while (!feof ($sourcefile)) {
   34                                 $sbuffer=fgets($sourcefile, 4096);
   35                                 if( (substr($sbuffer, 0,4) == "zone") && (ereg($fqdn,$sbuffer)) ) {
   36                                     $startc=(strpos($sbuffer,"\""))+1;
   37                                     $endc=strlen($fqdn);
   38                                         if ( substr($sbuffer, $startc, $endc) == $fqdn) {
   39                                             while(substr ($sbuffer, 0, 2) != "};") {
   40                                                 fwrite($destfile, "//$sbuffer");
   41                                                 $sbuffer=fgets($sourcefile, 4096);
   42                                                 }
   43                                             fwrite($destfile, "//$sbuffer\n");  
   44                                             $sbuffer=fgets($sourcefile, 4096);
   45                                             } else { fwrite($destfile, $sbuffer); }
   46                                 } else { fwrite($destfile, $sbuffer); }
   47                         }
   48                     fclose($sourcefile);
   49                     fclose($destfile);
   50                     exec ("$remexec $ipbe[$i] $subin[$i]/ndc reconfig , $resultA");
   51                     $resultt .= $resultA;
   52                     
   53                 }
   54             }
   55         }
   56     }
   57  rename($zonefile, "$zonefile.removed");
   58  fclose($fl);
   59  }
   60 }
   61 
   62 
   63 HTMLHeader();
   64 Banner("Zone Removed $resultt<BR><BR><A HREF=\"$phpbindurl\">Back To Search Page</A>",$REMOTE_USER,$servername[$idserver]);
   65 
   66 
   67 ?>