Skip to content

Commit

Permalink
phpversion() replacements and code branch collapsing for older PHP …
Browse files Browse the repository at this point in the history
…versions

Closes GH-600.
  • Loading branch information
Ayesh authored Jul 2, 2022
1 parent c3f9653 commit 38d4e07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 3 additions & 12 deletions include/ip-to-country.inc
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,9 @@ function i2c_realip()
// Skip RFC 1918 IP's 10.0.0.0/8, 172.16.0.0/12 and
// 192.168.0.0/16
// Also skip RFC 6598 IP's
if (!preg_match('/^(?:10|100\.(?:6[4-9]|[7-9]\d|1[01]\d|12[0-7])|172\.(?:1[6-9]|2\d|3[01])|192\.168)\./', $ips[$i])) {
if (version_compare(phpversion(), "5.0.0", ">=")) {
if (ip2long($ips[$i]) != false) {
$ip = $ips[$i];
break;
}
} else {
if (ip2long($ips[$i]) != -1) {
$ip = $ips[$i];
break;
}
}
if (!preg_match('/^(?:10|100\.(?:6[4-9]|[7-9]\d|1[01]\d|12[0-7])|172\.(?:1[6-9]|2\d|3[01])|192\.168)\./', $ips[$i]) && ip2long($ips[$i])) {
$ip = $ips[$i];
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion mirror-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function_exists('hash_file') &&

echo implode('|', array(
$MYSITE, // 0 : CNAME for mirror as accessed (CC, CC1, etc.)
phpversion(), // 1 : PHP version overview
PHP_VERSION, // 1 : PHP version overview
$LAST_UPDATED, // 2 : Update problems
$sqlite, // 3 : SQLite support?
$mirror_stats, // 4 : Optional local stats support
Expand Down

0 comments on commit 38d4e07

Please sign in to comment.