aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-09-15 15:50:15 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-09-15 15:50:15 +0000
commit9ae8d4cdc954f0120875f94fb68211106e38544a (patch)
tree6b024e998cfdbe7b7c81a89ba8ba5fdde3716d45 /engine
parentea4403c9240c3778cddc90d48d0a59c4d47dd2d8 (diff)
downloadelgg-9ae8d4cdc954f0120875f94fb68211106e38544a.tar.gz
elgg-9ae8d4cdc954f0120875f94fb68211106e38544a.tar.bz2
Fixes #2366: Deprecated test_ip() and is_ip_in_array().
git-svn-id: http://code.elgg.org/elgg/trunk@6934 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/elgglib.php80
1 files changed, 9 insertions, 71 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 47d05327e..ae6509454 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -1893,90 +1893,28 @@ function full_url() {
}
/**
- * Useful function found in the comments on the PHP man page for ip2long.
- * Returns 1 if an IP matches a given range.
+ * Does nothing.
*
- * @todo Check licence... assuming this is PD since it was found several places on the interwebs..
- * please check or rewrite.
- *
- * Matches:
- * xxx.xxx.xxx.xxx (exact)
- * xxx.xxx.xxx.[yyy-zzz] (range)
- * xxx.xxx.xxx.xxx/nn (nn = # bits, cisco style -- i.e. /24 = class C)
- * Does not match:
- * xxx.xxx.xxx.xx[yyy-zzz] (range, partial octets not supported)
- *
- * @todo not used at all.
+ * @param $range
+ * @param $ip
+ * @deprecated 1.7
*/
function test_ip($range, $ip) {
- $result = 1;
-
- # IP Pattern Matcher
- # J.Adams <jna@retina.net>
- #
- # Matches:
- #
- # xxx.xxx.xxx.xxx (exact)
- # xxx.xxx.xxx.[yyy-zzz] (range)
- # xxx.xxx.xxx.xxx/nn (nn = # bits, cisco style -- i.e. /24 = class C)
- #
- # Does not match:
- # xxx.xxx.xxx.xx[yyy-zzz] (range, partial octets not supported)
-
- if (ereg("([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/([0-9]+)",$range,$regs)) {
- # perform a mask match
- $ipl = ip2long($ip);
- $rangel = ip2long($regs[1] . "." . $regs[2] . "." . $regs[3] . "." . $regs[4]);
-
- $maskl = 0;
-
- for ($i = 0; $i< 31; $i++) {
- if ($i < $regs[5]-1) {
- $maskl = $maskl + pow(2,(30-$i));
- }
- }
+ elgg_deprecated_notice('test_ip() was removed because of licensing issues.', 1.7);
- if (($maskl & $rangel) == ($maskl & $ipl)) {
- return 1;
- } else {
- return 0;
- }
- } else {
- # range based
- $maskocts = split("\.",$range);
- $ipocts = split("\.",$ip);
-
- # perform a range match
- for ($i=0; $i<4; $i++) {
- if (ereg("\[([0-9]+)\-([0-9]+)\]",$maskocts[$i],$regs)) {
- if ( ($ipocts[$i] > $regs[2]) || ($ipocts[$i] < $regs[1])) {
- $result = 0;
- }
- } else {
- if ($maskocts[$i] <> $ipocts[$i]) {
- $result = 0;
- }
- }
- }
- }
-
- return $result;
+ return 0;
}
/**
- * Match an IP address against a number of ip addresses or ranges, returning true if found.
+ * Does nothing.
*
* @param array $networks
* @param string $ip
* @return bool
- * @todo not used at all in core.
+ * @deprecated 1.7
*/
function is_ip_in_array(array $networks, $ip) {
- foreach ($networks as $network) {
- if (test_ip(trim($network), $ip)) {
- return true;
- }
- }
+ elgg_deprecated_notice('is_ip_in_array() was removed because of licensing issues.', 1.7);
return false;
}