gunnar: server/php-kolab/Kolab_Filter/Filter Content.php,1.6,1.7
cvs at kolab.org
cvs at kolab.org
Tue Feb 12 08:39:14 CET 2008
Author: gunnar
Update of /kolabrepository/server/php-kolab/Kolab_Filter/Filter
In directory doto:/tmp/cvs-serv27370/php-kolab/Kolab_Filter/Filter
Modified Files:
Content.php
Log Message:
Added a unit test for the new privileged network setting.
Index: Content.php
===================================================================
RCS file: /kolabrepository/server/php-kolab/Kolab_Filter/Filter/Content.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Content.php 11 Feb 2008 17:34:43 -0000 1.6
+++ Content.php 12 Feb 2008 07:39:12 -0000 1.7
@@ -393,21 +393,17 @@
/** Match IP addresses against Networks in CIDR notation. **/
function match_ip($network, $ip)
{
- $iplong = ip2long($ip);
- $cidr = explode("/", $network);
- $netiplong = ip2long($cidr[0]);
- if ( $cidr[1] ) {
- $iplong = $iplong & ( 0xffffffff << 32 - $cidr[1] );
- $netiplong = $netiplong & ( 0xffffffff << 32 - $cidr[1] );
- }
- if ($iplong == $netiplong)
- {
- return TRUE;
+ $iplong = ip2long($ip);
+ $cidr = explode("/", $network);
+ $netiplong = ip2long($cidr[0]);
+ if ( $cidr[1] ) {
+ $iplong = $iplong & ( 0xffffffff << 32 - $cidr[1] );
+ $netiplong = $netiplong & ( 0xffffffff << 32 - $cidr[1] );
+ }
+ if ($iplong == $netiplong) {
+ return true;
}
- else
- {
- return FALSE;
- }
+ return false;
}
/** Check that the From header is not trying
@@ -458,7 +454,7 @@
$kolabhosts = 'localhost';
}
- if (!empty($conf['filter']['privileged_networks'])) {
+ if (isset($conf['filter']['privileged_networks'])) {
$privnetworks = $conf['filter']['privileged_networks'];
} else {
$privnetworks = '127.0.0.0/8';
@@ -480,9 +476,11 @@
return true;
}
- foreach ($privnetworks as $network)
- if (match_ip($network, $client_addr))
- return true;
+ foreach ($privnetworks as $network) {
+ if (match_ip($network, $client_addr)) {
+ return true;
+ }
+ }
if ($sasluser) {
$allowed_addrs = addrs_for_uid($sasluser);
More information about the commits
mailing list