From 02de47e2ada430fc1b1e681d2120aed2aaf46e6b Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sun, 1 Dec 2019 21:54:45 +0100 Subject: [PATCH] Display releases postdate information based on users location --- .env.example | 1 + Changelog | 2 + composer.json | 2 + composer.lock | 130 +++++++++++++- config/database.php | 2 +- config/geoip.php | 165 ++++++++++++++++++ ... 2015_01_16_195548_create_users_table.php} | 0 resources/views/themes/Gentele/books.tpl | 2 +- resources/views/themes/Gentele/browse.tpl | 2 +- resources/views/themes/Gentele/console.tpl | 2 +- resources/views/themes/Gentele/games.tpl | 2 +- resources/views/themes/Gentele/music.tpl | 2 +- resources/views/themes/Gentele/search.tpl | 4 +- resources/views/themes/Gentele/viewanime.tpl | 2 +- resources/views/themes/Gentele/viewnzb.tpl | 2 +- resources/views/themes/Gentele/viewseries.tpl | 2 +- resources/views/themes/admin/failrel-list.tpl | 2 +- resources/views/themes/admin/release-edit.tpl | 2 +- resources/views/themes/admin/release-list.tpl | 2 +- 19 files changed, 313 insertions(+), 15 deletions(-) create mode 100644 config/geoip.php rename database/migrations/{2018_01_16_195548_create_users_table.php => 2015_01_16_195548_create_users_table.php} (100%) diff --git a/.env.example b/.env.example index 17f15fe45..2d1df2a45 100644 --- a/.env.example +++ b/.env.example @@ -52,6 +52,7 @@ QUEUE_CONNECTION=sync REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 +REDIS_CLIENT = phpredis SESSION_DRIVER=file SESSION_DOMAIN=localhost diff --git a/Changelog b/Changelog index 384c25586..8320f235c 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2019-12-01 DariusIII + * Chg: Display releases postdate information based on users location 2019-11-27 DariusIII * Fix: Fix wrong Book categories seeders and fixtures 2019-11-25 DariusIII diff --git a/composer.json b/composer.json index 4bf1bcb3a..f6cbfab60 100755 --- a/composer.json +++ b/composer.json @@ -107,6 +107,7 @@ "intervention/image": "^2.4", "intervention/imagecache": "^2.3", "james-heinrich/getid3": "1.9.*", + "jamesmills/laravel-timezone": "^1.3", "joshpinkney/tv-maze-php-api": "dev-master", "jrean/laravel-user-verification": "^8.0", "junaidnasir/larainvite": "^3.0", @@ -130,6 +131,7 @@ "php-http/guzzle6-adapter": "^1.1", "php-http/message": "^1.6", "pragmarx/firewall": "^2.3", + "predis/predis": "^1.1", "propaganistas/laravel-disposable-email": "^2.0", "ramsey/uuid": "^3.7", "rtconner/laravel-tagging": "^3.0", diff --git a/composer.lock b/composer.lock index 73b1766bf..ec6f00b69 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d4a4fc9636f52a79f2542aa67c1187d6", + "content-hash": "3bce991fe31d6165781b1c3aa94c8176", "packages": [ { "name": "aharen/omdbapi", @@ -2394,6 +2394,60 @@ ], "time": "2019-09-16T19:08:47+00:00" }, + { + "name": "jamesmills/laravel-timezone", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/jamesmills/laravel-timezone.git", + "reference": "c8fefb4da8222914fc048a89be20af450d98d6fe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jamesmills/laravel-timezone/zipball/c8fefb4da8222914fc048a89be20af450d98d6fe", + "reference": "c8fefb4da8222914fc048a89be20af450d98d6fe", + "shasum": "" + }, + "require": { + "laravel/framework": "5.6.* || 5.7.* || 5.8.* || ^6", + "nesbot/carbon": "^1.0 || ^2.0", + "php": ">=7", + "torann/geoip": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.12" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "JamesMills\\LaravelTimezone\\LaravelTimezoneServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "JamesMills\\LaravelTimezone\\": "src/", + "JamesMills\\LaravelTimezone\\Database\\Seeds\\": "database/seeds/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "James Mills", + "email": "james@clicksco.com" + } + ], + "description": "Timezone storage and retrieval for Laravel", + "keywords": [ + "laravel", + "timezone" + ], + "time": "2019-10-21T12:14:23+00:00" + }, { "name": "jenssegers/model", "version": "v1.2.2", @@ -8617,6 +8671,80 @@ "homepage": "https://github.com/tijsverkoyen/CssToInlineStyles", "time": "2019-10-24T08:53:34+00:00" }, + { + "name": "torann/geoip", + "version": "1.0.13", + "source": { + "type": "git", + "url": "https://github.com/Torann/laravel-geoip.git", + "reference": "9577c9d865050af39bb4c23795c9eb09bebb6476" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Torann/laravel-geoip/zipball/9577c9d865050af39bb4c23795c9eb09bebb6476", + "reference": "9577c9d865050af39bb4c23795c9eb09bebb6476", + "shasum": "" + }, + "require": { + "illuminate/console": "~5.5|^6.0", + "illuminate/support": "~5.5|^6.0", + "php": "^7.1", + "vlucas/phpdotenv": "^3.5" + }, + "require-dev": { + "geoip2/geoip2": "~2.1", + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^7.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" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + }, + "laravel": { + "providers": [ + "Torann\\GeoIP\\GeoIPServiceProvider" + ], + "aliases": { + "GeoIP": "Torann\\GeoIP\\Facades\\GeoIP" + } + } + }, + "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" + ], + "time": "2019-10-30T15:41:29+00:00" + }, { "name": "vlucas/phpdotenv", "version": "v3.6.0", diff --git a/config/database.php b/config/database.php index 0e6b86b0d..49b840fb1 100644 --- a/config/database.php +++ b/config/database.php @@ -123,7 +123,7 @@ return [ */ 'redis' => [ - 'client' => 'phpredis', + 'client' => env('REDIS_CLIENT', 'phpredis'), 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), 'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_', diff --git a/config/geoip.php b/config/geoip.php new file mode 100644 index 000000000..7e43bd754 --- /dev/null +++ b/config/geoip.php @@ -0,0 +1,165 @@ + 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'), + 'lang' => 'en', + ], + + 'ipgeolocation' => [ + 'class' => \Torann\GeoIP\Services\IPGeoLocation::class, + 'secure' => true, + 'key' => env('IPGEOLOCATION_KEY'), + 'continent_path' => storage_path('app/continents.json'), + 'lang' => 'en', + ], + + 'ipdata' => [ + 'class' => \Torann\GeoIP\Services\IPData::class, + 'key' => env('IPDATA_API_KEY'), + 'secure' => true, + ], + + 'ipfinder' => [ + 'class' => \Torann\GeoIP\Services\IPFinder::class, + 'key' => env('IPFINDER_API_KEY'), + 'secure' => true, + 'locales' => ['en'], + ], + + ], + + /* + |-------------------------------------------------------------------------- + | 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', + ], + +]; diff --git a/database/migrations/2018_01_16_195548_create_users_table.php b/database/migrations/2015_01_16_195548_create_users_table.php similarity index 100% rename from database/migrations/2018_01_16_195548_create_users_table.php rename to database/migrations/2015_01_16_195548_create_users_table.php diff --git a/resources/views/themes/Gentele/books.tpl b/resources/views/themes/Gentele/books.tpl index faa78bf32..5e6411ba0 100755 --- a/resources/views/themes/Gentele/books.tpl +++ b/resources/views/themes/Gentele/books.tpl @@ -105,7 +105,7 @@ id="chksingle"/> {$result->size|filesize} - Posted {$result->postdate|timeago} + Posted {{{Timezone::convertToLocal($result->postdate, 'Y-m-d h:i:s')}}|timeago} ago
{if isset($result->review) && $result->review != ""} {$result->category_name} - {$result->postdate|timeago} + {{{Timezone::convertToLocal($result->postdate, 'Y-m-d h:i:s')}}|timeago} {$result->size|filesize} guid}")}}" diff --git a/resources/views/themes/Gentele/console.tpl b/resources/views/themes/Gentele/console.tpl index 733bfff6f..f0c1171cb 100755 --- a/resources/views/themes/Gentele/console.tpl +++ b/resources/views/themes/Gentele/console.tpl @@ -115,7 +115,7 @@ id="chksingle"/> {$result->size|filesize} - Posted {$result->postdate|timeago} + Posted {{{Timezone::convertToLocal($result->postdate, 'Y-m-d h:i:s')}}|timeago} ago {if isset($isadmin)} {$result->size|filesize} - Posted {$result->postdate|timeago} + Posted {{{Timezone::convertToLocal($result->postdate, 'Y-m-d h:i:s')}}|timeago} ago {if isset($isadmin)} {$result->size|filesize} - Posted {$result->postdate|timeago} + Posted {{{Timezone::convertToLocal($result->postdate, 'Y-m-d h:i:s')}}|timeago} ago {if isset($isadmin)}guid}")}}" diff --git a/resources/views/themes/Gentele/search.tpl b/resources/views/themes/Gentele/search.tpl index 5cbf597a5..2a79fa3de 100755 --- a/resources/views/themes/Gentele/search.tpl +++ b/resources/views/themes/Gentele/search.tpl @@ -312,8 +312,8 @@ parent_category}/{$result->sub_category}")}}"> {$result->category_name} - - {$result->postdate|timeago} + + {{{Timezone::convertToLocal($result->postdate, 'Y-m-d h:i:s')}}|timeago} {$result->size|filesize} diff --git a/resources/views/themes/Gentele/viewanime.tpl b/resources/views/themes/Gentele/viewanime.tpl index 51900a237..9c0f0c41b 100755 --- a/resources/views/themes/Gentele/viewanime.tpl +++ b/resources/views/themes/Gentele/viewanime.tpl @@ -136,7 +136,7 @@ {$result->category_name} - {$result->postdate|timeago} + {{{Timezone::convertToLocal($result->postdate, 'Y-m-d h:i:s')}}|timeago} {$result->size|filesize} guid}")}}"> Posted - {$release.postdate|date_format:"%b %e, %Y %T"} + {{Timezone::convertToLocal($release.postdate, 'F j, Y H:i:s')}} ({$release.postdate|daysago} ) diff --git a/resources/views/themes/Gentele/viewseries.tpl b/resources/views/themes/Gentele/viewseries.tpl index 9c6e0d6f9..8af3e2e33 100755 --- a/resources/views/themes/Gentele/viewseries.tpl +++ b/resources/views/themes/Gentele/viewseries.tpl @@ -206,7 +206,7 @@ {$result->category_name} {$result->postdate|timeago} + title="{{Timezone::convertToLocal($result->postdate, 'Y-m-d h:i:s')}}">{{{Timezone::convertToLocal($result->postdate, 'Y-m-d h:i:s')}}|timeago} {$result->size|filesize} diff --git a/resources/views/themes/admin/failrel-list.tpl b/resources/views/themes/admin/failrel-list.tpl index 85dbd932e..0c8f74ece 100644 --- a/resources/views/themes/admin/failrel-list.tpl +++ b/resources/views/themes/admin/failrel-list.tpl @@ -24,7 +24,7 @@ {$release.category_name} {$release.size|filesize} {$release.totalpart} - {$release.postdate|date_format} + {Timezone::convertToLocal($release.postdate, 'Y-m-d H:i:s')}} {$release.adddate|date_format} {$release.grabs} diff --git a/resources/views/themes/admin/release-edit.tpl b/resources/views/themes/admin/release-edit.tpl index 3d40a1054..7a36873c7 100644 --- a/resources/views/themes/admin/release-edit.tpl +++ b/resources/views/themes/admin/release-edit.tpl @@ -89,7 +89,7 @@ - + diff --git a/resources/views/themes/admin/release-list.tpl b/resources/views/themes/admin/release-list.tpl index ada748368..3608a9de2 100644 --- a/resources/views/themes/admin/release-list.tpl +++ b/resources/views/themes/admin/release-list.tpl @@ -24,7 +24,7 @@ {$release.category_name} {$release.size|filesize} {$release.totalpart} - {$release.postdate|date_format} + {Timezone::convertToLocal($release.postdate, 'Y-m-d H:i:s')}} {$release.adddate|date_format} {$release.grabs} delete