Skip to content

Commit

Permalink
add vendor for IP comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Pick committed Dec 4, 2018
1 parent c7ddc44 commit 5e43f12
Show file tree
Hide file tree
Showing 186 changed files with 28,816 additions and 77 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
],
"require": {
"geoip2/geoip2": "~2.0",
"php": ">=5.3.1"
"php": ">=5.3.1",
"symfony/http-foundation": "^4.2"
}
}
117 changes: 115 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions geoip-detect-lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// Their name / parameter may change without warning.

use YellowTree\GeoipDetect\DataSources\DataSourceRegistry;
use Symfony\Component\HttpFoundation\IpUtils;

/**
* Take the parameter options and add the default values.
Expand Down Expand Up @@ -262,11 +263,14 @@ function geoip_detect_normalize_ip($ip) {
return $ip;
}

function geoip_detect_is_ip_equal($ip1, $ip2) {
$one = @inet_pton($ip1);
$two = @inet_pton($ip2);

return !empty($one) && $one == $two;
/**
* Check if the expected IP left matches the actual IP
* @param string $actual IP
* @param string $expected IP (can include subnet)
* @return boolean
*/
function geoip_detect_is_ip_equal($actual, $expected) {
IpUtils::checkIp($actual, $expected);
}

function geoip_detect_is_ip($ip, $noIpv6 = false) {
Expand Down Expand Up @@ -295,7 +299,7 @@ function geoip_detect_is_ip_in_range($ip, $range_start, $range_end) {
*/
function geoip_detect_is_public_ip($ip) {
// filver_var only detects 127.0.0.1 as local ...
if (geoip_detect_is_ip_in_range($ip, '127.0.0.0', '127.255.255.255'))
if (geoip_detect_is_ip_equal($ip, '127.0.0.0/8'))
return false;
if (trim($ip) === '0.0.0.0')
return false;
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@ private function findFileWithExtension($class, $ext)
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
$length = $this->prefixLengthsPsr4[$first][$search];
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
Expand Down
10 changes: 10 additions & 0 deletions vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

// autoload_files.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
);
2 changes: 2 additions & 0 deletions vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
$baseDir = dirname($vendorDir);

return array(
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'),
'MaxMind\\WebService\\' => array($vendorDir . '/maxmind/web-service-common/src/WebService'),
'MaxMind\\Exception\\' => array($vendorDir . '/maxmind/web-service-common/src/Exception'),
'MaxMind\\Db\\' => array($vendorDir . '/maxmind-db/reader/src/MaxMind/Db'),
Expand Down
18 changes: 18 additions & 0 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ public static function getLoader()

$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInite354937679ffa734a3f63544e59103dd::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiree354937679ffa734a3f63544e59103dd($fileIdentifier, $file);
}

return $loader;
}
}

function composerRequiree354937679ffa734a3f63544e59103dd($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}
17 changes: 17 additions & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@

class ComposerStaticInite354937679ffa734a3f63544e59103dd
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
);

public static $prefixLengthsPsr4 = array (
'S' =>
array (
'Symfony\\Polyfill\\Mbstring\\' => 26,
'Symfony\\Component\\HttpFoundation\\' => 33,
),
'M' =>
array (
'MaxMind\\WebService\\' => 19,
Expand All @@ -24,6 +33,14 @@ class ComposerStaticInite354937679ffa734a3f63544e59103dd
);

public static $prefixDirsPsr4 = array (
'Symfony\\Polyfill\\Mbstring\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
),
'Symfony\\Component\\HttpFoundation\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/http-foundation',
),
'MaxMind\\WebService\\' =>
array (
0 => __DIR__ . '/..' . '/maxmind/web-service-common/src/WebService',
Expand Down
Loading

0 comments on commit 5e43f12

Please sign in to comment.