Code

ACls with no memebers are no inactive.
[gosa.git] / gosa-core / include / class_userinfo.inc
1 <?php
2 /*
3  * This code is part of GOsa (http://www.gosa-project.org)
4  * Copyright (C) 2003-2008 GONICUS GmbH
5  *
6  * ID: $$Id$$
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class userinfo
24 {
25   var $dn;
26   var $ip;
27   var $username;
28   var $cn;
29   var $uid;
30   var $restrictions= array();
31   var $gidNumber= -1;
32   var $language= "";
33   var $config;
34   var $gosaUnitTag= "";
35   var $subtreeACL= array();
36   var $ACL= array();
37   var $ocMapping= array();
38   var $groups= array();
39   var $result_cache =array();
40   var $ignoreACL = FALSE;
41   var $ACLperPath = array();
42   var $ACLperPath_usesFilter = array();
44   /* get acl's an put them into the userinfo object
45      attr subtreeACL (userdn:components, userdn:component1#sub1#sub2,component2,...) */
46   function userinfo(&$config, $userdn){
47     $this->config= &$config;
48     $ldap= $this->config->get_ldap_link();
49     $ldap->cat($userdn,array('sn', 'givenName', 'uid', 'gidNumber', 'preferredLanguage', 'gosaUnitTag', 'gosaLoginRestriction'));
50     $attrs= $ldap->fetch();
52     if (isset($attrs['givenName'][0]) && isset($attrs['sn'][0])){
53       $this->cn= $attrs['givenName'][0]." ".$attrs['sn'][0];
54     } else {
55       $this->cn= $attrs['uid'][0];
56     }
57     if (isset($attrs['gidNumber'][0])){
58       $this->gidNumber= $attrs['gidNumber'][0];
59     }
61     /* Restrictions? */
62     if (isset($attrs['gosaLoginRestriction'])){
63       $this->restrictions= $attrs['gosaLoginRestriction'];
64       unset($this->restrictions['count']);
65     }
67     /* Assign user language */
68     if (isset($attrs['preferredLanguage'][0])){
69       $this->language= $attrs['preferredLanguage'][0];
70     }
72     if (isset($attrs['gosaUnitTag'][0])){
73       $this->gosaUnitTag= $attrs['gosaUnitTag'][0];
74     }
76     $this->dn= $userdn;
77     $this->uid= $attrs['uid'][0];
78     $this->ip= $_SERVER['REMOTE_ADDR'];
80     $this->ignoreACL = ($this->config->get_cfg_value("ignoreAcl") == $this->dn);
82     /* Initialize ACL_CACHE */
83     $this->reset_acl_cache();
84   }
87   public function reset_acl_cache()
88   {
89     /* Initialize ACL_CACHE */
90     session::global_set('ACL_CACHE',array());
91   }
93   function loadACL()
94   {
95     $this->ACL= array();    
96     $this->groups= array();    
97     $this->result_cache =array();
98     $this->reset_acl_cache();
99     $ldap= $this->config->get_ldap_link();
100     $ldap->cd($this->config->current['BASE']);
102     /* Get member groups... */
103     $ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array('dn'));
104     while ($attrs= $ldap->fetch()){
105       $this->groups[$attrs['dn']]= $attrs['dn'];
106     }
108     /* Crawl through ACLs and move relevant to the tree */
109     $ldap->search("(objectClass=gosaACL)", array('dn', 'gosaAclEntry'));
110     $aclp= array();
111     $aclc= array();
112     while ($attrs= $ldap->fetch()){
114       /* Insert links in ACL array */
115       $aclp[$attrs['dn']]= substr_count($attrs['dn'], ',');
116       $aclc[$attrs['dn']]= array();
117       $ol= array();
118       for($i= 0; $i<$attrs['gosaAclEntry']['count']; $i++){
119         $ol= array_merge($ol, @acl::explodeAcl($attrs['gosaAclEntry'][$i]));
120       }
121       $aclc[$attrs['dn']]= $ol;
122     }
124     /* Resolve roles here. 
125      */
126     foreach($aclc as $dn => $data){
127       foreach($data as $prio => $aclc_value)  {
128         if($aclc_value['type'] == "role"){
130           unset($aclc[$dn][$prio]);
132           $ldap->cat($aclc_value['acl'],array("gosaAclTemplate"));
133           $attrs = $ldap->fetch();
135           if(isset($attrs['gosaAclTemplate'])){
136             for($i= 0; $i<$attrs['gosaAclTemplate']['count']; $i++){
137               $tmp = @acl::explodeAcl($attrs['gosaAclTemplate'][$i]);  
139               foreach($tmp as $new_acl){
141                 /* Keep non role attributes here! */
142                 $new_acl['filter'] = $aclc_value['filter'];
143                 $new_acl['members'] = $aclc_value['members'];
144                 $aclc[$dn][] =$new_acl;
145               }
146             }      
147           }
148         }
149       }
150     }
152     /* ACL's read, sort for tree depth */
153     asort($aclp);
155     /* Sort in tree order */
156     foreach ($aclp as $dn => $acl){
157       /* Check if we need to keep this ACL */
158       foreach($aclc[$dn] as $idx => $type){
159         $interresting= FALSE;
160         
161         /* No members? This ACL rule is deactivated ... */
162         if (!count($type['members'])){
163           $interresting= FALSE; 
164         } else {
166           /* Inspect members... */
167           foreach ($type['members'] as $grp => $grpdsc){
169             /* Some group inside the members that is relevant for us? */
170             if (in_array_ics(@LDAP::convert(preg_replace('/^G:/', '', $grp)), $this->groups)){
171               $interresting= TRUE;
172             }
174             /* User inside the members? */
175             if (preg_replace('/^U:/', '', $grp) == $this->dn){
176               $interresting= TRUE;
177             }
178           }
179         }
181         if ($interresting){
182           if (!isset($this->ACL[$dn])){
183             $this->ACL[$dn]= array();
184           }
185           $this->ACL[$dn][$idx]= $type;
186         }
187       }
188     }
190     /* Create an array which represenet all relevant permissions settings 
191         per dn.
193       The array will look like this:
194       
195       .     ['ou=base']        ['ou=base']          = array(ACLs);
196       .     
197       .     ['ou=dep1,ou=base']['ou=dep1,ou=base']  = array(ACLs);
198       .                        ['ou=base']          = array(ACLs);
201       For object located in 'ou=dep1,ou=base' we have to both ACLs,
202        for objects in 'ou=base' we only have to apply on ACL.
203      */
204     $without_self_acl = $all_acl = array();
205     foreach($this->ACL as $dn => $acl){
206       $sdn =$dn;
207       $first= TRUE; // Run at least once 
208       while(strpos($dn,",") !== FALSE || $first){
209         $first = FALSE;
210         if(isset($this->ACL[$dn])){
211           $all_acl[$sdn][$dn] = $this->ACL[$dn];
212           $without_self_acl[$sdn][$dn] = $this->ACL[$dn]; 
213           foreach($without_self_acl[$sdn][$dn] as $acl_id => $acl_set){
214   
215             /* Remember which ACL set has speicial user filter 
216              */
217             if(isset($acl_set['filter']{1})){
218               $this->ACLperPath_usesFilter[$sdn] = TRUE;
219             }
220           
221             /* Remove all acl entries which are especially for the current user (self acl)
222              */
223             foreach($acl_set['acl'] as $object => $object_acls){
224               if(isset($object_acls[0]) && strpos($object_acls[0],"s")){
225                 unset($without_self_acl[$sdn][$dn][$acl_id]['acl'][$object]);
226               }
227             }
228           }
229         }
230         $dn = preg_replace("/^[^,]*+,/","",$dn);
231       }
232     } 
233     $this->ACLperPath =$without_self_acl;
235     /* Append Self entry */
236     $dn = $this->dn;
237     while(strpos($dn,",") && !isset($all_acl[$dn])){
238       $dn = preg_replace("/^[^,]*+,/","",$dn);
239     }
240     if(isset($all_acl[$dn])){
241       $this->ACLperPath[$this->dn] = $all_acl[$dn];
242     }
243   }
246   function get_category_permissions($dn, $category, $any_acl = FALSE)
247   {
248     return(@$this->get_permissions($dn,$category.'/0',""));
249   }
251   
252   /*! \brief Check if the given object (dn) is copyable
253       @param  String The object dn 
254       @param  String The acl  category (e.g. users) 
255       @param  String The acl  class (e.g. user) 
256       @return Boolean   TRUE if the given object is copyable else FALSE 
257   */
258   function is_copyable($dn, $object, $class)
259   {
260     return(preg_match("/r/",$this->has_complete_category_acls($dn, $object)));
261   }
264   /*! \brief Check if the given object (dn) is cutable
265       @param  String The object dn 
266       @param  String The acl  category (e.g. users) 
267       @param  String The acl  class (e.g. user) 
268       @return Boolean   TRUE if the given object is cutable else FALSE 
269   */
270   function is_cutable($dn, $object, $class)
271   {
272     $remove = preg_match("/d/",$this->get_permissions($dn,$object."/".$class));
273     $read   = preg_match("/r/",$this->has_complete_category_acls($dn, $object));
274     return($remove && $read);
275   }
278   /*! \brief  Checks if we are allowed to paste an object to the given destination ($dn)
279       @param  String The destination dn 
280       @param  String The acl  category (e.g. users) 
281       @param  String The acl  class (e.g. user) 
282       @return Boolean   TRUE if we are allowed to paste an object.
283   */
284   function is_pasteable($dn, $object)
285   {
286     return(preg_match("/w/",$this->has_complete_category_acls($dn, $object)));
287   }
290   /*! \brief  Checks if we are allowed to restore a snapshot for the given dn.
291       @param  String The destination dn 
292       @param  String The acl  category (e.g. users) 
293       @return Boolean   TRUE if we are allowed to restore a snapshot.
294   */
295   function allow_snapshot_restore($dn, $object)
296   {
297     if(!is_array($object)){
298       $object = array($object);
299     }
300     $r = $w = TRUE;
301     foreach($object as $category){
302       $w &= preg_match("/w/",$this->has_complete_category_acls($dn, $category));
303       $r &= preg_match("/r/",$this->has_complete_category_acls($dn, $category));
304     }
305     return($r && $w ); 
306   }  
309   /*! \brief  Checks if we are allowed to create a snapshot of the given dn.
310       @param  String The source dn 
311       @param  String The acl category (e.g. users) 
312       @return Boolean   TRUE if we are allowed to restore a snapshot.
313   */
314   function allow_snapshot_create($dn, $object)
315   {
316     if(!is_array($object)){
317       $object = array($object);
318     }
319     $r = TRUE;
320     foreach($object as $category){
321       $r &= preg_match("/r/",$this->has_complete_category_acls($dn, $category));
322     }
323     return($r) ; 
324   }  
327   function get_permissions($dn, $object, $attribute= "", $skip_write= FALSE)
328   {
329     /* If we are forced to skip ACLs checks for the current user 
330         then return all permissions.
331      */
332     if($this->ignore_acl_for_current_user()){
333       if($skip_write){
334         return("rcdm");
335       }
336       return("rwcdm");
337     }
339     /* Push cache answer? */
340     $ACL_CACHE = &session::global_get('ACL_CACHE');
341     if (isset($ACL_CACHE["$dn+$object+$attribute"])){
342       $ret = $ACL_CACHE["$dn+$object+$attribute"];
343       if($skip_write){
344         $ret = str_replace(array('w','c','d','m'), '',$ret);
345       }
346       return($ret);
347     }
349     /* Detect the set of ACLs we have to check for this object 
350      */
351     $adn = $dn;
352     while(!isset($this->ACLperPath[$adn]) && strpos($adn,",") !== FALSE){
353       $adn = preg_replace("/^[^,]*+,/","",$adn);
354     }
355     if(isset($this->ACLperPath[$adn])){
356       $ACL = $this->ACLperPath[$adn];
357     }else{
358       $ACL_CACHE["$dn+$object+$attribute"] = "";
359       return("");
360     }
361  
362     /* If we do not need to respect any user-filter settings 
363         we can skip the per object ACL checks.
364      */
365     $orig_dn= $dn;
366     if(!isset($this->ACLperPath_usesFilter[$adn])){
367       $dn = $adn;
368       if (isset($ACL_CACHE["$dn+$object+$attribute"])){
369         $ret = $ACL_CACHE["$dn+$object+$attribute"];
370         if(!isset($ACL_CACHE["$orig_dn+$object+$attribute"])){
371           $ACL_CACHE["$orig_dn+$object+$attribute"] = $ACL_CACHE["$dn+$object+$attribute"];
372         }
373         if($skip_write){
374           $ret = str_replace('w','',$ret);
375         }
376         return($ret);
377       }
378     }
379  
380     /* Get ldap object, for later filter checks 
381      */
382     $ldap = $this->config->get_ldap_link();
384     $acl= array("r" => "", "w" => "", "c" => "", "d" => "", "m" => "", "a" => "");
386     /* Build dn array */
387     $path= split(',', $dn);
388     $path= array_reverse($path);
390     /* Walk along the path to evaluate the acl */
391     $cpath= "";
392     foreach ($path as $element){
394       /* Clean potential ACLs for each level */
395                         if(isset($this->config->idepartments[$cpath])){
396         $acl= $this->cleanACL($acl);
397       }
399       if ($cpath == ""){
400         $cpath= $element;
401       } else {
402         $cpath= $element.','.$cpath;
403       }
405       if (isset($ACL[$cpath])){
407         /* Inspect this ACL, place the result into ACL */
408         foreach ($ACL[$cpath] as $subacl){
410           /* Reset? Just clean the ACL and turn over to the next one... */
411           if ($subacl['type'] == 'reset'){
412             $acl= $this->cleanACL($acl, TRUE);
413             continue;
414           }
416           if($subacl['type'] == "role") {
417             echo "role skipped";
418             continue;
419           }
421           /* With user filter */
422           if (isset($subacl['filter']) && !empty($subacl['filter'])){
423             $id = $dn."-".$subacl['filter'];
424             if(!isset($ACL_CACHE['FILTER'][$id])){
425               $ACL_CACHE['FILTER'][$id] = $ldap->object_match_filter($dn,$subacl['filter']);
426             }
427             if(!$ACL_CACHE['FILTER'][$id]){
428               continue;
429             }
430           }
432           /* Self ACLs? 
433            */
434           if($dn != $this->dn && isset($subacl['acl'][$object][0]) && (strpos($subacl['acl'][$object][0],"s") !== FALSE)){
435             continue;
436           }
438           /* If attribute is "", we want to know, if we've *any* permissions here... 
439               Merge global class ACLs [0] with attributes specific ACLs [attribute].
440            */
441           if ($attribute == "" && isset($subacl['acl'][$object])){
442             foreach($subacl['acl'][$object] as $attr => $dummy){
443               $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$object][$attr]);
444             }
445             continue;
446           }
448           /* Per attribute ACL? */
449           if (isset($subacl['acl'][$object][$attribute])){
450             $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$object][$attribute]);
451             continue;
452           }
454           /* Per object ACL? */
455           if (isset($subacl['acl'][$object][0])){
456             $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$object][0]);
457             continue;
458           }
460           /* Global ACL? */
461           if (isset($subacl['acl']['all'][0])){
462             $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl']['all'][0]);
463             continue;
464           }
466           /* Category ACLs    (e.g. $object = "user/0")
467            */
468           if(strstr($object,"/0")){
469             $ocs = preg_replace("/\/0$/","",$object);
470             if(isset($this->ocMapping[$ocs])){
472               /* if $attribute is "", then check every single attribute for this object.
473                  if it is 0, then just check the object category ACL.
474                */
475               if($attribute == ""){    
476                 foreach($this->ocMapping[$ocs] as $oc){
477                   if (isset($subacl['acl'][$ocs.'/'.$oc])){
479                     if($dn != $this->dn && strpos($subacl['acl'][$ocs.'/'.$oc][0],"s") !== FALSE) continue;
481                     foreach($subacl['acl'][$ocs.'/'.$oc] as $attr => $dummy){
482                       $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$ocs.'/'.$oc][$attr]);
483                     }
484                     continue;
485                   }
486                 }
487               }else{
488                 if(isset($subacl['acl'][$ocs.'/'.$oc][0])){
489                   if($dn != $this->dn && strpos($subacl['acl'][$ocs.'/'.$oc][0],"s") !== FALSE) continue;
490                   $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$ocs.'/'.$oc][0]);
491                 }
492               }
493             }
494             continue;
495           }
496         }
497       }
498     }
500     /* If the requested ACL is for a container object, then alter 
501         ACLs by applying cleanACL a last time.
502      */
503     if(isset($this->config->idepartments[$dn])){
504       $acl = $this->cleanACL($acl);
505     }
507     /* Assemble string */
508     $ret= "";
509     foreach ($acl as $key => $value){
510       if ($value !== ""){
511         $ret.= $key;
512       }
513     }
515     $ACL_CACHE["$dn+$object+$attribute"]= $ret;
516     $ACL_CACHE["$orig_dn+$object+$attribute"]= $ret;
518     /* Remove write if needed */
519     if ($skip_write){
520       $ret = str_replace(array('w','c','d','m'), '',$ret);
521     }
522     return ($ret);
523   }
526   /* Extract all departments that are accessible (direct or 'on the way' to an
527      accessible department) */
528   function get_module_departments($module, $skip_self_acls = FALSE )
529   {
530     /* If we are forced to skip ACLs checks for the current user 
531         then return all departments as valid.
532      */
533     if($this->ignore_acl_for_current_user()){
534       return(array_keys($this->config->idepartments));
535     }
537     /* Use cached results if possilbe */
538     $ACL_CACHE = &session::global_get('ACL_CACHE');
540     if(!is_array($module)){
541       $module = array($module);
542     }
544     global $plist;
545     $res = array();
546     foreach($module as $mod){
547       if(isset($ACL_CACHE['MODULE_DEPARTMENTS'][$mod])){
548         $res = array_merge($res,$ACL_CACHE['MODULE_DEPARTMENTS'][$mod]);
549         continue;
550       }
552       $deps = array();
554       /* Search for per object ACLs */
555       foreach($this->ACL as $dn => $infos){
556         foreach($infos as $info){
557           $found = FALSE;
558           foreach($info['acl'] as $cat => $data){
560             /* Skip self acls? */
561             if($skip_self_acls && isset($data['0']) && (strpos($data['0'], "s") !== FALSE)) continue;
562             if(preg_match("/^".preg_quote($mod, '/')."/",$cat)){
563               $found =TRUE;
564               break;
565             }
566           } 
568           if($found && !isset($this->config->idepartments[$dn])){
569             while(!isset($this->config->idepartments[$dn]) && strpos($dn, ",")){
570               $dn = preg_replace("/^[^,]+,/","",$dn);
571             }
572             if(isset($this->config->idepartments[$dn])){
573               $deps[$dn] = $dn;
574             }
575           }
576         }
577       }
579       /* For all gosaDepartments */
580       foreach ($this->config->departments as $dn){
581         if(isset($deps[$dn])) continue;
582         $acl = "";
583         if(strpos($mod, '/')){
584           $acl.=  $this->get_permissions($dn,$mod);
585         }else{
586           $acl.=  $this->get_category_permissions($dn,$mod,TRUE);
587         }
588         if(!empty($acl)) {
589           $deps[$dn] = $dn;
590         }
591       }
593       $ACL_CACHE['MODULE_DEPARTMENTS'][$mod] = $deps;
594       $res = array_merge($res,$deps);
595     }
597     return (array_values($res));
598   }
601   function mergeACL($acl, $type, $newACL)
602   {
603                 $at= array("psub" => "p", "sub" => "s", "one" => "1");
605     if (strpos($newACL, 'w') !== FALSE && strpos($newACL, 'r') === FALSE){
606       $newACL .= "r";
607     }
609                 /* Ignore invalid characters */
610                 $newACL= preg_replace('/[^rwcdm]/', '', $newACL);
612     foreach(str_split($newACL) as $char){
614       /* Skip "self" ACLs without combination of rwcdm, they have no effect.
615          -self flag without read/write/create/...
616        */
617       if(empty($char)) continue;
619       /* Skip permanent and subtree entries */
620       if (preg_match('/[sp]/', $acl[$char])){
621         continue;
622       }
624                         if ($type == "base" && $acl[$char] != 1) {
625                                 $acl[$char]= 0;
626                         } else {
627         $acl[$char]= $at[$type];
628                         }
629     }
631     return ($acl);
632   }
635   function cleanACL($acl, $reset= FALSE)
636   {
637     foreach ($acl as $key => $value){
639       /* Continue, if value is empty or permanent */
640       if ($value == "" || $value == "p") {
641             continue;
642       }
644       /* Reset removes everything but 'p' */
645       if ($reset && $value != 'p'){
646         $acl[$key]= "";
647         continue;
648       }
650       /* Decrease tree level */
651       if (is_int($value)){
652         if ($value){
653           $acl[$key]--;
654         } else {
655           $acl[$key]= "";
656         }
657       }
658     }
660     return ($acl);
661   }
664   /* #FIXME This could be logical wrong or could be optimized in the future
665      Return combined acls for a given category. 
666      All acls will be combined like boolean AND 
667       As example ('rwcdm' + 'rcd' + 'wrm'= 'r') 
668     
669      Results will be cached in $this->result_cache.
670       $this->result_cache will be resetted if load_acls is called.
671   */
672   function has_complete_category_acls($dn,$category)
673   {
674     $acl    = "rwcdm";
675     $types  = "rwcdm";
677     if(!is_string($category)){
678       trigger_error("category must be string");   
679       $acl = "";
680     }else{
681       if(!isset($this->result_cache['has_complete_category_acls'][$dn][$category]))   {
682         if (isset($this->ocMapping[$category])){
683           foreach($this->ocMapping[$category] as $oc){
685             /* Skip objectClass '0' (e.g. users/0) get_permissions will ever return '' ??  */
686             if($oc == "0") continue;
687             $tmp =  $this->get_permissions($dn, $category."/".$oc);
688             for($i = 0, $l= strlen($types); $i < $l; $i++) {
689               if(!preg_match("/".$types[$i]."/",$tmp)){ 
690                 $acl = preg_replace("/".$types[$i]."/","",$acl);
691               }
692             }
693           }
694         }else{
695           trigger_error("Invalid type of category ".$category);
696           $acl = "";
697         }
698         $this->result_cache['has_complete_category_acls'][$dn][$category] = $acl;
699       }else{
700         $acl = $this->result_cache['has_complete_category_acls'][$dn][$category];
701       }
702     }
703     return($acl);
704   }
706  
707   /*! \brief  Returns TRUE if the current user is configured in IGNORE_ACL=".." in your gosa.conf 
708       @param  Return Boolean TRUE if we have to skip ACL checks else FALSE.
709    */ 
710   function ignore_acl_for_current_user()
711   {
712     return($this->ignoreACL);
713   }
716   function loginAllowed()
717   {
718     // Need to check restrictions?
719     if (count($this->restrictions)){
721       // We have restrictions but cannot check them
722       if (!isset($_SERVER['REMOTE_ADDR'])){
723         return false;
724       }
726       // Move to binary...
727       $source= $_SERVER['REMOTE_ADDR'];
728       foreach ($this->restrictions as $restriction) {
730         // Single IP
731         if (preg_match('/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/', $restriction)) {
732            if ($source == $restriction){
733              return true;
734            }
735         }
737         // Match with short netmask
738         if (preg_match('/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\/([0-9]+)$/', $restriction, $matches)) {
739           if (isIpInNet($source, $matches[1], long2ip(~(pow(2, (32-$matches[2]))-1)))) {
740             return true;
741           }
742         }
744         // Match with long netmask
745         if (preg_match('/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$/', $restriction, $matches)) {
746           if (isIpInNet($source, $matches[1], $matches[2])) {
747             return true;
748           }
749         }
751       }
753       return false;
754     }
756     return true;
757   }
762 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
763 ?>