"Fossies" - the Fresh Open Source Software Archive

Member "webbind_0.98/createnewzone.php" (5 Jan 2002, 4592 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("htmlcommon.php");
    3 require("global.php");
    4 require("locking.php");
    5 
    6 function CheckExists ($zonefile,$username,$phpbindurl,$server)
    7 {
    8 if (file_exists($zonefile)) {
    9     HTMLHeader();
   10     Banner("Zone Name already exists on $server ....<BR>Only modification allowed !<BR><BR><A HREF=\"$phpbindurl\">Back To Search Page</A>",$username,$server);
   11     clearstatcache();
   12     exit();
   13     }
   14 }
   15 
   16 function CheckSyntax($zonefile)
   17 {
   18  $ar_zonefile = explode(".", $zonefile) ;
   19  if (end($ar_zonefile) != "dns") {
   20     $zonefile .= ".dns";
   21     return($zonefile);
   22  } else {
   23     return($zonefile);
   24  }
   25 }
   26  
   27 
   28 //Riceve la query dal form nuovo dominio
   29 //
   30 if ( $newzonechoose != ".dns" ) {
   31         $server = $servername[$newserverchoose];
   32     
   33     $newzone = $newzonechoose;
   34     
   35     $newchekedzone = CheckSyntax($newzone); //Appende il suffisso .dns se rimosso dal form in fase di inserimento nome zona
   36 
   37         $zonefile="$basemount/$server/zones/$newchekedzone";
   38 
   39             CheckExists ($zonefile,$username,$phpbindurl,$server);
   40 
   41         //prepara output per named.conf master e slave 
   42         //crea file di zona iniziale
   43         //reconfig dei name servers daemons
   44         
   45     $ZONENAME = ereg_replace("\.dns", "", $newchekedzone);
   46         
   47             $namedoutmaster .= "zone \"$ZONENAME\" {\n";
   48                 $namedoutmaster .= "\ttype master;\n";
   49                 $namedoutmaster .= "\tfile \"$newchekedzone\";\n";
   50 //SE ESISTE UNA SELEZIONE PER SLAVE SERVER O EXTERNAL SERVER
   51         $namedoutmaster .= "\tallow-transfer { ";
   52         if ($newslavechoose != "") { $namedoutmaster .= "$ipfe[$newslavechoose];"; }
   53         if ($extslavefqdn != "") { $namedoutmaster .= " $extslaveip;"; }
   54         for ($tal = 0; $tal < (count ($transallowed)); $tal++) { $namedoutmaster .= " $transallowed[$tal];"; }
   55         $namedoutmaster .= " };\n";
   56 //
   57                 $namedoutmaster .= "};\n";
   58         $namedoutmaster .= "\n";
   59 $fl=Filelock();
   60     if ($fl) {
   61         $fp = fopen ("$basemount/$servername[$newserverchoose]/etc/named.conf","a");
   62                 fwrite ($fp, $namedoutmaster);
   63                 fclose ($fp);
   64         fclose($fl);
   65     }        
   66                 $ZONENAME = ereg_replace("\.dns", "", $newchekedzone);
   67         $TIMESTAMP = "Last modification on  ".date("Y/m/d H:i:s")."  by user: $username" ;
   68 
   69         $zoneout .= ";\n";
   70         $zoneout .= ";\t$TIMESTAMP\n";
   71         $zoneout .= ";\n";
   72         $zoneout .= ";\tDatabase file $newchekedzone for $ZONENAME zone.\n";
   73         $zoneout .= ";\n";
   74         $zoneout .= ";\n";
   75         $zoneout .= "\$TTL 86400\n";
   76         $zoneout .= "@\t\tIN\tSOA $server. postmaster.$server. (\n";
   77         $zoneout .= "\t\t\t$serial\t; serial number\n";
   78         $zoneout .= "\t\t\t$refresh\t\t; refresh\n";
   79         $zoneout .= "\t\t\t$retry\t\t; retry\n";
   80         $zoneout .= "\t\t\t$expire\t\t; expire\n";
   81         $zoneout .= "\t\t\t$ttl )\t\t; minimum TTL\n";
   82         $zoneout .= ";\n";
   83         $zoneout .= ";\n";
   84         $zoneout .= ";\tZone NS records\n";
   85         $zoneout .= ";\n";
   86         $zoneout .= ";\n";
   87         $zoneout .= "@\t\tNS\t$server.\n";
   88 //SE ESISTE UNA SELEZIONE PER SLAVE SERVER O EXTERNAL SLAVE SERVER
   89 if ($newslavechoose != "") { $zoneout .= "@\t\tNS\t$servername[$newslavechoose].\n"; }
   90 if ($extslavefqdn != "") { $zoneout .= "@\t\tNS\t$extslavefqdn.\n"; }
   91 //
   92         $fp = fopen ("$zonefile", "w+");
   93         fwrite ($fp, $zoneout);
   94         fclose ($fp);
   95 
   96                 exec ("$remexec $ipbe[$newserverchoose] $subin[$newserverchoose]/ndc reconfig , $result");
   97                 
   98 //SE ESISTE UNA SELEZIONE PER SLAVE SERVER DIRETTAMENTE MANTENUTO AGGIORNARE IL NAMED.CONF SULLA MACCHINA
   99     if ($newslavechoose != "") {
  100             $namedoutslave .= "zone \"$ZONENAME\" {\n";
  101                     $namedoutslave .= "\ttype slave;\n";
  102                     $namedoutslave .= "\tfile \"$newchekedzone.slavezone\";\n";
  103             $namedoutslave .= "\tmasters { $ipfe[$newserverchoose]; };\n";
  104                $namedoutslave .= "\tallow-transfer { ";
  105                for ($tal = 0; $tal < (count ($transallowed)); $tal++) { $namedoutslave .= " $transallowed[$tal];"; }
  106                $namedoutslave .= " };\n";
  107                     $namedoutslave .= "};\n";
  108             $namedoutslave .= "\n";
  109 $fl=Filelock();
  110         if ($fl) {
  111                     $fp = fopen ("$basemount/$servername[$newslavechoose]/etc/named.conf","a");
  112                     fwrite ($fp, $namedoutslave);
  113                     fclose ($fp);
  114         fclose($fl);
  115         }
  116                     exec ("$remexec $ipbe[$newslavechoose] $subin[$newslavechoose]/ndc reconfig , $result");
  117         }
  118 
  119 
  120         
  121         header ("Location: $phpbindurl/showzone.php?modifica=Modifica&zonechoose=$zonefile&idserver=$newserverchoose&username=$username");
  122 
  123 } else {
  124     HTMLHeader();
  125     Banner("Zone Name not specified<BR><BR><A HREF=\"$phpbindurl\">Back To Search Page</A>",$username,$servername[$newserverchoose]);
  126 }
  127 
  128 ?>