Code

Closes #235 Propose IP addresses for selected zone.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Dec 2007 08:07:23 +0000 (08:07 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Dec 2007 08:07:23 +0000 (08:07 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8004 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_termDNS.inc
plugins/admin/systems/network.tpl

index 5910182ba3b4d02c43c51d23af4586f82dd4434e..025933291e6aebd46ae0fec893cb435652aa65eb 100644 (file)
@@ -231,7 +231,6 @@ class termDNS extends plugin
         }
       }
     }
-
     
   
     /**********
@@ -282,6 +281,10 @@ class termDNS extends plugin
     $smarty->assign("dhcpParentNodeCnt",count($this->dhcpParentNodes));
 
 
+    /**********
+     * DNS Handling
+     **********/
+
     /* There is no dns available
      */
     if($this->DNSenabled == false){
@@ -305,6 +308,16 @@ class termDNS extends plugin
         $this->dnsEntry['RECORDS'][]  =array("type"=>"aRecord","value"=>"");
       }
 
+      /* propose_ip */
+      if(isset($_POST['propose_ip'])){
+        foreach($this->Zones as $key => $name){
+          if($name == $this->dnsEntry['zoneName']){
+            $net = FlipIp(str_replace(".in-addr.arpa","",getNameFromMix($key)));
+            $this->ipHostNumber = $this->generateRandomIp($net);
+          }
+        }
+      }
+
       /* Handle all posts */
       $only_once =true;
       foreach($_POST as $name => $value){
@@ -956,6 +969,20 @@ class termDNS extends plugin
   }
 
   
+  function generateRandomIP($net = "")
+  {
+    $str = $net;
+    $cnt = 4;
+    while(substr_count($str,".") < 3 && $cnt > 0){
+      $str .= ".".rand(0,255);
+      $str = preg_replace("/\.\.*/",".",$str);
+      $str = trim($str,". ");
+      $cnt --;
+    }
+    return($str);
+  }
+
+  
   function create_tree($arr,$base,$current = "")
   {
     $ret = array();
index 98c21d66b4ab62f31158b14e077cc57b7796f71c..7cb6b3ff996db6be15412e5e4c498a4fa82023d1 100644 (file)
                                        <td>
 {render acl=$ipHostNumberACL}
             <input     id="ipHostNumber"       name="ipHostNumber"     size=25 maxlength=80    value="{$ipHostNumber}">
+{/render}
+{render acl=$ipHostNumberACL}
+{if $DNSAccount == true}
+      <input id="propose_ip" type="submit" name="propose_ip" value="{t}Propose ip{/t}" style="visibility:visible;">
+      {else}
+      <input id="propose_ip" type="submit" name="propose_ip" value="{t}Propose ip{/t}" style="visibility:hidden;">
+      {/if}
 {/render}
           </td>
                                </tr>
@@ -77,6 +84,7 @@
         onclick="toggle('test2');
           changeState('zoneName');
           changeState('dNSTTL');
+          toggle('propose_ip');
           changeState('AddNewRecord');
           {$changeStateForRecords}"/>
         {else}
@@ -84,6 +92,7 @@
         onclick="toggle('test2');
           changeState('zoneName');
           changeState('dNSTTL');
+          toggle('propose_ip');
           changeState('AddNewRecord');"/>
         {/if}