From ca32203d6f833c6e1a28a8a5f475b7162ed296af Mon Sep 17 00:00:00 2001 From: Manish Verma Date: Thu, 3 Nov 2016 15:28:03 +0530 Subject: [PATCH] Package-update-patch Update Torann/GeoIP package from 0.2 to 1.0.0 which is being used to show country code in phone nuber in various forms. --- .../Admin/helpdesk/AgentController.php | 4 +- .../Agent/helpdesk/TicketController.php | 4 +- .../Agent/helpdesk/UserController.php | 6 +- .../Client/helpdesk/FormController.php | 4 +- .../Client/helpdesk/GuestController.php | 2 +- composer.json | 2 +- composer.lock | 40 ++- config/app.php | 2 +- config/geoip.php | 126 +++++-- vendor/composer/autoload_classmap.php | 18 +- vendor/composer/autoload_files.php | 1 + vendor/composer/autoload_psr4.php | 2 +- vendor/composer/autoload_static.php | 21 +- vendor/composer/installed.json | 123 +++---- vendor/torann/geoip/.travis.yml | 11 +- vendor/torann/geoip/LICENCE | 2 +- vendor/torann/geoip/README.md | 131 +++----- vendor/torann/geoip/composer.json | 85 +++-- vendor/torann/geoip/config/geoip.php | 143 ++++++++ vendor/torann/geoip/phpunit.xml | 5 +- vendor/torann/geoip/resources/geoip.mmdb | Bin 0 -> 20740 bytes vendor/torann/geoip/src/Cache.php | 74 +++++ vendor/torann/geoip/src/Console/Clear.php | 59 ++++ vendor/torann/geoip/src/Console/Update.php | 49 +++ .../geoip/src/Contracts/ServiceInterface.php | 42 +++ vendor/torann/geoip/src/Facades/GeoIP.php | 18 + vendor/torann/geoip/src/GeoIP.php | 309 ++++++++++++++++++ .../torann/geoip/src/GeoIPServiceProvider.php | 75 +++++ vendor/torann/geoip/src/Location.php | 197 +++++++++++ .../geoip/src/Services/AbstractService.php | 61 ++++ vendor/torann/geoip/src/Services/IPApi.php | 142 ++++++++ .../geoip/src/Services/MaxMindDatabase.php | 93 ++++++ .../geoip/src/Services/MaxMindWebService.php | 52 +++ .../torann/geoip/src/Support/Currencies.php | 251 ++++++++++++++ .../torann/geoip/src/Support/HttpClient.php | 245 ++++++++++++++ .../Torann/GeoIP/Console/UpdateCommand.php | 57 ---- .../torann/geoip/src/Torann/GeoIP/GeoIP.php | 282 ---------------- .../geoip/src/Torann/GeoIP/GeoIPFacade.php | 14 - .../src/Torann/GeoIP/GeoIPServiceProvider.php | 57 ---- .../geoip/src/Torann/GeoIP/GeoIPUpdater.php | 62 ---- vendor/torann/geoip/src/config/.gitkeep | 0 vendor/torann/geoip/src/config/geoip.php | 55 ---- vendor/torann/geoip/src/helpers.php | 19 ++ vendor/torann/geoip/tests/.gitkeep | 0 vendor/torann/geoip/tests/CacheTest.php | 84 +++++ vendor/torann/geoip/tests/GeoIPTest.php | 46 +++ .../torann/geoip/tests/GeoIPUpdaterTest.php | 37 --- .../tests/Services/MaxMindDatabaseTest.php | 69 ++++ vendor/torann/geoip/tests/TestCase.php | 55 ++++ vendor/torann/geoip/tests/TestFunctions.php | 22 ++ vendor/torann/geoip/tests/data/.gitkeep | 0 vendor/torann/geoip/tests/tmp/.gitignore | 2 + 52 files changed, 2446 insertions(+), 814 deletions(-) create mode 100644 vendor/torann/geoip/config/geoip.php create mode 100644 vendor/torann/geoip/resources/geoip.mmdb create mode 100644 vendor/torann/geoip/src/Cache.php create mode 100644 vendor/torann/geoip/src/Console/Clear.php create mode 100644 vendor/torann/geoip/src/Console/Update.php create mode 100644 vendor/torann/geoip/src/Contracts/ServiceInterface.php create mode 100644 vendor/torann/geoip/src/Facades/GeoIP.php create mode 100644 vendor/torann/geoip/src/GeoIP.php create mode 100644 vendor/torann/geoip/src/GeoIPServiceProvider.php create mode 100644 vendor/torann/geoip/src/Location.php create mode 100644 vendor/torann/geoip/src/Services/AbstractService.php create mode 100644 vendor/torann/geoip/src/Services/IPApi.php create mode 100644 vendor/torann/geoip/src/Services/MaxMindDatabase.php create mode 100644 vendor/torann/geoip/src/Services/MaxMindWebService.php create mode 100644 vendor/torann/geoip/src/Support/Currencies.php create mode 100644 vendor/torann/geoip/src/Support/HttpClient.php delete mode 100644 vendor/torann/geoip/src/Torann/GeoIP/Console/UpdateCommand.php delete mode 100644 vendor/torann/geoip/src/Torann/GeoIP/GeoIP.php delete mode 100644 vendor/torann/geoip/src/Torann/GeoIP/GeoIPFacade.php delete mode 100644 vendor/torann/geoip/src/Torann/GeoIP/GeoIPServiceProvider.php delete mode 100644 vendor/torann/geoip/src/Torann/GeoIP/GeoIPUpdater.php delete mode 100644 vendor/torann/geoip/src/config/.gitkeep delete mode 100644 vendor/torann/geoip/src/config/geoip.php create mode 100644 vendor/torann/geoip/src/helpers.php delete mode 100644 vendor/torann/geoip/tests/.gitkeep create mode 100644 vendor/torann/geoip/tests/CacheTest.php create mode 100644 vendor/torann/geoip/tests/GeoIPTest.php delete mode 100644 vendor/torann/geoip/tests/GeoIPUpdaterTest.php create mode 100644 vendor/torann/geoip/tests/Services/MaxMindDatabaseTest.php create mode 100644 vendor/torann/geoip/tests/TestCase.php create mode 100644 vendor/torann/geoip/tests/TestFunctions.php delete mode 100644 vendor/torann/geoip/tests/data/.gitkeep create mode 100644 vendor/torann/geoip/tests/tmp/.gitignore diff --git a/app/Http/Controllers/Admin/helpdesk/AgentController.php b/app/Http/Controllers/Admin/helpdesk/AgentController.php index 2197277df..0ddfb4df2 100644 --- a/app/Http/Controllers/Admin/helpdesk/AgentController.php +++ b/app/Http/Controllers/Admin/helpdesk/AgentController.php @@ -89,7 +89,7 @@ class AgentController extends Controller // list all the teams in a single variable $teams = $team->lists('id', 'name')->toArray(); $location = GeoIP::getLocation(); - $phonecode = $code->where('iso', '=', $location['isoCode'])->first(); + $phonecode = $code->where('iso', '=', $location->iso_code)->first(); // returns to the page with all the variables and their datas $send_otp = DB::table('common_settings')->select('status')->where('option_name', '=', 'send_otp')->first(); @@ -184,7 +184,7 @@ class AgentController extends Controller { try { $location = GeoIP::getLocation(); - $phonecode = $code->where('iso', '=', $location['isoCode'])->first(); + $phonecode = $code->where('iso', '=', $location->iso_code)->first(); $user = $user->whereId($id)->first(); $team = $team->get(); $teams1 = $team->lists('name', 'id'); diff --git a/app/Http/Controllers/Agent/helpdesk/TicketController.php b/app/Http/Controllers/Agent/helpdesk/TicketController.php index b8a52c02c..9419fd080 100644 --- a/app/Http/Controllers/Agent/helpdesk/TicketController.php +++ b/app/Http/Controllers/Agent/helpdesk/TicketController.php @@ -281,7 +281,7 @@ class TicketController extends Controller public function newticket(CountryCode $code) { $location = GeoIP::getLocation(); - $phonecode = $code->where('iso', '=', $location['isoCode'])->first(); + $phonecode = $code->where('iso', '=', $location->iso_code)->first(); $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first(); @@ -330,7 +330,7 @@ class TicketController extends Controller $status = 1; if ($phone != null || $mobile_number != null) { $location = GeoIP::getLocation(); - $geoipcode = $code->where('iso', '=', $location['isoCode'])->first(); + $geoipcode = $code->where('iso', '=', $location->iso_code)->first(); if ($phonecode == null) { $data = [ 'fails' => Lang::get('lang.country-code-required-error'), diff --git a/app/Http/Controllers/Agent/helpdesk/UserController.php b/app/Http/Controllers/Agent/helpdesk/UserController.php index 97c2b9205..c1c9b2f0e 100644 --- a/app/Http/Controllers/Agent/helpdesk/UserController.php +++ b/app/Http/Controllers/Agent/helpdesk/UserController.php @@ -188,7 +188,7 @@ class UserController extends Controller $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $email_mandatory = CommonSettings::select('status')->where('option_name', '=', 'email_mandatory')->first(); $location = GeoIP::getLocation(); - $phonecode = $code->where('iso', '=', $location['isoCode'])->first(); + $phonecode = $code->where('iso', '=', $location->iso_code)->first(); $org = Organization::lists('name', 'id')->toArray(); return view('themes.default1.agent.helpdesk.user.create', compact('org', 'settings', 'email_mandatory'))->with('phonecode', $phonecode->phonecode); @@ -575,7 +575,7 @@ class UserController extends Controller /* select the field where id = $id(request Id) */ $users = $user->whereId($id)->first(); $location = GeoIP::getLocation(); - $phonecode = $code->where('iso', '=', $location['isoCode'])->first(); + $phonecode = $code->where('iso', '=', $location->iso_code)->first(); $org = Organization::lists('name', 'id')->toArray(); return view('themes.default1.agent.helpdesk.user.edit', compact('users', 'org', '$settings', '$email_mandatory'))->with('phonecode', $phonecode->phonecode); @@ -651,7 +651,7 @@ class UserController extends Controller { $user = Auth::user(); $location = GeoIP::getLocation(); - $phonecode = $code->where('iso', '=', $location['isoCode'])->first(); + $phonecode = $code->where('iso', '=', $location->iso_code)->first(); $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $status = $settings->status; try { diff --git a/app/Http/Controllers/Client/helpdesk/FormController.php b/app/Http/Controllers/Client/helpdesk/FormController.php index 1835b5189..a4b4d42c6 100644 --- a/app/Http/Controllers/Client/helpdesk/FormController.php +++ b/app/Http/Controllers/Client/helpdesk/FormController.php @@ -68,7 +68,7 @@ class FormController extends Controller return redirect('auth/login')->with(['login_require' => 'Please login to your account for submitting a ticket', 'referer' => 'form']); } $location = GeoIP::getLocation(); - $phonecode = $code->where('iso', '=', $location['isoCode'])->first(); + $phonecode = $code->where('iso', '=', $location->iso_code)->first(); if (System::first()->status == 1) { $topics = $topic->get(); $codes = $code->get(); @@ -193,7 +193,7 @@ class FormController extends Controller $team_assign = null; if ($phone != null || $mobile_number != null) { $location = GeoIP::getLocation(); - $geoipcode = $code->where('iso', '=', $location['isoCode'])->first(); + $geoipcode = $code->where('iso', '=', $location->iso_code)->first(); if ($phonecode == null) { $data = [ 'fails' => Lang::get('lang.country-code-required-error'), diff --git a/app/Http/Controllers/Client/helpdesk/GuestController.php b/app/Http/Controllers/Client/helpdesk/GuestController.php index 5be2e258c..0b1281d8d 100644 --- a/app/Http/Controllers/Client/helpdesk/GuestController.php +++ b/app/Http/Controllers/Client/helpdesk/GuestController.php @@ -61,7 +61,7 @@ class GuestController extends Controller { $user = Auth::user(); $location = GeoIP::getLocation(); - $phonecode = $code->where('iso', '=', $location['isoCode'])->first(); + $phonecode = $code->where('iso', '=', $location->iso_code)->first(); $settings = CommonSettings::select('status')->where('option_name', '=', 'send_otp')->first(); $status = $settings->status; diff --git a/composer.json b/composer.json index 83eac0dcb..9407c7f43 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "tymon/jwt-auth": "0.5.*", "php": ">=5.5.9", "davejamesmiller/laravel-breadcrumbs": "^3.0", - "torann/geoip": "0.2.*@dev", + "torann/geoip": "1.0.*", "davibennun/laravel-push-notification": "dev-laravel5", "brozot/laravel-fcm": "^1.0", "barryvdh/laravel-debugbar": "^2.2", diff --git a/composer.lock b/composer.lock index 018a1e943..c97900830 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "615811edcfb01884df1bc69a965f2d42", - "content-hash": "8bd72cd6f3a5070073b9f5bbd69ecd04", + "hash": "74863d52fcd4223ce972f755ac112a52", + "content-hash": "af38f59008695dff3ad2c6cf7571b35b", "packages": [ { "name": "aws/aws-sdk-php", @@ -4166,16 +4166,16 @@ }, { "name": "torann/geoip", - "version": "dev-master", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/Torann/laravel-geoip.git", - "reference": "f16f839160b1ab1fe41382e18ec9a32dd09b10fd" + "reference": "ae77f4ad99926fa35c89378f00a6a7295a7246ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Torann/laravel-geoip/zipball/f16f839160b1ab1fe41382e18ec9a32dd09b10fd", - "reference": "f16f839160b1ab1fe41382e18ec9a32dd09b10fd", + "url": "https://api.github.com/repos/Torann/laravel-geoip/zipball/ae77f4ad99926fa35c89378f00a6a7295a7246ea", + "reference": "ae77f4ad99926fa35c89378f00a6a7295a7246ea", "shasum": "" }, "require": { @@ -4184,18 +4184,26 @@ "php": ">=5.5.9" }, "require-dev": { - "phpspec/phpspec": "~2.1", - "phpunit/phpunit": "~4.0" + "geoip2/geoip2": "~2.1", + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.8" + }, + "suggest": { + "geoip2/geoip2": "Required to use the MaxMind database or web service with GeoIP (~2.1).", + "monolog/monolog": "Allows for storing location not found errors to the log" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "0.2-dev" + "dev-master": "1.0-dev" } }, "autoload": { + "files": [ + "src/helpers.php" + ], "psr-4": { - "Torann\\GeoIP\\": "src/Torann/GeoIP" + "Torann\\GeoIP\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -4205,18 +4213,21 @@ "authors": [ { "name": "Daniel Stainback", - "email": "daniel@lyften.com" + "email": "torann@gmail.com" } ], - "description": "Supports the two main GeoIP services (infoDB and Maxmind).", + "description": "Support for multiple GeoIP services.", "keywords": [ + "IP API", "geoip", "geolocation", + "infoDB", "laravel", "laravel 5", - "location" + "location", + "maxmind" ], - "time": "2015-06-30 16:13:35" + "time": "2016-10-17 17:29:40" }, { "name": "tymon/jwt-auth", @@ -6209,7 +6220,6 @@ "stability-flags": { "neitanod/forceutf8": 20, "chumper/datatable": 20, - "torann/geoip": 20, "davibennun/laravel-push-notification": 20 }, "prefer-stable": false, diff --git a/config/app.php b/config/app.php index 39bf3cb04..4e7802cdc 100644 --- a/config/app.php +++ b/config/app.php @@ -245,7 +245,7 @@ return [ 'JWTAuth' => 'Tymon\JWTAuth\Facades\JWTAuth', 'JWTFactory' => 'Tymon\JWTAuth\Facades\JWTFactory', 'Breadcrumbs' => 'DaveJamesMiller\Breadcrumbs\Facade', - 'GeoIP' => 'Torann\GeoIP\GeoIPFacade', + 'GeoIP' => \Torann\GeoIP\Facades\GeoIP::class, 'Image' => Intervention\Image\Facades\Image::class, 'FCM' => LaravelFCM\Facades\FCM::class, 'FCMGroup' => LaravelFCM\Facades\FCMGroup::class, diff --git a/config/geoip.php b/config/geoip.php index 23374b319..114928967 100644 --- a/config/geoip.php +++ b/config/geoip.php @@ -1,35 +1,100 @@ 'maxmind', - + 'log_failures' => true, /* |-------------------------------------------------------------------------- - | Services settings + | Include Currency in Results |-------------------------------------------------------------------------- | - | Service specific settings. + | When enabled the system will do it's best in deciding the user's currency + | by matching their ISO code to a preset list of currencies. | */ - - 'maxmind' => [ - 'type' => env('GEOIP_DRIVER', 'database'), // database or web_service - 'user_id' => env('GEOIP_USER_ID'), - 'license_key' => env('GEOIP_LICENSE_KEY'), - 'database_path' => storage_path('app/geoip.mmdb'), - 'update_url' => 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz', + 'include_currency' => true, + /* + |-------------------------------------------------------------------------- + | Default Service + |-------------------------------------------------------------------------- + | + | Here you may specify the default storage driver that should be used + | by the framework. + | + | Supported: "maxmind_database", "maxmind_api", "ipapi" + | + */ + 'service' => 'ipapi', + /* + |-------------------------------------------------------------------------- + | Storage Specific Configuration + |-------------------------------------------------------------------------- + | + | Here you may configure as many storage drivers as you wish. + | + */ + 'services' => [ + 'maxmind_database' => [ + 'class' => \Torann\GeoIP\Services\MaxMindDatabase::class, + 'database_path' => storage_path('app/geoip.mmdb'), + 'update_url' => 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz', + 'locales' => ['en'], + ], + 'maxmind_api' => [ + 'class' => \Torann\GeoIP\Services\MaxMindWebService::class, + 'user_id' => env('MAXMIND_USER_ID'), + 'license_key' => env('MAXMIND_LICENSE_KEY'), + 'locales' => ['en'], + ], + 'ipapi' => [ + 'class' => \Torann\GeoIP\Services\IPApi::class, + 'secure' => true, + 'key' => env('IPAPI_KEY'), + 'continent_path' => storage_path('app/continents.json'), + ], ], - + /* + |-------------------------------------------------------------------------- + | Default Cache Driver + |-------------------------------------------------------------------------- + | + | Here you may specify the type of caching that should be used + | by the package. + | + | Options: + | + | all - All location are cached + | some - Cache only the requesting user + | none - Disable cached + | + */ + 'cache' => 'all', + /* + |-------------------------------------------------------------------------- + | Cache Tags + |-------------------------------------------------------------------------- + | + | Cache tags are not supported when using the file or database cache + | drivers in Laravel. This is done so that only locations can be cleared. + | + */ + 'cache_tags' => '', + /* + |-------------------------------------------------------------------------- + | Cache Expiration + |-------------------------------------------------------------------------- + | + | Define how long cached location are valid. + | + */ + 'cache_expires' => 30, /* |-------------------------------------------------------------------------- | Default Location @@ -38,18 +103,19 @@ return [ | Return when a location is not found. | */ - 'default_location' => [ - 'ip' => '127.0.0.0', - 'isoCode' => 'IN', - 'country' => 'INDIA', - 'city' => 'Bangalore', - 'state' => 'KT', - 'postal_code' => '06510', - 'lat' => 41.31, - 'lon' => -72.92, - 'timezone' => 'America/New_York', - 'continent' => 'NA', + 'ip' => '127.0.0.0', + 'iso_code' => 'IN', + 'country' => 'INDIA', + 'city' => 'Bangalore', + 'state' => 'KA', + 'state_name' => 'Connecticut', + 'postal_code' => '06510', + 'lat' => 41.31, + 'lon' => -72.92, + 'timezone' => 'Asia/Kolkata', + 'continent' => 'NA', + 'default' => true, + 'currency' => 'USD', ], - -]; +]; \ No newline at end of file diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 4814a6f48..aee7cbcea 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -4563,11 +4563,19 @@ return array( 'TijsVerkoyen\\CssToInlineStyles\\Exception' => $vendorDir . '/tijsverkoyen/css-to-inline-styles/src/Exception.php', 'TijsVerkoyen\\CssToInlineStyles\\Selector' => $vendorDir . '/tijsverkoyen/css-to-inline-styles/src/Selector.php', 'TijsVerkoyen\\CssToInlineStyles\\Specificity' => $vendorDir . '/tijsverkoyen/css-to-inline-styles/src/Specificity.php', - 'Torann\\GeoIP\\Console\\UpdateCommand' => $vendorDir . '/torann/geoip/src/Torann/GeoIP/Console/UpdateCommand.php', - 'Torann\\GeoIP\\GeoIP' => $vendorDir . '/torann/geoip/src/Torann/GeoIP/GeoIP.php', - 'Torann\\GeoIP\\GeoIPFacade' => $vendorDir . '/torann/geoip/src/Torann/GeoIP/GeoIPFacade.php', - 'Torann\\GeoIP\\GeoIPServiceProvider' => $vendorDir . '/torann/geoip/src/Torann/GeoIP/GeoIPServiceProvider.php', - 'Torann\\GeoIP\\GeoIPUpdater' => $vendorDir . '/torann/geoip/src/Torann/GeoIP/GeoIPUpdater.php', + 'Torann\\GeoIP\\Cache' => $vendorDir . '/torann/geoip/src/Cache.php', + 'Torann\\GeoIP\\Console\\Clear' => $vendorDir . '/torann/geoip/src/Console/Clear.php', + 'Torann\\GeoIP\\Console\\Update' => $vendorDir . '/torann/geoip/src/Console/Update.php', + 'Torann\\GeoIP\\Contracts\\ServiceInterface' => $vendorDir . '/torann/geoip/src/Contracts/ServiceInterface.php', + 'Torann\\GeoIP\\Facades\\GeoIP' => $vendorDir . '/torann/geoip/src/Facades/GeoIP.php', + 'Torann\\GeoIP\\GeoIP' => $vendorDir . '/torann/geoip/src/GeoIP.php', + 'Torann\\GeoIP\\GeoIPServiceProvider' => $vendorDir . '/torann/geoip/src/GeoIPServiceProvider.php', + 'Torann\\GeoIP\\Location' => $vendorDir . '/torann/geoip/src/Location.php', + 'Torann\\GeoIP\\Services\\AbstractService' => $vendorDir . '/torann/geoip/src/Services/AbstractService.php', + 'Torann\\GeoIP\\Services\\IPApi' => $vendorDir . '/torann/geoip/src/Services/IPApi.php', + 'Torann\\GeoIP\\Services\\MaxMindDatabase' => $vendorDir . '/torann/geoip/src/Services/MaxMindDatabase.php', + 'Torann\\GeoIP\\Services\\MaxMindWebService' => $vendorDir . '/torann/geoip/src/Services/MaxMindWebService.php', + 'Torann\\GeoIP\\Support\\HttpClient' => $vendorDir . '/torann/geoip/src/Support/HttpClient.php', 'Tymon\\JWTAuth\\Blacklist' => $vendorDir . '/tymon/jwt-auth/src/Blacklist.php', 'Tymon\\JWTAuth\\Claims\\Audience' => $vendorDir . '/tymon/jwt-auth/src/Claims/Audience.php', 'Tymon\\JWTAuth\\Claims\\Claim' => $vendorDir . '/tymon/jwt-auth/src/Claims/Claim.php', diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 201daf828..203cfdd38 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -23,4 +23,5 @@ return array( '58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php', '017b24472353920ed42bb364f7653c43' => $vendorDir . '/propaganistas/laravel-phone/src/helpers.php', '4a1f389d6ce373bda9e57857d3b61c84' => $vendorDir . '/barryvdh/laravel-debugbar/src/helpers.php', + '1e298922c3e2134d42dcdb03e6d5f55a' => $vendorDir . '/torann/geoip/src/helpers.php', ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 09405c3f9..820c84a6b 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -20,7 +20,7 @@ return array( 'Unisharp\\Laravelfilemanager\\' => array($vendorDir . '/unisharp/laravel-filemanager/src'), 'Unisharp\\Ckeditor\\' => array($vendorDir . '/unisharp/laravel-ckeditor'), 'Tymon\\JWTAuth\\' => array($vendorDir . '/tymon/jwt-auth/src'), - 'Torann\\GeoIP\\' => array($vendorDir . '/torann/geoip/src/Torann/GeoIP'), + 'Torann\\GeoIP\\' => array($vendorDir . '/torann/geoip/src'), 'TijsVerkoyen\\CssToInlineStyles\\' => array($vendorDir . '/tijsverkoyen/css-to-inline-styles/src'), 'Thomaswelton\\Tests\\LaravelGravatar\\' => array($vendorDir . '/thomaswelton/laravel-gravatar/tests'), 'Thomaswelton\\LaravelGravatar\\' => array($vendorDir . '/thomaswelton/laravel-gravatar/src'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 383768852..e5414c6f8 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -24,6 +24,7 @@ class ComposerStaticInit1bacc9bd2a82216bf11bc15e6aee6c79 '58571171fd5812e6e447dce228f52f4d' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Support/helpers.php', '017b24472353920ed42bb364f7653c43' => __DIR__ . '/..' . '/propaganistas/laravel-phone/src/helpers.php', '4a1f389d6ce373bda9e57857d3b61c84' => __DIR__ . '/..' . '/barryvdh/laravel-debugbar/src/helpers.php', + '1e298922c3e2134d42dcdb03e6d5f55a' => __DIR__ . '/..' . '/torann/geoip/src/helpers.php', ); public static $prefixLengthsPsr4 = array ( @@ -217,7 +218,7 @@ class ComposerStaticInit1bacc9bd2a82216bf11bc15e6aee6c79 ), 'Torann\\GeoIP\\' => array ( - 0 => __DIR__ . '/..' . '/torann/geoip/src/Torann/GeoIP', + 0 => __DIR__ . '/..' . '/torann/geoip/src', ), 'TijsVerkoyen\\CssToInlineStyles\\' => array ( @@ -5172,11 +5173,19 @@ class ComposerStaticInit1bacc9bd2a82216bf11bc15e6aee6c79 'TijsVerkoyen\\CssToInlineStyles\\Exception' => __DIR__ . '/..' . '/tijsverkoyen/css-to-inline-styles/src/Exception.php', 'TijsVerkoyen\\CssToInlineStyles\\Selector' => __DIR__ . '/..' . '/tijsverkoyen/css-to-inline-styles/src/Selector.php', 'TijsVerkoyen\\CssToInlineStyles\\Specificity' => __DIR__ . '/..' . '/tijsverkoyen/css-to-inline-styles/src/Specificity.php', - 'Torann\\GeoIP\\Console\\UpdateCommand' => __DIR__ . '/..' . '/torann/geoip/src/Torann/GeoIP/Console/UpdateCommand.php', - 'Torann\\GeoIP\\GeoIP' => __DIR__ . '/..' . '/torann/geoip/src/Torann/GeoIP/GeoIP.php', - 'Torann\\GeoIP\\GeoIPFacade' => __DIR__ . '/..' . '/torann/geoip/src/Torann/GeoIP/GeoIPFacade.php', - 'Torann\\GeoIP\\GeoIPServiceProvider' => __DIR__ . '/..' . '/torann/geoip/src/Torann/GeoIP/GeoIPServiceProvider.php', - 'Torann\\GeoIP\\GeoIPUpdater' => __DIR__ . '/..' . '/torann/geoip/src/Torann/GeoIP/GeoIPUpdater.php', + 'Torann\\GeoIP\\Cache' => __DIR__ . '/..' . '/torann/geoip/src/Cache.php', + 'Torann\\GeoIP\\Console\\Clear' => __DIR__ . '/..' . '/torann/geoip/src/Console/Clear.php', + 'Torann\\GeoIP\\Console\\Update' => __DIR__ . '/..' . '/torann/geoip/src/Console/Update.php', + 'Torann\\GeoIP\\Contracts\\ServiceInterface' => __DIR__ . '/..' . '/torann/geoip/src/Contracts/ServiceInterface.php', + 'Torann\\GeoIP\\Facades\\GeoIP' => __DIR__ . '/..' . '/torann/geoip/src/Facades/GeoIP.php', + 'Torann\\GeoIP\\GeoIP' => __DIR__ . '/..' . '/torann/geoip/src/GeoIP.php', + 'Torann\\GeoIP\\GeoIPServiceProvider' => __DIR__ . '/..' . '/torann/geoip/src/GeoIPServiceProvider.php', + 'Torann\\GeoIP\\Location' => __DIR__ . '/..' . '/torann/geoip/src/Location.php', + 'Torann\\GeoIP\\Services\\AbstractService' => __DIR__ . '/..' . '/torann/geoip/src/Services/AbstractService.php', + 'Torann\\GeoIP\\Services\\IPApi' => __DIR__ . '/..' . '/torann/geoip/src/Services/IPApi.php', + 'Torann\\GeoIP\\Services\\MaxMindDatabase' => __DIR__ . '/..' . '/torann/geoip/src/Services/MaxMindDatabase.php', + 'Torann\\GeoIP\\Services\\MaxMindWebService' => __DIR__ . '/..' . '/torann/geoip/src/Services/MaxMindWebService.php', + 'Torann\\GeoIP\\Support\\HttpClient' => __DIR__ . '/..' . '/torann/geoip/src/Support/HttpClient.php', 'Tymon\\JWTAuth\\Blacklist' => __DIR__ . '/..' . '/tymon/jwt-auth/src/Blacklist.php', 'Tymon\\JWTAuth\\Claims\\Audience' => __DIR__ . '/..' . '/tymon/jwt-auth/src/Claims/Audience.php', 'Tymon\\JWTAuth\\Claims\\Claim' => __DIR__ . '/..' . '/tymon/jwt-auth/src/Claims/Claim.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 3a565be4e..02b2ea0d0 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -2059,62 +2059,6 @@ "timer" ] }, - { - "name": "torann/geoip", - "version": "dev-master", - "version_normalized": "9999999-dev", - "source": { - "type": "git", - "url": "https://github.com/Torann/laravel-geoip.git", - "reference": "f16f839160b1ab1fe41382e18ec9a32dd09b10fd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Torann/laravel-geoip/zipball/f16f839160b1ab1fe41382e18ec9a32dd09b10fd", - "reference": "f16f839160b1ab1fe41382e18ec9a32dd09b10fd", - "shasum": "" - }, - "require": { - "illuminate/console": "~5.0", - "illuminate/support": "~5.0", - "php": ">=5.5.9" - }, - "require-dev": { - "phpspec/phpspec": "~2.1", - "phpunit/phpunit": "~4.0" - }, - "time": "2015-06-30 16:13:35", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.2-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Torann\\GeoIP\\": "src/Torann/GeoIP" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD 2-Clause" - ], - "authors": [ - { - "name": "Daniel Stainback", - "email": "daniel@lyften.com" - } - ], - "description": "Supports the two main GeoIP services (infoDB and Maxmind).", - "keywords": [ - "geoip", - "geolocation", - "laravel", - "laravel 5", - "location" - ] - }, { "name": "phpdocumentor/reflection-common", "version": "1.0", @@ -6418,5 +6362,72 @@ "text", "wysiwyg" ] + }, + { + "name": "torann/geoip", + "version": "1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/Torann/laravel-geoip.git", + "reference": "ae77f4ad99926fa35c89378f00a6a7295a7246ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Torann/laravel-geoip/zipball/ae77f4ad99926fa35c89378f00a6a7295a7246ea", + "reference": "ae77f4ad99926fa35c89378f00a6a7295a7246ea", + "shasum": "" + }, + "require": { + "illuminate/console": "~5.0", + "illuminate/support": "~5.0", + "php": ">=5.5.9" + }, + "require-dev": { + "geoip2/geoip2": "~2.1", + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.8" + }, + "suggest": { + "geoip2/geoip2": "Required to use the MaxMind database or web service with GeoIP (~2.1).", + "monolog/monolog": "Allows for storing location not found errors to the log" + }, + "time": "2016-10-17 17:29:40", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Torann\\GeoIP\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD 2-Clause" + ], + "authors": [ + { + "name": "Daniel Stainback", + "email": "torann@gmail.com" + } + ], + "description": "Support for multiple GeoIP services.", + "keywords": [ + "IP API", + "geoip", + "geolocation", + "infoDB", + "laravel", + "laravel 5", + "location", + "maxmind" + ] } ] diff --git a/vendor/torann/geoip/.travis.yml b/vendor/torann/geoip/.travis.yml index 0a1c1cb2e..e994d8b29 100644 --- a/vendor/torann/geoip/.travis.yml +++ b/vendor/torann/geoip/.travis.yml @@ -1,9 +1,14 @@ language: php -php: - - 5.3 - - 5.4 +php: - 5.5 + - 5.6 + - 7.0 + - hhvm + +matrix: + allow_failures: + - php: 7.0 before_script: - curl -s http://getcomposer.org/installer | php diff --git a/vendor/torann/geoip/LICENCE b/vendor/torann/geoip/LICENCE index fda3aa61b..9faba7c5a 100644 --- a/vendor/torann/geoip/LICENCE +++ b/vendor/torann/geoip/LICENCE @@ -1,5 +1,5 @@ The BSD 2-Clause License -Copyright (c) 2013, Daniel Stainback +Copyright (c) 2013-2016, Daniel Stainback All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/vendor/torann/geoip/README.md b/vendor/torann/geoip/README.md index 38242fb65..5a3515a42 100644 --- a/vendor/torann/geoip/README.md +++ b/vendor/torann/geoip/README.md @@ -1,103 +1,50 @@ # GeoIP for Laravel 5 -[![Latest Stable Version](https://poser.pugx.org/torann/geoip/v/stable.png)](https://packagist.org/packages/torann/geoip) [![Total Downloads](https://poser.pugx.org/torann/geoip/downloads.png)](https://packagist.org/packages/torann/geoip) +[![Build Status](https://travis-ci.org/Torann/laravel-geoip.svg?branch=master)](https://travis-ci.org/Torann/laravel-geoip) +[![Latest Stable Version](https://poser.pugx.org/torann/geoip/v/stable.png)](https://packagist.org/packages/torann/geoip) +[![Total Downloads](https://poser.pugx.org/torann/geoip/downloads.png)](https://packagist.org/packages/torann/geoip) +[![Patreon donate button](https://img.shields.io/badge/patreon-donate-yellow.svg)](https://www.patreon.com/torann) +[![Donate weekly to this project using Gratipay](https://img.shields.io/badge/gratipay-donate-yellow.svg)](https://gratipay.com/~torann) +[![Donate to this project using Flattr](https://img.shields.io/badge/flattr-donate-yellow.svg)](https://flattr.com/profile/torann) +[![Donate to this project using Paypal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4CJA2A97NPYVU) -Determine the geographical location of website visitors based on their IP addresses. [Homepage](http://lyften.com/projects/laravel-geoip/) - ----------- - -## Installation +Determine the geographical location and currency of website visitors based on their IP addresses. - [GeoIP for Laravel 5 on Packagist](https://packagist.org/packages/torann/geoip) - [GeoIP for Laravel 5 on GitHub](https://github.com/Torann/laravel-geoip) -- [Laravel 4 Installation](https://github.com/Torann/laravel-geoip/tree/0.1.1) +- [Upgrade Guides](http://lyften.com/projects/laravel-geoip/doc/upgrade.html) -To get the latest version of GeoIP simply require it in your `composer.json` file. +## Official Documentation -~~~ -"torann/geoip": "0.2.*@dev" -~~~ +Documentation for the package can be found on [Lyften.com](http://lyften.com/projects/laravel-geoip/). -You'll then need to run `composer install` to download it and have the autoloader updated. +## Laravel 4 -Once GeoIP is installed you need to register the service provider with the application. Open up `config/app.php` and find the `providers` key. - -~~~php -'providers' => array( - - 'Torann\GeoIP\GeoIPServiceProvider', - -) -~~~ - -GeoIP also ships with a facade which provides the static syntax for creating collections. You can register the facade in the `aliases` key of your `config/app.php` file. - -~~~php -'aliases' => array( - - 'GeoIP' => 'Torann\GeoIP\GeoIPFacade', - -) -~~~ - -### Publish the configurations - -Run this on the command line from the root of your project: - -~~~ -$ php artisan vendor:publish -~~~ - -A configuration file will be publish to `config/geoip.php` - -### Update max mind cities database - -~~~ -$ php artisan geoip:update -~~~ - -**Database Service**: To use the database version of [MaxMind](http://www.maxmind.com) services download the `GeoLite2-City.mmdb` from [http://dev.maxmind.com/geoip/geoip2/geolite2/](http://dev.maxmind.com/geoip/geoip2/geolite2/) and extract it to `storage/app/geoip.mmdb`. And that's it. - -## Usage - -Get the location data for a website visitor: - -```php -$location = GeoIP::getLocation(); -``` - -> When an IP is not given the `$_SERVER["REMOTE_ADDR"]` is used. - -Getting the location data for a given IP: - -```php -$location = GeoIP::getLocation('232.223.11.11'); -``` - -### Example Data - -```php -array ( - "ip" => "232.223.11.11", - "isoCode" => "US", - "country" => "United States", - "city" => "New Haven", - "state" => "CT", - "postal_code" => "06510", - "lat" => 41.28, - "lon" => -72.88, - "timezone" => "America/New_York", - "continent" => "NA", - "default" => false -); -``` - -#### Default Location - -In the case that a location is not found the fallback location will be returned with the `default` parameter set to `true`. To set your own default change it in the configurations `config/geoip.php` +For Laravel 4 Installation see [version 0.1.1](https://github.com/Torann/laravel-geoip/tree/0.1.1) ## Change Log +#### v1.0.2 + +- Support double IP addresses #25 + +#### v1.0.1 + +- Fix bug #60 + +#### v1.0.0 + +- Major code refactoring and cleanup +- Add currency support +- Add Location object +- Add cache drivers +- Add `state_name` to `$location` array #46 +- Set locales in config #45 +- Raise PHP requirement to 5.5 +- Fix file structure to adher to PSR-4 file structure. #40 +- Support custom Geo IP services + - Added ip-api.com service (Thanks to [nikkiii](https://github.com/nikkiii)) + #### v0.2.1 - Add database_path to config @@ -113,3 +60,13 @@ In the case that a location is not found the fallback location will be returned - Log address not found exceptions - Supports a custom default location +## Contributions + +Many people have contributed to project since its inception. + +Thanks to: + +- [nikkiii](https://github.com/nikkiii) +- [jeffhennis](https://github.com/jeffhennis) +- [max-kovpak](https://github.com/max-kovpak) +- [dotpack](https://github.com/dotpack) \ No newline at end of file diff --git a/vendor/torann/geoip/composer.json b/vendor/torann/geoip/composer.json index 3fd79d1a6..c4698f062 100644 --- a/vendor/torann/geoip/composer.json +++ b/vendor/torann/geoip/composer.json @@ -1,35 +1,56 @@ { - "name": "torann/geoip", - "description": "Supports the two main GeoIP services (infoDB and Maxmind).", - "keywords": ["laravel", "laravel 5", "geoip", "location", "geolocation"], - "license": "BSD 2-Clause", - "authors": [ - { - "name": "Daniel Stainback", - "email": "daniel@lyften.com" - } - ], - "require": { - "php": ">=5.3.0", - "illuminate/support": "~5.0", - "illuminate/session": "~5.0", - "illuminate/console": "~5.0", - "illuminate/config": "~5.0", - "monolog/monolog": "~1.11", - "geoip2/geoip2": "~2.1" - }, - "require-dev": { - "phpunit/phpunit": "~4.0", - "phpspec/phpspec": "~2.1" - }, - "autoload": { - "psr-4": { - "Torann\\GeoIP\\": "src/Torann/GeoIP" - } - }, - "extra": { - "branch-alias": { - "dev-master": "0.2-dev" - } + "name": "torann/geoip", + "description": "Support for multiple GeoIP services.", + "keywords": [ + "laravel", + "laravel 5", + "geoip", + "location", + "geolocation", + "MaxMind", + "IP API", + "infoDB" + ], + "license": "BSD 2-Clause", + "authors": [ + { + "name": "Daniel Stainback", + "email": "torann@gmail.com" } + ], + "require": { + "php": ">=5.5.9", + "illuminate/support": "~5.0", + "illuminate/console": "~5.0" + }, + "suggest": { + "geoip2/geoip2": "Required to use the MaxMind database or web service with GeoIP (~2.1).", + "monolog/monolog": "Allows for storing location not found errors to the log" + }, + "require-dev": { + "phpunit/phpunit": "^4.8", + "mockery/mockery": "^0.9.4", + "geoip2/geoip2": "~2.1" + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Torann\\GeoIP\\": "src/" + } + }, + "autoload-dev": { + "files": [ + "tests/TestFunctions.php" + ], + "psr-4": { + "Torann\\GeoIP\\Tests\\": "tests/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + } } diff --git a/vendor/torann/geoip/config/geoip.php b/vendor/torann/geoip/config/geoip.php new file mode 100644 index 000000000..9699b1adc --- /dev/null +++ b/vendor/torann/geoip/config/geoip.php @@ -0,0 +1,143 @@ + true, + + /* + |-------------------------------------------------------------------------- + | Include Currency in Results + |-------------------------------------------------------------------------- + | + | When enabled the system will do it's best in deciding the user's currency + | by matching their ISO code to a preset list of currencies. + | + */ + + 'include_currency' => true, + + /* + |-------------------------------------------------------------------------- + | Default Service + |-------------------------------------------------------------------------- + | + | Here you may specify the default storage driver that should be used + | by the framework. + | + | Supported: "maxmind_database", "maxmind_api", "ipapi" + | + */ + + 'service' => 'ipapi', + + /* + |-------------------------------------------------------------------------- + | Storage Specific Configuration + |-------------------------------------------------------------------------- + | + | Here you may configure as many storage drivers as you wish. + | + */ + + 'services' => [ + + 'maxmind_database' => [ + 'class' => \Torann\GeoIP\Services\MaxMindDatabase::class, + 'database_path' => storage_path('app/geoip.mmdb'), + 'update_url' => 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz', + 'locales' => ['en'], + ], + + 'maxmind_api' => [ + 'class' => \Torann\GeoIP\Services\MaxMindWebService::class, + 'user_id' => env('MAXMIND_USER_ID'), + 'license_key' => env('MAXMIND_LICENSE_KEY'), + 'locales' => ['en'], + ], + + 'ipapi' => [ + 'class' => \Torann\GeoIP\Services\IPApi::class, + 'secure' => true, + 'key' => env('IPAPI_KEY'), + 'continent_path' => storage_path('app/continents.json'), + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Default Cache Driver + |-------------------------------------------------------------------------- + | + | Here you may specify the type of caching that should be used + | by the package. + | + | Options: + | + | all - All location are cached + | some - Cache only the requesting user + | none - Disable cached + | + */ + + 'cache' => 'all', + + /* + |-------------------------------------------------------------------------- + | Cache Tags + |-------------------------------------------------------------------------- + | + | Cache tags are not supported when using the file or database cache + | drivers in Laravel. This is done so that only locations can be cleared. + | + */ + + 'cache_tags' => ['torann-geoip-location'], + + /* + |-------------------------------------------------------------------------- + | Cache Expiration + |-------------------------------------------------------------------------- + | + | Define how long cached location are valid. + | + */ + + 'cache_expires' => 30, + + /* + |-------------------------------------------------------------------------- + | Default Location + |-------------------------------------------------------------------------- + | + | Return when a location is not found. + | + */ + + 'default_location' => [ + 'ip' => '127.0.0.0', + 'iso_code' => 'US', + 'country' => 'United States', + 'city' => 'New Haven', + 'state' => 'CT', + 'state_name' => 'Connecticut', + 'postal_code' => '06510', + 'lat' => 41.31, + 'lon' => -72.92, + 'timezone' => 'America/New_York', + 'continent' => 'NA', + 'default' => true, + 'currency' => 'USD', + ], + +]; \ No newline at end of file diff --git a/vendor/torann/geoip/phpunit.xml b/vendor/torann/geoip/phpunit.xml index e89ac6d80..22a7b8dc6 100644 --- a/vendor/torann/geoip/phpunit.xml +++ b/vendor/torann/geoip/phpunit.xml @@ -9,10 +9,11 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" + verbose="true" > - - ./tests/ + + ./tests \ No newline at end of file diff --git a/vendor/torann/geoip/resources/geoip.mmdb b/vendor/torann/geoip/resources/geoip.mmdb new file mode 100644 index 0000000000000000000000000000000000000000..2c4d08f9e5bbaae5f0ad1cf3e5981ddfcdf3992b GIT binary patch literal 20740 zcmZ{q2Yggj7XQz@_XZV3r79MfAVNS81$!lRGD!$A1yH~+BttTg%!HYY5O&v1QKT28 z2uKMn6p>Jr4(h0Dcj8*sU0ueAz(Q;9LG*;v>$y*^<>vx4UY&oj81VWJmesTYY}k|KW*yi9byQy%+@;8g~M^g1f`Hqjd~^*4#$61|9^ zIhu!u@$>#Fct`LqLuI^=oBb@pzY%>9)uX=?{R4TeL?6b4A4$o73O*K`7JMT3RL~+g z!%z=u!_7V?YUi8LSwV;3GlnXK{|fX4(Z3|`OTkyMyswG=Ey8aE-wM8q75QH7@*kof zB=5h1A7e%SCq;f@bi0`77sM=#MtFe@apX53Ma_F;8%{P5X4y1>4&flO8Nj7vvx~5c z;2goZg7XAj1?LMc5Ofnz*9%6Xnm5VQN0IFY5#Go!YouVinQXU6-mTF*+ijwEJK64t3GWo)U1Ymk6h_DL zlE{`EP2s+_)M(03d!kn0Jtf=P-?x73Ojp{-9 zf&xLIV4PsQV1nRYfy{rliJamlm?Za{EV!R+MN)E#z#T1#(yUNSwi3zn2&P4g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ixu?2=o+9-gKg;RyyK+YkPr+A`StXueF(wK1xu5z5Wb#nSbf`>6f%h z@l&lwAItPsMr+W;g?Xkl1gF9$cX%#}XZr9BrhEzbynS_6z*CI1M^Vr_$J21d{{bzu BGC=?U literal 0 HcmV?d00001 diff --git a/vendor/torann/geoip/src/Cache.php b/vendor/torann/geoip/src/Cache.php new file mode 100644 index 000000000..7b9381a33 --- /dev/null +++ b/vendor/torann/geoip/src/Cache.php @@ -0,0 +1,74 @@ +cache = $tags ? $cache->tags($tags) : $cache; + $this->expires = $expires; + } + + /** + * Get an item from the cache. + * + * @param string $name + * + * @return Location|null + */ + public function get($name) + { + $value = $this->cache->get($name); + + return is_array($value) + ? new Location($value) + : null; + } + + /** + * Store an item in cache. + * + * @param string $name + * @param Location $location + * + * @return bool + */ + public function set($name, Location $location) + { + return $this->cache->put($name, $location->toArray(), $this->expires); + } + + /** + * Flush cache for tags. + * + * @return bool + */ + public function flush() + { + return $this->cache->flush(); + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Console/Clear.php b/vendor/torann/geoip/src/Console/Clear.php new file mode 100644 index 000000000..def950865 --- /dev/null +++ b/vendor/torann/geoip/src/Console/Clear.php @@ -0,0 +1,59 @@ +isSupported() === false) { + return $this->output->error('Default cache system does not support tags'); + } + + $this->performFlush(); + } + + /** + * Is cache flushing supported. + * + * @return bool + */ + protected function isSupported() + { + return empty(app('geoip')->config('cache_tags')) === false + && in_array(config('cache.default'), ['file', 'database']) === false; + } + + /** + * Flush the cache. + * + * @return void + */ + protected function performFlush() + { + $this->output->write("Clearing cache..."); + + app('geoip')->getCache()->flush(); + + $this->output->writeln("complete"); + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Console/Update.php b/vendor/torann/geoip/src/Console/Update.php new file mode 100644 index 000000000..13077ab92 --- /dev/null +++ b/vendor/torann/geoip/src/Console/Update.php @@ -0,0 +1,49 @@ +getService(); + + // Ensure the selected service supports updating + if (method_exists($service, 'update') === false) { + $this->info('The current service "' . get_class($service). '" does not support updating.'); + return; + } + + $this->comment('Updating...'); + + // Perform update + if ($result = $service->update()) { + $this->info($result); + } + else { + $this->error('Update failed!'); + } + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Contracts/ServiceInterface.php b/vendor/torann/geoip/src/Contracts/ServiceInterface.php new file mode 100644 index 000000000..7582d3ded --- /dev/null +++ b/vendor/torann/geoip/src/Contracts/ServiceInterface.php @@ -0,0 +1,42 @@ + '127.0.0.0', + 'iso_code' => 'US', + 'country' => 'United States', + 'city' => 'New Haven', + 'state' => 'CT', + 'state_name' => 'Connecticut', + 'postal_code' => '06510', + 'lat' => 41.31, + 'lon' => -72.92, + 'timezone' => 'America/New_York', + 'continent' => 'NA', + 'currency' => 'USD', + 'default' => true, + 'cached' => false, + ]; + + /** + * Create a new GeoIP instance. + * + * @param array $config + * @param CacheManager $cache + */ + public function __construct(array $config, CacheManager $cache) + { + $this->config = $config; + + // Create caching instance + $this->cache = new Cache( + $cache, + $this->config('cache_tags'), + $this->config('cache_expires', 30) + ); + + // Set custom default location + $this->default_location = array_merge( + $this->default_location, + $this->config('default_location', []) + ); + + // Set IP + $this->remote_ip = $this->default_location['ip'] = $this->getClientIP(); + } + + /** + * Get the location from the provided IP. + * + * @param string $ip + * + * @return \Torann\GeoIP\Location + */ + public function getLocation($ip = null) + { + // Get location data + $this->location = $this->find($ip); + + // Should cache location + if ($this->shouldCache($ip, $this->location)) { + $this->getCache()->set($ip, $this->location); + } + + return $this->location; + } + + /** + * Find location from IP. + * + * @param string $ip + * + * @return \Torann\GeoIP\Location + * @throws \Exception + */ + private function find($ip = null) + { + // Check cache for location + if ($this->config('cache', 'none') !== 'none' && $location = $this->getCache()->get($ip)) { + $location->cached = true; + + return $location; + } + + // If IP not set, user remote IP + $ip = $ip ?: $this->remote_ip; + + // Check if the ip is not local or empty + if ($this->isValid($ip)) { + try { + // Find location + $location = $this->getService()->locate($ip); + + // Set currency if not already set by the service + if (!$location->currency) { + $location->currency = $this->getCurrency($location->iso_code); + } + + // Set default + $location->default = false; + + return $location; + } + catch (\Exception $e) { + if ($this->config('log_failures', true) === true) { + $log = new Logger('geoip'); + $log->pushHandler(new StreamHandler(storage_path('logs/geoip.log'), Logger::ERROR)); + $log->addError($e); + } + } + } + + return $this->getService()->hydrate($this->default_location); + } + + /** + * Get the currency code from ISO. + * + * @param string $iso + * + * @return string + */ + public function getCurrency($iso) + { + if ($this->currencies === null && $this->config('include_currency', false)) { + $this->currencies = include(__DIR__ . '/Support/Currencies.php'); + } + + return Arr::get($this->currencies, $iso); + } + + /** + * Get service instance. + * + * @return \Torann\GeoIP\Contracts\ServiceInterface + * @throws Exception + */ + public function getService() + { + if ($this->service === null) { + // Get service configuration + $config = $this->config('services.' . $this->config('service'), []); + + // Get service class + $class = Arr::pull($config, 'class'); + + // Sanity check + if ($class === null) { + throw new Exception('The GeoIP service is not valid.'); + } + + // Create service instance + $this->service = app($class, [$config]); + } + + return $this->service; + } + + /** + * Get cache instance. + * + * @return \Torann\GeoIP\Cache + */ + public function getCache() + { + return $this->cache; + } + + /** + * Get the client IP address. + * + * @return string + */ + public function getClientIP() + { + $remotes_keys = [ + 'HTTP_X_FORWARDED_FOR', + 'HTTP_CLIENT_IP', + 'HTTP_X_FORWARDED', + 'HTTP_FORWARDED_FOR', + 'HTTP_FORWARDED', + 'REMOTE_ADDR', + 'HTTP_X_CLUSTER_CLIENT_IP', + ]; + + foreach ($remotes_keys as $key) { + if ($address = getenv($key)) { + foreach (explode(',', $address) as $ip) { + if ($this->isValid($ip)) { + return $ip; + } + } + } + } + + return '127.0.0.0'; + } + + /** + * Checks if the ip is valid. + * + * @param string $ip + * + * @return bool + */ + private function isValid($ip) + { + if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) + && !filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE) + ) { + return false; + } + + return true; + } + + /** + * Determine if the location should be cached. + * + * @param string $ip + * @param Location $location + * + * @return bool + */ + private function shouldCache($ip = null, Location $location) + { + if ($location->default === true || $location->cached === true) { + return false; + } + + switch($this->config('cache', 'none')) { + case 'all': + return true; + case 'some' && $ip === null: + return true; + } + + return false; + } + + /** + * Get configuration value. + * + * @param string $key + * @param mixed $default + * + * @return mixed + */ + public function config($key, $default = null) + { + return Arr::get($this->config, $key, $default); + } +} diff --git a/vendor/torann/geoip/src/GeoIPServiceProvider.php b/vendor/torann/geoip/src/GeoIPServiceProvider.php new file mode 100644 index 000000000..9f7121821 --- /dev/null +++ b/vendor/torann/geoip/src/GeoIPServiceProvider.php @@ -0,0 +1,75 @@ +registerGeoIpService(); + + if ($this->app->runningInConsole()) { + $this->registerResources(); + $this->registerGeoIpCommands(); + } + } + + /** + * Register currency provider. + * + * @return void + */ + public function registerGeoIpService() + { + $this->app->singleton('geoip', function ($app) { + return new GeoIP( + $app->config->get('geoip', []), + $app['cache'] + ); + }); + } + + /** + * Register currency resources. + * + * @return void + */ + public function registerResources() + { + if ($this->isLumen() === false) { + $this->publishes([ + __DIR__ . '/../config/geoip.php' => config_path('geoip.php'), + ], 'config'); + } + } + + /** + * Register currency commands. + * + * @return void + */ + public function registerGeoIpCommands() + { + $this->commands([ + Console\Update::class, + Console\Clear::class, + ]); + } + + /** + * Check if package is running under Lumen app + * + * @return bool + */ + protected function isLumen() + { + return str_contains($this->app->version(), 'Lumen') === true; + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Location.php b/vendor/torann/geoip/src/Location.php new file mode 100644 index 000000000..f9a0e8e09 --- /dev/null +++ b/vendor/torann/geoip/src/Location.php @@ -0,0 +1,197 @@ +attributes = $attributes; + } + + /** + * Determine if the location is for the same IP address. + * + * @param string $ip + * + * @return bool + */ + public function same($ip) + { + return $this->getAttribute('ip') == $ip; + } + + /** + * Set a given attribute on the location. + * + * @param string $key + * @param mixed $value + * + * @return $this + */ + public function setAttribute($key, $value) + { + $this->attributes[$key] = $value; + + return $this; + } + + /** + * Get an attribute from the $attributes array. + * + * @param string $key + * + * @return mixed + */ + public function getAttribute($key) + { + $value = Arr::get($this->attributes, $key); + + // First we will check for the presence of a mutator for the set operation + // which simply lets the developers tweak the attribute as it is set. + if (method_exists($this, 'get' . Str::studly($key) . 'Attribute')) { + $method = 'get' . Str::studly($key) . 'Attribute'; + + return $this->{$method}($value); + } + + return $value; + } + + /** + * Return the display name of the location. + * + * @return string + */ + public function getDisplayNameAttribute() + { + return preg_replace('/^,\s/', '', "{$this->city}, {$this->state}"); + } + + /** + * Is the location the default. + * + * @return bool + */ + public function getDefaultAttribute($value) + { + return is_null($value) ? false : $value; + } + + /** + * Get the instance as an array. + * + * @return array + */ + public function toArray() + { + return $this->attributes; + } + + /** + * Get the location's attribute + * + * @param string $key + * + * @return mixed + */ + public function __get($key) + { + return $this->getAttribute($key); + } + + /** + * Set the location's attribute + * + * @param string $key + * @param mixed $value + */ + public function __set($key, $value) + { + $this->setAttribute($key, $value); + } + + /** + * Determine if the given attribute exists. + * + * @param mixed $offset + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Get the value for a given offset. + * + * @param mixed $offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Set the value for a given offset. + * + * @param mixed $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unset the value for a given offset. + * + * @param mixed $offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + + /** + * Check if the location's attribute is set + * + * @param $key + * + * @return bool + */ + public function __isset($key) + { + return array_key_exists($key, $this->attributes); + } + + /** + * Unset an attribute on the location. + * + * @param string $key + * @return void + */ + public function __unset($key) + { + unset($this->attributes[$key]); + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Services/AbstractService.php b/vendor/torann/geoip/src/Services/AbstractService.php new file mode 100644 index 000000000..3cd493094 --- /dev/null +++ b/vendor/torann/geoip/src/Services/AbstractService.php @@ -0,0 +1,61 @@ +config = $config; + + $this->boot(); + } + + /** + * The "booting" method of the service. + * + * @return void + */ + public function boot() + { + // + } + + /** + * {@inheritdoc} + */ + public function hydrate(array $attributes = []) + { + return new Location($attributes); + } + + /** + * Get configuration value. + * + * @param string $key + * @param mixed $default + * + * @return mixed + */ + public function config($key, $default = null) + { + return Arr::get($this->config, $key, $default); + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Services/IPApi.php b/vendor/torann/geoip/src/Services/IPApi.php new file mode 100644 index 000000000..df28a6ef3 --- /dev/null +++ b/vendor/torann/geoip/src/Services/IPApi.php @@ -0,0 +1,142 @@ + 'http://ip-api.com/', + 'headers' => [ + 'User-Agent' => 'Laravel-GeoIP', + ], + 'query' => [ + 'fields' => 49663, + ], + ]; + + // Using the Pro service + if ($this->config('key')) { + $base['base_uri'] = ($this->config('secure') ? 'https' : 'http') . '://pro.ip-api.com/'; + $base['query']['key'] = $this->config('key'); + } + + $this->client = new HttpClient($base); + + // Set continents + if (file_exists($this->config('continent_path'))) { + $this->continents = json_decode(file_get_contents($this->config('continent_path')), true); + } + } + + /** + * {@inheritdoc} + */ + public function locate($ip) + { + // Get data from client + $data = $this->client->get('json/' . $ip); + + // Verify server response + if ($this->client->getErrors() !== null) { + throw new Exception('Request failed (' . $this->client->getErrors() . ')'); + } + + // Parse body content + $json = json_decode($data[0]); + + // Verify response status + if ($json->status !== 'success') { + throw new Exception('Request failed (' . $json->message . ')'); + } + + return $this->hydrate([ + 'ip' => $ip, + 'iso_code' => $json->countryCode, + 'country' => $json->country, + 'city' => $json->city, + 'state' => $json->region, + 'state_name' => $json->regionName, + 'postal_code' => $json->zip, + 'lat' => $json->lat, + 'lon' => $json->lon, + 'timezone' => $json->timezone, + 'continent' => $this->getContinent($json->countryCode), + ]); + } + + /** + * Update function for service. + * + * @return string + * @throws Exception + */ + public function update() + { + $data = $this->client->get('http://dev.maxmind.com/static/csv/codes/country_continent.csv'); + + // Verify server response + if ($this->client->getErrors() !== null) { + throw new Exception($this->client->getErrors()); + } + + $lines = explode("\n", $data[0]); + + array_shift($lines); + + $output = []; + + foreach ($lines as $line) { + $arr = str_getcsv($line); + + if (count($arr) < 2) { + continue; + } + + $output[$arr[0]] = $arr[1]; + } + + // Get path + $path = $this->config('continent_path'); + + file_put_contents($path, json_encode($output)); + + return "Continent file ({$path}) updated."; + } + + /** + * Get continent based on country code. + * + * @param string $code + * + * @return string + */ + private function getContinent($code) + { + return Arr::get($this->continents, $code, 'Unknown'); + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Services/MaxMindDatabase.php b/vendor/torann/geoip/src/Services/MaxMindDatabase.php new file mode 100644 index 000000000..359c316d7 --- /dev/null +++ b/vendor/torann/geoip/src/Services/MaxMindDatabase.php @@ -0,0 +1,93 @@ +config('database_path')) === false) { + copy(__DIR__ . '/../../resources/geoip.mmdb', $this->config('database_path')); + } + + $this->reader = new Reader( + $this->config('database_path'), + $this->config('locales', ['en']) + ); + } + + /** + * {@inheritdoc} + */ + public function locate($ip) + { + $record = $this->reader->city($ip); + + return $this->hydrate([ + 'ip' => $ip, + 'iso_code' => $record->country->isoCode, + 'country' => $record->country->name, + 'city' => $record->city->name, + 'state' => $record->mostSpecificSubdivision->isoCode, + 'state_name' => $record->mostSpecificSubdivision->name, + 'postal_code' => $record->postal->code, + 'lat' => $record->location->latitude, + 'lon' => $record->location->longitude, + 'timezone' => $record->location->timeZone, + 'continent' => $record->continent->code, + ]); + } + + /** + * Update function for service. + * + * @return string + * @throws Exception + */ + public function update() + { + if ($this->config('database_path', false) === false) { + throw new Exception('Database path not set in config file.'); + } + + // Get settings + $url = $this->config('update_url'); + $path = $this->config('database_path'); + + // Get header response + $headers = get_headers($url); + + if (substr($headers[0], 9, 3) != '200') { + throw new Exception('Unable to download database. ('. substr($headers[0], 13) .')'); + } + + // Download zipped database to a system temp file + $tmpFile = tempnam(sys_get_temp_dir(), 'maxmind'); + file_put_contents($tmpFile, fopen($url, 'r')); + + // Unzip and save database + file_put_contents($path, gzopen($tmpFile, 'r')); + + // Remove temp file + @unlink($tmpFile); + + return "Database file ({$path}) updated."; + } +} diff --git a/vendor/torann/geoip/src/Services/MaxMindWebService.php b/vendor/torann/geoip/src/Services/MaxMindWebService.php new file mode 100644 index 000000000..12aba728a --- /dev/null +++ b/vendor/torann/geoip/src/Services/MaxMindWebService.php @@ -0,0 +1,52 @@ +client = new Client( + $this->config('user_id'), + $this->config('license_key'), + $this->config('locales', ['en']) + ); + } + + /** + * {@inheritdoc} + */ + public function locate($ip) + { + $record = $this->client->city($ip); + + return $this->hydrate([ + 'ip' => $ip, + 'iso_code' => $record->country->isoCode, + 'country' => $record->country->name, + 'city' => $record->city->name, + 'state' => $record->mostSpecificSubdivision->isoCode, + 'state_name' => $record->mostSpecificSubdivision->name, + 'postal_code' => $record->postal->code, + 'lat' => $record->location->latitude, + 'lon' => $record->location->longitude, + 'timezone' => $record->location->timeZone, + 'continent' => $record->continent->code, + ]); + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Support/Currencies.php b/vendor/torann/geoip/src/Support/Currencies.php new file mode 100644 index 000000000..f7aee40aa --- /dev/null +++ b/vendor/torann/geoip/src/Support/Currencies.php @@ -0,0 +1,251 @@ + 'EUR', + 'AE' => 'AED', + 'AF' => 'AFN', + 'AG' => 'XCD', + 'AI' => 'XCD', + 'AL' => 'ALL', + 'AM' => 'AMD', + 'AN' => 'ANG', + 'AO' => 'AOA', + 'AQ' => '', + 'AR' => 'ARS', + 'AS' => 'USD', + 'AT' => 'EUR', + 'AU' => 'AUD', + 'AW' => 'AWG', + 'AZ' => 'AZN', + 'BA' => 'BAM', + 'BB' => 'BBD', + 'BD' => 'BDT', + 'BE' => 'EUR', + 'BF' => 'XOF', + 'BG' => 'BGN', + 'BH' => 'BHD', + 'BI' => 'BIF', + 'BJ' => 'XOF', + 'BL' => 'EUR', + 'BM' => 'BMD', + 'BN' => 'BND', + 'BO' => 'BOB', + 'BR' => 'BRL', + 'BS' => 'BSD', + 'BT' => 'BTN', + 'BV' => 'NOK', + 'BW' => 'BWP', + 'BY' => 'BYR', + 'BZ' => 'BZD', + 'CA' => 'CAD', + 'CC' => 'AUD', + 'CD' => 'CDF', + 'CF' => 'XAF', + 'CG' => 'CDF', + 'CH' => 'CHF', + 'CI' => 'XOF', + 'CK' => 'NZD', + 'CL' => 'CLP', + 'CM' => 'XAF', + 'CN' => 'CNY', + 'CO' => 'COP', + 'CR' => 'CRC', + 'CU' => 'CUP', + 'CV' => 'CVE', + 'CW' => 'ANG', + 'CX' => 'AUD', + 'CY' => 'EUR', + 'CZ' => 'CZK', + 'DE' => 'EUR', + 'DJ' => 'DJF', + 'DK' => 'DKK', + 'DM' => 'XCD', + 'DO' => 'DOP', + 'DZ' => 'DZD', + 'EC' => 'USD', + 'EE' => 'EUR', + 'EG' => 'EGP', + 'EH' => 'MAD', + 'ER' => 'ERN', + 'ES' => 'EUR', + 'ET' => 'ETB', + 'FI' => 'EUR', + 'FJ' => 'FJD', + 'FK' => 'FKP', + 'FM' => 'USD', + 'FO' => 'DKK', + 'FR' => 'EUR', + 'GA' => 'XAF', + 'GB' => 'GBP', + 'GD' => 'XCD', + 'GE' => 'GEL', + 'GF' => 'EUR', + 'GG' => 'GGP', + 'GH' => 'GHS', + 'GI' => 'GIP', + 'GL' => 'DKK', + 'GM' => 'GMD', + 'GN' => 'GNF', + 'GP' => 'EUR', + 'GQ' => 'XAF', + 'GR' => 'EUR', + 'GS' => 'GBP', + 'GT' => 'GTQ', + 'GU' => 'USD', + 'GW' => 'XOF', + 'GY' => 'GYD', + 'HK' => 'HKD', + 'HM' => 'AUD', + 'HN' => 'HNL', + 'HR' => 'HRK', + 'HT' => 'HTG', + 'HU' => 'HUF', + 'ID' => 'IDR', + 'IE' => 'EUR', + 'IL' => 'ILS', + 'IM' => 'IMP', + 'IN' => 'INR', + 'IO' => 'USD', + 'IQ' => 'IQD', + 'IR' => 'IRR', + 'IS' => 'ISK', + 'IT' => 'EUR', + 'JE' => 'JEP', + 'JM' => 'JMD', + 'JO' => 'JOD', + 'JP' => 'JPY', + 'KE' => 'KES', + 'KG' => 'KGS', + 'KH' => 'KHR', + 'KI' => 'AUD', + 'KM' => 'KMF', + 'KN' => 'XCD', + 'KP' => 'KPW', + 'KR' => 'KRW', + 'KW' => 'KWD', + 'KY' => 'KYD', + 'KZ' => 'KZT', + 'LA' => 'LAK', + 'LB' => 'LBP', + 'LC' => 'XCD', + 'LI' => 'CHF', + 'LK' => 'LKR', + 'LR' => 'LRD', + 'LS' => 'LSL', + 'LT' => 'EUR', + 'LU' => 'EUR', + 'LV' => 'EUR', + 'LY' => 'LYD', + 'MA' => 'MAD', + 'MC' => 'EUR', + 'MD' => 'MDL', + 'ME' => 'EUR', + 'MG' => 'MGA', + 'MH' => 'USD', + 'MK' => 'MKD', + 'ML' => 'XOF', + 'MM' => 'MMK', + 'MN' => 'MNT', + 'MO' => 'MOP', + 'MP' => 'USD', + 'MQ' => 'EUR', + 'MR' => 'MRO', + 'MS' => 'XCD', + 'MT' => 'EUR', + 'MU' => 'MUR', + 'MV' => 'MVR', + 'MW' => 'MWK', + 'MX' => 'MXN', + 'MY' => 'MYR', + 'MZ' => 'MZN', + 'NA' => 'NAD', + 'NC' => 'XPF', + 'NE' => 'XOF', + 'NF' => 'AUD', + 'NG' => 'NGN', + 'NI' => 'NIO', + 'NL' => 'EUR', + 'NO' => 'NOK', + 'NP' => 'NPR', + 'NR' => 'AUD', + 'NU' => 'NZD', + 'NZ' => 'NZD', + 'OM' => 'OMR', + 'PA' => 'PAB', + 'PE' => 'PEN', + 'PF' => 'XPF', + 'PG' => 'PGK', + 'PH' => 'PHP', + 'PK' => 'PKR', + 'PL' => 'PLN', + 'PM' => 'EUR', + 'PN' => 'GBP', + 'PR' => 'USD', + 'PS' => 'ILS', + 'PT' => 'EUR', + 'PW' => 'USD', + 'PY' => 'PYG', + 'QA' => 'QAR', + 'RE' => 'EUR', + 'RO' => 'RON', + 'RS' => 'RSD', + 'RU' => 'RUB', + 'RW' => 'RWF', + 'SA' => 'SAR', + 'SB' => 'SBD', + 'SC' => 'SCR', + 'SD' => 'SDG', + 'SE' => 'SEK', + 'SG' => 'SGD', + 'SH' => 'SHP', + 'SI' => 'EUR', + 'SJ' => 'NOK', + 'SK' => 'EUR', + 'SL' => 'SLL', + 'SM' => 'EUR', + 'SN' => 'XOF', + 'SO' => 'SOS', + 'SR' => 'SRD', + 'SS' => 'SSP', + 'ST' => 'STD', + 'SV' => 'USD', + 'SX' => 'ANG', + 'SY' => 'SYP', + 'SZ' => 'SZL', + 'TC' => 'USD', + 'TD' => 'XAF', + 'TF' => 'EUR', + 'TG' => 'XOF', + 'TH' => 'THB', + 'TJ' => 'TJS', + 'TK' => 'NZD', + 'TL' => 'USD', + 'TM' => 'TMT', + 'TN' => 'TND', + 'TO' => 'TOP', + 'TR' => 'TRY', + 'TT' => 'TTD', + 'TV' => 'AUD', + 'TW' => 'TWD', + 'TZ' => 'TZS', + 'UA' => 'UAH', + 'UG' => 'UGX', + 'US' => 'USD', + 'UY' => 'UYU', + 'UZ' => 'UZS', + 'VA' => 'EUR', + 'VC' => 'XCD', + 'VE' => 'VEF', + 'VG' => 'USD', + 'VI' => 'USD', + 'VN' => 'VND', + 'VU' => 'VUV', + 'WF' => 'XPF', + 'WS' => 'WST', + 'XK' => 'EUR', + 'YE' => 'YER', + 'YT' => 'EUR', + 'ZA' => 'ZAR', + 'ZM' => 'ZMK', + 'ZW' => 'ZWL', +]; diff --git a/vendor/torann/geoip/src/Support/HttpClient.php b/vendor/torann/geoip/src/Support/HttpClient.php new file mode 100644 index 000000000..d66679293 --- /dev/null +++ b/vendor/torann/geoip/src/Support/HttpClient.php @@ -0,0 +1,245 @@ + '', + 'headers' => [], + 'query' => [], + ]; + + /** + * Last request http status. + * + * @var int + **/ + protected $http_code = 200; + + /** + * Last request error string. + * + * @var string + **/ + protected $errors = null; + + /** + * Array containing headers from last performed request. + * + * @var array + */ + private $headers = []; + + /** + * HttpClient constructor. + * + * @param array $config + */ + public function __construct(array $config = []) + { + $this->config = $config; + } + + /** + * Perform a get request. + * + * @param string $url + * @param array $query + * @param array $headers + * + * @return array + */ + public function get($url, array $query = [], array $headers = []) + { + return $this->execute('GET', $this->buildGetUrl($url, $query), [], $headers); + } + + /** + * Execute the curl request + * + * @param string $method + * @param string $url + * @param array $query + * @param array $headers + * + * @return array + */ + public function execute($method, $url, array $query = [], array $headers = []) + { + // Merge global and request headers + $headers = array_merge( + Arr::get($this->config, 'headers', []), + $headers + ); + + // Merge global and request queries + $query = array_merge( + Arr::get($this->config, 'query', []), + $query + ); + + $this->errors = null; + + $curl = curl_init(); + + // Set options + curl_setopt_array($curl, [ + CURLOPT_URL => $this->getUrl($url), + CURLOPT_HTTPHEADER => $headers, + CURLOPT_CONNECTTIMEOUT => 20, + CURLOPT_TIMEOUT => 90, + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_SSL_VERIFYPEER => 0, + CURLOPT_SSL_VERIFYHOST => 0, + CURLOPT_HEADER => 1, + CURLINFO_HEADER_OUT => 1, + CURLOPT_VERBOSE => 1, + ]); + + // Setup method specific options + switch ($method) { + case 'PUT': + case 'PATCH': + case 'POST': + curl_setopt_array($curl, [ + CURLOPT_CUSTOMREQUEST => $method, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $query, + ]); + break; + + case 'DELETE': + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE'); + break; + + default: + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); + break; + } + + // Make request + curl_setopt($curl, CURLOPT_HEADER, true); + $response = curl_exec($curl); + + // Set HTTP response code + $this->http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + // Set errors if there are any + if (curl_errno($curl)) { + $this->errors = curl_error($curl); + } + + // Parse body + $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); + $header = substr($response, 0, $header_size); + $body = substr($response, $header_size); + + curl_close($curl); + + return [$body, $this->parseHeaders($header)]; + } + + /** + * Check if the curl request ended up with errors + * + * @return bool + */ + public function hasErrors() + { + return is_null($this->errors) === false; + } + + /** + * Get curl errors + * + * @return string + */ + public function getErrors() + { + return $this->errors; + } + + /** + * Get last curl HTTP code. + * + * @return int + */ + public function getHttpCode() + { + return $this->http_code; + } + + /** + * Parse string headers into array + * + * @param string $headers + * + * @return array + */ + private function parseHeaders($headers) + { + $result = []; + + foreach (preg_split("/\\r\\n|\\r|\\n/", $headers) as $row) { + $header = explode(':', $row, 2); + + if (count($header) == 2) { + $result[$header[0]] = trim($header[1]); + } + else { + $result[] = $header[0]; + } + } + + return $result; + } + + /** + * Get request URL. + * + * @param string $url + * + * @return string + */ + private function getUrl($url) + { + // Check for URL scheme + if (parse_url($url, PHP_URL_SCHEME) === null) { + $url = Arr::get($this->config, 'base_uri') . $url; + } + + return $url; + } + + /** + * Build a GET request string. + * + * @param string $url + * @param array $query + * + * @return string + */ + private function buildGetUrl($url, array $query = []) + { + // Merge global and request queries + $query = array_merge( + Arr::get($this->config, 'query', []), + $query + ); + + // Append query + if ($query = http_build_query($query)) { + $url .= strpos($url, '?') ? $query : "?{$query}"; + } + + return $url; + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Torann/GeoIP/Console/UpdateCommand.php b/vendor/torann/geoip/src/Torann/GeoIP/Console/UpdateCommand.php deleted file mode 100644 index 6bcf585da..000000000 --- a/vendor/torann/geoip/src/Torann/GeoIP/Console/UpdateCommand.php +++ /dev/null @@ -1,57 +0,0 @@ -geoIPUpdater = new GeoIPUpdater($config); - } - - /** - * Execute the console command. - * - * @return void - */ - public function fire() - { - $result = $this->geoIPUpdater->update(); - - if (!$result) { - $this->error('Update failed!'); - - return; - } - - $this->info('New update file ('.$result.') installed.'); - } -} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Torann/GeoIP/GeoIP.php b/vendor/torann/geoip/src/Torann/GeoIP/GeoIP.php deleted file mode 100644 index f2e59d789..000000000 --- a/vendor/torann/geoip/src/Torann/GeoIP/GeoIP.php +++ /dev/null @@ -1,282 +0,0 @@ - "127.0.0.0", - "isoCode" => "US", - "country" => "United States", - "city" => "New Haven", - "state" => "CT", - "postal_code" => "06510", - "lat" => 41.31, - "lon" => -72.92, - "timezone" => "America/New_York", - "continent" => "NA", - "default" => true, - ); - - /** - * Create a new GeoIP instance. - * - * @param \Illuminate\Config\Repository $config - * @param \Illuminate\Session\Store $session - */ - public function __construct(Repository $config, SessionStore $session) - { - $this->config = $config; - $this->session = $session; - - // Set custom default location - $this->default_location = array_merge( - $this->default_location, - $this->config->get('geoip.default_location', array()) - ); - - // Set IP - $this->remote_ip = $this->default_location['ip'] = $this->getClientIP(); - } - - /** - * Save location data in the session. - * - * @return void - */ - function saveLocation() - { - $this->session->set('geoip-location', $this->location); - } - - /** - * Get location from IP. - * - * @param string $ip Optional - * @return array - */ - public function getLocation($ip = null) - { - // Get location data - $this->location = $this->find($ip); - - // Save user's location - if ($ip === null) { - $this->saveLocation(); - } - - return $this->location; - } - - /** - * Find location from IP. - * - * @param string $ip Optional - * @return array - * @throws \Exception - */ - private function find($ip = null) - { - // Check Session - if ($ip === null && $position = $this->session->get('geoip-location')) { - return $position; - } - - // If IP not set, user remote IP - if ($ip === null) { - $ip = $this->remote_ip; - } - - // Check if the ip is not local or empty - if ($this->checkIp($ip)) { - // Get service name - $service = 'locate_'.$this->config->get('geoip.service'); - - // Check for valid service - if (! method_exists($this, $service)) { - throw new \Exception("GeoIP Service not support or setup."); - } - - return $this->$service($ip); - } - - return $this->default_location; - } - - private $maxmind; - - /** - * Maxmind Service. - * - * @param string $ip - * @return array - */ - private function locate_maxmind($ip) - { - $settings = $this->config->get('geoip.maxmind'); - - if (empty($this->maxmind)) { - if ($settings['type'] === 'web_service') { - $this->maxmind = new Client($settings['user_id'], $settings['license_key']); - } - else { - $this->maxmind = new Reader($settings['database_path']); - } - } - - try { - $record = $this->maxmind->city($ip); - - $location = array( - "ip" => $ip, - "isoCode" => $record->country->isoCode, - "country" => $record->country->name, - "city" => $record->city->name, - "state" => $record->mostSpecificSubdivision->isoCode, - "postal_code" => $record->postal->code, - "lat" => $record->location->latitude, - "lon" => $record->location->longitude, - "timezone" => $record->location->timeZone, - "continent" => $record->continent->code, - "default" => false, - ); - } - catch (AddressNotFoundException $e) - { - $location = $this->default_location; - - $logFile = 'geoip'; - - $log = new Logger($logFile); - $log->pushHandler(new StreamHandler(storage_path("logs/{$logFile}.log"), Logger::ERROR)); - $log->addError($e); - } - - unset($record); - - return $location; - } - - /** - * Get the client IP address. - * - * @return string - */ - private function getClientIP() - { - if (getenv('HTTP_CLIENT_IP')) { - $ipaddress = getenv('HTTP_CLIENT_IP'); - } - else if (getenv('HTTP_X_FORWARDED_FOR')) { - $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); - } - else if (getenv('HTTP_X_FORWARDED')) { - $ipaddress = getenv('HTTP_X_FORWARDED'); - } - else if (getenv('HTTP_FORWARDED_FOR')) { - $ipaddress = getenv('HTTP_FORWARDED_FOR'); - } - else if (getenv('HTTP_FORWARDED')) { - $ipaddress = getenv('HTTP_FORWARDED'); - } - else if (getenv('REMOTE_ADDR')) { - $ipaddress = getenv('REMOTE_ADDR'); - } - else if (isset($_SERVER['REMOTE_ADDR'])) { - $ipaddress = $_SERVER['REMOTE_ADDR']; - } - else { - $ipaddress = '127.0.0.0'; - } - - return $ipaddress; - } - - /** - * Checks if the ip is not local or empty. - * - * @return bool - */ - private function checkIp($ip) - { - if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { - $longip = ip2long($ip); - - if (! empty($ip)) { - foreach ($this->reserved_ips as $r) { - $min = ip2long($r[0]); - $max = ip2long($r[1]); - - if ($longip >= $min && $longip <= $max) { - return false; - } - } - - return true; - } - } else if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { - return true; - } - - return false; - } - -} diff --git a/vendor/torann/geoip/src/Torann/GeoIP/GeoIPFacade.php b/vendor/torann/geoip/src/Torann/GeoIP/GeoIPFacade.php deleted file mode 100644 index 1e5642b3c..000000000 --- a/vendor/torann/geoip/src/Torann/GeoIP/GeoIPFacade.php +++ /dev/null @@ -1,14 +0,0 @@ -publishes([ - __DIR__.'/../../config/geoip.php' => config_path('geoip.php'), - ]); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - // Register providers. - $this->app['geoip'] = $this->app->share(function($app) - { - return new GeoIP($app['config'], $app["session.store"]); - }); - - $this->app['command.geoip.update'] = $this->app->share(function ($app) - { - return new UpdateCommand($app['config']); - }); - $this->commands(['command.geoip.update']); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return array('geoip', 'command.geoip.update'); - } - -} \ No newline at end of file diff --git a/vendor/torann/geoip/src/Torann/GeoIP/GeoIPUpdater.php b/vendor/torann/geoip/src/Torann/GeoIP/GeoIPUpdater.php deleted file mode 100644 index 611627d23..000000000 --- a/vendor/torann/geoip/src/Torann/GeoIP/GeoIPUpdater.php +++ /dev/null @@ -1,62 +0,0 @@ -config = $config; - } - - /** - * Main update function. - * - * @return bool|string - */ - public function update() - { - if ($this->config->get('geoip.maxmind.database_path', false)) { - return $this->updateMaxMindDatabase(); - } - - return false; - } - - /** - * Update function for max mind database. - * - * @return string - */ - protected function updateMaxMindDatabase() - { - $maxMindDatabaseUrl = $this->config->get('geoip.maxmind.update_url'); - $databasePath = $this->config->get('geoip.maxmind.database_path'); - - // Download zipped database to a system temp file - $tmpFile = tempnam(sys_get_temp_dir(), 'maxmind'); - file_put_contents($tmpFile, fopen($maxMindDatabaseUrl, 'r')); - - // Unzip and save database - file_put_contents($databasePath, gzopen($tmpFile, 'r')); - - // Remove temp file - @unlink($tmpFile); - - return $databasePath; - } -} \ No newline at end of file diff --git a/vendor/torann/geoip/src/config/.gitkeep b/vendor/torann/geoip/src/config/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/torann/geoip/src/config/geoip.php b/vendor/torann/geoip/src/config/geoip.php deleted file mode 100644 index 385213da5..000000000 --- a/vendor/torann/geoip/src/config/geoip.php +++ /dev/null @@ -1,55 +0,0 @@ - 'maxmind', - - /* - |-------------------------------------------------------------------------- - | Services settings - |-------------------------------------------------------------------------- - | - | Service specific settings. - | - */ - - 'maxmind' => array( - 'type' => env('GEOIP_DRIVER', 'database'), // database or web_service - 'user_id' => env('GEOIP_USER_ID'), - 'license_key' => env('GEOIP_LICENSE_KEY'), - 'database_path' => storage_path('app/geoip.mmdb'), - 'update_url' => 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz', - ), - - /* - |-------------------------------------------------------------------------- - | Default Location - |-------------------------------------------------------------------------- - | - | Return when a location is not found. - | - */ - - 'default_location' => array ( - "ip" => "127.0.0.0", - "isoCode" => "US", - "country" => "United States", - "city" => "New Haven", - "state" => "CT", - "postal_code" => "06510", - "lat" => 41.31, - "lon" => -72.92, - "timezone" => "America/New_York", - "continent" => "NA", - ), - -); \ No newline at end of file diff --git a/vendor/torann/geoip/src/helpers.php b/vendor/torann/geoip/src/helpers.php new file mode 100644 index 000000000..d43c5be6c --- /dev/null +++ b/vendor/torann/geoip/src/helpers.php @@ -0,0 +1,19 @@ +getLocation($ip); + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/tests/.gitkeep b/vendor/torann/geoip/tests/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/torann/geoip/tests/CacheTest.php b/vendor/torann/geoip/tests/CacheTest.php new file mode 100644 index 000000000..0c17e209f --- /dev/null +++ b/vendor/torann/geoip/tests/CacheTest.php @@ -0,0 +1,84 @@ + '81.2.69.142', + 'iso_code' => 'US', + 'lat' => 41.31, + 'lon' => -72.92, + ]; + + $cacheMock = Mockery::mock('Illuminate\Cache\CacheManager'); + $cacheMock->shouldReceive('get')->with($data['ip'])->andReturn($data); + + $geo_ip = $this->makeGeoIP([], $cacheMock); + + $location = $geo_ip->getCache()->get($data['ip']); + + $this->assertInstanceOf(\Torann\GeoIP\Location::class, $location); + $this->assertEquals($location->ip, $data['ip']); + $this->assertEquals($location->default, false); + } + + /** + * @test + */ + public function shouldReturnInvalidLocation() + { + $cacheMock = Mockery::mock('Illuminate\Cache\CacheManager'); + + $geo_ip = $this->makeGeoIP([], $cacheMock); + + $cacheMock->shouldReceive('get')->with('81.2.69.142')->andReturn(null); + $cacheMock->shouldReceive('tags')->with($geo_ip->config('cache_tags'))->andReturnSelf(); + + $this->assertEquals($geo_ip->getCache()->get('81.2.69.142'), null); + } + + /** + * @test + */ + public function shouldSetLocation() + { + $location = new \Torann\GeoIP\Location([ + 'ip' => '81.2.69.142', + 'iso_code' => 'US', + 'lat' => 41.31, + 'lon' => -72.92, + ]); + + $cacheMock = Mockery::mock('Illuminate\Cache\CacheManager'); + + $geo_ip = $this->makeGeoIP([], $cacheMock); + + $cacheMock->shouldReceive('put')->withArgs(['81.2.69.142', $location->toArray(), $geo_ip->config('cache_expires')])->andReturn(null); + $cacheMock->shouldReceive('tags')->with($geo_ip->config('cache_tags'))->andReturnSelf(); + + $this->assertEquals($geo_ip->getCache()->set('81.2.69.142', $location), null); + } + + /** + * @test + */ + public function shouldFlushLocations() + { + $cacheMock = Mockery::mock('Illuminate\Cache\CacheManager'); + + $geo_ip = $this->makeGeoIP([], $cacheMock); + + $cacheMock->shouldReceive('flush')->andReturn(true); + $cacheMock->shouldReceive('tags')->with($geo_ip->config('cache_tags'))->andReturnSelf(); + + $this->assertEquals($geo_ip->getCache()->flush(), true); + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/tests/GeoIPTest.php b/vendor/torann/geoip/tests/GeoIPTest.php new file mode 100644 index 000000000..63a74de89 --- /dev/null +++ b/vendor/torann/geoip/tests/GeoIPTest.php @@ -0,0 +1,46 @@ +makeGeoIP(); + + $this->assertEquals($geo_ip->getCurrency('US'), 'USD'); + } + + /** + * @test + */ + public function testGetService() + { + $geo_ip = $this->makeGeoIP([ + 'service' => 'maxmind_database', + ]); + + // Get config values + $config = $this->getConfig()['services']['maxmind_database']; + unset($config['class']); + + self::$functions->shouldReceive('app')->with('Torann\GeoIP\Services\MaxMindDatabase', [$config])->andReturn(true); + + $this->assertEquals($geo_ip->getService(), true); + } + + /** + * @test + */ + public function testGetCache() + { + $geo_ip = $this->makeGeoIP(); + + $this->assertInstanceOf(\Torann\GeoIP\Cache::class, $geo_ip->getCache()); + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/tests/GeoIPUpdaterTest.php b/vendor/torann/geoip/tests/GeoIPUpdaterTest.php deleted file mode 100644 index a85d58fec..000000000 --- a/vendor/torann/geoip/tests/GeoIPUpdaterTest.php +++ /dev/null @@ -1,37 +0,0 @@ -assertFalse($geoIPUpdater->update()); - } - - public function test_max_mind_updater() - { - $database = __DIR__ . '/data/GeoLite2-City.mmdb'; - $config = new Repository([ - 'geoip' => [ - 'service' => 'maxmind', - 'maxmind' => [ - 'type' => 'database', - 'database_path' => $database, - 'update_url' => 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz', - ], - ], - ]); - - $geoIPUpdater = new GeoIPUpdater($config); - $this->assertEquals($geoIPUpdater->update(), $database); - unlink($database); - } -} \ No newline at end of file diff --git a/vendor/torann/geoip/tests/Services/MaxMindDatabaseTest.php b/vendor/torann/geoip/tests/Services/MaxMindDatabaseTest.php new file mode 100644 index 000000000..553534557 --- /dev/null +++ b/vendor/torann/geoip/tests/Services/MaxMindDatabaseTest.php @@ -0,0 +1,69 @@ +getService(); + + $this->assertEquals($service->config('database_path'), $config['database_path']); + } + + /** + * @test + */ + public function shouldReturnValidLocation() + { + list($service, $config) = $this->getService(); + + $location = $service->locate('81.2.69.142'); + + $this->assertInstanceOf(\Torann\GeoIP\Location::class, $location); + $this->assertEquals($location->ip, '81.2.69.142'); + $this->assertEquals($location->default, false); + } + + /** + * @test + */ + public function shouldReturnInvalidLocation() + { + list($service, $config) = $this->getService(); + + try { + $location = $service->locate('1.1.1.1'); + $this->assertEquals($location->default, 'Poop'); // This should never get a chance + } + catch (\GeoIp2\Exception\AddressNotFoundException $e) { + $this->assertEquals($e->getMessage(), 'The address 1.1.1.1 is not in the database.'); + } + } + + /** + * @test + */ + public function shouldUpdateLocalDatabase() + { + list($service, $config) = $this->getService(); + + $this->assertEquals($service->update(), "Database file ({$config['database_path']}) updated."); + + unlink($config['database_path']); + } + + protected function getService() + { + $config = $this->getConfig()['services']['maxmind_database']; + + $service = new $config['class']($config); + + return [$service, $config]; + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/tests/TestCase.php b/vendor/torann/geoip/tests/TestCase.php new file mode 100644 index 000000000..ef3ea83db --- /dev/null +++ b/vendor/torann/geoip/tests/TestCase.php @@ -0,0 +1,55 @@ +getConfig(), $config); + + $cacheMock->shouldReceive('tags')->with(['torann-geoip-location'])->andReturnSelf(); + + return new \Torann\GeoIP\GeoIP($config, $cacheMock); + } + + protected function getConfig() + { + $config = include(__DIR__ . '/../config/geoip.php'); + + $this->databaseCheck($config['services']['maxmind_database']['database_path']); + + return $config; + } + + /** + * Check for test database and make a copy of it + * if it does not exist. + * + * @param string $database + */ + protected function databaseCheck($database) + { + if (file_exists($database) === false) { + @mkdir(dirname($database), 0755, true); + copy(__DIR__ . '/../resources/geoip.mmdb', $database); + } + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/tests/TestFunctions.php b/vendor/torann/geoip/tests/TestFunctions.php new file mode 100644 index 000000000..e7ab1a342 --- /dev/null +++ b/vendor/torann/geoip/tests/TestFunctions.php @@ -0,0 +1,22 @@ +app($key, $default); + } +} \ No newline at end of file diff --git a/vendor/torann/geoip/tests/data/.gitkeep b/vendor/torann/geoip/tests/data/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/torann/geoip/tests/tmp/.gitignore b/vendor/torann/geoip/tests/tmp/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/vendor/torann/geoip/tests/tmp/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file