Code

e775a21f05f3ee0c41aab93d675e676d38d479b7
[gosa.git] / plugins / admin / systems / class_servDNSeditZoneEntries.inc
1 <?php
3 class servDNSeditZoneEntries extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary= "Manage server basic objects";
7   var $cli_description= "Some longer text\nfor help";
8   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account= TRUE;
12   var $attributes= array("zoneName");
13   var $objectclasses= array("whatever");
15   var $Devices      = array();
16   var $InitDevices  = array();
18   var $zoneName       = "";   // ZoneName of currently edited Zone
19   var $reverseName    = "";   // ReverseZone of the currently edited Zone
21   var $RecordTypes= array();  // Possible record type. They will be set in contrucktor
22   //  and some types will be added later  (cName/Ptr)
25   var $disableDialog = false; // Dialog will be disabled, if this zone is new 
27   function servDNSeditZoneEntries ($config, $dn= NULL,$zoneName,$reverseName,$RTypes)
28   {
29     plugin::plugin ($config, $dn);
31     /* Initialise class
32      */
33     $this->zoneName     = $zoneName;
34     $this->reverseName  = $reverseName;
35     $this->RecordTypes  = $RTypes;
37     /* Add records types which are not allowed in zones 
38      */
39     $this->RecordTypes['cNAMERecord']  = "relativeDomainName";
40     $this->RecordTypes['pTRRecord']    = "relativeDomainName";
41     $this->RecordTypes['tXTRecord']    = "tXTRecord";
43     /* Get ldap connection 
44      */
45     $ldap = $this->config->get_ldap_link();
46     $ldap->cd($this->config->current['BASE']);
48     /* Get all objects using this zone  
49      * Workstations / Terminals
50      */
51     $res = $ldap->search("(&(objectClass=dNSZone)(|(zoneName=".$zoneName.")(zoneName=".$reverseName.".in-addr.arpa))(!(relativeDomainName=@)))");
52     $this->disableDialog = false;
53     while($attrs = $ldap->fetch($res)){
54       if(preg_match("/zoneName=/",$attrs['dn'])) continue;
55       foreach($this->RecordTypes as $atr => $val){
56         if((isset($attrs[$atr])) && (is_array($attrs[$atr]))){
57           unset($attrs[$val]['count']);
58           $dn = preg_replace("/^.*,cn/","cn",$attrs['dn']);
59           $this->Devices[$dn]['RECORDS'][$atr] = $attrs[$val]; 
60           $this->Devices[$dn]['Type']   = "Exists";
61         }
62       }
63     }
64    
65     /* Check if this zone exists 
66      */ 
67     $res = $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@)(|(zoneName=".$zoneName.")(zoneName=".$reverseName.".in-addr.arpa)))",
68         array("zoneName"));
69     if($ldap->count()){
70     }else{
71       $this->disableDialog = true;
72     }
74     /* Add additional informations 
75        to all caught objects ( ObjectInformations)
76      */
77     foreach($this->Devices as $dn => $Recs){
78       $attrs = $ldap->fetch($ldap->cat($dn,array("objectClass","cn")));
79       $this->Devices[$dn]['OBJECT'] = $attrs;
80       $this->Devices[$dn]['OrigCn'] = $attrs['cn'][0];
81     }
83     /* Add free entries
84      * Free entries are entries which are not directly assigned
85      *  to an existing network object like a WS or a Terminal.
86      * They will be found in a subtrees within a zone.
87      * For example : 
88      *  The object name is free1, 
89      *                                                             zoneName=test.de,cn=server ...
90      *                                // ObjectContainer
91      *                                relativeDomainName=Free1,zoneName=....
92      * // Dns entry
93      * relativeDomainName=Free1,  relativeDomainName=Free1,zoneName=....
94      * // cName entry .... 
95      * relativeDomainName=terminal12, relativeDomainName=Free1,zone...
96      */
97     $ldap->cd ("zoneName=".$this->zoneName.",".$this->dn);
98     $ldap->ls ("(&(objectClass=dNSZone)(!(relativeDomainName=@)))","zoneName=".$this->zoneName.",".$this->dn,array("*"));
100     $GetSubInformations = array();
101     while($attrs = $ldap->fetch()){
103       $dn = $attrs['dn'];
105       /* Split dn into relativeDomainNames 
106        */
107       $tmp =  split("relativeDomainName=",trim(preg_replace("/,zoneName=.*$/","\\1",$dn)));
108       $tmp2 = array();
109       foreach($tmp as $t){
110         if(empty($t)) continue;
111         $tmp2[] = preg_replace("/,$/","",$t);
112       }
114       /* Set object Name
115        */
116       $cn = $tmp2[0];
117       $dn = "relativeDomainName=".$cn.",zoneName=".$this->zoneName.",".$this->dn;  
119       /* Create entry 
120        */
121       $this->Devices[$dn]['OBJECT']           = $attrs;
122       $this->Devices[$dn]['OBJECT']['cn'][0]  = $cn;//attrs['relativeDomainName'];
123       $this->Devices[$dn]['OBJECT']['OrigCn'] = $cn;//attrs['relativeDomainName'][0];
124       $this->Devices[$dn]['Type']             = "Free";
126       $GetSubInformations [] = $dn;
127     }
129     /* Get sub informations 
130        CName or pTR records are stored in a sub entry.
132     // The base entry with aRecords/tXTrecords/....
133     relativeDomainName=Keks, relativeDomainName=Keks, zoneName=....
135     // And the sub entries like this one
136     relativeDomainName=10.2.64.in-addr.arpa, relativeDomainName=Keks, zoneName =...
137     (  They can't be stored in a single entry, so i decided to store them this way  ).
138      */ 
139     foreach($GetSubInformations as $dn){
140       $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$dn,array("*"));
141       while($attrs= $ldap->fetch()){
142         foreach($this->RecordTypes as $atr => $val){
143           if((isset($attrs[$atr])) && (is_array($attrs[$atr]))){
144             unset($attrs[$val]['count']);
145             $this->Devices[$dn]['RECORDS'][$atr]    = $attrs[$val];
146           }
147         }
148       } 
149     }
151     $this->Devices;
152     $this->InitDevices = $this->Devices;
153   }
155   function execute()
156   {
157     plugin::execute();
159     /* Check posts for operations ...  
160      */
161     $once = true;
162     foreach($_POST as $name => $value){
164       /* Add a new Record in given object  
165        */
166       if((preg_match("/^AddRecord_/",$name)) && ($once)){
167         $once   = false;
168         $tmp    = preg_replace("/^AddRecord_/","",$name);
169         $tmp    = preg_replace("/_.*$/","",$tmp);
170         $tmp2   = split("\|",$tmp);
172         $dn     = base64_decode($tmp2[0]);
173         $record = $tmp2[1];
174         $numrec = $tmp2[2];        
176         $this->Devices[$dn]['RECORDS'][$record][] = ""; 
177       }
179       /* Remove record from given dn
180        */
181       if((preg_match("/^RemoveRecord_/",$name)) && ($once)){
182         $once   = false;
183         $tmp    = preg_replace("/^RemoveRecord_/","",$name);
184         $tmp    = preg_replace("/_.*$/","",$tmp);
185         $tmp2   = split("\|",$tmp);
187         $dn     = base64_decode($tmp2[0]);
188         $record = $tmp2[1];
189         $numrec = $tmp2[2];        
191         unset($this->Devices[$dn]['RECORDS'][$record][$numrec]); 
193         if(count($this->Devices[$dn]['RECORDS'][$record]) == 0){
194           unset($this->Devices[$dn]['RECORDS'][$record]);
195           if(count($this->Devices[$dn]['RECORDS']) ==0){
196             unset($this->Devices[$dn]);
197           }
198         }
200       }
202       /* Add new host entry
203        */
204       if((preg_match("/^UserRecord_/",$name)) && ($once)){
205         $once = false;
206         $tmp['RECORDS']['aRecord'][0] =  'empty';
207         $tmp['Type']                  =  'Free';
208         $tmp['OBJECT']['cn'][0]       =  'Free';
209         $this->Devices[] = $tmp;
210       }
211     }
213     /* Fill templating stuff */
214     $smarty= get_smarty();
215     $display= "";
217     $table = "";
218     foreach($this->Devices as $key => $dev){
219       $table .= $this->generateRecordConfigurationRow($key);
220     }
223     $smarty->assign("disableDialog",$this->disableDialog);
224     $smarty->assign("table",$table);;
225     $display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE));
226     return($display);
227   }
230   /* Create html table out of given entry 
231    */
232   function generateRecordConfigurationRow($obj_dn){
234     /* get some basic inforamtions 
235      */
236     $obj        = $this->Devices[$obj_dn];
237     $objectName = $obj['OBJECT']['cn'][0];
239     /* Set title 
240      */
241     if($obj['Type'] == "Free"){   
242       $str = "<h3>".sprintf(_("Settings for host entry #%s"),($obj_dn +1))." : </h3>";
243     }else{
244       $str = "<h3>".sprintf(_("Settings for '%s'"),$obj_dn)." : </h3>";
245     }
247     $hostNameOnce = true;
248     /* Walk through all defined records 
249      */
250     $str.= "<table cellspacing='0' cellpadding='0'>";
251     foreach($obj['RECORDS'] as $id => $types){
253       /* Create table
254        */
255       foreach($types as $key => $type){
257         /* Create unique post name
258          */
259         $name = base64_encode($obj_dn)."|".$id."|".$key;
261         $str .= "<tr>
262           <td style='width:80px;'>";
264         if($hostNameOnce){
265           $hostNameOnce = false;  
266           $str .="<input type='text' name='RenameHost_".$name."' value='".$objectName."'>";
267         }else{
268           $str .=$objectName;
269         }  
271         $str .="
272           </td>
273           <td style='width:80px;'>
274           ".$this->createRecordTypeSelection($id,$name)."
275           </td>
276           <td>
277           <input type='text'  value='".$type."' name='ValueSelection_".$name."' style='width:250px;'>
278           </td>
279           <td style='width:50px;text-align:right;'>
280           <input type='image' name='AddRecord_".$name."'   src='images/crossref.png' alt='"._("Add")."' title='"._("Add")."'>
281           <input type='image' name='RemoveRecord_".$name."' src='images/edittrash.png'      alt='"._("Remove")."' title='"._("Remove")."'>
282           </td>
283           </tr>";
284       }
285     }
286     $str .="</table>";
287     return($str); 
288   }
290   /* Create selectbox with all available option types 
291    */
292   function createRecordTypeSelection($id,$refID,$isFreeRecord =false){
293     if(!$isFreeRecord){
294       $str = "\n<select name='RecordTypeSelection_".$refID."'>";
295     }else{
296       $str = "\n<select name='FreeRecordTypeSelection_".$refID."'>";
297     }
298     foreach($this->RecordTypes as $type => $atr) {
299       if($id == $type){
300         $str .="\n<option value='".$type."' selected >".strtoupper(preg_replace("/record/i","",$type))."</option>";
301       }else{
302         $str .="\n<option value='".$type."'>".strtoupper(preg_replace("/record/i","",$type))."</option>";
303       }
304     }
305     $str.= "\n</select>";
306     return($str);
307   }
309   function remove_from_parent()
310   {
311   }
313   function save_object()
314   {
315     /* Save all form fields 
316      */
318     /* Possible attributes posted 
319      */
320     $actions = array("RenameHost_","ValueSelection_");
321     foreach($_POST as $name=>$value){
323       foreach($actions as $act){
324         /* Check if attribute was posted 
325          */
326         if(preg_match("/".$act."/",$name)){
328           /* Extract informations out of postname 
329            */
330           $action = $act;
331           $tmp    = preg_replace("/^".$action."/","",$name);
332           $tmp    = preg_replace("/_.*$/","",$tmp); 
333           $tmp2   = split("\|",$tmp);      
335           $dn     = base64_decode($tmp2[0]);
336           $record = $tmp2[1];
337           $numrec = $tmp2[2]; 
339           // entry value was psoted
340           if($act == "ValueSelection_"){ 
341             $this->Devices[$dn]['RECORDS'][$record][$numrec] = $value;
342           }elseif($act == "RenameHost_"){
343             $tmp = array();
344             foreach($this->Devices as $dnn => $dev){
345               if($dn == $dnn){
346                 continue;
347               }
348               if(isset($dev['OrigCn'])){
349                 $n1 = strtolower($dev['OrigCn']);
350                 $tmp[$n1] = $n1;
351               } 
352               $n2 = strtolower($dev['OBJECT']['cn'][0]);
353               $tmp[$n2] = $n2;
354             }
356             if(!isset($tmp[strtolower($value)])){
357               $this->Devices[$dn]['OBJECT']['cn'][0] = $value;
358             }
359           }
360         }
361       }
362     }
363     foreach($_POST as $name => $value){
365       /* Check if attribute was posted
366        */
367       if(preg_match("/^RecordTypeSelection_/",$name)){
369         /* Extract informations out of postname
370          */
371         $action = "RecordTypeSelection_";
372         $tmp    = preg_replace("/^".$action."/","",$name);
373         $tmp    = preg_replace("/_.*$/","",$tmp);
374         $tmp2   = split("\|",$tmp);
376         $dn     = base64_decode($tmp2[0]);
377         $record = $tmp2[1];
378         $numrec = $tmp2[2];
380         if($record != $value){ 
381           $str =  $this->Devices[$dn]['RECORDS'][$record][$numrec];
382           unset($this->Devices[$dn]['RECORDS'][$record][$numrec]);
383           $this->Devices[$dn]['RECORDS'][$value][] = $str;
384         } 
385       }
386     }
387   }
389   /*  check something 
390    */
391   function check()
392   {
393     $message= array();
395     $ldap = $this->config->get_ldap_link();
396     $ldap->cd($this->config->current['BASE']);
398     $names = array();
399     foreach($this->Devices as $devDN => $device){
401       /* check: if given name for host entry is valid.
402        * cn exists ? invalid characters ? ...
403        */
404       if($device['Type'] == "Free"){
405         $cn = $device['OBJECT']['cn'][0];
407         $ldap->search("(cn=".$cn.")",array("cn"));
408         if($ldap->count()){
409           $message[] = sprintf(_("The name '%s' can't be used as host entry, the name is already used in this ldap tree."),$cn);
410         }
411       }
413       /* Checking entry name
414        */
415       if(!is_uid($device['OBJECT']['cn'][0])){
416         $message[] = sprintf(_("Entry name '%s' contains invalid characters."), $device['OBJECT']['cn'][0]);
417       }      
419       /* Check if we have renamed the server, hich we are currently editing.
420        * reset the value and display a message.
421        */
422       if(strcmp($devDN,$this->dn) ==0 ){  
423         $new = $device['OBJECT']['cn'][0];
424         $old = $this->InitDevices[$devDN]['OBJECT']['cn'][0];
426         if($new != $old){
427           $message[] = sprintf(_("Can't rename the server '%s' to '%s', the server contains this zone."),$old,$new); 
428         }
429       }
432       /* Renaming check for existing devices 
433        */
434       if(($device['Type'] == "Exists") && ($device['OrigCn'] != $device['OBJECT']['cn'][0])){
435         $cn = $device['OBJECT']['cn'][0];
437         $ldap->search("(cn=".$cn.")",array("cn"));
438         if($ldap->count()){
439           $message[] = sprintf(_("Can't rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$cn);
440         }
442         if(!is_uid($cn)){
443           $message[] = sprintf(_("Can't rename '%s' to '%s',the destination name contains invalid characters."),$device['OrigCn'],$cn);
444         }      
445       }
447       /* Check names 
448        */
449       if(!isset($names[$device['OBJECT']['cn'][0]])){
450         $names[$device['OBJECT']['cn'][0]] = "";
451       }else{
452         $message[] = sprintf(_("The name '%s' is used more than once."),$device['OBJECT']['cn'][0]);
453       }
455       /* Names should be written in lowercase
456        */
457       if(strtolower($device['OBJECT']['cn'][0]) != $device['OBJECT']['cn'][0]){
458         $message[] = sprintf(_("The host name '%s' should be written in lowercase."), $device['OBJECT']['cn'][0]);
459       }
461       /* Check records
462        */                 
463       $singleEntries = array("cNAMERecord","pTRRecord");
465       $tmp2 = array();
466       foreach($device['RECORDS'] as $type => $entries){
468         /* Check for multiple use of unique record types
469          */
470         if((in_array($type,$singleEntries)) && (count($entries) > 1)){
471           $message[] = sprintf(_("The record type '%s' is a unique type and can't be defined twice."),$type);
472         }
474         /* Check for empty / duplicate entries in record array 
475          */
476         $tmp = array();
477         foreach($entries as $entry){
479           /* Check for empty records 
480            */
481           if(empty($entry)){
482             $message[] = sprintf(_("There is an empty '%s' for host '%s'."),$type,$device['OBJECT']['cn'][0]);
483           }
485           /* Check for duplicate record entries 
486            */
487           if(!isset($tmp[$entry])){
488             $tmp[$entry]= 'test';
489           }else{
490             $message[] = sprintf(_("There is a duplicate entry in '%s' for '%s'."),$type,$device['OBJECT']['cn'][0]); 
491           }
492         }
493       }
494     }
495     return ($message);
496   }
498   function save()
499   {
500   
501     if($this->disableDialog) return;
503     /* Set all initial records to array()
504        This means they will be removed from the entry
505        if they won't be overwritten
506      */
507     foreach($this->InitDevices as $dn => $obj){
508       $attrs[$dn]= array();
509       foreach($obj['RECORDS'] as $rectype => $records){
510         $attrs[$dn][$rectype] = array();
511       }
512     }
514     /* Add new entries
515      */
516     foreach($this->Devices as $dn => $obj){
517       foreach($obj['RECORDS'] as $rectype => $records){
518         $attrs[$dn][$rectype] = array();
519         foreach($records as $rec){
520           $attrs[$dn][$rectype][] = $rec;
521         } 
522       }
523     }
525     /* Get ldap link
526      */
527     $ldap = $this->config->get_ldap_link();
528     $ldap->cd ($this->config->current['BASE']);
530     /* Generate 'T odo' :-)
531      */
532     $tmp = ($this->generate_LDAP_entries($attrs));
534     /* Delete all objects which should be delted 
535      */
536     foreach($tmp['del'] as $key => $ntr){
537       $ldap->rmdir_recursive($key);   
538     }
540     /* Add append new / updated entries 
541      */
542     foreach($tmp['addupdate'] as $key => $attrs){
543       $ldap->cat($key);
544       if($ldap->count() > 0){
545         $ldap->cd($key);
546         $ldap->modify($attrs);
547       }else{
548         $ldap->cd($this->config->current['BASE']);
549         $ldap->cd($key);
550         $ldap->add($attrs);        
551       }
553       /* Display errors ...
554        */
555       if($ldap->error != "Success"){
556         echo "<br>".$ldap->error."<br>";
557         print_a($attrs);
558         echo $key;
559       }
560     }
562     /* Rename entries 
563        !! Terminals / WS / etc will be renamed too
564      */
565     foreach($tmp['rename'] as $old => $new){
566       $ldap->cat($old);
567       $this->recursive_move($old,$new);
568     }
569   }
572   /* This function creates an array with following indexs
573    * 'delete'       for all dns which should be deleted recursivly
574    * 'addupdated'   Contains all entries which should be written
575    * 'rename'       Contains all dns which should be renamed 
576    */
577   function generate_LDAP_entries($objs)
578   {
580     $entries = array();
581     $delete  = array();    
582     $rename  = array();
584     $ldap = $this->config->get_ldap_link();
585     $ldap->cd ($this->config->current['BASE']);
587     /* these entries are added to base object ... 
588      */
589     $normal = array("mDRecord","aRecord","tXTRecord","mXRecord","hInfoRecord","mInfoRecord","aFSDBRecord","SigRecord","KeyRecord","aAAARecord","nSRecord",
590         "LocRecord","nXTRecord","sRVRecord","nAPTRRecord","kXRecord","certRecord","a6Record","dSRecord","sSHFPRecord","rRSIGRecord","nSECRecord");
592     /* Create t odo
593      */
594     foreach($objs as $dn => $recs){
596       /* Check if object must be renamed 
597        */
598       if(isset($this->Devices[$dn]['OrigCn'])){
599         if($this->Devices[$dn]['OBJECT']['cn'][0] != $this->Devices[$dn]['OrigCn']){
600           $newdn = str_replace("cn=".$this->Devices[$dn]['OrigCn'], "cn=".$this->Devices[$dn]['OBJECT']['cn'][0],$this->Devices[$dn]['OBJECT']['dn']);
601           $rename[$this->Devices[$dn]['OBJECT']['dn']]  =  $newdn;
602           $rename["relativeDomainName=".$this->Devices[$dn]['OrigCn'].",".$newdn]  = "relativeDomainName=".$this->Devices[$dn]['OBJECT']['cn'][0].",".$newdn;
603         }
604       }
606       /* Get basic info
607        */ 
608       if(isset($this->Devices[$dn])){
609         $obj = $this->Devices[$dn];
610       }else{
611         $obj = NULL;
612       }
614       /* If is valid entry 
615        */
616       if($obj != NULL){  
618         /*  Both type must be handled different 
619          *  free / Exists 
620          */
621         if($obj["Type"] == "Free"){
622           $objectName = $obj['OBJECT']['cn'][0];
623         }else{
624           $objectName = $obj['OrigCn'];
625         }
628         /* If type is free, check 
629          */
630         if($obj['Type'] == "Free"){
632           /* Remove entry, if it was renamed 
633            */
634           if(isset($obj['OBJECT']['OrigCn'])){
635             if($obj['OBJECT']['cn'][0] != $obj['OBJECT']['OrigCn']){
636               $delete["relativeDomainName=".$obj['OBJECT']['OrigCn'].",zoneName=".$this->zoneName.",".$this->dn]="";
637             }
638           }
640           /* Add new entry 
641            */
642           $dn  = "relativeDomainName=".$objectName.",zoneName=".$this->zoneName.",".$this->dn;
643           $dn2 = $dn;
645           $ldap->cat($dn);
646           if($ldap->count() == 0){
647             $entries[$dn]['objectClass']        = array("top","dNSZone");
648             $entries[$dn]['zoneName']           = $this->zoneName;
649             $entries[$dn]['relativeDomainName'] = $objectName;
650           }
651         }
652       }
654       /* Calculate records ... 
655        */
656       foreach($recs as $type =>  $rec){
658         /*  Simply add normal entries 
659          */
660         if($obj != NULL){
661           if(in_array($type,$normal)){
662             $ldap->cat('relativeDomainName='.$objectName.','.$dn);
664             /* Append objectFrame if object doesn't exists in ldap
665              */
666             if($ldap->count()  == 0) {
667               $entries['relativeDomainName='.$objectName.','.$dn]['objectClass']        = array("top","dNSZone");
668               $entries['relativeDomainName='.$objectName.','.$dn]['zoneName']           = $this->zoneName;
669               $entries['relativeDomainName='.$objectName.','.$dn]['relativeDomainName'] = $objectName;
670             }
671             $entries['relativeDomainName='.$objectName.','.$dn][$type] = $rec ;
672           }
674           /*  Special handling for cNAMERecords 
675            */
676           if($type == "cNAMERecord"){
678             $useDn = $dn;
679             if($obj['Type'] == "Free"){
680               $useDn = $dn2;
681             }
683             if(isset($this->InitDevices[$useDn]['RECORDS']['cNAMERecord'])){
684               foreach($this->InitDevices[$useDn]['RECORDS']['cNAMERecord'] as $warmal){
685                 $delete['relativeDomainName='.$warmal.','.$useDn] = "";
686               }
687             }
688             foreach($rec as $r){
689               if(!empty($r)){
690                 $entries['relativeDomainName='.$r.','.$useDn]['objectClass']        = array("top","dNSZone");
691                 $entries['relativeDomainName='.$r.','.$useDn]['zoneName']           = $this->zoneName;
692                 $entries['relativeDomainName='.$r.','.$useDn]['cNAMERecord']        = $objectName;
693                 $entries['relativeDomainName='.$r.','.$useDn]['relativeDomainName'] = $r;
694               }
695             }
696           }
698           /* Special handling for ptrrecord
699            */ 
700           if($type == "pTRRecord"){
702             $useDn = $dn;
703             if($obj['Type'] == "Free"){
704               $useDn = $dn2;
705             }
707             if(isset($this->InitDevices[$dn]['RECORDS']['pTRRecord'])){
708               foreach($this->InitDevices[$dn]['RECORDS']['pTRRecord'] as $warmal){
709                 $delete['relativeDomainName='.$warmal.','.$useDn] = "";
710               }
711             }
712             foreach($rec as $r){
713               if(!empty($r)){
714                 $entries['relativeDomainName='.$r.','.$useDn]['pTRRecord']          = $objectName;
715                 $entries['relativeDomainName='.$r.','.$useDn]['zoneName']           = $this->reverseName.".in-addr.arpa";
716                 $entries['relativeDomainName='.$r.','.$useDn]['relativeDomainName'] = $r;
717                 $entries['relativeDomainName='.$r.','.$useDn]['objectClass']        = array("top","dNSZone");
718               }
719             }
720           }
721         }
722         if($obj == NULL){
723           $obj = $this->InitDevices[$dn];
724           if($obj['Type'] == "Free"){
725             $delete['relativeDomainName='.$objectName.','.$dn] = "";
726           }else{
727             $ldap->cd($dn);
728             $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$dn,array("relativeDomainName"));
729             while($attrs = $ldap->fetch()){
730               $delete[$attrs['dn']] = "";
731             }
732           }
733         }    
735       }
736     }
737     $ret = array("del"=> $delete , "addupdate"=> $entries, "rename"=> $rename);
738     return($ret);
739   }
743 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
744 ?>