phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: phpgwapi/inc class.setup.inc.php,1.13,1.14


From: Miles Lott <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc class.setup.inc.php,1.13,1.14
Date: Sat, 11 May 2002 15:30:12 -0400

Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv15267

Modified Files:
        class.setup.inc.php 
Log Message:
add remote ip check function (not used)

Index: class.setup.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.setup.inc.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** class.setup.inc.php 30 Apr 2002 03:35:52 -0000      1.13
--- class.setup.inc.php 11 May 2002 19:30:10 -0000      1.14
***************
*** 70,73 ****
--- 70,75 ----
                function auth($auth_type='Config')
                {
+                       $remoteip     = $GLOBALS['REMOTE_ADDR'];
+ 
                        $FormLogout   = get_var('FormLogout',  
array('GET','POST'));
                        $ConfigLogin  = get_var('ConfigLogin', array('POST'));
***************
*** 81,84 ****
--- 83,93 ----
                        $ConfigLang   = get_var('ConfigLang',  
array('POST','COOKIE'));
  
+                       /*
+                       if(!empty($remoteip) && !$this->checkip($remoteip))
+                       {
+                               return False;
+                       }
+                       */
+ 
                        /* 6 cases:
                                1. Logging into header admin
***************
*** 188,191 ****
--- 197,254 ----
                                return False;
                        }
+               }
+ 
+               function checkip($remoteip='')
+               {
+                       $allowed_ips = 
split(',',$GLOBALS['phpgw_info']['server']['setup_acl']);
+                       if(is_array($allowed_ips))
+                       {
+                               $foundip = False;
+                               while(list(,$value) = @each($allowed_ips))
+                               {
+                                       $test = split("\.",$value);
+                                       if(count($test) < 3)
+                                       {
+                                               $value .= ".0.0";
+                                               $tmp = split("\.",$remoteip);
+                                               $tmp[2] = 0;
+                                               $tmp[3] = 0;
+                                               $testremoteip = join('.',$tmp);
+                                       }
+                                       elseif(count($test) < 4)
+                                       {
+                                               $value .= ".0";
+                                               $tmp = split("\.",$remoteip);
+                                               $tmp[3] = 0;
+                                               $testremoteip = join('.',$tmp);
+                                       }
+                                       elseif(count($test) == 4 &&
+                                               intval($test[3]) == 0)
+                                       {
+                                               $tmp = split("\.",$remoteip);
+                                               $tmp[3] = 0;
+                                               $testremoteip = join('.',$tmp);
+                                       }
+                                       else
+                                       {
+                                               $testremoteip = $remoteip;
+                                       }
+ 
+                                       //echo '<br>testing: ' . $testremoteip 
. ' compared to ' . $value;
+ 
+                                       if($testremoteip == $value)
+                                       {
+                                               //echo ' - PASSED!';
+                                               $foundip = True;
+                                       }
+                               }
+                               if(!$foundip)
+                               {
+                                       
$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = '';
+                                       
$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG'] = lang('Invalid IP address');
+                                       return False;
+                               }
+                       }
+                       return True;
                }
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]