hi,

i wrote a patch, can anyone test it?

thx
onovy
Fri, Jul 23, 2004 at 08:15:10AM -0700  Bill Shupp napsal:
> > so, what about checkbox? :D
> 
> If anything, this should be an option.  But this would have to be done
> carefully, as it could easily become a sloppy mess.  Someone else will
> have to submit a patch, I'm not that interested in it.
> 
> Regards,
> 
> Bill Shupp
diff -Naur vegadns.orig/src/domains.php vegadns/src/domains.php
--- vegadns.orig/src/domains.php        2004-06-18 05:45:48.000000000 +0200
+++ vegadns/src/domains.php     2004-07-26 10:24:08.000000000 +0200
@@ -461,6 +461,16 @@
     $array = array_unique($array_notunique);
 
     $counter = 0;
+    // default SOA and NS
+    if ($_REQUEST['default_soa']=="on")
+     $def_soa=mysql_fetch_array(
+      mysql_query("SELECT host,val FROM default_records WHERE type='S'"));
+    if ($_REQUEST['default_ns']=="on") {
+     $q=mysql_query("SELECT host,val,distance,ttl FROM default_records WHERE 
type='N'");
+     while ($l = mysql_fetch_array($q))
+      $def_ns[]=$l;
+    }
+
     while(list($key,$domain) = each($array)) {
         if(strlen($domain) == 0) continue;
 
@@ -503,19 +513,42 @@
             if($line_key != 'domain' && !ereg("^#", $value)) {
                 $result = parse_dataline($value);
                 if(is_array($result)) {
-                    $q = "insert into records 
-                        (domain_id,host,type,val,distance,ttl) 
-                        values(
-                            $domain_id,
-                            '".mysql_escape_string(ereg_replace("[\]052", "*", 
$result['host']))."',
-                            '".$result['type']."',
-                            '".mysql_escape_string($result['val'])."',
-                            '".$result['distance']."',
-                            '".$result['ttl']."')";
-                    mysql_query($q) or die(mysql_error().$q);
+                   if (($_REQUEST['default_soa']=="on") && ($result['type']=='S')) {
+                    $result['val']=$def_soa['val'];
+                    $result['host']=$def_soa['host'];
+                   }
+                   if (($_REQUEST['default_ns']!="on") || ($result['type']!='N')) {
+                     $q = "insert into records 
+                         (domain_id,host,type,val,distance,ttl) 
+                         values(
+                             $domain_id,
+                             '".mysql_escape_string(ereg_replace("[\]052", "*", 
$result['host']))."',
+                             '".$result['type']."',
+                             '".mysql_escape_string($result['val'])."',
+                             '".$result['distance']."',
+                             '".$result['ttl']."')";
+                     mysql_query($q) or die(mysql_error().$q);
+                   }
                 }
             }
-        }
+       }
+        if ($_REQUEST['default_ns']=="on") {
+        $counter=0;
+         while ($ns = $def_ns[$counter]) {
+         $host = ereg_replace("DOMAIN", $domain, $ns['host']);
+          $q = "insert into records 
+                (domain_id,host,type,val,distance,ttl) 
+                values(
+                $domain_id,
+                '".mysql_escape_string($host)."',
+                'N',
+                '".mysql_escape_string($ns['val'])."',
+                '".$ns['distance']."',
+                '".$ns['ttl']."')";
+          mysql_query($q) or die(mysql_error().$q);      
+         $counter++;
+        }
+       }
         $log_entry = "imported via axfr from ".$_REQUEST['hostname'];
         dns_log($domain_id,$log_entry);
     }
diff -Naur vegadns.orig/templates/import_form.tpl vegadns/templates/import_form.tpl
--- vegadns.orig/templates/import_form.tpl      2004-07-26 09:44:57.000000000 +0200
+++ vegadns/templates/import_form.tpl   2004-07-26 10:09:29.000000000 +0200
@@ -23,5 +23,7 @@
     </table>
 </td></tr>
 </table>
-    <br><input type="submit" value="get domains">
+    Rewrite SOA to default value?<input type="checkbox" name="default_soa">
+    <br>Rewrite NS servers to defalt values?<input type="checkbox" name="default_ns">
+    <br><br><input type="submit" value="get domains">
 </form>

Reply via email to