diff --git a/Changelog b/Changelog index 146428728..3ab78669c 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,27 @@ +2017-06-18 DariusIII + * Chg: Improve XXX releases logic + * Mrg: Merge PR #145 by Nightah - Admin Menu cleanup +2017-06-16 DariusIII + * Chg: Catch exception when checking for existing and missing collection tables (irritating message about Base table or view not found) + * Chg: Increase xref column in collections and multigroup_collections to 1024 and change classused + in xxxinfo table to varchar(20) and empty default value + * Chg: Remove getXXXSamples script from tmux loop as it serves no purpose anymore + * Chg: Add more debugging output to DbUpdate class and install_nntmux script +2017-06-15 DariusIII + * Fix: Fix collection regexes testing page +2017-06-14 DariusIII + * Chg: Use monolog/monolog to handle logging + * Chg: Update composer libraries +2017-06-09 DariusIII + * Chg: Update composer.lock +2017-06-06 DariusIII + * Chg: Use laravel helpers file and replace getenv with env function + * Chg: Update composer.lock +2017-06-05 DariusIII + * Chg: Update minimum MariaDB version to 10.1 + * Chg: Add laravel/framework to composer.json for future usage +2017-06-02 DariusIII + * Chg: Update php-tmdb and php-giantbomb libraries 2017-05-28 DariusIII * Chg: Possible fix for videos query in getVideoFromSiteID function 2017-05-26 DariusIII diff --git a/_install/install_nntmux.php b/_install/install_nntmux.php index 5a60e276b..3244bfb68 100644 --- a/_install/install_nntmux.php +++ b/_install/install_nntmux.php @@ -24,8 +24,8 @@ if (file_exists(NN_ROOT . '_install/install.lock')) { } // Check if user selected right DB type. -if (getenv('DB_SYSTEM') !== 'mysql') { - ColorCLI::doEcho(ColorCLI::error('Invalid database system. Must be: mysql ; Not: ' . getenv('DB_SYSTEM'))); +if (env('DB_SYSTEM') !== 'mysql') { + ColorCLI::doEcho(ColorCLI::error('Invalid database system. Must be: mysql ; Not: ' . env('DB_SYSTEM'))); $error = true; } else { // Connect to the SQL server. @@ -35,13 +35,13 @@ if (getenv('DB_SYSTEM') !== 'mysql') { [ 'checkVersion' => true, 'createDb' => true, - 'dbhost' => getenv('DB_HOST'), - 'dbname' => getenv('DB_NAME'), - 'dbpass' => getenv('DB_PASSWORD'), - 'dbport' => getenv('PORT'), - 'dbsock' => getenv('DB_SOCKET'), - 'dbtype' => getenv('DB_SYSTEM'), - 'dbuser' => getenv('DB_USER'), + 'dbhost' => env('DB_HOST'), + 'dbname' => env('DB_NAME'), + 'dbpass' => env('DB_PASSWORD'), + 'dbport' => env('PORT'), + 'dbsock' => env('DB_SOCKET'), + 'dbtype' => env('DB_SYSTEM'), + 'dbuser' => env('DB_USER'), ] ); $dbConnCheck = true; @@ -78,7 +78,7 @@ if (getenv('DB_SYSTEM') !== 'mysql') { $error = true; ColorCLI::doEcho(ColorCLI::error( 'You are using an unsupported version of ' . - getenv('DB_SYSTEM') . + env('DB_SYSTEM') . ' the minimum allowed version is ' . NN_MINIMUM_MYSQL_VERSION ) @@ -149,13 +149,13 @@ if (!$error) { } } //Insert admin user into database -if (getenv('ADMIN_USER') === '' || getenv('ADMIN_PASS') === '' || getenv('ADMIN_EMAIL') === '') { +if (env('ADMIN_USER') === '' || env('ADMIN_PASS') === '' || env('ADMIN_EMAIL') === '') { $error = true; ColorCLI::doEcho(ColorCLI::error('Admin user data cannot be empty! Please edit .env file and fill in admin user details and run this script again!')); exit(); } -switch (getenv('DB_SYSTEM')) { +switch (env('DB_SYSTEM')) { case 'mysql': $adapter = 'MySql'; break; @@ -167,10 +167,10 @@ switch (getenv('DB_SYSTEM')) { } if ($adapter !== null) { - if (empty(getenv('DB_SOCKET'))) { - $host = empty(getenv('DB_PORT')) ? getenv('DB_HOST') : getenv('DB_HOST') . ':' . getenv('DB_PORT'); + if (empty(env('DB_SOCKET'))) { + $host = empty(env('DB_PORT')) ? env('DB_HOST') : env('DB_HOST') . ':' . env('DB_PORT'); } else { - $host = getenv('DB_SOCKET'); + $host = env('DB_SOCKET'); } lithium\data\Connections::add('default', @@ -178,9 +178,9 @@ if ($adapter !== null) { 'type' => 'database', 'adapter' => $adapter, 'host' => $host, - 'login' => getenv('DB_USER'), - 'password' => getenv('DB_PASSWORD'), - 'database' => getenv('DB_NAME'), + 'login' => env('DB_USER'), + 'password' => env('DB_PASSWORD'), + 'database' => env('DB_NAME'), 'encoding' => 'UTF-8', 'persistent' => false, ] @@ -188,20 +188,20 @@ if ($adapter !== null) { } $user = new Users(); -if (!$user->isValidUsername(getenv('ADMIN_USER'))) { +if (!$user->isValidUsername(env('ADMIN_USER'))) { $error = true; } else { - $usrCheck = $user->getByUsername(getenv('ADMIN_USER')); + $usrCheck = $user->getByUsername(env('ADMIN_USER')); if ($usrCheck) { $error = true; } } -if (!$user->isValidEmail(getenv('ADMIN_EMAIL'))) { +if (!$user->isValidEmail(env('ADMIN_EMAIL'))) { $error = true; } if (!$error) { - $adminCheck = $user->add(getenv('ADMIN_USER'), getenv('ADMIN_PASS'), getenv('ADMIN_EMAIL'), 2, '', ''); + $adminCheck = $user->add(env('ADMIN_USER'), env('ADMIN_PASS'), env('ADMIN_EMAIL'), 2, '', ''); if (!is_numeric($adminCheck)) { $error = true; } diff --git a/app/config/bootstrap/connections.php b/app/config/bootstrap/connections.php index 1a8f27c14..fd1ae97c5 100644 --- a/app/config/bootstrap/connections.php +++ b/app/config/bootstrap/connections.php @@ -89,7 +89,7 @@ if (!defined('NN_INSTALLER')) { ); } - switch (getenv('DB_SYSTEM')) { + switch (env('DB_SYSTEM')) { case 'mysql': $adapter = 'MySql'; break; @@ -101,10 +101,10 @@ if (!defined('NN_INSTALLER')) { } if (isset($adapter)) { - if (empty(getenv('DB_SOCKET'))) { - $host = empty(getenv('DB_PORT')) ? getenv('DB_HOST') : getenv('DB_HOST') . ':' . getenv('DB_PORT'); + if (empty(env('DB_SOCKET'))) { + $host = empty(env('DB_PORT')) ? env('DB_HOST') : env('DB_HOST') . ':' . env('DB_PORT'); } else { - $host = getenv('DB_SOCKET'); + $host = env('DB_SOCKET'); } Connections::add('default', @@ -112,9 +112,9 @@ if (!defined('NN_INSTALLER')) { 'type' => 'database', 'adapter' => $adapter, 'host' => $host, - 'login' => getenv('DB_USER'), - 'password' => getenv('DB_PASSWORD'), - 'database' => getenv('DB_NAME'), + 'login' => env('DB_USER', 'nntmux'), + 'password' => env('DB_PASSWORD', 'nntmux'), + 'database' => env('DB_NAME', 'nntmux'), 'encoding' => 'UTF-8', 'persistent' => false, ] diff --git a/app/extensions/helper/helpers.php b/app/extensions/helper/helpers.php new file mode 100644 index 000000000..8c9cefd1f --- /dev/null +++ b/app/extensions/helper/helpers.php @@ -0,0 +1,44 @@ +setCookie(SetCookie::fromString($cookie)); + $client = new Client(['cookies' => $cookieJar]); + } + try { + $response = $client->get($url)->getBody()->getContents(); + } catch (RequestException $e) { + if ($e->hasResponse()) { + if($e->getCode() === 404) { + ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + } else if ($e->getCode() === 503) { + ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + } else { + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from server, http error reported: ' . $e->getCode())); + } + } + } catch (\RuntimeException $e) { + ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); + } + + return $response; + } +} \ No newline at end of file diff --git a/build/nntmux.xml b/build/nntmux.xml index 4e3f046fa..1b8945259 100755 --- a/build/nntmux.xml +++ b/build/nntmux.xml @@ -16,8 +16,8 @@ - 310 - 310 + 311 + 311 diff --git a/cli/verify_permissions.php b/cli/verify_permissions.php index 76aa36960..ddee77779 100644 --- a/cli/verify_permissions.php +++ b/cli/verify_permissions.php @@ -58,7 +58,7 @@ foreach (['anime', 'audio', 'audiosample', 'book', 'console', 'games', 'movies', } // Set up covers paths. -if (getenv('DB_PASSWORD') !== '') { +if (env('DB_PASSWORD') !== '') { $ri = new ReleaseImage(); $folders[$ri->audSavePath] = [R, W]; diff --git a/composer.json b/composer.json index a9cf091b9..4d93f8681 100755 --- a/composer.json +++ b/composer.json @@ -5,6 +5,10 @@ } ], "autoload": { + "files": [ + "app/libraries/laravel/framework/src/Illuminate/Support/helpers.php", + "app/extensions/helper/helpers.php" + ], "psr-4": { "nntmux\\": "nntmux/" }, @@ -137,10 +141,10 @@ "bower-asset/slimScroll": "~1.3.7", "bower-asset/tinymce-builded": "~4.4.3", "unionofrad/lithium": "^1.1.0-beta", - "illuminate/filesystem": "^5.4", "monolog/monolog": "^1.22", "aharen/omdbapi": "^2.0", - "vlucas/phpdotenv": "^2.4" + "vlucas/phpdotenv": "^2.4", + "laravel/framework": "^5.4" }, "require-dev": { diff --git a/composer.lock b/composer.lock index f702e1117..9571015c9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "a9563463542fa483d403d0c08b7b4c59", + "content-hash": "f2aa144131a6fb8b3d72a01fc6bed139", "packages": [ { "name": "adrenth/thetvdb2", @@ -604,19 +604,41 @@ }, { "name": "bower-asset/fancybox", - "version": "v3.0.47", + "version": "v3.1.20", "source": { "type": "git", "url": "https://github.com/fancyapps/fancybox.git", - "reference": "04bd1bd751ac10048c06e7db79197770cff4a1d7" + "reference": "3607c5562130ff4eb4ced258e30de6613dc7c2c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fancyapps/fancybox/zipball/04bd1bd751ac10048c06e7db79197770cff4a1d7", - "reference": "04bd1bd751ac10048c06e7db79197770cff4a1d7", + "url": "https://api.github.com/repos/fancyapps/fancybox/zipball/3607c5562130ff4eb4ced258e30de6613dc7c2c1", + "reference": "3607c5562130ff4eb4ced258e30de6613dc7c2c1", "shasum": "" }, - "type": "bower-asset-library" + "require": { + "bower-asset/jquery": ">=1.9.0" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": [ + "dist/jquery.fancybox.min.css", + "dist/jquery.fancybox.min.js" + ] + }, + "license": [ + "GPL-3.0" + ], + "description": "Touch enabled, responsive and fully customizable jQuery lightbox script", + "keywords": [ + "fancybox", + "gallery", + "jQuery", + "lightbox", + "plugin", + "responsive", + "touch" + ] }, { "name": "bower-asset/fastclick", @@ -1528,12 +1550,12 @@ "source": { "type": "git", "url": "https://github.com/dborsatto/php-giantbomb.git", - "reference": "e95553774caf9b6dace6d044710c7e03dee3af43" + "reference": "909b2b75200270daf62b1cd3dab91ffdca49ab23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dborsatto/php-giantbomb/zipball/e95553774caf9b6dace6d044710c7e03dee3af43", - "reference": "e95553774caf9b6dace6d044710c7e03dee3af43", + "url": "https://api.github.com/repos/dborsatto/php-giantbomb/zipball/909b2b75200270daf62b1cd3dab91ffdca49ab23", + "reference": "909b2b75200270daf62b1cd3dab91ffdca49ab23", "shasum": "" }, "require": { @@ -1562,7 +1584,7 @@ } ], "description": "A PHP library that acts as a wrapper for the GiantBomb API.", - "time": "2017-05-18 16:20:43" + "time": "2017-05-29 12:05:57" }, { "name": "doctrine/annotations", @@ -1963,6 +1985,48 @@ ], "time": "2014-09-09T13:34:57+00:00" }, + { + "name": "erusev/parsedown", + "version": "1.6.2", + "source": { + "type": "git", + "url": "https://github.com/erusev/parsedown.git", + "reference": "1bf24f7334fe16c88bf9d467863309ceaf285b01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/1bf24f7334fe16c88bf9d467863309ceaf285b01", + "reference": "1bf24f7334fe16c88bf9d467863309ceaf285b01", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Parsedown": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Emanuil Rusev", + "email": "hello@erusev.com", + "homepage": "http://erusev.com" + } + ], + "description": "Parser for Markdown.", + "homepage": "http://parsedown.org", + "keywords": [ + "markdown", + "parser" + ], + "time": "2017-03-29T16:04:15+00:00" + }, { "name": "exeu/apai-io", "version": "2.1.0", @@ -2127,12 +2191,12 @@ "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "1739e8b94e058421d4da8b66887c52ee523f7d45" + "reference": "065287bc14f3e606fe6aec6ecfeac9616afbd3cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1739e8b94e058421d4da8b66887c52ee523f7d45", - "reference": "1739e8b94e058421d4da8b66887c52ee523f7d45", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/065287bc14f3e606fe6aec6ecfeac9616afbd3cb", + "reference": "065287bc14f3e606fe6aec6ecfeac9616afbd3cb", "shasum": "" }, "require": { @@ -2184,7 +2248,7 @@ "rest", "web service" ], - "time": "2017-05-15 08:45:24" + "time": "2017-06-10 14:17:14" }, { "name": "guzzlehttp/promises", @@ -2302,155 +2366,6 @@ ], "time": "2017-03-20T17:10:46+00:00" }, - { - "name": "illuminate/contracts", - "version": "v5.4.19", - "source": { - "type": "git", - "url": "https://github.com/illuminate/contracts.git", - "reference": "ab2825726bee46a67c8cc66789852189dbef74a9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/ab2825726bee46a67c8cc66789852189dbef74a9", - "reference": "ab2825726bee46a67c8cc66789852189dbef74a9", - "shasum": "" - }, - "require": { - "php": ">=5.6.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.4-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Contracts\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Contracts package.", - "homepage": "https://laravel.com", - "time": "2017-03-29T13:17:47+00:00" - }, - { - "name": "illuminate/filesystem", - "version": "v5.4.19", - "source": { - "type": "git", - "url": "https://github.com/illuminate/filesystem.git", - "reference": "7f656e3421b94d759627e891567380b50586f045" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/filesystem/zipball/7f656e3421b94d759627e891567380b50586f045", - "reference": "7f656e3421b94d759627e891567380b50586f045", - "shasum": "" - }, - "require": { - "illuminate/contracts": "5.4.*", - "illuminate/support": "5.4.*", - "php": ">=5.6.4", - "symfony/finder": "~3.2" - }, - "suggest": { - "league/flysystem": "Required to use the Flysystem local and FTP drivers (~1.0).", - "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).", - "league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0)." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.4-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Filesystem\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Filesystem package.", - "homepage": "https://laravel.com", - "time": "2017-04-07T19:38:05+00:00" - }, - { - "name": "illuminate/support", - "version": "v5.4.19", - "source": { - "type": "git", - "url": "https://github.com/illuminate/support.git", - "reference": "b8cb37e15331c59da51c8ee5838038baa22d7955" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/b8cb37e15331c59da51c8ee5838038baa22d7955", - "reference": "b8cb37e15331c59da51c8ee5838038baa22d7955", - "shasum": "" - }, - "require": { - "doctrine/inflector": "~1.0", - "ext-mbstring": "*", - "illuminate/contracts": "5.4.*", - "paragonie/random_compat": "~1.4|~2.0", - "php": ">=5.6.4" - }, - "replace": { - "tightenco/collect": "self.version" - }, - "suggest": { - "illuminate/filesystem": "Required to use the composer class (5.2.*).", - "symfony/process": "Required to use the composer class (~3.2).", - "symfony/var-dumper": "Required to use the dd function (~3.2)." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.4-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Support\\": "" - }, - "files": [ - "helpers.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Support package.", - "homepage": "https://laravel.com", - "time": "2017-04-09T14:34:57+00:00" - }, { "name": "james-heinrich/getid3", "version": "v1.9.14", @@ -2624,6 +2539,218 @@ ], "time": "2017-01-16T07:02:13+00:00" }, + { + "name": "laravel/framework", + "version": "v5.4.27", + "source": { + "type": "git", + "url": "https://github.com/laravel/framework.git", + "reference": "66f5e1b37cbd66e730ea18850ded6dc0ad570404" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/framework/zipball/66f5e1b37cbd66e730ea18850ded6dc0ad570404", + "reference": "66f5e1b37cbd66e730ea18850ded6dc0ad570404", + "shasum": "" + }, + "require": { + "doctrine/inflector": "~1.0", + "erusev/parsedown": "~1.6", + "ext-mbstring": "*", + "ext-openssl": "*", + "league/flysystem": "~1.0", + "monolog/monolog": "~1.11", + "mtdowling/cron-expression": "~1.0", + "nesbot/carbon": "~1.20", + "paragonie/random_compat": "~1.4|~2.0", + "php": ">=5.6.4", + "ramsey/uuid": "~3.0", + "swiftmailer/swiftmailer": "~5.4", + "symfony/console": "~3.2", + "symfony/debug": "~3.2", + "symfony/finder": "~3.2", + "symfony/http-foundation": "~3.2", + "symfony/http-kernel": "~3.2", + "symfony/process": "~3.2", + "symfony/routing": "~3.2", + "symfony/var-dumper": "~3.2", + "tijsverkoyen/css-to-inline-styles": "~2.2", + "vlucas/phpdotenv": "~2.2" + }, + "replace": { + "illuminate/auth": "self.version", + "illuminate/broadcasting": "self.version", + "illuminate/bus": "self.version", + "illuminate/cache": "self.version", + "illuminate/config": "self.version", + "illuminate/console": "self.version", + "illuminate/container": "self.version", + "illuminate/contracts": "self.version", + "illuminate/cookie": "self.version", + "illuminate/database": "self.version", + "illuminate/encryption": "self.version", + "illuminate/events": "self.version", + "illuminate/exception": "self.version", + "illuminate/filesystem": "self.version", + "illuminate/hashing": "self.version", + "illuminate/http": "self.version", + "illuminate/log": "self.version", + "illuminate/mail": "self.version", + "illuminate/notifications": "self.version", + "illuminate/pagination": "self.version", + "illuminate/pipeline": "self.version", + "illuminate/queue": "self.version", + "illuminate/redis": "self.version", + "illuminate/routing": "self.version", + "illuminate/session": "self.version", + "illuminate/support": "self.version", + "illuminate/translation": "self.version", + "illuminate/validation": "self.version", + "illuminate/view": "self.version", + "tightenco/collect": "self.version" + }, + "require-dev": { + "aws/aws-sdk-php": "~3.0", + "doctrine/dbal": "~2.5", + "mockery/mockery": "~0.9.4", + "pda/pheanstalk": "~3.0", + "phpunit/phpunit": "~5.7", + "predis/predis": "~1.0", + "symfony/css-selector": "~3.2", + "symfony/dom-crawler": "~3.2" + }, + "suggest": { + "aws/aws-sdk-php": "Required to use the SQS queue driver and SES mail driver (~3.0).", + "doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.5).", + "fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).", + "guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (~6.0).", + "laravel/tinker": "Required to use the tinker console command (~1.0).", + "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).", + "league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0).", + "nexmo/client": "Required to use the Nexmo transport (~1.0).", + "pda/pheanstalk": "Required to use the beanstalk queue driver (~3.0).", + "predis/predis": "Required to use the redis cache and queue drivers (~1.0).", + "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (~2.0).", + "symfony/css-selector": "Required to use some of the crawler integration testing tools (~3.2).", + "symfony/dom-crawler": "Required to use most of the crawler integration testing tools (~3.2).", + "symfony/psr-http-message-bridge": "Required to psr7 bridging features (0.2.*)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + }, + "autoload": { + "files": [ + "src/Illuminate/Foundation/helpers.php", + "src/Illuminate/Support/helpers.php" + ], + "psr-4": { + "Illuminate\\": "src/Illuminate/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Laravel Framework.", + "homepage": "https://laravel.com", + "keywords": [ + "framework", + "laravel" + ], + "time": "2017-06-15T19:08:25+00:00" + }, + { + "name": "league/flysystem", + "version": "1.0.40", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem.git", + "reference": "3828f0b24e2c1918bb362d57a53205d6dc8fde61" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/3828f0b24e2c1918bb362d57a53205d6dc8fde61", + "reference": "3828f0b24e2c1918bb362d57a53205d6dc8fde61", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "conflict": { + "league/flysystem-sftp": "<1.0.6" + }, + "require-dev": { + "ext-fileinfo": "*", + "mockery/mockery": "~0.9", + "phpspec/phpspec": "^2.2", + "phpunit/phpunit": "~4.8" + }, + "suggest": { + "ext-fileinfo": "Required for MimeType", + "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", + "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", + "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", + "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", + "league/flysystem-copy": "Allows you to use Copy.com storage", + "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", + "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", + "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", + "league/flysystem-webdav": "Allows you to use WebDAV storage", + "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", + "spatie/flysystem-dropbox": "Allows you to use Dropbox storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Flysystem\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frenky.net" + } + ], + "description": "Filesystem abstraction: Many filesystems, one API.", + "keywords": [ + "Cloud Files", + "WebDAV", + "abstraction", + "aws", + "cloud", + "copy.com", + "dropbox", + "file systems", + "files", + "filesystem", + "filesystems", + "ftp", + "rackspace", + "remote", + "s3", + "sftp", + "storage" + ], + "time": "2017-04-28T10:15:08+00:00" + }, { "name": "monolog/monolog", "version": "1.22.1", @@ -2702,6 +2829,103 @@ ], "time": "2017-03-13T07:08:03+00:00" }, + { + "name": "mtdowling/cron-expression", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/mtdowling/cron-expression.git", + "reference": "9504fa9ea681b586028adaaa0877db4aecf32bad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mtdowling/cron-expression/zipball/9504fa9ea681b586028adaaa0877db4aecf32bad", + "reference": "9504fa9ea681b586028adaaa0877db4aecf32bad", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0|~5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Cron\\": "src/Cron/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due", + "keywords": [ + "cron", + "schedule" + ], + "time": "2017-01-23T04:29:33+00:00" + }, + { + "name": "nesbot/carbon", + "version": "1.22.1", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc", + "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "symfony/translation": "~2.6 || ~3.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2", + "phpunit/phpunit": "~4.0 || ~5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.23-dev" + } + }, + "autoload": { + "psr-4": { + "Carbon\\": "src/Carbon/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "http://nesbot.com" + } + ], + "description": "A simple API extension for DateTime.", + "homepage": "http://carbon.nesbot.com", + "keywords": [ + "date", + "datetime", + "time" + ], + "time": "2017-01-16T07:55:07+00:00" + }, { "name": "paragonie/random_compat", "version": "v2.0.10", @@ -2752,16 +2976,16 @@ }, { "name": "php-tmdb/api", - "version": "2.1.8", + "version": "v2.1.9", "source": { "type": "git", "url": "https://github.com/php-tmdb/api.git", - "reference": "5aae08086a17301b78aa26fd59bd6c10910cd5f6" + "reference": "1c2e87653f6df62ea9075b7118c2a80dcb355f66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-tmdb/api/zipball/5aae08086a17301b78aa26fd59bd6c10910cd5f6", - "reference": "5aae08086a17301b78aa26fd59bd6c10910cd5f6", + "url": "https://api.github.com/repos/php-tmdb/api/zipball/1c2e87653f6df62ea9075b7118c2a80dcb355f66", + "reference": "1c2e87653f6df62ea9075b7118c2a80dcb355f66", "shasum": "" }, "require": { @@ -2785,7 +3009,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -2816,7 +3040,7 @@ "tvdb", "wrapper" ], - "time": "2017-02-28T23:30:08+00:00" + "time": "2017-06-02T03:27:09+00:00" }, { "name": "phpmailer/phpmailer", @@ -3037,18 +3261,100 @@ ], "time": "2016-10-10T12:19:37+00:00" }, + { + "name": "ramsey/uuid", + "version": "3.6.1", + "source": { + "type": "git", + "url": "https://github.com/ramsey/uuid.git", + "reference": "4ae32dd9ab8860a4bbd750ad269cba7f06f7934e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/4ae32dd9ab8860a4bbd750ad269cba7f06f7934e", + "reference": "4ae32dd9ab8860a4bbd750ad269cba7f06f7934e", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "^1.0|^2.0", + "php": "^5.4 || ^7.0" + }, + "replace": { + "rhumsaa/uuid": "self.version" + }, + "require-dev": { + "apigen/apigen": "^4.1", + "codeception/aspect-mock": "^1.0 | ^2.0", + "doctrine/annotations": "~1.2.0", + "goaop/framework": "1.0.0-alpha.2 | ^1.0 | ^2.1", + "ircmaxell/random-lib": "^1.1", + "jakub-onderka/php-parallel-lint": "^0.9.0", + "mockery/mockery": "^0.9.4", + "moontoast/math": "^1.1", + "php-mock/php-mock-phpunit": "^0.3|^1.1", + "phpunit/phpunit": "^4.7|>=5.0 <5.4", + "satooshi/php-coveralls": "^0.6.1", + "squizlabs/php_codesniffer": "^2.3" + }, + "suggest": { + "ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator", + "ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator", + "ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter", + "moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).", + "ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid", + "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Ramsey\\Uuid\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marijn Huizendveld", + "email": "marijn.huizendveld@gmail.com" + }, + { + "name": "Thibaud Fabre", + "email": "thibaud@aztech.io" + }, + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + } + ], + "description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).", + "homepage": "https://github.com/ramsey/uuid", + "keywords": [ + "guid", + "identifier", + "uuid" + ], + "time": "2017-03-26T20:37:53+00:00" + }, { "name": "roave/security-advisories", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "ccffea64be8575eaa7ad09cd16dfeedfa4711607" + "reference": "7cd88c8d4e4e6b483633bb13c35bcec95fd6cd4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/ccffea64be8575eaa7ad09cd16dfeedfa4711607", - "reference": "ccffea64be8575eaa7ad09cd16dfeedfa4711607", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/7cd88c8d4e4e6b483633bb13c35bcec95fd6cd4c", + "reference": "7cd88c8d4e4e6b483633bb13c35bcec95fd6cd4c", "shasum": "" }, "conflict": { @@ -3090,6 +3396,7 @@ "magento/magento2ce": ">=2,<2.2", "monolog/monolog": ">=1.8,<1.12", "namshi/jose": "<2.2", + "onelogin/php-saml": "<2.10.4", "oro/crm": ">=1.7,<1.7.4", "oro/platform": ">=1.7,<1.7.4", "phpmailer/phpmailer": ">=5,<5.2.22", @@ -3170,7 +3477,7 @@ } ], "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", - "time": "2017-05-13T14:02:28+00:00" + "time": "2017-06-07T12:12:03+00:00" }, { "name": "rtheunissen/guzzle-log-middleware", @@ -3279,22 +3586,76 @@ "time": "2016-12-14T21:57:25+00:00" }, { - "name": "symfony/polyfill-intl-icu", - "version": "v1.3.0", + "name": "swiftmailer/swiftmailer", + "version": "v5.4.8", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-intl-icu.git", - "reference": "2d6e2b20d457603eefb6e614286c22efca30fdb4" + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "9a06dc570a0367850280eefd3f1dc2da45aef517" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/2d6e2b20d457603eefb6e614286c22efca30fdb4", - "reference": "2d6e2b20d457603eefb6e614286c22efca30fdb4", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/9a06dc570a0367850280eefd3f1dc2da45aef517", + "reference": "9a06dc570a0367850280eefd3f1dc2da45aef517", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "mockery/mockery": "~0.9.1", + "symfony/phpunit-bridge": "~3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "email", + "mail", + "mailer" + ], + "time": "2017-05-01T15:54:03+00:00" + }, + { + "name": "symfony/polyfill-intl-icu", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-icu.git", + "reference": "3191cbe0ce64987bd382daf6724af31c53daae01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/3191cbe0ce64987bd382daf6724af31c53daae01", + "reference": "3191cbe0ce64987bd382daf6724af31c53daae01", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/intl": "~2.3|~3.0" + "symfony/intl": "~2.3|~3.0|~4.0" }, "suggest": { "ext-intl": "For best performance" @@ -3302,7 +3663,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3334,20 +3695,20 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2017-06-09T08:25:21+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" + "reference": "f29dca382a6485c3cbe6379f0c61230167681937" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937", + "reference": "f29dca382a6485c3cbe6379f0c61230167681937", "shasum": "" }, "require": { @@ -3359,7 +3720,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3393,20 +3754,20 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2017-06-09T14:24:12+00:00" }, { "name": "symfony/polyfill-php56", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php56.git", - "reference": "1dd42b9b89556f18092f3d1ada22cb05ac85383c" + "reference": "bc0b7d6cb36b10cfabb170a3e359944a95174929" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/1dd42b9b89556f18092f3d1ada22cb05ac85383c", - "reference": "1dd42b9b89556f18092f3d1ada22cb05ac85383c", + "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/bc0b7d6cb36b10cfabb170a3e359944a95174929", + "reference": "bc0b7d6cb36b10cfabb170a3e359944a95174929", "shasum": "" }, "require": { @@ -3416,7 +3777,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3449,20 +3810,20 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2017-06-09T08:25:21+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "13ce343935f0f91ca89605a2f6ca6f5c2f3faac2" + "reference": "032fd647d5c11a9ceab8ee8747e13b5448e93874" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/13ce343935f0f91ca89605a2f6ca6f5c2f3faac2", - "reference": "13ce343935f0f91ca89605a2f6ca6f5c2f3faac2", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/032fd647d5c11a9ceab8ee8747e13b5448e93874", + "reference": "032fd647d5c11a9ceab8ee8747e13b5448e93874", "shasum": "" }, "require": { @@ -3472,7 +3833,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3508,20 +3869,20 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2017-06-09T14:24:12+00:00" }, { "name": "symfony/polyfill-util", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-util.git", - "reference": "746bce0fca664ac0a575e465f65c6643faddf7fb" + "reference": "ebccbde4aad410f6438d86d7d261c6b4d2b9a51d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/746bce0fca664ac0a575e465f65c6643faddf7fb", - "reference": "746bce0fca664ac0a575e465f65c6643faddf7fb", + "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/ebccbde4aad410f6438d86d7d261c6b4d2b9a51d", + "reference": "ebccbde4aad410f6438d86d7d261c6b4d2b9a51d", "shasum": "" }, "require": { @@ -3530,7 +3891,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -3560,7 +3921,7 @@ "polyfill", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2017-06-09T08:25:21+00:00" }, { "name": "symfony/symfony", @@ -3707,17 +4068,64 @@ "time": "2017-03-10T18:35:48+00:00" }, { - "name": "twig/twig", - "version": "v2.3.2", + "name": "tijsverkoyen/css-to-inline-styles", + "version": "2.2.0", "source": { "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "85e8372c451510165c04bf781295f9d922fa524b" + "url": "https://github.com/tijsverkoyen/CssToInlineStyles.git", + "reference": "ab03919dfd85a74ae0372f8baf9f3c7d5c03b04b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/85e8372c451510165c04bf781295f9d922fa524b", - "reference": "85e8372c451510165c04bf781295f9d922fa524b", + "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/ab03919dfd85a74ae0372f8baf9f3c7d5c03b04b", + "reference": "ab03919dfd85a74ae0372f8baf9f3c7d5c03b04b", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7", + "symfony/css-selector": "^2.7|~3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8|5.1.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "TijsVerkoyen\\CssToInlineStyles\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Tijs Verkoyen", + "email": "css_to_inline_styles@verkoyen.eu", + "role": "Developer" + } + ], + "description": "CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.", + "homepage": "https://github.com/tijsverkoyen/CssToInlineStyles", + "time": "2016-09-20T12:50:39+00:00" + }, + { + "name": "twig/twig", + "version": "v2.4.3", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "eab7c3288ae6603d7d6f92b531626af2b162d1f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/eab7c3288ae6603d7d6f92b531626af2b162d1f2", + "reference": "eab7c3288ae6603d7d6f92b531626af2b162d1f2", "shasum": "" }, "require": { @@ -3732,12 +4140,15 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.4-dev" } }, "autoload": { "psr-0": { "Twig_": "lib/" + }, + "psr-4": { + "Twig\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -3767,7 +4178,7 @@ "keywords": [ "templating" ], - "time": "2017-04-21T00:13:02+00:00" + "time": "2017-06-07T18:47:58+00:00" }, { "name": "unionofrad/lithium", @@ -4526,16 +4937,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.1.4", + "version": "6.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "42b7f394a8e009516582331b1e03a1aba40175d1" + "reference": "f2786490399836d2a544a34785c4a8d3ab32cf0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/42b7f394a8e009516582331b1e03a1aba40175d1", - "reference": "42b7f394a8e009516582331b1e03a1aba40175d1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f2786490399836d2a544a34785c4a8d3ab32cf0e", + "reference": "f2786490399836d2a544a34785c4a8d3ab32cf0e", "shasum": "" }, "require": { @@ -4580,7 +4991,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.1.x-dev" + "dev-master": "6.2.x-dev" } }, "autoload": { @@ -4606,7 +5017,7 @@ "testing", "xunit" ], - "time": "2017-05-22T07:45:30+00:00" + "time": "2017-06-13T14:07:07+00:00" }, { "name": "phpunit/phpunit-mock-objects", diff --git a/misc/testing/DB/check_unique_indexes.php b/misc/testing/DB/check_unique_indexes.php index 4f0753f90..130e70c2f 100755 --- a/misc/testing/DB/check_unique_indexes.php +++ b/misc/testing/DB/check_unique_indexes.php @@ -53,7 +53,7 @@ if ($handle) { if (trim($match['table']) === 'collections') { $tables = $pdo->query("SHOW TABLES"); foreach ($tables as $row) { - $tbl = $row['tables_in_' . getenv('DB_NAME')]; + $tbl = $row['tables_in_' . env('DB_NAME')]; if (preg_match('/collections_\d+/', $tbl)) { $check = $pdo->checkColumnIndex($tbl, $column); if (!isset($check_collections['key_name'])) { @@ -67,7 +67,7 @@ if ($handle) { } else if (trim($match['table']) === 'binaries') { $tables = $pdo->query("SHOW TABLES"); foreach ($tables as $row) { - $tbl = $row['tables_in_' . getenv('DB_NAME')]; + $tbl = $row['tables_in_' . env('DB_NAME')]; if (preg_match('/binaries_\d+/', $tbl)) { $checkBinaries = $pdo->checkColumnIndex($tbl, $column); if (!isset($checkBinaries['key_name'])) { @@ -81,7 +81,7 @@ if ($handle) { } else if (trim($match['table']) === 'parts') { $tables = $pdo->query("SHOW TABLES"); foreach ($tables as $row) { - $tbl = $row['tables_in_' . getenv('DB_NAME')]; + $tbl = $row['tables_in_' . env('DB_NAME')]; if (preg_match('/parts_\d+/', $tbl)) { $checkParts = $pdo->checkColumnIndex($tbl, $column); if (!isset($checkParts['key_name'])) { @@ -95,7 +95,7 @@ if ($handle) { } else if (trim($match['table']) === 'missed_parts') { $tables = $pdo->query("SHOW TABLES"); foreach ($tables as $row) { - $tbl = $row['tables_in_' . getenv('DB_NAME')]; + $tbl = $row['tables_in_' . env('DB_NAME')]; if (preg_match('/partrepair_\d+/', $tbl)) { $checkPartRepair = $pdo->checkColumnIndex($tbl, $column); if (!isset($checkPartRepair['key_name'])) { diff --git a/misc/testing/DB/mysqldump_tables.php b/misc/testing/DB/mysqldump_tables.php index 807f5666c..281635a6f 100644 --- a/misc/testing/DB/mysqldump_tables.php +++ b/misc/testing/DB/mysqldump_tables.php @@ -32,14 +32,14 @@ function builddefaultsfile() //generate file contents $filetext = "[mysqldump]" ."\n" - ."user = " . getenv('DB_USER') + ."user = " . env('DB_USER') ."\n" - ."password = " . getenv('DB_PASSWORD') + ."password = " . env('DB_PASSWORD') ."\n[mysql]" ."\n" - ."user = " . getenv('DB_USER') + ."user = " . env('DB_USER') ."\n" - ."password = " . getenv('DB_PASSWORD'); + ."password = " . env('DB_PASSWORD'); $filehandle = fopen("mysql-defaults.txt", "w+"); if(!$filehandle) { @@ -51,14 +51,14 @@ function builddefaultsfile() } } -$dbhost = getenv('DB_HOST'); -$dbport = getenv('DB_PORT'); -$dbsocket = getenv('DB_SOCKET'); -$dbuser = getenv('DB_USER'); -$dbpass = getenv('DB_PASSWORD'); -$dbname = getenv(getenv('DB_NAME')); +$dbhost = env('DB_HOST'); +$dbport = env('DB_PORT'); +$dbsocket = env('DB_SOCKET'); +$dbuser = env('DB_USER'); +$dbpass = env('DB_PASSWORD'); +$dbname = env(env('DB_NAME')); -if (getenv('DB_SOCKET') !== '') { +if (env('DB_SOCKET') !== '') { $use = "-S $dbsocket"; } else { $use = "-P$dbport"; @@ -88,7 +88,7 @@ if((isset($argv[1]) && $argv[1] == "db") && (isset($argv[2]) && $argv[2] == "dum $sql = "SHOW tables"; $tables = $pdo->query($sql); foreach($tables as $row) { - $tbl = $row['Tables_in_'. getenv('DB_NAME')]; + $tbl = $row['Tables_in_'. env('DB_NAME')]; $filename = $argv[3]."/".$tbl.".gz"; echo $pdo->log->header("Dumping $tbl."); if (file_exists($filename)) { @@ -102,7 +102,7 @@ if((isset($argv[1]) && $argv[1] == "db") && (isset($argv[2]) && $argv[2] == "dum $tables = $pdo->query($sql); $pdo->queryExec("SET FOREIGN_KEY_CHECKS=0"); foreach($tables as $row) { - $tbl = $row['Tables_in_'.getenv('DB_NAME')]; + $tbl = $row['Tables_in_'.env('DB_NAME')]; $filename = $argv[3]."/".$tbl.".gz"; if (file_exists($filename)) { echo $pdo->log->header("Restoring $tbl."); @@ -138,7 +138,7 @@ if((isset($argv[1]) && $argv[1] == "db") && (isset($argv[2]) && $argv[2] == "dum $sql = "SHOW tables"; $tables = $pdo->query($sql); foreach($tables as $row) { - $tbl = $row['Tables_in_'.getenv('DB_NAME')]; + $tbl = $row['Tables_in_'.env('DB_NAME')]; $filename = $argv[3].$tbl.".csv"; echo $pdo->log->header("Dumping $tbl."); if (file_exists($filename)) { @@ -151,7 +151,7 @@ if((isset($argv[1]) && $argv[1] == "db") && (isset($argv[2]) && $argv[2] == "dum $tables = $pdo->query($sql); $pdo->queryExec("SET FOREIGN_KEY_CHECKS=0"); foreach($tables as $row) { - $tbl = $row['Tables_in_'.getenv('DB_NAME')]; + $tbl = $row['Tables_in_'.env('DB_NAME')]; $filename = $argv[3].$tbl.".csv"; if (file_exists($filename)) { echo $pdo->log->header("Restoring $tbl."); diff --git a/misc/testing/DB/rename_to_lower.php b/misc/testing/DB/rename_to_lower.php index c186f6935..072d1612e 100644 --- a/misc/testing/DB/rename_to_lower.php +++ b/misc/testing/DB/rename_to_lower.php @@ -27,7 +27,7 @@ if ($argc == 1 || $argv[1] != 'true') { exit($pdo->log->error("\nThis script will rename every table column to lowercase that is not already lowercase.\nTo run:\nphp $argv[0] true\n")); } -$database = getenv('DB_NAME'); +$database = env('DB_NAME'); $count = 0; $list = $pdo->query("SELECT TABLE_NAME, COLUMN_NAME, UPPER(COLUMN_TYPE), EXTRA FROM information_schema.columns WHERE table_schema = '" . $database . "'"); diff --git a/misc/testing/DB/show_table_sizes.php b/misc/testing/DB/show_table_sizes.php index 7e7a4cf05..e93c09705 100644 --- a/misc/testing/DB/show_table_sizes.php +++ b/misc/testing/DB/show_table_sizes.php @@ -20,7 +20,7 @@ $table_data = "SELECT TABLE_NAME AS 'Table', TABLE_ROWS AS 'Rows', " . "((INDEX_LENGTH) / POWER(1024,2)) AS 'index', " . "((DATA_FREE) / POWER(1024,2)) AS 'free', " . "((DATA_LENGTH + INDEX_LENGTH) / POWER(1024,2)) AS 'total' " - . "FROM information_schema.TABLES WHERE information_schema.TABLES.table_schema = '" . getenv('DB_NAME') . "' " + . "FROM information_schema.TABLES WHERE information_schema.TABLES.table_schema = '" . env('DB_NAME') . "' " . "ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC"; $run = $pdo->queryDirect($table_data); diff --git a/misc/update/nix/multiprocessing/.do_not_run/switch.php b/misc/update/nix/multiprocessing/.do_not_run/switch.php index 16bfe0c71..31d585ad4 100644 --- a/misc/update/nix/multiprocessing/.do_not_run/switch.php +++ b/misc/update/nix/multiprocessing/.do_not_run/switch.php @@ -323,8 +323,12 @@ function charCheck($char) */ function collectionCheck(&$pdo, $groupID) { - if ($pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $groupID)) === false) { - exit(); + try { + if ($pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $groupID)) === false) { + exit(); + } + } catch (PDOException $e) { + $e->getMessage(); } } diff --git a/misc/update/nix/tmux/monitor.php b/misc/update/nix/tmux/monitor.php index 41c1f2efd..9558e4f69 100644 --- a/misc/update/nix/tmux/monitor.php +++ b/misc/update/nix/tmux/monitor.php @@ -18,8 +18,8 @@ $runVar['paths']['misc'] = NN_MISC; $runVar['paths']['cli'] = NN_ROOT . 'cli/'; $runVar['paths']['scraper'] = NN_MISC . 'IRCScraper' . DS . 'scrape.php'; -$db_name = getenv('DB_NAME'); -$dbtype = getenv('DB_SYSTEM'); +$db_name = env('DB_NAME'); +$dbtype = env('DB_SYSTEM'); $tmux = $tRun->get('niceness'); $tmux_niceness = $tmux->niceness ?? 2; diff --git a/misc/update/postprocess.php b/misc/update/postprocess.php index 3ff461ecb..bd15c9b58 100644 --- a/misc/update/postprocess.php +++ b/misc/update/postprocess.php @@ -37,9 +37,9 @@ $bool = array( 'false' ); -if (!isset($argv[1]) || !in_array($argv[1], $args) || !isset($argv[2]) || !in_array($argv[2], $bool)) { +if (!isset($argv[1]) || !in_array($argv[1], $args, false) || !isset($argv[2]) || !in_array($argv[2], $bool, false)) { exit( - $pdo->log->error( + \nntmux\ColorCLI::error( "\nIncorrect arguments.\n" . "The second argument (true/false) determines wether to echo or not.\n\n" . "php postprocess.php all true ...: Does all the types of post processing.\n" @@ -65,12 +65,12 @@ if (!isset($argv[1]) || !in_array($argv[1], $args) || !isset($argv[2]) || !in_ar $nntp = null; if ($args[$argv[1]] === true) { $nntp = new NNTP(['Settings' => $pdo]); - if ((Settings::value('..alternate_nntp') == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { - exit($pdo->log->error("Unable to connect to usenet." . PHP_EOL)); + if ((Settings::value('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { + exit($pdo->log->error('Unable to connect to usenet.' . PHP_EOL)); } } -$postProcess = new PostProcess(['Settings' => $pdo, 'Echo' => ($argv[2] === 'true' ? true : false)]); +$postProcess = new PostProcess(['Settings' => $pdo, 'Echo' => $argv[2] === 'true' ? true : false]); $charArray = ['a','b','c','d','e','f','0','1','2','3','4','5','6','7','8','9']; @@ -87,7 +87,7 @@ switch ($argv[1]) { } break; case 'additional': - $postProcess->processAdditional($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : '')); + $postProcess->processAdditional($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray, false) ? $argv[3] : '')); break; case 'amazon': $postProcess->processBooks(); @@ -109,10 +109,10 @@ switch ($argv[1]) { $postProcess->processGames(); break; case 'nfo': - $postProcess->processNfos($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : '')); + $postProcess->processNfos($nntp, '', (isset($argv[3]) && in_array($argv[3], $charArray, false) ? $argv[3] : '')); break; case 'movies': - $postProcess->processMovies('', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : '')); + $postProcess->processMovies('', (isset($argv[3]) && in_array($argv[3], $charArray, false) ? $argv[3] : '')); break; case 'music': $postProcess->processMusic(); @@ -126,7 +126,7 @@ switch ($argv[1]) { $postProcess->processSpotnab(); break; case 'tv': - $postProcess->processTv('', (isset($argv[3]) && in_array($argv[3], $charArray) ? $argv[3] : '')); + $postProcess->processTv('', (isset($argv[3]) && in_array($argv[3], $charArray, false) ? $argv[3] : '')); break; case 'xxx': $postProcess->processXXX(); diff --git a/nntmux/ADE.php b/nntmux/ADE.php deleted file mode 100755 index 1ed1daca7..000000000 --- a/nntmux/ADE.php +++ /dev/null @@ -1,413 +0,0 @@ -_html = new \simple_html_dom(); - $this->_edithtml = new \simple_html_dom(); - $this->client = new Client(); - $this->pdo = new DB(); - } - - /** - * - * Remove from memory if they were not removed - * - */ - public function __destruct() - { - $this->_html->clear(); - $this->_edithtml->clear(); - unset($this->_response, $this->_tmpResponse); - } - - /** - * Gets Trailer Movies - * @return array - url, streamid, basestreamingurl - */ - public function trailers() - { - $this->getUrl($this->_trailers . $this->_urlFound); - $this->_html->load($this->_response); - if (preg_match("/(\"|')(?P[^\"']+.swf)(\"|')/i", $this->_response, $matches)) { - $this->_res['trailers']['url'] = self::ADE . trim(trim($matches['swf']), '"'); - if (preg_match('#(?:streamID:\s\")(?P[0-9A-Z]+)(?:\")#', - $this->_response, - $matches) - ) { - $this->_res['trailers']['streamid'] = trim($matches['streamid']); - } - if (preg_match('#(?:BaseStreamingUrl:\s\")(?P[\d]+.[\d]+.[\d]+.[\d]+)(?:\")#', - $this->_response, - $matches) - ) { - $this->_res['trailers']['baseurl'] = $matches['baseurl']; - } - } - unset($matches); - $this->_html->clear(); - - return $this->_res; - } - - /** - * Gets cover images for the xxx release - * @return array - Boxcover and backcover - */ - public function covers() - { - if ($ret = $this->_html->find('div#Boxcover, img[itemprop=image]', 1)) { - $this->_res['boxcover'] = preg_replace('/m\.jpg/', 'h.jpg', $ret->src); - $this->_res['backcover'] = preg_replace('/m\.jpg/', 'bh.jpg', $ret->src); - } - - return $this->_res; - } - - /** - * Gets the sypnosis and tagline - * - * @param bool $tagline - Include tagline? true/false - * - * @return array - plot,tagline - */ - public function sypnosis($tagline = false) - { - if ($tagline === true) { - $ret = $this->_html->find('p.Tagline', 0); - if (!empty($ret->plaintext)) { - $this->_res['tagline'] = trim($ret->plaintext); - } - } - if ($ret = @$this->_html->find('p.Tagline', 0)->next_sibling()->next_sibling()) { - $this->_res['sypnosis'] = trim($ret->innertext); - } - - return $this->_res; - } - - /** - * Gets the cast members and/or awards - * - * @param bool $awards - Include Awards? true/false - * - * @return array - cast, awards - */ - public function cast($awards = false) - { - $this->_tmpResponse = str_ireplace('Section Cast', 'scast', $this->_response); - $this->_edithtml->load($this->_tmpResponse); - - - if ($ret = $this->_edithtml->find('div[class=scast]', 0)) { - $this->_tmpResponse = trim($ret->outertext); - $ret = $this->_edithtml->load($this->_tmpResponse); - foreach ($ret->find('a.PerformerName') as $a) { - if ($a->plaintext !== '(bio)' && $a->plaintext !== '(interview)') { - $this->_res['cast'][] = trim($a->plaintext); - } - } - } - if ($awards === true) { - if ($ret->find('ul', 1)) { - foreach ($ret->find('ul', 1)->find('li, strong') as $li) { - $this->_res['awards'][] = trim($li->plaintext); - } - } - } - $this->_edithtml->clear(); - unset($ret, $this->_tmpResponse); - - return $this->_res; - } - - /** - * Gets Genres, if exists return array else return false - * @return mixed array - Genres - */ - public function genres() - { - $genres = []; - $this->_tmpResponse = str_ireplace('Section Categories', 'scat', $this->_response); - $this->_edithtml->load($this->_tmpResponse); - if ($ret = $this->_edithtml->find('div[class=scat]', 0)) { - $ret = $ret->find('p', 0); - $this->_tmpResponse = trim($ret->outertext); - $ret = $this->_edithtml->load($this->_tmpResponse); - - foreach ($ret->find('a') as $categories) { - $categories = trim($categories->plaintext); - if (strpos($categories, ',') !== false) { - $genres = explode(',', $categories); - $genres = array_map('trim', $genres); - } else { - $genres[] = $categories; - } - } - if (is_array($genres)) { - $this->_res['genres'] = array_unique($genres); - } - } - $this->_edithtml->clear(); - unset($this->_tmpResponse, $ret); - return $this->_res; - } - - /** - * Gets Product Information and/or Features - * - * @param bool $features Include features? true/false - * - * @return array - ProductInfo/Extras = features - */ - public function productInfo($features = false) - { - $dofeature = null; - $this->_tmpResponse = str_ireplace('Section ProductInfo', 'spdinfo', $this->_response); - $this->_edithtml->load($this->_tmpResponse); - if ($ret = $this->_edithtml->find('div[class=spdinfo]', 0)) { - $this->_tmpResponse = trim($ret->outertext); - $ret = $this->_edithtml->load($this->_tmpResponse); - foreach ($ret->find("text") as $strong) { - if (trim($strong->innertext) === 'Features') { - $dofeature = true; - } - if ($dofeature !== true) { - if (trim($strong->innertext) !== ' ') { - $this->_res['productinfo'][] = trim($strong->innertext); - } - } else { - if ($features === true) { - $this->_res['extras'][] = trim($strong->innertext); - } - } - } - - array_shift($this->_res['productinfo']); - array_shift($this->_res['productinfo']); - $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); - } - $this->_edithtml->clear(); - unset($this->_tmpResponse, $ret); - - return $this->_res; - } - - /** - * Gets the direct link information and returns it - * @return array|bool - */ - public function getDirect() - { - if (!empty($this->directLink) && $this->getUrl() !== false) { - $this->_html->load($this->_response); - return $this->getAll(); - } - return false; - } - /** - * Searches xxx name. - * @return bool - True if releases has 90% match, else false - */ - public function search() - { - if (empty($this->searchTerm)) { - return false; - } - if ($this->getUrl($this->_dvdQuery . rawurlencode($this->searchTerm)) === false) { - return false; - } else { - $this->_html->load($this->_response); - if ($ret = $this->_html->find('a.boxcover', 0)) { - $title = $ret->title; - $title = str_replace('/XXX/', '', $title); - $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); - $ret = (string)trim($ret->href); - similar_text(strtolower($this->searchTerm), strtolower($title), $p); - if ($p >= 90) { - $this->found = true; - $this->_urlFound = $ret; - $this->_directUrl = self::ADE . $ret; - $this->_title = trim($title); - unset($ret); - $this->_html->clear(); - $this->getUrl($this->_urlFound); - $this->_html->load($this->_response); - } else { - $this->found = false; - - return false; - } - } else { - return false; - } - } - return false; - } - - /** - * Gets raw html content using adeurl and any trailing url. - * - * @param string $trailing - required - * - * @return bool - true if page has content - */ - private function getUrl($trailing = "") - { - if (!empty($trailing)) { - try { - $this->_response = $this->client->get(self::ADE . $trailing)->getBody()->getContents(); - } catch (RequestException $e) { - if ($e->hasResponse()) { - if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on ADE server')); - } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('ADE service unavailable')); - } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from ADE, http error reported: ' . $e->getCode())); - } - } - } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); - } - } - if (!empty($this->directLink)) { - try { - $this->_response = $this->client->get($this->directLink)->getBody()->getContents(); - $this->directLink = ''; - } catch (RequestException $e) { - if ($e->hasResponse()) { - if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on ADE server')); - } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('ADE service unavailable')); - } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from ADE, http error reported: ' . $e->getCode())); - } - } - } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); - } - } - - if (!$this->_response) { - return false; - } - - return $this->_response; - } - - /** - * Gets All Information from the methods - * - * @return array - */ - public function getAll() - { - $results = []; - if (!empty($this->_directUrl)) { - $results['directurl'] = $this->_directUrl; - $results['title'] = $this->_title; - } - if (is_array($this->sypnosis(true))) { - $results = array_merge($results, $this->sypnosis(true)); - } - if (is_array($this->productInfo(true))) { - $results = array_merge($results, $this->productInfo(true)); - } - if (is_array($this->cast(true))) { - $results = array_merge($results, $this->cast(true)); - } - if (is_array($this->genres())) { - $results = array_merge($results, $this->genres()); - } - if (is_array($this->covers())) { - $results = array_merge($results, $this->covers()); - } - if (is_array($this->trailers())) { - $results = array_merge($results, $this->trailers()); - } - return $results; - } -} diff --git a/nntmux/AEBN.php b/nntmux/AEBN.php deleted file mode 100755 index 85e3c8d81..000000000 --- a/nntmux/AEBN.php +++ /dev/null @@ -1,406 +0,0 @@ - [], - 'boxcover' => [], - 'cast' => [], - 'director' => [], - 'genres' => [], - 'productinfo' => [], - 'synopsis' => [], - 'trailers' => ['url' =>[]], - ]; - - /** - * If searchTerm is found - * @var bool - */ - protected $_searchFound = false; - - /** - * Sets title in getAll method - * @var string - */ - protected $_title = ''; - - /** - * Trailing Url - * @var string - */ - protected $_trailUrl = ''; - - /** - * Used in __construct - * @var array - straight, gay - */ - protected $_whichSite = []; - - - - /** - * Sets the variables that used throughout the class - * - */ - public function __construct() - { - $this->_whichSite = ['straight' => self::AEBNSURL, 'gay' => self::AEBNGURL]; - $this->_html = new \simple_html_dom(); - $this->client = new Client(); - $this->cookiejar = new CookieJar(); - $this->pdo = new DB(); - if (!empty($this->cookie)) { - $cookieJar = $this->cookiejar->setCookie(SetCookie::fromString($this->cookie)); - $this->client = new Client(['cookies' => $cookieJar]); - } - } - - /** - * If they arent' removed from memory. Force them. - */ - public function __destruct() - { - $this->_html->clear(); - unset($this->_response, $this->_res); - } - - /** - * Gets Trailer URL .. will be processed in XXX insertswf - * - * @return array|bool - */ - public function trailers() - { - $ret = $this->_html->find('a[itemprop=trailer]', 0); - if (preg_match('/movieId=(?\d+)&/', trim($ret->href), $matches)) { - $movieid = $matches['movieid']; - $this->_res['trailers']['url'] = $this->_whichSite[$this->_currentSite] . self::TRAILERURL . $movieid; - } - - return $this->_res; - } - - /** - * Gets the front and back cover of the box - * - * @return array - */ - public function covers() - { - if ($ret = $this->_html->find('div#md-boxCover, img[itemprop=thumbnailUrl]', 1)) { - $ret = trim($ret->src); - if (strpos($ret, '//') === 0) { - $ret = 'http:' . $ret; - } - $this->_res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret); - $this->_res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret); - } - return $this->_res; - } - - /** - * Gets the Genres "Categories". - * - * @return array - */ - public function genres() - { - if ($ret = $this->_html->find('div.md-detailsCategories', 0)) { - foreach ($ret->find('a[itemprop=genre]') as $genre) { - $this->_res['genres'][] = trim($genre->plaintext); - } - } - $this->_res['genres'] = array_unique($this->_res['genres']); - return $this->_res; - } - - /** - * Gets the Cast Members "Stars" and Director if any - * - * @return array - */ - public function cast() - { - if ($ret = $this->_html->find('div.starsFull', 0)) { - foreach ($ret->find('span[itemprop=name]') as $star) { - $this->_res['cast'][] = trim($star->plaintext); - } - } else { - if ($ret = $this->_html->find('div.detailsLink', 0)) { - foreach ($ret->find('span') as $star) { - if (strpos($star->plaintext, '/More/') !== false && strpos($star->plaintext, '/Stars/') !== false) { - $this->_res['cast'][] = trim($star->plaintext); - } - } - } - } - - return $this->_res; - } - - /** - * Gets the product information - * - * @return array - */ - public function productInfo() - { - if ($ret = $this->_html->find('div#md-detailsLeft', 0)) { - foreach ($ret->find('div') as $div) { - foreach ($div->find('span') as $span) { - $span->plaintext = rawurldecode($span->plaintext); - $span->plaintext = preg_replace('/ /', '', $span->plaintext); - $this->_res['productinfo'][] = trim($span->plaintext); - } - } - if (false !== $key = array_search('Running Time:', $this->_res['productinfo'])) { - unset($this->_res['productinfo'][$key + 2]); - } - if (false !== $key = array_search("Director:", $this->_res['productinfo'])) { - $this->_res['director'] = $this->_res['productinfo'][$key + 1]; - unset($this->_res['productinfo'][$key], $this->_res['productinfo'][$key + 1]); - } - $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); - } - - return $this->_res; - } - - /** - * Gets the synopsis "plot" - * - * @return array - * - */ - public function synopsis() - { - if ($ret = $this->_html->find('span[itemprop=about]', 0)) { - if ($ret === null) { - if ($ret = $this->_html->find('div.movieDetailDescription', 0)) { - $this->_res['synopsis'] = trim($ret->plaintext); - $this->_res['synopsis'] = preg_replace('/Description:\s/', "", $this->_res['plot']); - } - } else { - $this->_res['synopsis'] = trim($ret->plaintext); - } - } - - return $this->_res; - } - - /** - * Searches for a XXX name - * - * @return bool - */ - public function search() - { - if (empty($this->searchTerm)) { - return false; - } - $this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); - if ($this->getUrl($this->_currentSite) === false) { - return false; - } else { - if ($count = count($this->_html->find('div.movie'))) { - $i = 1; - foreach ($this->_html->find('div.movie') as $movie) { - $string = 'a#FTSMovieSearch_link_title_detail_' . $i; - if ($ret = $movie->find($string, 0)) { - $title = str_replace('/XXX/', '', $ret->title); - $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); - $title = trim($title); - similar_text(strtolower($this->searchTerm), strtolower($title), $p); - if ($p >= 90) { - $this->_title = trim($ret->title); - $this->_trailUrl = html_entity_decode($ret->href); - $this->_directUrl = $this->_whichSite[$this->_currentSite] . $this->_trailUrl; - $this->getUrl($this->_currentSite); - return true; - } else { - continue; - } - } - $i++; - } - if ($i === $count || $count === 0) { - if ($this->_currentSite === 'gay') { - return false; - } - $this->_currentSite = 'gay'; - $this->search(); - } - } else { - return false; - } - } - - return false; - } - - /** - * Gets all the information - * - * @return array|bool - */ - public function getAll() - { - $results = []; - if (!empty($this->_directUrl)) { - $results['title'] = $this->_title; - $results['directurl'] = $this->_directUrl; - } - if (is_array($this->synopsis())) { - $results = array_merge($results, $this->synopsis()); - } - if (is_array($this->productInfo())) { - $results = array_merge($results, $this->productInfo()); - } - if (is_array($this->cast())) { - $results = array_merge($results, $this->cast()); - } - if (is_array($this->genres())) { - $results = array_merge($results, $this->genres()); - } - $covers = $this->covers(); - if (is_array($covers)) { - $results = array_merge($results, $covers); - } - if (is_array($this->trailers())) { - $results = array_merge($results, $this->trailers()); - } - if (empty($results) === true) { - return false; - } else { - return $results; - } - } - - /** - * Get Raw html of webpage - * - * @param string $site - * - * @return bool - */ - private function getUrl($site = 'straight') - { - if (!empty($this->_trailUrl)) { - try { - $this->_response = $this->client->get($this->_whichSite[$site] . $this->_trailUrl)->getBody()->getContents(); - } catch (RequestException $e) { - if ($e->hasResponse()) { - if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on AEBN server')); - } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('AEBN service unavailable')); - } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from AEBN, http error reported: ' . $e->getCode())); - } - } - } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); - } - } else { - try { - $this->_response = $this->client->get(self::IF18)->getBody()->getContents(); - } catch (RequestException $e) { - if ($e->hasResponse()) { - if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on AEBN server')); - } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('AEBN service unavailable')); - } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from AEBN, http error reported: ' . $e->getCode())); - } - } - } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); - } - } - - if (!$this->_response) { - return false; - } - - $this->_html->load($this->_response); - return true; - } -} diff --git a/nntmux/DnzbFailures.php b/nntmux/DnzbFailures.php index 91e236799..b23c25f3e 100755 --- a/nntmux/DnzbFailures.php +++ b/nntmux/DnzbFailures.php @@ -103,9 +103,9 @@ class DnzbFailures * * @param string $guid * @param string $userid - * @return string + * @return string|array */ - public function getAlternate($guid, $userid): string + public function getAlternate($guid, $userid) { $rel = $this->pdo->queryOneRow( sprintf(' diff --git a/nntmux/IAFD.php b/nntmux/IAFD.php deleted file mode 100755 index 465531943..000000000 --- a/nntmux/IAFD.php +++ /dev/null @@ -1,192 +0,0 @@ -_html = new \simple_html_dom(); - if (!empty($this->cookie)) { - @$this->getUrl(); - } - } - - public function __destruct() - { - $this->_html->clear(); - unset($this->response, $this->res); - } - - public function findme() - { - if ($this->search() === true) { - if ($this->_html->find('div#commerce', 0)) { - foreach ($this->_html->find('div#commerce') as $e) { - foreach ($e->find('h4, p.item') as $h4) { - //echo ($h4->innertext) ."\n"; - if (trim($h4->plaintext) === 'DVD') { - $this->_dvdFound = true; - $h4 = null; - } - if ($this->_dvdFound === true && isset($h4)) { - foreach ($h4->find('a') as $alink) { - $compare = trim($alink->innertext); - if ($compare === self::ADE && !empty($compare)) { - $this->classUsed = 'ade'; - $this->_getRedirect = self::IAFDURL . trim($alink->href); - $this->directUrl = $this->getUrl(); - $this->directUrl = preg_replace('/\?(.*)/', '', $this->directUrl); - $this->_dvdFound = false; - break; - } - if ($compare === self::ADM && !empty($compare)) { - $this->classUsed = 'adm'; - $this->_getRedirect = self::IAFDURL . trim($alink->href); - $this->directUrl = $this->getUrl(); - $this->directUrl = preg_replace('/\?(.*)/', - '', - $this->directUrl); - $this->_dvdFound = false; - break; - } - } - } - } - } - } - if (empty($this->classUsed)) { - return false; - } else { - return true; - } - } else { - return false; - } - } - - private function search() - { - - if (empty($this->searchTerm)) { - return false; - } - - $this->_doSearch = true; - - if ($this->getUrl() === false) { - return false; - } else { - $firsttitle = null; - $secondtitle = null; - if ($ret = $this->_html->find('div#moviedata, h2, dt', 0)) { - if ($ret->find('h2', 0)) { - $firsttitle = $ret->find('h2', 0)->innertext; - if (preg_match('/Movie Titles/', $firsttitle)) { - return false; - } - } - if ($ret->find('dt', 0)) { - $secondtitle = $ret->find('dd', 0)->innertext; - } - unset($ret); - if (isset($secondtitle) || isset($firsttitle)) { - $firsttitle = preg_replace('/\(([\d]+)\)/', '', $firsttitle); - $firsttitle = str_replace('/XXX/', '', $firsttitle); - $firsttitle = preg_replace('/\(.*?\)|[-._]/', '', $firsttitle); - $secondtitle = preg_replace('/\(([\d]+)\)/', '', $secondtitle); - $secondtitle = str_replace('/XXX/', '', $secondtitle); - $secondtitle = preg_replace('/\(.*?\)|[-._]/', '', $secondtitle); - similar_text(strtolower($this->searchTerm), strtolower(trim($firsttitle)), $p); - if ($p >= 90) { - $this->title = trim($firsttitle); - - return true; - } else { - similar_text(strtolower($this->searchTerm), - strtolower(trim($secondtitle)), $p); - if ($p >= 90) { - $this->title = trim($secondtitle); - - return true; - } else { - return false; - } - } - } else { - return false; - } - } else { - return false; - } - } - } - - private function getUrl() - { - if ($this->_doSearch === true) { - $ch = curl_init(self::IAFDSEARCHURL . urlencode($this->searchTerm)); - } else { - if (empty($this->_getRedirect)) { - $ch = curl_init(self::IAFDURL); - } else { - $ch = curl_init($this->_getRedirect); - } - } - - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_VERBOSE, 0); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36'); - curl_setopt($ch, CURLOPT_FAILONERROR, 1); - - if (!empty($this->cookie)) { - curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie); - curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie); - } - - curl_setopt_array($ch, Utility::curlSslContextOptions()); - $this->_response = curl_exec($ch); - - if (!empty($this->_getRedirect)) { - $this->_getRedirect = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); - curl_close($ch); - return $this->_getRedirect; - } - - if (!$this->_response) { - curl_close($ch); - - return false; - } - curl_close($ch); - - if ($this->_doSearch === true) { - $this->_html->load($this->_response); - $this->_doSearch = false; - } - - return true; - } -} diff --git a/nntmux/Logger.php b/nntmux/Logger.php index 6e39c8264..0a1a894c4 100755 --- a/nntmux/Logger.php +++ b/nntmux/Logger.php @@ -1,5 +1,8 @@ colorCLI = ($options['ColorCLI'] instanceof ColorCLI ? $options['ColorCLI'] : new ColorCLI()); - $this->getSettings(); $this->currentLogFolder = ( @@ -198,21 +199,12 @@ class Logger : $this->currentLogName ) . '.log'; - $this->setLogFile(); - $this->outputCLI = (strtolower(PHP_SAPI) === 'cli'); - $this->isWindows = (strtolower(substr(PHP_OS, 0, 3)) === 'win'); + $this->isWindows = stripos(PHP_OS, 'win') === 0; $this->timeStart = time(); - } - /** - * Close the log file resource. - * - * @access public - */ - public function __destruct() - { - $this->closeFile(); + $this->logger = new MonoLogger('nntmux'); + $this->logger->pushHandler(new StreamHandler($this->currentLogFolder . $this->currentLogName, MonoLogger::DEBUG)); } /** @@ -283,17 +275,14 @@ class Logger round( $actualUsage / - pow( - 1024, - ($i = + (1024 ** ($i = floor( log( $actualUsage, 1024 ) ) - ) - ), 2 + )), 2 ) ), 4, '~~~', STR_PAD_LEFT ) . @@ -353,13 +342,14 @@ class Logger * * @param string $folder Folder where the log should be stored. * @param string $fileName Name of the file (must be alphanumeric and contain no file extensions). + * * @access public + * @throws \nntmux\LoggerException */ public function changeLogFileLocation($folder, $fileName) { $this->currentLogFolder = $folder; $this->currentLogName = $fileName; - $this->setLogFile(); } /** @@ -382,34 +372,6 @@ class Logger ]; } - /** - * Sets the path and name for the log file. - * - * @throws LoggerException - * @access private - */ - private function setLogFile() - { - // Only run this if NN_LOGGING is on. - if (!NN_LOGGING) { - return; - } - - $this->closeFile(); - - $this->logPath = $this->currentLogFolder . $this->currentLogName; - - if (!is_dir($this->currentLogFolder)) { - $this->createFolder(); - } - - $this->initiateLog(); - - // Check if we need to rotate the log if it exceeds max size.. - $this->rotateLog(); - - $this->openFile(); - } /** * Get/set all settings. @@ -430,34 +392,6 @@ class Logger $this->currentLogFolder = $paths['LogFolder']; } - /** - * Close the file resource. - * - * @access private - */ - private function closeFile() - { - if (is_resource($this->resource)) { - @fclose($this->resource); - } - $this->resource = null; - } - - /** - * Opens the log file. - * - * @throws LoggerException - */ - private function openFile() - { - if (!is_resource($this->resource)) { - $this->resource = @fopen($this->logPath, 'ab'); - - if (!$this->resource) { - throw new LoggerException('Unable to open log file ' . $this->logPath); - } - } - } /** * Log message to file. @@ -471,17 +405,7 @@ class Logger return; } - clearstatcache(true, $this->logPath); - - // Check if we should rotate the logs. - $this->rotateLog(); - - // If another process deleted the file, try to re-open it. - if (!is_file($this->logPath)) { - $this->setLogFile(); - } - - @fwrite($this->resource, $this->logMessage . PHP_EOL); + $this->logger->info($this->logMessage); } /** @@ -502,114 +426,6 @@ class Logger return $this->dateCache; } - /** - * Check if the log folder exists, if not create it. - * - * @access private - * @throws LoggerException - */ - private function createFolder() - { - // Check if the log folder exists, create it if not. - if (!is_dir($this->currentLogFolder)) { - $old = umask(0777); - if (!mkdir($this->currentLogFolder)) { - throw new LoggerException('Unable to create log file folder ' . $this->currentLogFolder); - } - chmod($this->currentLogFolder, 0777); - umask($old); - } - } - - /** - * Initiate a log file. - * - * @access private - * @throws LoggerException - */ - private function initiateLog() - { - if (!is_file($this->logPath)) { - if (!file_put_contents( - $this->logPath, - '[' . $this->getDate() . '] [INIT] [Initiating new log file.]' . PHP_EOL) - ) { - throw new LoggerException('Unable to create new log file ' . $this->logPath); - } - chmod($this->logPath, 0664); - } - } - - /** - * Rotate log file if it exceeds a certain size. - * - * @access private - */ - private function rotateLog() - { - // Check if we need to rotate the log if it exceeds max size.. - $logSize = filesize($this->logPath); - if ($logSize === false) { - return; - } else if ($logSize >= ($this->maxLogSize * 1024 * 1024)) { - $this->closeFile(); - $this->compressLog(); - $this->initiateLog(); - $this->pruneLogs(); - $this->openFile(); - } - } - - /** - * Compress the old log using GZip. - * - * @access private - */ - private function compressLog() - { - $handle = @fopen($this->logPath, 'rb'); - $zipHandle = @gzopen(str_replace('.log', '', $this->logPath) . '.' . time() . '.gz', 'w6'); - if (!$handle || !$zipHandle) { - return; - } - - while (!feof($handle)) { - $data = @fread($handle, 32768); - @gzwrite($zipHandle, $data); - } - - @fclose($handle); - @gzclose($zipHandle); - - // Delete the original uncompressed log file. - unlink($this->logPath); - } - - /** - * Delete old logs (if we have more than $this->maxLogs). - * - * @access private - */ - private function pruneLogs() - { - // Get all the logs with the name. - $logs = glob(str_replace('.log', '', $this->logPath) . '.[0-9]*.gz'); - - // If there are no old logs or less than maxLogs return false. - if (!$logs || (count($logs) < $this->maxLogs)) { - return; - } - - // Sort the logs alphabetically, so the oldest ones are at the top, the new at the bottom. - asort($logs); - - // Remove all new logs from array (all elements under the last 51 elements of the array). - array_splice($logs, -$this->maxLogs+1); - - // Delete all the logs left in the array. - array_map('unlink', $logs); - } - /** * Echo log message to CLI or web. * @@ -623,7 +439,7 @@ class Logger // Check if this is CLI or web. if ($this->outputCLI) { - echo $this->colorCLI->debug($this->logMessage); + ColorCLI::doEcho(ColorCLI::debug($this->logMessage)); } else { echo '
' . $this->logMessage . '

'; } diff --git a/nntmux/Logging.php b/nntmux/Logging.php index 03b4ffa4f..367cdf98a 100755 --- a/nntmux/Logging.php +++ b/nntmux/Logging.php @@ -16,13 +16,13 @@ class Logging private $newLine; /** - * @var object DB Class instance. + * @var DB Class instance. * @access public */ public $pdo; /** - * @var object Class instance. + * @var ColorCLI * @access public */ public $colorCLI; @@ -51,7 +51,7 @@ class Logging * * @access public */ - public function get() + public function get(): array { return $this->pdo->query('SELECT * FROM logging'); } @@ -63,28 +63,29 @@ class Logging * @param string $host * * @return void + * @throws \Exception * * @access public */ - public function LogBadPasswd($username = '', $host = '') + public function LogBadPasswd($username = '', $host = ''): void { // If logggingopt is = 0, then we do nothing, 0 = logging off. $loggingOpt = Settings::value('site.main.loggingopt'); $logFile = Settings::value('site.main.logfile'); - if ($loggingOpt == '1') { + if ((int)$loggingOpt === 1) { $this->pdo->queryInsert(sprintf('INSERT INTO logging (time, username, host) VALUES (NOW(), %s, %s)', $this->pdo->escapeString($username), $this->pdo->escapeString($host))); - } else if ($loggingOpt == '2') { + } else if ((int)$loggingOpt === 2) { $this->pdo->queryInsert(sprintf('INSERT INTO logging (time, username, host) VALUES (NOW(), %s, %s)', $this->pdo->escapeString($username), $this->pdo->escapeString($host))); - $logData = date('M d H:i:s ') . "Login Failed for " . $username . " from " . $host . "." . + $logData = date('M d H:i:s ') . 'Login Failed for ' . $username . ' from ' . $host . '.' . $this->newLine; - if (!empty($logFile)) { + if ($logFile !== null) { file_put_contents($logFile, $logData, FILE_APPEND); } - } else if ($loggingOpt == '3') { + } else if ((int)$loggingOpt === 3) { $logData = date('M d H:i:s ') . 'Login Failed for ' . $username . ' from ' . $host . '.' . $this->newLine; - if (!empty($logFile)) { + if ($logFile !== null) { file_put_contents($logFile, $logData, FILE_APPEND); } } @@ -95,7 +96,7 @@ class Logging * * @access public */ - public function getTopCombined() + public function getTopCombined(): array { return $this->pdo->query('SELECT MAX(time) AS time, username, host, COUNT(host) AS count FROM logging GROUP BY host, username ORDER BY count DESC LIMIT 10'); } @@ -105,7 +106,7 @@ class Logging * * @access public */ - public function getTopIPs() + public function getTopIPs(): array { return $this->pdo->query('SELECT MAX(time) AS time, host, COUNT(host) AS count FROM logging GROUP BY host ORDER BY count DESC LIMIT 10'); } diff --git a/nntmux/NNTP.php b/nntmux/NNTP.php index c870b4b8d..7a3c4a4d0 100755 --- a/nntmux/NNTP.php +++ b/nntmux/NNTP.php @@ -148,7 +148,7 @@ class NNTP extends \Net_NNTP_Client public function doConnect($compression = true, $alternate = false) { if (// (Alternate is wanted, AND current server is alt, OR Alternate is not wanted AND current is main.) AND - (($alternate && $this->_currentServer === getenv('NNTP_SERVER_A')) || (!$alternate && $this->_currentServer === getenv('NNTP_SERVER'))) && + (($alternate && $this->_currentServer === env('NNTP_SERVER_A')) || (!$alternate && $this->_currentServer === env('NNTP_SERVER'))) && // Don't reconnect to usenet if: // We are already connected to usenet. parent::_isConnected() @@ -163,19 +163,19 @@ class NNTP extends \Net_NNTP_Client // Set variables to connect based on if we are using the alternate provider or not. if (!$alternate) { - $sslEnabled = getenv('NNTP_SSLENABLED') ? true : false; - $this->_currentServer = getenv('NNTP_SERVER'); - $this->_currentPort = getenv('NNTP_PORT'); - $userName = getenv('NNTP_USERNAME'); - $password = getenv('NNTP_PASSWORD'); - $socketTimeout = !empty(getenv('NNTP_SOCKET_TIMEOUT')) ? getenv('NNTP_SOCKET_TIMEOUT') : $this->_socketTimeout; + $sslEnabled = env('NNTP_SSLENABLED') ? true : false; + $this->_currentServer = env('NNTP_SERVER'); + $this->_currentPort = env('NNTP_PORT'); + $userName = env('NNTP_USERNAME'); + $password = env('NNTP_PASSWORD'); + $socketTimeout = !empty(env('NNTP_SOCKET_TIMEOUT')) ? env('NNTP_SOCKET_TIMEOUT') : $this->_socketTimeout; } else { - $sslEnabled = getenv('NNTP_SSLENABLED_A') ? true : false; - $this->_currentServer = getenv('NNTP_SERVER_A'); - $this->_currentPort = getenv('NNTP_PORT_A'); - $userName = getenv('NNTP_USERNAME_A'); - $password = getenv('NNTP_PASSWORD_A'); - $socketTimeout = !empty(getenv('NNTP_SOCKET_TIMEOUT_A')) ? getenv('NNTP_SOCKET_TIMEOUT_A') : $this->_socketTimeout; + $sslEnabled = env('NNTP_SSLENABLED_A') ? true : false; + $this->_currentServer = env('NNTP_SERVER_A'); + $this->_currentPort = env('NNTP_PORT_A'); + $userName = env('NNTP_USERNAME_A'); + $password = env('NNTP_PASSWORD_A'); + $socketTimeout = !empty(env('NNTP_SOCKET_TIMEOUT_A')) ? env('NNTP_SOCKET_TIMEOUT_A') : $this->_socketTimeout; } $enc = ($sslEnabled ? ' (ssl)' : ' (non-ssl)'); @@ -581,7 +581,7 @@ class NNTP extends \Net_NNTP_Client if ($alternate === true) { if ($aConnected === false) { // Check if the current connected server is the alternate or not. - if ($this->_currentServer === getenv('NNTP_SERVER')) { + if ($this->_currentServer === env('NNTP_SERVER')) { // It's the main so connect to the alternate. $aConnected = $nntp->doConnect(true, true); } else { @@ -1483,13 +1483,13 @@ class NNTP extends \Net_NNTP_Client $retVal = true; } else { switch ($this->_currentServer) { - case getenv('NNTP_SERVER'): + case env('NNTP_SERVER'): if (is_resource($this->_socket)) { $this->doQuit(true); } $retVal = $this->doConnect(); break; - case getenv('NNTP_SERVER_A'): + case env('NNTP_SERVER_A'): if (is_resource($this->_socket)) { $this->doQuit(true); } diff --git a/nntmux/Tmux.php b/nntmux/Tmux.php index bea73d127..9fc5c6f75 100755 --- a/nntmux/Tmux.php +++ b/nntmux/Tmux.php @@ -90,12 +90,12 @@ class Tmux public function getConnectionsInfo($constants) { $runVar['connections']['port_a'] = $runVar['connections']['host_a'] = $runVar['connections']['ip_a'] = false; - $runVar['connections']['port'] = getenv('NNTP_PORT'); - $runVar['connections']['host'] = getenv('NNTP_SERVER'); + $runVar['connections']['port'] = env('NNTP_PORT'); + $runVar['connections']['host'] = env('NNTP_SERVER'); $runVar['connections']['ip'] = gethostbyname($runVar['connections']['host']); if ($constants['alternate_nntp'] === '1') { - $runVar['connections']['port_a'] = getenv('NNTP_PORT_A'); - $runVar['connections']['host_a'] = getenv('NNTP_SERVER_A'); + $runVar['connections']['port_a'] = env('NNTP_PORT_A'); + $runVar['connections']['host_a'] = env('NNTP_SERVER_A'); $runVar['connections']['ip_a'] = gethostbyname($runVar['connections']['host_a']); } return $runVar['connections']; diff --git a/nntmux/TmuxRun.php b/nntmux/TmuxRun.php index a1e0f9874..0de37e79f 100755 --- a/nntmux/TmuxRun.php +++ b/nntmux/TmuxRun.php @@ -229,8 +229,7 @@ class TmuxRun extends Tmux $log = $this->writelog($runVar['panes']['two'][2]); shell_exec("tmux respawnp -t{$runVar['constants']['tmux_session']}:2.2 ' \ - {$runVar['commands']['_phpn']} {$runVar['paths']['misc']}update/postprocess.php amazon true $log; \ - {$runVar['commands']['_php']} {$runVar['paths']['misc']}testing/PostProc/getXXXSamples.php true 100 $log; date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer_amazon']}' 2>&1 1> /dev/null" + {$runVar['commands']['_phpn']} {$runVar['paths']['misc']}update/postprocess.php amazon true $log; date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer_amazon']}' 2>&1 1> /dev/null" ); break; case $runVar['settings']['post_amazon'] == 1 && $runVar['settings']['processbooks'] == 0 diff --git a/nntmux/XXX.php b/nntmux/XXX.php index d5f5ae095..0571f7c6b 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -4,6 +4,11 @@ namespace nntmux; use app\models\Settings; use nntmux\db\DB; +use nntmux\processing\adult\AEBN; +use nntmux\processing\adult\ADM; +use nntmux\processing\adult\ADE; +use nntmux\processing\adult\Hotmovies; +use nntmux\processing\adult\Popporn; /** @@ -73,6 +78,8 @@ class XXX /** * @param array $options Echo to cli / Class instances. + * + * @throws \Exception */ public function __construct(array $options = []) { @@ -409,288 +416,6 @@ class XXX } } - /** - * Fetch xxx info for the movie. - * - * @param $xxxmovie - * - * @return bool - */ - public function updateXXXInfo($xxxmovie): bool - { - - $res = false; - $this->whichclass = ''; - - $iafd = new IAFD(); - $iafd->searchTerm = $xxxmovie; - - if ($iafd->findme() !== false) { - - switch ($iafd->classUsed) { - case 'ade': - $mov = new ADE(); - $mov->directLink = (string)$iafd->directUrl; - $res = $mov->getDirect(); - $res['title'] = $iafd->title; - $res['directurl'] = (string)$iafd->directUrl; - $this->whichclass = $iafd->classUsed; - ColorCLI::doEcho(ColorCLI::primary('Fetching XXX info from IAFD -> Adult DVD Empire')); - break; - } - } - - if ($res === false) { - - $this->whichclass = 'aebn'; - $mov = new AEBN(); - $mov->cookie = $this->cookie; - $mov->searchTerm = $xxxmovie; - $res = $mov->search(); - - if ($res === false) { - $this->whichclass = 'ade'; - $mov = new ADE(); - $mov->searchTerm = $xxxmovie; - $res = $mov->search(); - } - - if ($res === false) { - $this->whichclass = 'pop'; - $mov = new Popporn(); - $mov->cookie = $this->cookie; - $mov->searchTerm = $xxxmovie; - $res = $mov->search(); - } - - // Last in list as it doesn't have trailers - if ($res === false) { - $this->whichclass = 'adm'; - $mov = new ADM(); - $mov->cookie = $this->cookie; - $mov->searchTerm = $xxxmovie; - $res = $mov->search(); - } - - - // If a result is true getAll information. - if ($res !== false) { - if ($this->echooutput) { - - switch ($this->whichclass) { - case 'aebn': - $fromstr = 'Adult Entertainment Broadcast Network'; - break; - case 'ade': - $fromstr = 'Adult DVD Empire'; - break; - case 'pop': - $fromstr = 'PopPorn'; - break; - case 'adm': - $fromstr = 'Adult DVD Marketplace'; - break; - default: - $fromstr = null; - } - ColorCLI::doEcho(ColorCLI::primary('Fetching XXX info from: ' . $fromstr)); - } - $res = $mov->getAll(); - } else { - // Nothing was found, go ahead and set to -2 - return -2; - } - } - - $res['cast'] = !empty($res['cast']) ? implode(',', $res['cast']) : ''; - $res['genres'] = !empty($res['genres']) ? $this->getGenreID($res['genres']) : ''; - - $mov = [ - 'trailers' => !empty($res['trailers']) ? serialize($res['trailers']) : '', - 'extras' => !empty($res['extras']) ? serialize($res['extras']) : '', - 'productinfo' => !empty($res['productinfo']) ? serialize($res['productinfo']) : '', - 'backdrop' => !empty($res['backcover']) ? $res['backcover'] : 0, - 'cover' => !empty($res['boxcover']) ? $res['boxcover'] : 0, - 'title' => !empty($res['title']) ? html_entity_decode($res['title'], ENT_QUOTES, 'UTF-8') : '', - 'plot' => !empty($res['sypnosis']) ? html_entity_decode($res['sypnosis'], ENT_QUOTES, 'UTF-8') : '', - 'tagline' => !empty($res['tagline']) ? html_entity_decode($res['tagline'], ENT_QUOTES, 'UTF-8') : '', - 'genre' => !empty($res['genres']) ? html_entity_decode($res['genres'], ENT_QUOTES, 'UTF-8') : '', - 'director' => !empty($res['director']) ? html_entity_decode($res['director'], ENT_QUOTES, 'UTF-8') : '', - 'actors' => !empty($res['cast']) ? html_entity_decode($res['cast'], ENT_QUOTES, 'UTF-8') : '', - 'directurl' => !empty($res['directurl']) ? html_entity_decode($res['directurl'], ENT_QUOTES, 'UTF-8') : '', - 'classused' => $this->whichclass - ]; - - $check = $this->pdo->queryOneRow(sprintf('SELECT id FROM xxxinfo WHERE title = %s', $this->pdo->escapeString($mov['title']))); - $xxxID = 0; - if (isset($check['id'])) { - $xxxID = $check['id']; - } - - // Update Current XXX Information - getXXXCovers.php - if ($xxxID > 0) { - $this->update($check['id'], $mov['title'], $mov['tagline'], $mov['plot'], $mov['genre'], $mov['director'], $mov['actors'], $mov['extras'], $mov['productinfo'], $mov['trailers'], $mov['directurl'], $mov['classused']); - $xxxID = $check['id']; - - // BoxCover. - if (isset($mov['cover'])) { - $mov['cover'] = $this->releaseImage->saveImage($xxxID . '-cover', $mov['cover'], $this->imgSavePath); - } - - // BackCover. - if (isset($mov['backdrop'])) { - $mov['backdrop'] = $this->releaseImage->saveImage($xxxID . '-backdrop', $mov['backdrop'], $this->imgSavePath, 1920, 1024); - } - - $this->pdo->queryExec(sprintf('UPDATE xxxinfo SET cover = %d, backdrop = %d WHERE id = %d', $mov['cover'], $mov['backdrop'], $xxxID)); - - } else { - $xxxID = -2; - } - - // Insert New XXX Information - if ($check === false) { - $xxxID = $this->pdo->queryInsert( - sprintf(' - INSERT INTO xxxinfo - (title, tagline, plot, genre, director, actors, extras, productinfo, trailers, directurl, classused, cover, backdrop, createddate, updateddate) - VALUES - (%s, %s, COMPRESS(%s), %s, %s, %s, %s, %s, %s, %s, %s, 0, 0, NOW(), NOW())', - $this->pdo->escapeString($mov['title']), - $this->pdo->escapeString($mov['tagline']), - $this->pdo->escapeString($mov['plot']), - $this->pdo->escapeString(substr($mov['genre'], 0, 64)), - $this->pdo->escapeString($mov['director']), - $this->pdo->escapeString($mov['actors']), - $this->pdo->escapeString($mov['extras']), - $this->pdo->escapeString($mov['productinfo']), - $this->pdo->escapeString($mov['trailers']), - $this->pdo->escapeString($mov['directurl']), - $this->pdo->escapeString($mov['classused']) - ) - ); - } - - if ($this->echooutput) { - ColorCLI::doEcho( - ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: ' . ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: ' . ColorCLI::primary($mov['title']))) - ); - } - - return $xxxID; - } - - /** - * Process XXX releases where xxxinfo is 0 - * - */ - public function processXXXReleases(): void - { - $res = $this->pdo->query(sprintf(' - SELECT r.searchname, r.id - FROM releases r - WHERE r.nzbstatus = 1 - AND r.xxxinfo_id = 0 - %s - LIMIT %d', - $this->catWhere, - $this->movieqty - ) - ); - $movieCount = count($res); - - if ($movieCount > 0) { - - if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::header('Processing ' . $movieCount . ' XXX releases.')); - } - - // Loop over releases. - foreach ($res as $arr) { - - $idcheck = -2; - - // Try to get a name. - if ($this->parseXXXSearchName($arr['searchname']) !== false) { - $check = $this->checkXXXInfoExists($this->currentTitle); - if ($check === false) { - $this->currentRelID = $arr['id']; - $movieName = $this->currentTitle; - if ($this->debug && $this->echooutput) { - ColorCLI::doEcho('DB name: ' . $arr['searchname'], true); - } - if ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::primaryOver('Looking up: ') . ColorCLI::headerOver($movieName), true); - } - - $idcheck = $this->updateXXXInfo($movieName); - } else { - $idcheck = (int)$check['id']; - } - } else { - ColorCLI::doEcho('.', true); - } - $this->pdo->queryExec(sprintf('UPDATE releases SET xxxinfo_id = %d WHERE id = %d %s', $idcheck, $arr['id'], $this->catWhere)); - } - } elseif ($this->echooutput) { - ColorCLI::doEcho(ColorCLI::header('No xxx releases to process.')); - } - } - - /** - * Checks xxxinfo to make sure releases exist - * - * @param $releaseName - * - * @return array|bool - */ - protected function checkXXXInfoExists($releaseName) - { - return $this->pdo->queryOneRow(sprintf('SELECT id, title FROM xxxinfo WHERE title %s', $this->pdo->likeString($releaseName, false, true))); - } - - /** - * Cleans up a searchname to make it easier to scrape. - * - * @param string $releaseName - * - * @return bool - */ - protected function parseXXXSearchName($releaseName): bool - { - $name = ''; - $followingList = '[^\w]((2160|1080|480|720)(p|i)|AC3D|Directors([^\w]CUT)?|DD5\.1|(DVD|BD|BR)(Rip)?|BluRay|divx|HDTV|iNTERNAL|LiMiTED|(Real\.)?Proper|RE(pack|Rip)|Sub\.?(fix|pack)|Unrated|WEB-DL|(x|H)[-._ ]?264|xvid|[Dd][Ii][Ss][Cc](\d+|\s*\d+|\.\d+)|XXX|BTS|DirFix|Trailer|WEBRiP|NFO|(19|20)\d\d)[^\w]'; - - if (preg_match('/([^\w]{2,})?(?P[\w .-]+?)' . $followingList . '/i', $releaseName, $matches)) { - $name = $matches['name']; - } - - // Check if we got something. - if ($name !== '') { - - // If we still have any of the words in $followingList, remove them. - $name = preg_replace('/' . $followingList . '/i', ' ', $name); - // Remove periods, underscored, anything between parenthesis. - $name = preg_replace('/\(.*?\)|[-._]/i', ' ', $name); - // Finally remove multiple spaces and trim leading spaces. - $name = trim(preg_replace('/\s{2,}/', ' ', $name)); - // Remove Private Movies {d} from name better matching. - $name = trim(preg_replace('/^Private\s(Specials|Blockbusters|Blockbuster|Sports|Gold|Lesbian|Movies|Classics|Castings|Fetish|Stars|Pictures|XXX|Private|Black\sLabel|Black)\s\d+/i', '', $name)); - // Remove Foreign Words at the end of the name. - $name = trim(preg_replace('/(brazilian|chinese|croatian|danish|deutsch|dutch|estonian|flemish|finnish|french|german|greek|hebrew|icelandic|italian|latin|nordic|norwegian|polish|portuguese|japenese|japanese|russian|serbian|slovenian|spanish|spanisch|swedish|thai|turkish)$/i', '', $name)); - - // Check if the name is long enough and not just numbers and not file (d) of (d) and does not contain Episodes and any dated 00.00.00 which are site rips.. - if (strlen($name) > 5 && !preg_match('/^\d+$/', $name) && !preg_match('/( File \d+ of \d+|\d+.\d+.\d+)/', $name) && !preg_match('/(E\d+)/', $name) && !preg_match('/\d\d\.\d\d.\d\d/', $name)) { - $this->currentTitle = $name; - - return true; - } - ColorCLI::doEcho('.', false); - } - - return false; - } - /** * Get all genres for search-filter.tpl * @@ -749,7 +474,7 @@ class XXX * * @return string - If array .. 1,2,3,4 if string .. 1 */ - private function getGenreID($arr): string + protected function getGenreID($arr): string { $ret = null; @@ -825,4 +550,278 @@ class XXX return $ret; } + + /** + * @param $movie + * + * @return false|int|string + * @throws \Exception + */ + public function updateXXXInfo($movie) + { + $cover = $backdrop = 0; + $xxxID = -2; + $this->whichclass = 'aebn'; + $mov = new AEBN(); + $mov->cookie = $this->cookie; + ColorCLI::doEcho(ColorCLI::info('Checking AEBN for movie info')); + $res = $mov->processSite($movie); + + if ($res === false) { + $this->whichclass = 'ade'; + $mov = new ADE(); + ColorCLI::doEcho(ColorCLI::info('Checking ADE for movie info')); + $res = $mov->processSite($movie); + } + + if ($res === false) { + $this->whichclass = 'pop'; + $mov = new Popporn(); + $mov->cookie = $this->cookie; + ColorCLI::doEcho(ColorCLI::info('Checking PopPorn for movie info')); + $res = $mov->processSite($movie); + } + + if ($res === false) { + $this->whichclass = 'hotm'; + $mov = new Hotmovies(); + $mov->cookie = $this->cookie; + ColorCLI::doEcho(ColorCLI::info('Checking HotMovies for movie info')); + $res = $mov->processSite($movie); + } + + // Last in list as it doesn't have trailers + if ($res === false) { + $this->whichclass = 'adm'; + $mov = new ADM(); + $mov->cookie = $this->cookie; + ColorCLI::doEcho(ColorCLI::info('Checking ADM for movie info')); + $res = $mov->processSite($movie); + } + + + // If a result is true getAll information. + if ($res) { + if ($this->echooutput) { + + switch ($this->whichclass) { + case 'aebn': + $fromstr = 'Adult Entertainment Broadcast Network'; + break; + case 'ade': + $fromstr = 'Adult DVD Empire'; + break; + case 'pop': + $fromstr = 'PopPorn'; + break; + case 'adm': + $fromstr = 'Adult DVD Marketplace'; + break; + case 'hotm': + $fromstr = 'HotMovies'; + break; + default: + $fromstr = ''; + } + ColorCLI::doEcho(ColorCLI::primary('Fetching XXX info from: ' . $fromstr)); + } + $res = $mov->getAll(); + } else { + // Nothing was found, go ahead and set to -2 + return -2; + } + + $res['cast'] = !empty($res['cast']) ? implode(',', $res['cast']) : ''; + $res['genres'] = !empty($res['genres']) ? $this->getGenreID($res['genres']) : ''; + + $mov = [ + 'trailers' => !empty($res['trailers']) ? serialize($res['trailers']) : '', + 'extras' => !empty($res['extras']) ? serialize($res['extras']) : '', + 'productinfo' => !empty($res['productinfo']) ? serialize($res['productinfo']) : '', + 'backdrop' => !empty($res['backcover']) ? $res['backcover'] : 0, + 'cover' => !empty($res['boxcover']) ? $res['boxcover'] : 0, + 'title' => !empty($res['title']) ? html_entity_decode($res['title'], ENT_QUOTES, 'UTF-8') : '', + 'plot' => !empty($res['synopsis']) ? html_entity_decode($res['synopsis'], ENT_QUOTES, 'UTF-8') : '', + 'tagline' => !empty($res['tagline']) ? html_entity_decode($res['tagline'], ENT_QUOTES, 'UTF-8') : '', + 'genre' => !empty($res['genres']) ? html_entity_decode($res['genres'], ENT_QUOTES, 'UTF-8') : '', + 'director' => !empty($res['director']) ? html_entity_decode($res['director'], ENT_QUOTES, 'UTF-8') : '', + 'actors' => !empty($res['cast']) ? html_entity_decode($res['cast'], ENT_QUOTES, 'UTF-8') : '', + 'directurl' => !empty($res['directurl']) ? html_entity_decode($res['directurl'], ENT_QUOTES, 'UTF-8') : '', + 'classused' => $this->whichclass + ]; + + $check = $this->pdo->queryOneRow(sprintf('SELECT id FROM xxxinfo WHERE title = %s', $this->pdo->escapeString($mov['title']))); + + if ($check['id'] > 0) { + + $xxxID = $check['id']; + + // Update BoxCover. + if (!empty($mov['cover'])) { + $cover = $this->releaseImage->saveImage($xxxID . '-cover', $mov['cover'], $this->imgSavePath); + } + + // BackCover. + if (!empty($mov['backdrop'])) { + $backdrop = $this->releaseImage->saveImage($xxxID . '-backdrop', $mov['backdrop'], $this->imgSavePath, 1920, 1024); + } + + // Update Current XXX Information + $this->update($check['id'], $mov['title'], $mov['tagline'], $mov['plot'], $mov['genre'], $mov['director'], $mov['actors'], $mov['extras'], $mov['productinfo'], $mov['trailers'], $mov['directurl'], $mov['classused'], $cover, $backdrop); + } + + // Insert New XXX Information + if ($check === false) { + $xxxID = $this->pdo->queryInsert( + sprintf(' + INSERT INTO xxxinfo + (title, tagline, plot, genre, director, actors, extras, productinfo, trailers, directurl, classused, createddate, updateddate) + VALUES + (%s, %s, COMPRESS(%s), %s, %s, %s, %s, %s, %s, %s, %s, NOW(), NOW())', + $this->pdo->escapeString($mov['title']), + $this->pdo->escapeString($mov['tagline']), + $this->pdo->escapeString($mov['plot']), + $this->pdo->escapeString(substr($mov['genre'], 0, 64)), + $this->pdo->escapeString($mov['director']), + $this->pdo->escapeString($mov['actors']), + $this->pdo->escapeString($mov['extras']), + $this->pdo->escapeString($mov['productinfo']), + $this->pdo->escapeString($mov['trailers']), + $this->pdo->escapeString($mov['directurl']), + $this->pdo->escapeString($mov['classused']) + ) + ); + // Update BoxCover. + if (!empty($mov['cover'])) { + $cover = $this->releaseImage->saveImage($xxxID . '-cover', $mov['cover'], $this->imgSavePath); + } + + // BackCover. + if (!empty($mov['backdrop'])) { + $backdrop = $this->releaseImage->saveImage($xxxID . '-backdrop', $mov['backdrop'], $this->imgSavePath, 1920, 1024); + } + + $this->pdo->queryExec(sprintf('UPDATE xxxinfo SET cover = %d, backdrop = %d WHERE id = %d', $cover, $backdrop, $xxxID)); + } + + if ($this->echooutput) { + ColorCLI::doEcho( + ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: ' . ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: ' . ColorCLI::primary($mov['title']))) + ); + } + + return $xxxID; + } + + /** + * Process XXX releases where xxxinfo is 0 + * + * @throws \Exception + */ + public function processXXXReleases(): void + { + $res = $this->pdo->query(sprintf(' + SELECT r.searchname, r.id + FROM releases r + WHERE r.nzbstatus = 1 + AND r.xxxinfo_id = 0 + %s + LIMIT %d', + $this->catWhere, + $this->movieqty + ) + ); + $movieCount = count($res); + + if ($movieCount > 0) { + + if ($this->echooutput) { + ColorCLI::doEcho(ColorCLI::header('Processing ' . $movieCount . ' XXX releases.')); + } + + // Loop over releases. + foreach ($res as $arr) { + + $idcheck = -2; + + // Try to get a name. + if ($this->parseXXXSearchName($arr['searchname']) !== false) { + $check = $this->checkXXXInfoExists($this->currentTitle); + if ($check === false) { + $this->currentRelID = $arr['id']; + if ($this->debug && $this->echooutput) { + ColorCLI::doEcho('DB name: ' . $arr['searchname'], true); + } + if ($this->echooutput) { + ColorCLI::doEcho(ColorCLI::primaryOver('Looking up: ') . ColorCLI::headerOver($this ->currentTitle), true); + } + + ColorCLI::doEcho(ColorCLI::info('Local match not found, checking web!'), true); + $idcheck = $this->updateXXXInfo($this->currentTitle); + } else { + ColorCLI::doEcho(ColorCLI::info('Local match found for XXX Movie: ' . ColorCLI::headerOver($this->currentTitle)), true); + $idcheck = (int)$check['id']; + } + } else { + ColorCLI::doEcho('.', true); + } + $this->pdo->queryExec(sprintf('UPDATE releases SET xxxinfo_id = %d WHERE id = %d %s', $idcheck, $arr['id'], $this->catWhere)); + } + } elseif ($this->echooutput) { + ColorCLI::doEcho(ColorCLI::header('No xxx releases to process.')); + } + } + + /** + * Checks xxxinfo to make sure releases exist + * + * @param $releaseName + * + * @return array|bool + */ + protected function checkXXXInfoExists($releaseName) + { + return $this->pdo->queryOneRow(sprintf('SELECT id, title FROM xxxinfo WHERE title %s', $this->pdo->likeString($releaseName, false, true))); + } + + /** + * Cleans up a searchname to make it easier to scrape. + * + * @param string $releaseName + * + * @return bool + */ + protected function parseXXXSearchName($releaseName): bool + { + $name = ''; + $followingList = '[^\w]((2160|1080|480|720)(p|i)|AC3D|Directors([^\w]CUT)?|DD5\.1|(DVD|BD|BR)(Rip)?|BluRay|divx|HDTV|iNTERNAL|LiMiTED|(Real\.)?Proper|RE(pack|Rip)|Sub\.?(fix|pack)|Unrated|WEB-DL|(x|H)[-._ ]?264|xvid|[Dd][Ii][Ss][Cc](\d+|\s*\d+|\.\d+)|XXX|BTS|DirFix|Trailer|WEBRiP|NFO|(19|20)\d\d)[^\w]'; + + if (preg_match('/([^\w]{2,})?(?P[\w .-]+?)' . $followingList . '/i', $releaseName, $matches)) { + $name = $matches['name']; + } + + // Check if we got something. + if ($name !== '') { + + // If we still have any of the words in $followingList, remove them. + $name = preg_replace('/' . $followingList . '/i', ' ', $name); + // Remove periods, underscored, anything between parenthesis. + $name = preg_replace('/\(.*?\)|[-._]/i', ' ', $name); + // Finally remove multiple spaces and trim leading spaces. + $name = trim(preg_replace('/\s{2,}/', ' ', $name)); + // Remove Private Movies {d} from name better matching. + $name = trim(preg_replace('/^Private\s(Specials|Blockbusters|Blockbuster|Sports|Gold|Lesbian|Movies|Classics|Castings|Fetish|Stars|Pictures|XXX|Private|Black\sLabel|Black)\s\d+/i', '', $name)); + // Remove Foreign Words at the end of the name. + $name = trim(preg_replace('/(brazilian|chinese|croatian|danish|deutsch|dutch|estonian|flemish|finnish|french|german|greek|hebrew|icelandic|italian|latin|nordic|norwegian|polish|portuguese|japenese|japanese|russian|serbian|slovenian|spanish|spanisch|swedish|thai|turkish)$/i', '', $name)); + + // Check if the name is long enough and not just numbers and not file (d) of (d) and does not contain Episodes and any dated 00.00.00 which are site rips.. + if (strlen($name) > 5 && !preg_match('/^\d+$/', $name) && !preg_match('/( File \d+ of \d+|\d+.\d+.\d+)/', $name) && !preg_match('/(E\d+)/', $name) && !preg_match('/\d\d\.\d\d.\d\d/', $name)) { + $this->currentTitle = $name; + + return true; + } + } + + return false; + } } diff --git a/nntmux/constants.php b/nntmux/constants.php index 5ff435d7e..c1eb7a3f7 100755 --- a/nntmux/constants.php +++ b/nntmux/constants.php @@ -3,7 +3,7 @@ define('NN_MINIMUM_PHP_VERSION', '7.1.0'); define('NN_MINIMUM_MYSQL_VERSION', '5.6'); -define('NN_MINIMUM_MARIA_VERSION', '10.0'); +define('NN_MINIMUM_MARIA_VERSION', '10.1'); define('DS', DIRECTORY_SEPARATOR); diff --git a/nntmux/db/DB.php b/nntmux/db/DB.php index a7b5325eb..9a0107915 100755 --- a/nntmux/db/DB.php +++ b/nntmux/db/DB.php @@ -112,13 +112,13 @@ class DB extends \PDO 'checkVersion' => false, 'createDb' => false, // create dbname if it does not exist? 'ct' => new ConsoleTools(), - 'dbhost' => getenv('DB_HOST'), - 'dbname' => getenv('DB_NAME'), - 'dbpass' => getenv('DB_PASSWORD'), - 'dbport' => getenv('DB_PORT'), - 'dbsock' => getenv('DB_SOCKET'), - 'dbtype' => getenv('DB_SYSTEM'), - 'dbuser' => getenv('DB_USER'), + 'dbhost' => env('DB_HOST', '127.0.0.1'), + 'dbname' => env('DB_NAME', 'nntmux'), + 'dbpass' => env('DB_PASSWORD', 'nntmux'), + 'dbport' => env('DB_PORT', '3306'), + 'dbsock' => env('DB_SOCKET'), + 'dbtype' => env('DB_SYSTEM','mysql'), + 'dbuser' => env('DB_USER', 'nntmux'), 'log' => new ColorCLI(), 'persist' => false, ]; diff --git a/nntmux/db/DbUpdate.php b/nntmux/db/DbUpdate.php index d0ffadc98..4d71acfd0 100755 --- a/nntmux/db/DbUpdate.php +++ b/nntmux/db/DbUpdate.php @@ -84,6 +84,7 @@ class DbUpdate public function loadTables(array $options = []) { $defaults = [ + 'enclosedby' => null, 'ext' => 'tsv', 'files' => [], 'path' => NN_RES . 'db' . DS . 'schema' . DS . 'data', @@ -96,8 +97,10 @@ class DbUpdate $files = empty($options['files']) ? Utility::getDirFiles($options) : $options['files']; natsort($files); $local = $this->pdo->isLocalDb() ? '' : 'LOCAL '; + $enclosedby = empty($options['enclosedby']) ? '' : 'OPTIONALLY ENCLOSED BY "' . + $options['enclosedby'] . '"'; $sql = 'LOAD DATA ' . - $local . 'INFILE "%s" IGNORE INTO TABLE `%s` FIELDS TERMINATED BY "\t" OPTIONALLY ENCLOSED BY "\"" LINES TERMINATED BY "\n" IGNORE 1 LINES (%s)'; + $local . 'INFILE "%s" IGNORE INTO TABLE `%s` FIELDS TERMINATED BY "\t" ' . $enclosedby . 'LINES TERMINATED BY "\n" IGNORE 1 LINES (%s)'; foreach ($files as $file) { if ($show === true) { echo "File: $file\n"; @@ -107,7 +110,7 @@ class DbUpdate if (preg_match($options['regex'], $file, $matches)) { $table = $matches['table']; // Get the first line of the file which holds the columns used. - $handle = @fopen($file, "r"); + $handle = @fopen($file, 'rb'); if (is_resource($handle)) { $line = fgets($handle); fclose($handle); @@ -118,12 +121,20 @@ class DbUpdate $fields = trim($line); if ($show === true) { - echo "Inserting data into table: '$table'\n"; + ColorCLI::doEcho(ColorCLI::info('Inserting data into table: ' . $table)); } if (Utility::isWin()) { $file = str_replace("\\", '\/', $file); } - $this->pdo->exec(sprintf($sql, $file, $table, $fields)); + $this->pdo->queryExec(sprintf($sql, $file, $table, $fields)); + if ($table !== 'settings') { + $success = $this->pdo->query(sprintf('SELECT COUNT(id) AS num FROM %s', $table)); + if (empty($success[0]['num'])) { + ColorCLI::doEcho(ColorCLI::error('Failed to insert data into table: ' . $table)); + } else { + ColorCLI::doEcho(ColorCLI::notice('Successfully inserted data into ' . $table . ' table')); + } + } } else { exit("Failed to open file: '$file'\n"); } diff --git a/nntmux/libraries/Forking.php b/nntmux/libraries/Forking.php index 21830318a..ae5c29325 100755 --- a/nntmux/libraries/Forking.php +++ b/nntmux/libraries/Forking.php @@ -597,8 +597,12 @@ class Forking extends \fork_daemon if ($groups instanceof \Traversable) { foreach ($groups as $group) { - if ($this->pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $group['id'])) !== false) { - $this->work[] = ['id' => $group['id']]; + try { + if ($this->pdo->queryOneRow(sprintf('SELECT id FROM collections_%d LIMIT 1', $group['id'])) !== false) { + $this->work[] = ['id' => $group['id']]; + } + } catch (\PDOException $e) { + $e->getMessage(); } } } diff --git a/nntmux/processing/PostProcess.php b/nntmux/processing/PostProcess.php index 49e6a83f4..f1199bb20 100755 --- a/nntmux/processing/PostProcess.php +++ b/nntmux/processing/PostProcess.php @@ -3,28 +3,34 @@ namespace nntmux\processing; use app\models\Settings; use dariusiii\rarinfo\Par2Info; +use nntmux\ADE; +use nntmux\ADM; +use nntmux\AEBN; use nntmux\Books; use nntmux\Category; use nntmux\ColorCLI; use nntmux\Console; use nntmux\Games; use nntmux\Groups; +use nntmux\Hotmovies; use nntmux\Logger; use nntmux\Movie; use nntmux\Music; use nntmux\NameFixer; use nntmux\Nfo; +use nntmux\Popporn; use nntmux\Sharing; +use nntmux\processing\adult\AdultMovies; use nntmux\processing\tv\TVDB; use nntmux\processing\tv\TVMaze; use nntmux\processing\tv\TMDB; use nntmux\processing\tv\TraktTv; -use nntmux\XXX; use nntmux\ReleaseFiles; use nntmux\db\DB; use nntmux\processing\post\AniDB; use nntmux\processing\post\ProcessAdditional; use nntmux\SpotNab; +use nntmux\XXX; class PostProcess { @@ -254,12 +260,13 @@ class PostProcess /** * Process all TV related releases which will assign their series/episode/rage data. * - * @param string $groupID (Optional) ID of a group to work on. - * @param string $guidChar (Optional) First letter of a release GUID to use to get work. - * @param string|int $processTV (Optional) 0 Don't process, 1 process all releases, + * @param string $groupID (Optional) ID of a group to work on. + * @param string $guidChar (Optional) First letter of a release GUID to use to get work. + * @param string|int $processTV (Optional) 0 Don't process, 1 process all releases, * 2 process renamed releases only, '' check site setting * * @return void + * @throws \Exception */ public function processTv($groupID = '', $guidChar = '', $processTV = '') { @@ -295,6 +302,8 @@ class PostProcess /** * Lookup xxx if enabled. + * + * @throws \Exception */ public function processXXX() { diff --git a/nntmux/processing/adult/ADE.php b/nntmux/processing/adult/ADE.php new file mode 100755 index 000000000..698142c5f --- /dev/null +++ b/nntmux/processing/adult/ADE.php @@ -0,0 +1,284 @@ +_html = new \simple_html_dom(); + } + + /** + * Gets Trailer Movies + * @return array - url, streamid, basestreamingurl + */ + public function trailers() + { + $this->_response = getRawHtml(self::ADE . $this->_trailers . $this->_directUrl); + $this->_html->load($this->_response); + if (preg_match("/(\"|')(?P[^\"']+.swf)(\"|')/i", $this->_response, $matches)) { + $this->_res['trailers']['url'] = self::ADE . trim(trim($matches['swf']), '"'); + if (preg_match('#(?:streamID:\s\")(?P[0-9A-Z]+)(?:\")#', + $this->_response, + $matches) + ) { + $this->_res['trailers']['streamid'] = trim($matches['streamid']); + } + if (preg_match('#(?:BaseStreamingUrl:\s\")(?P[\d]+.[\d]+.[\d]+.[\d]+)(?:\")#', + $this->_response, + $matches) + ) { + $this->_res['trailers']['baseurl'] = $matches['baseurl']; + } + } + + return $this->_res; + } + + /** + * Gets cover images for the xxx release + * @return array - Boxcover and backcover + */ + public function covers() + { + if ($ret = $this->_html->find('div#Boxcover, img[itemprop=image]', 1)) { + $this->_res['boxcover'] = preg_replace('/m\.jpg/', 'h.jpg', $ret->src); + $this->_res['backcover'] = preg_replace('/m\.jpg/', 'bh.jpg', $ret->src); + } + + return $this->_res; + } + + /** + * Gets the synopsis + * + * @return array - plot + */ + public function synopsis() + { + $ret = $this->_html->find('meta[name=og:description]', 0)->content; + if ($ret !== false) { + $this->_res['synopsis'] = trim($ret); + } + + return $this->_res; + } + + /** + * Gets the cast members and/or awards + * + * + * @return array - cast, awards + */ + public function cast() + { + foreach ($this->_html->find('a.PerformerName') as $a) { + if ($a->plaintext !== '(bio)' && $a->plaintext !== '(interview)') { + $this->_res['cast'][] = trim($a->innertext); + } + } + + return $this->_res; + } + + /** + * Gets Genres, if exists return array else return false + * @return mixed array - Genres + */ + public function genres() + { + $genres = []; + $ret = $this->_html->find('h2[border-bottom-site-default]'); + foreach ($ret as $categories) { + $cats = $categories->find('a[label]'); + foreach ($cats as $c) { + $categories = trim($c); + if (strpos($categories, ',') !== false) { + $genres = explode(',', $categories); + $genres = array_map('trim', $genres); + } else { + $genres[] = $categories; + } + } + } + if (is_array($genres)) { + $this->_res['genres'] = array_unique($genres); + } + return $this->_res; + } + + /** + * Gets Product Information and/or Features + * + * @param bool $features Include features? true/false + * + * @return array - ProductInfo/Extras = features + */ + public function productInfo($features = false) + { + $dofeature = null; + $this->_tmpResponse = str_ireplace('Section ProductInfo', 'spdinfo', $this->_response); + $this->_html->load($this->_tmpResponse); + if ($ret = $this->_html->find('div[class=spdinfo]', 0)) { + $this->_tmpResponse = trim($ret->outertext); + $ret = $this->_html->load($this->_tmpResponse); + foreach ($ret->find("text") as $strong) { + if (trim($strong->innertext) === 'Features') { + $dofeature = true; + } + if ($dofeature !== true) { + if (trim($strong->innertext) !== ' ') { + $this->_res['productinfo'][] = trim($strong->innertext); + } + } else { + if ($features === true) { + $this->_res['extras'][] = trim($strong->innertext); + } + } + } + + array_shift($this->_res['productinfo']); + array_shift($this->_res['productinfo']); + $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); + } + + return $this->_res; + } + + /** + * Searches xxx name. + * + * @param string $movie + * + * @return bool - True if releases has 90% match, else false + */ + public function processSite($movie): bool + { + if (empty($movie)) { + return false; + } + $this->_response = getRawHtml(self::ADE . $this->_dvdQuery . rawurlencode($movie)); + if ($this->_response !== false) { + $this->_html->load($this->_response); + if ($res = $this->_html->find('a[class=boxcover]')) { + foreach ($res as $ret) { + $title = $ret->title; + $title = str_replace('/XXX/', '', $title); + $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); + $url = (string)trim($ret->href); + similar_text(strtolower($movie), strtolower($title), $p); + if ($p >= 90) { + $this->_directUrl = self::ADE . $url; + $this->_title = trim($title); + $this->_html->clear(); + unset($this->_response); + $this->_response = getRawHtml($this->_directUrl); + $this->_html->load($this->_response); + return true; + } + continue; + } + return false; + } + return false; + } + return false; + } + + /** + * Gets All Information from the methods + * + * @return array + */ + protected function getAll() + { + $results = []; + if (!empty($this->_directUrl)) { + $results['directurl'] = $this->_directUrl; + $results['title'] = $this->_title; + } + if (is_array($this->synopsis())) { + $results = array_merge($results, $this->synopsis()); + } + if (is_array($this->productInfo(true))) { + $results = array_merge($results, $this->productInfo(true)); + } + if (is_array($this->cast())) { + $results = array_merge($results, $this->cast()); + } + if (is_array($this->genres())) { + $results = array_merge($results, $this->genres()); + } + if (is_array($this->covers())) { + $results = array_merge($results, $this->covers()); + } + if (is_array($this->trailers())) { + $results = array_merge($results, $this->trailers()); + } + return $results; + } +} diff --git a/nntmux/ADM.php b/nntmux/processing/adult/ADM.php similarity index 66% rename from nntmux/ADM.php rename to nntmux/processing/adult/ADM.php index 42e2a44b7..3aafc0d71 100755 --- a/nntmux/ADM.php +++ b/nntmux/processing/adult/ADM.php @@ -1,14 +1,9 @@ _html = new \simple_html_dom(); - $this->client = new Client(); - $this->cookiejar = new CookieJar(); $this->pdo = new DB(); - if (!empty($this->cookie)) { - $cookieJar = $this->cookiejar->setCookie(SetCookie::fromString($this->cookie)); - $this->client = new Client(['cookies' => $cookieJar]); - } } /** @@ -115,7 +90,7 @@ class ADM * Get Box Cover Images * @return array - boxcover,backcover */ - public function covers() + protected function covers() { $baseUrl = 'http://www.adultdvdmarketplace.com/'; if ($ret = $this->_html->find('a[rel=fancybox-button]', 0)) { @@ -133,9 +108,10 @@ class ADM /** * Gets the synopsis + * * @return array */ - public function synopsis() + protected function synopsis() { $this->_res['synopsis'] = 'N/A'; foreach ($this->_html->find('h3') as $heading) { @@ -148,12 +124,12 @@ class ADM } /** - * Get Product Informtion and Director + * Get Product Information and Director * * * @return array */ - public function productInfo() + protected function productInfo() { foreach ($this->_html->find('ul.list-unstyled li') as $li) { @@ -177,7 +153,7 @@ class ADM * Gets the cast members * @return array */ - public function cast() + protected function cast() { $cast = []; foreach ($this->_html->find('h3') as $heading) { @@ -198,10 +174,10 @@ class ADM * Gets categories * @return array */ - public function genres() + protected function genres() { $genres = []; - foreach ($this->_html->find('ul.list-unstyled li') as $li) { + foreach ($this->_html->find('ul.list-unstyled') as $li) { $category = explode(':', $li->plaintext); if (trim($category[0]) === 'Category') { $genre = explode(',', $category[1]); @@ -217,14 +193,19 @@ class ADM /** * Searches for match against searchterm + * + * @param $movie + * * @return bool - true if search = 100% */ - public function search() + public function processSite($movie) { $result = false; - if (!empty($this->searchTerm)) { - $this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); - if ($this->getUrl() !== false) { + if (!empty($movie)) { + $this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie); + $this->_response = getRawHtml(self::ADMURL . $this->_trailUrl, $this->cookie); + if ($this->_response !== false) { + $this->_html->load($this->_response); if ($ret = $this->_html->find('img[rel=license]')) { if (count($ret) > 0) { foreach ($this->_html->find('img[rel=license]') as $ret) { @@ -232,23 +213,26 @@ class ADM $title = trim($ret->alt, '"'); $title = str_replace('/XXX/', '', $title); $comparetitle = preg_replace('/[\W]/', '', $title); - $comparesearch = preg_replace('/[\W]/', '', $this->searchTerm); + $comparesearch = preg_replace('/[\W]/', '', $movie); similar_text($comparetitle, $comparesearch, $p); - if ($p === 100) { + if ($p >= 90) { if (preg_match('/\/(?\d+)\.jpg/i', $ret->src, $matches)) { $this->_title = trim($title); $this->_trailUrl = '/dvd_view_' . (string)$matches['sku'] . '.html'; $this->_directUrl = self::ADMURL . $this->_trailUrl; + $this->_html->clear(); + unset($this->_response); + $this->_response = getRawHtml($this->_directUrl, $this->cookie); + $this->_html->load($this->_response); + $result = true; } } } } } } - $result = true; } } - return $result; } @@ -256,7 +240,7 @@ class ADM * Gets all information * @return array */ - public function getAll() + protected function getAll() { $results = []; if (!empty($this->_directUrl)) { @@ -288,52 +272,10 @@ class ADM return $results; } - /** - * Get Raw html of webpage - * - * @return bool - */ - private function getUrl() + protected function trailers() { - if (!empty($this->_trailUrl)) { - try { - $this->_response = $this->client->get(self::ADMURL . $this->_trailUrl)->getBody()->getContents(); - } catch (RequestException $e) { - if ($e->hasResponse()) { - if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on ADM server')); - } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('ADM Service unavailable')); - } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from ADM, http error reported: ' . $e->getCode())); - } - } - } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); - } - } else { - try { - $this->_response = $this->client->get(self::IF18)->getBody()->getContents(); - } catch (RequestException $e) { - if ($e->hasResponse()) { - if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on ADM server')); - } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('ADM service unavailable')); - } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from ADM, http error reported: ' . $e->getCode())); - } - } - } catch (\RuntimeException $e) { - ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); - } - } + // TODO: Implement trailers() method. - if (!$this->_response) { - return false; - } - - $this->_html->load($this->_response); - return true; + return false; } } diff --git a/nntmux/processing/adult/AEBN.php b/nntmux/processing/adult/AEBN.php new file mode 100755 index 000000000..90f86ac4f --- /dev/null +++ b/nntmux/processing/adult/AEBN.php @@ -0,0 +1,293 @@ + [], + 'boxcover' => [], + 'cast' => [], + 'director' => [], + 'genres' => [], + 'productinfo' => [], + 'synopsis' => [], + 'trailers' => ['url' => []], + ]; + + /** + * Sets title in getAll method + * + * @var string + */ + protected $_title = ''; + + + /** + * Sets the variables that used throughout the class + * + * @param array $options + * + * @throws \Exception + */ + public function __construct(array $options = []) + { + parent::__construct($options); + $this->_html = new \simple_html_dom(); + } + + /** + * Gets Trailer URL .. will be processed in XXX insertswf + * + * @return array|bool + */ + protected function trailers() + { + $ret = $this->_html->find('a[itemprop=trailer]', 0); + if (!empty($ret) && preg_match('/movieId=(?\d+)&/', trim($ret->href), $matches)) { + $movieid = $matches['movieid']; + $this->_res['trailers']['url'] = self::AEBNSURL . self::TRAILERURL . $movieid; + } + + return $this->_res; + } + + /** + * Gets the front and back cover of the box + * + * @return array + */ + protected function covers() + { + $ret = $this->_html->find('div#md-boxCover, img[itemprop=thumbnailUrl]', 1); + if ($ret !== false) { + $ret = trim($ret->src); + if (strpos($ret, '//') === 0) { + $ret = 'http:' . $ret; + } + $this->_res['boxcover'] = str_ireplace('160w.jpg', 'xlf.jpg', $ret); + $this->_res['backcover'] = str_ireplace('160w.jpg', 'xlb.jpg', $ret); + } + + return $this->_res; + } + + /** + * Gets the Genres "Categories". + * + * @return array + */ + protected function genres() + { + if ($ret = $this->_html->find('div.md-detailsCategories', 0)) { + foreach ($ret->find('a[itemprop=genre]') as $genre) { + $this->_res['genres'][] = trim($genre->plaintext); + } + } + if (!empty($this->_res['genres'])) { + $this->_res['genres'] = array_unique($this->_res['genres']); + } + return $this->_res; + } + + /** + * Gets the Cast Members "Stars" and Director if any + * + * @return array + */ + protected function cast() + { + $this->_res = false; + if ($ret = $this->_html->find('div.starsFull', 0)) { + foreach ($ret->find('span[itemprop=name]') as $star) { + $this->_res['cast'][] = trim($star->plaintext); + } + } else { + if ($ret = $this->_html->find('div.detailsLink', 0)) { + foreach ($ret->find('span') as $star) { + if (strpos($star->plaintext, '/More/') !== false && strpos($star->plaintext, '/Stars/') !== false) { + $this->_res['cast'][] = trim($star->plaintext); + } + } + } + } + + return $this->_res; + } + + /** + * Gets the product information + * + * @return array + */ + protected function productInfo() + { + if ($ret = $this->_html->find('div#md-detailsLeft', 0)) { + foreach ($ret->find('div') as $div) { + foreach ($div->find('span') as $span) { + $span->plaintext = rawurldecode($span->plaintext); + $span->plaintext = preg_replace('/ /', '', $span->plaintext); + $this->_res['productinfo'][] = trim($span->plaintext); + } + } + if (false !== $key = array_search('Running Time:', $this->_res['productinfo'], false)) { + unset($this->_res['productinfo'][$key + 2]); + } + if (false !== $key = array_search('Director:' , $this->_res['productinfo'], false)) { + $this->_res['director'] = $this->_res['productinfo'][$key + 1]; + unset($this->_res['productinfo'][$key], $this->_res['productinfo'][$key + 1]); + } + $this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); + } + + return $this->_res; + } + + /** + * Gets the synopsis "plot" + * + * @return array + * + */ + protected function synopsis() + { + if ($ret = $this->_html->find('span[itemprop=about]', 0)) { + if ($ret === null) { + if ($ret = $this->_html->find('div.movieDetailDescription', 0)) { + $this->_res['synopsis'] = preg_replace('/Description:\s/', '', $this->_res['plot']); + } + } else { + $this->_res['synopsis'] = trim($ret->plaintext); + } + } + + return $this->_res; + } + + /** + * Searches for a XXX name + * + * @param string $movie + * + * @return bool + */ + public function processSite($movie): bool + { + if (empty($movie)) { + return false; + } + $this->_trailerUrl = self::TRAILINGSEARCH . urlencode($movie); + $this->_response = getRawHtml(self::AEBNSURL . $this->_trailerUrl, $this->cookie); + if ($this->_response !== false) { + $this->_html->load($this->_response); + $i = 1; + foreach ($this->_html->find('div.movie') as $mov) { + $string = 'a#FTSMovieSearch_link_title_detail_' . $i; + if ($ret = $mov->find($string, 0)) { + $title = str_replace('/XXX/', '', $ret->title); + $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); + $title = trim($title); + similar_text(strtolower($movie), strtolower($title), $p); + if ($p >= 90) { + $this->_title = trim($ret->title); + $this->_trailerUrl = html_entity_decode($ret->href); + $this->_directUrl = self::AEBNSURL . $this->_trailerUrl; + $this->_html->clear(); + unset($this->_response); + $this->_response = getRawHtml(self::AEBNSURL . $this->_trailerUrl, $this->cookie); + $this->_html->load($this->_response); + + return true; + } + continue; + } + $i++; + } + } + + return false; + } + + /** + * Gets all the information + * + * @return array|bool + */ + protected function getAll() + { + $results = []; + if (!empty($this->_directUrl)) { + $results['title'] = $this->_title; + $results['directurl'] = $this->_directUrl; + } + if (is_array($this->synopsis())) { + $results = array_merge($results, $this->synopsis()); + } + if (is_array($this->productInfo())) { + $results = array_merge($results, $this->productInfo()); + } + if (is_array($this->cast())) { + $results = array_merge($results, $this->cast()); + } + if (is_array($this->genres())) { + $results = array_merge($results, $this->genres()); + } + $covers = $this->covers(); + if (is_array($covers)) { + $results = array_merge($results, $covers); + } + if (is_array($this->trailers())) { + $results = array_merge($results, $this->trailers()); + } + if (empty($results)) { + return false; + } + + return $results; + } +} diff --git a/nntmux/processing/adult/AdultMovies.php b/nntmux/processing/adult/AdultMovies.php new file mode 100644 index 000000000..3644db42f --- /dev/null +++ b/nntmux/processing/adult/AdultMovies.php @@ -0,0 +1,70 @@ +_html = new \simple_html_dom(); - - // Set a cookie to override +18 warning. - if (!empty($this->cookie)) { - @$this->getUrl(); - } } - /* - * Remove from memory if it still exists - */ - - /** - * Get Raw html of webpage - * - * @param bool $usepost - * - * @return bool - */ - private function getUrl($usepost = false) + protected function trailers() { - if (!empty($this->_getLink)) { - $ch = curl_init($this->_getLink); - } else { - $ch = curl_init(self::HMURL); - } - if (!empty($this->directLink)) { - $ch = curl_init($this->directLink); - $this->directLink = ''; - } - if ($usepost === true){ - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_postParams); - } - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_VERBOSE, 0); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36'); - curl_setopt($ch, CURLOPT_FAILONERROR, 1); - if (!empty($this->cookie)) { - curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie); - curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie); - } - $this->_response = curl_exec($ch); - if (!$this->_response) { - curl_close($ch); + // TODO: Implement trailers() method. - return false; - } - $this->_html->load($this->_response); - curl_close($ch); - return true; - } - - public function __destruct() - { - $this->_html->clear(); - unset($this->_response, $this->_res); - } - - /** - * Directly gets the link if directlink is set, and parses it. - * - * @return bool|array - */ - public function getDirect() - { - if (!empty($this->directLink)) { - if ($this->getUrl() === false) { - return false; - } else { - return $this->getAll(); - } - } return false; } @@ -165,15 +103,15 @@ class Hotmovies * Gets all information * @return bool|array */ - public function getAll() + protected function getAll() { $results = []; if (!empty($this->_directUrl)) { $results['title'] = $this->_title; $results['directurl'] = $this->_directUrl; } - if (is_array($this->sypnosis())) { - $results = array_merge($results, $this->sypnosis()); + if (is_array($this->synopsis())) { + $results = array_merge($results, $this->synopsis()); } if (is_array($this->productInfo())) { $results = array_merge($results, $this->productInfo()); @@ -188,24 +126,26 @@ class Hotmovies $results = array_merge($results, $this->covers()); } - if (empty($results) === true){ + if (empty($results)) { return false; - }else{ - return $results; } + + return $results; + } /** - * Gets the sypnosis + * Gets the synopsis * * @return array */ - public function sypnosis() + protected function synopsis(): array { + $this->_res['synopsis'] = 'N/A'; if ($this->_html->find('.desc_link', 0)) { - preg_match('/var descfullcontent = (?.*)/', $this->_response,$matches); - if (is_array($matches)) { - $this->_res['sypnosis'] = rawurldecode($matches['content']); + $ret = $this->_html->find('.video_description', 0); + if ($ret !== false) { + $this->_res['synopsis'] = trim($ret->innertext); } } @@ -216,18 +156,14 @@ class Hotmovies * * @return array */ - public function productInfo() + protected function productInfo(): array { $studio = false; $director = false; if ($ret = $this->_html->find('div.page_video_info', 0)) { foreach ($ret->find('text') as $e) { $e = trim($e->innertext); - $rArray = [ - ',', - '...', - ' :' - ]; + $rArray = [',', '...', ' :']; $e = str_replace($rArray, '', $e); if (stripos($e, 'Studio:') !== false) { $studio = true; @@ -267,15 +203,16 @@ class Hotmovies /** * Gets the cast members and director * - *@return array + * @return array */ - public function cast() + protected function cast() { - $cast = null; - if ($this->_html->find('a[itemprop=actor]')) { - foreach ($this->_html->find('a[itemprop=actor]') as $e) { + $cast = []; + if ($this->_html->find('.stars bottom_margin')) { + file_put_contents('hm_cast.txt', $this->_html->find('.stars bottom_margin')); + foreach ($this->_html->find('a[title]') as $e) { $e = trim($e->title); - $e = preg_replace('/\((.*)\)/','',$e); + $e = preg_replace('/\((.*)\)/', '', $e); $cast[] = trim($e); } $this->_res['cast'] = $cast; @@ -288,22 +225,20 @@ class Hotmovies /** * Gets categories * - *@return array + * @return array */ - public function genres() + protected function genres() { $genres = []; if ($ret = $this->_html->find('div.categories',0)) { foreach ($ret->find('a') as $e) { - if (strpos($e->title, '->') !== false) { - $e = explode('->',$e->plaintext); + if (strpos($e->title, ' -> ') !== false) { + $e = explode(' -> ',$e->plaintext); $genres[] = trim($e[1]); } } $this->_res['genres'] = $genres; - } - return $this->_res; } @@ -311,12 +246,12 @@ class Hotmovies * Get Box Cover Images * @return bool|array - boxcover,backcover */ - public function covers() + protected function covers() { if ($ret = $this->_html->find('div#large_cover, img#cover', 1)) { $this->_res['boxcover'] = trim($ret->src); $this->_res['backcover'] = str_ireplace('.cover', '.back', trim($ret->src)); - }else{ + } else { return false; } @@ -324,45 +259,53 @@ class Hotmovies } /** - * Searches for match against searchterm - * @return bool, true if search >= 90% + * Searches for match against xxx movie name + * + * @param string $movie + * + * @return bool , true if search >= 90% */ - public function search() + public function processSite($movie): bool { - if (empty($this->searchTerm)) { + if (empty($movie)) { return false; } - $this->_getLink = self::HMURL . self::TRAILINGSEARCH . urlencode($this->searchTerm) . self::EXTRASEARCH; - if ($this->getUrl() === false) { - return false; - } else { + $this->_response = false; + $this->_getLink = self::HMURL . self::TRAILINGSEARCH . urlencode($movie) . self::EXTRASEARCH; + $this->_response = getRawHtml($this->_getLink, $this->cookie); + if ($this->_response !== false) { + $this->_html->load($this->_response); if ($ret = $this->_html->find('h3[class=title]', 0)) { - if ($ret->find('a[title]',0)){ + if ($ret->find('a[title]', 0)) { $ret = $ret->find('a[title]', 0); $title = trim($ret->title); $title = str_replace('/XXX/', '', $title); $title = preg_replace('/\(.*?\)|[-._]/', ' ', $title); - $this->_getLink = trim($ret->href); - $this->_directUrl = trim($ret->href); - } - } else { - return false; - } - if (!empty($title)) { - similar_text($this->searchTerm, $title, $p); - if ($p >= 90) { - $this->_title = $title; - // 90$ match found, load the url to start parsing - $this->getUrl(); - unset($ret); + if (!empty($title)) { + similar_text($movie, $title, $p); + if ($p >= 90) { + $this->_title = $title; + $this->_getLink = trim($ret->href); + $this->_directUrl = trim($ret->href); + $this->_html->clear(); + unset($this->_response); + if ($this->_getLink !== false) { + $this->_response = getRawHtml($this->_getLink, $this->cookie); + $this->_html->load($this->_response); + } else { + $this->_response = getRawHtml($this->_directUrl, $this->cookie); + $this->_html->load($this->_response); + } - return true; - } else { - return false; + return true; + } + } } - } else { - return false; } + } else { + return false; } + + return false; } } diff --git a/nntmux/Popporn.php b/nntmux/processing/adult/Popporn.php similarity index 59% rename from nntmux/Popporn.php rename to nntmux/processing/adult/Popporn.php index 803662fd0..2dfc34a98 100755 --- a/nntmux/Popporn.php +++ b/nntmux/processing/adult/Popporn.php @@ -1,37 +1,37 @@ _html = new \simple_html_dom(); - if (isset($this->cookie)) { - $this->getUrl(); - } - } - - /** - * Remove from memory. - */ - public function __destruct() - { - $this->_html->clear(); - unset($this->_response); - unset($this->_res); } /** * Get Box Cover Images * @return array - boxcover,backcover */ - public function covers() + public function covers(): array { if ($ret = $this->_html->find('div[id=box-art], a[rel=box-art]', 1)) { $this->_res['boxcover'] = trim($ret->href); - if (stristr(trim($ret->href), "_aa")) { - $this->_res['backcover'] = str_ireplace("_aa", "_bb", trim($ret->href)); + if (false !== stripos(trim($ret->href), '_aa')) { + $this->_res['backcover'] = str_ireplace('_aa', '_bb', trim($ret->href)); } else { - $this->_res['backcover'] = str_ireplace(".jpg", "_b.jpg", trim($ret->href)); + $this->_res['backcover'] = str_ireplace('.jpg', '_b.jpg', trim($ret->href)); } } else { if ($ret = $this->_html->find('img.front', 0)) { @@ -114,20 +97,20 @@ class Popporn } /** - * Gets the sypnosis + * Gets the synopsis * @return array|bool */ - public function sypnosis() + public function synopsis() { if ($ret = $this->_html->find('div[id=product-info] ,h3[class=highlight]', 1)) { if ($ret->next_sibling()->plaintext) { if (!stristr(trim($ret->next_sibling()->plaintext), "POPPORN EXCLUSIVE")) { - $this->_res['sypnosis'] = trim($ret->next_sibling()->plaintext); + $this->_res['synopsis'] = trim($ret->next_sibling()->plaintext); } else { if ($ret->next_sibling()->next_sibling()) { - $this->_res['sypnosis'] = trim($ret->next_sibling()->next_sibling()->next_sibling()->plaintext); + $this->_res['synopsis'] = trim($ret->next_sibling()->next_sibling()->next_sibling()->plaintext); } else { - $this->_res['sypnosis'] = "N/A"; + $this->_res['synopsis'] = 'N/A'; } } } @@ -144,19 +127,19 @@ class Popporn { if ($ret = $this->_html->find('input#thickbox-trailer-link', 0)) { $ret->value = trim($ret->value); - $ret->value = str_replace("..", "", $ret->value); + $ret->value = str_replace('..', '', $ret->value); $tmprsp = $this->_response; $this->_trailUrl = $ret->value; - $this->getUrl(); + $this->getRawHtml(); if (preg_match_all('/productID="\+(?[0-9]+),/', $this->_response, $matches)) { $productid = $matches['id'][0]; $random = ((float)rand() / (float)getrandmax()) * 5400000000000000; - $this->_trailUrl = "/com/tlavideo/vod/FlvAjaxSupportService.cfc?random=" . $random; - $this->_postParams = "method=pipeStreamLoc&productID=" . $productid; - $this->getUrl(true); + $this->_trailUrl = '/com/tlavideo/vod/FlvAjaxSupportService.cfc?random=' . $random; + $this->_postParams = 'method=pipeStreamLoc&productID=' . $productid; + $this->getRawHtml(true); $ret = json_decode(json_decode($this->_response, true), true); - $this->_res['trailers']['baseurl'] = self::POPURL . "/flashmediaserver/trailerPlayer.swf"; - $this->_res['trailers']['flashvars'] = "subscribe=false&image=&file=" . self::POPURL . "/" . $ret['LOC'] . "&autostart=false"; + $this->_res['trailers']['baseurl'] = self::POPURL . '/flashmediaserver/trailerPlayer.swf'; + $this->_res['trailers']['flashvars'] = 'subscribe=false&image=&file=' . self::POPURL . '/' . $ret['LOC'] . '&autostart=false'; unset($this->_response); $this->_response = $tmprsp; } @@ -178,14 +161,14 @@ class Popporn if ($ret = $this->_html->find('div#lside', 0)) { foreach ($ret->find("text") as $e) { $e = trim($e->innertext); - $e = str_replace(",", "", $e); - $e = str_replace("...", "", $e); - $e = str_replace(" ", "", $e); - if (stristr($e, "Country:")) { + $e = str_replace(',', '', $e); + $e = str_replace('...', '', $e); + $e = str_replace(' ', '', $e); + if (stristr($e, 'Country:')) { $country = true; } if ($country === true) { - if (!stristr($e, "addthis_config")) { + if (!stristr($e, 'addthis_config')) { if (!empty($e)) { $this->_res['productinfo'][] = $e; } @@ -204,11 +187,11 @@ class Popporn foreach ($this->_html->find('ul.stock-information') as $ul) { foreach ($ul->find('li') as $e) { $e = trim($e->plaintext); - if ($e == "Features:") { + if ($e == 'Features:') { $features = true; $e = null; } - if ($features == true) { + if ($features === true) { if (!empty($e)) { $this->_res['extras'][] = $e; } @@ -231,16 +214,16 @@ class Popporn $director = false; $er = []; if ($ret = $this->_html->find('div#lside', 0)) { - foreach ($ret->find("text") as $e) { + foreach ($ret->find('text') as $e) { $e = trim($e->innertext); - $e = str_replace(",", "", $e); - $e = str_replace(" ", "", $e); - if (stristr($e, "Cast")) { + $e = str_replace(',', '', $e); + $e = str_replace(' ', '', $e); + if (stristr($e, 'Cast')) { $cast = true; } - $e = str_replace("Cast:", "", $e); + $e = str_replace('Cast:', '', $e); if ($cast === true) { - if (stristr($e, "Director:")) { + if (stristr($e, 'Director:')) { $director = true; $e = null; } @@ -252,7 +235,7 @@ class Popporn $e = null; } } - if (!stristr($e, "Country:")) { + if (!stristr($e, 'Country:')) { if (!empty($e)) { $er[] = $e; } @@ -286,14 +269,18 @@ class Popporn /** * Searches for match against searchterm - * @return bool, true if search >= 90% + * + * @param string $movie + * + * @return bool , true if search >= 90% */ - public function search() + public function processSite($movie): bool { - $result = false; - if (isset($this->searchTerm)) { - $this->_trailUrl = self::TRAILINGSEARCH . urlencode($this->searchTerm); - if ($this->getUrl() !== false) { + if (!empty($movie)) { + $this->_trailUrl = self::TRAILINGSEARCH . urlencode($movie); + $this->_response = getRawHtml(self::POPURL . $this->_trailUrl, $this->cookie); + if ($this->_response !== false) { + $this->_html->load($this->_response); if ($ret = $this->_html->find('div.product-info, div.title', 1)) { $this->_title = trim($ret->plaintext); $title = preg_replace('/XXX/', '', $ret->plaintext); @@ -301,36 +288,50 @@ class Popporn $title = trim($title); if ($ret = $ret->find('a', 0)) { $this->_trailUrl = trim($ret->href); - if ($this->getUrl() !== false) { + $this->_html->clear(); + unset($this->_response); + $this->_response = getRawHtml($this->_trailUrl, $this->cookie); + if ($this->_response !== false) { + $this->_html->load($this->_response); if ($ret = $this->_html->find('#link-to-this', 0)) { $this->_directUrl = trim($ret->href); + $this->_html->clear(); + unset($this->_response); + $this->_response = getRawHtml($this->_directUrl, $this->cookie); + $this->_html->load($this->_response); } - similar_text(strtolower($this->searchTerm), strtolower($title), $p); + similar_text(strtolower($movie), strtolower($title), $p); if ($p >= 90) { - $result = true; + return true; } } } } + } else { + $this->_response = getRawHtml(self::IF18); + if ($this->_response !== false) { + $this->_html->load($this->_response); + return true; + } + return false; } } - - return $result; + return false; } /** * Gets all information - * @return array + * @return array|bool */ - public function getAll() + protected function getAll() { $results = []; if (isset($this->_directUrl)) { $results['title'] = $this->_title; $results['directurl'] = $this->_directUrl; } - if (is_array($this->sypnosis())) { - $results = array_merge($results, $this->sypnosis()); + if (is_array($this->synopsis())) { + $results = array_merge($results, $this->synopsis()); } if (is_array($this->productInfo(true))) { $results = array_merge($results, $this->productInfo(true)); @@ -347,51 +348,9 @@ class Popporn if (is_array($this->trailers())) { $results = array_merge($results, $this->trailers()); } - if (empty($results) === true) { - return false; - } else { - return $results; - } - } - - /** - * Get Raw html of webpage - * - * @param bool $usepost - * - * @return bool - */ - private function getUrl($usepost = false) - { - if (isset($this->_trailUrl)) { - $ch = curl_init(self::POPURL . $this->_trailUrl); - } else { - $ch = curl_init(self::IF18); - } - - if ($usepost === true) { - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_postParams); - } - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_VERBOSE, 0); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_USERAGENT, "Firefox/2.0.0.1"); - curl_setopt($ch, CURLOPT_FAILONERROR, 1); - if (isset($this->cookie)) { - curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie); - curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie); - } - curl_setopt_array($ch, Utility::curlSslContextOptions()); - $this->_response = curl_exec($ch); - if (!$this->_response) { - curl_close($ch); + if (empty($results)) { return false; } - curl_close($ch); - $this->_html->load($this->_response); - return true; + return $results; } } diff --git a/nntmux/processing/tv/TV.php b/nntmux/processing/tv/TV.php index f07593c4a..9f648adc9 100755 --- a/nntmux/processing/tv/TV.php +++ b/nntmux/processing/tv/TV.php @@ -126,7 +126,7 @@ abstract class TV extends Videos */ abstract protected function formatEpisodeInfo($episode): array; - /** + /** * Retrieve releases for TV processing * Returns a PDO Object of rows or false if none found * diff --git a/nntmux/utility/Utility.php b/nntmux/utility/Utility.php index e8a059cce..803f215ce 100755 --- a/nntmux/utility/Utility.php +++ b/nntmux/utility/Utility.php @@ -413,7 +413,7 @@ class Utility if ($verify && NN_SSL_VERIFY_HOST && (!empty(NN_SSL_CAFILE) || !empty(NN_SSL_CAPATH))) { $options += [ CURLOPT_SSL_VERIFYPEER => (bool)NN_SSL_VERIFY_PEER, - CURLOPT_SSL_VERIFYHOST => (NN_SSL_VERIFY_HOST ? 2 : 0), + CURLOPT_SSL_VERIFYHOST => NN_SSL_VERIFY_HOST ? 2 : 0, ]; if (!empty(NN_SSL_CAFILE)) { $options += [CURLOPT_CAINFO => NN_SSL_CAFILE]; @@ -466,24 +466,24 @@ class Utility switch ($options['language']) { case 'fr': case 'fr-fr': - $options['language'] = "fr-fr"; + $options['language'] = 'fr-fr'; break; case 'de': case 'de-de': - $options['language'] = "de-de"; + $options['language'] = 'de-de'; break; case 'en-us': - $options['language'] = "en-us"; + $options['language'] = 'en-us'; break; case 'en-gb': - $options['language'] = "en-gb"; + $options['language'] = 'en-gb'; break; case '': case 'en': default: $options['language'] = 'en'; } - $header[] = "Accept-Language: " . $options['language']; + $header[] = 'Accept-Language: ' . $options['language']; if (is_array($options['requestheaders'])) { $header += $options['requestheaders']; } @@ -526,9 +526,9 @@ class Utility if ($err !== 0) { return false; - } else { - return $buffer; } + + return $buffer; } diff --git a/resources/db/patches/mysql/0311~general.sql b/resources/db/patches/mysql/0311~general.sql new file mode 100644 index 000000000..b466e8816 --- /dev/null +++ b/resources/db/patches/mysql/0311~general.sql @@ -0,0 +1,8 @@ +# Increase the varchar for xref in collections to 1024 +ALTER TABLE collections CHANGE xref xref VARCHAR(1024) NOT NULL DEFAULT ''; + +# Increase the varchar for xref in multigroup_collections to 1024 +ALTER TABLE multigroup_collections CHANGE xref xref VARCHAR(1024) NOT NULL DEFAULT ''; + +# Change classussed column in xxxinfo table +ALTER TABLE xxxinfo CHANGE classused classused VARCHAR(20) NOT NULL DEFAULT ''; \ No newline at end of file diff --git a/resources/db/schema/data/10-settings.tsv b/resources/db/schema/data/10-settings.tsv index 4f63270fc..29230cd43 100755 --- a/resources/db/schema/data/10-settings.tsv +++ b/resources/db/schema/data/10-settings.tsv @@ -109,7 +109,7 @@ APIs amazonpubkey AKIAIPDNG5EU7LB4AD3Q The amazon public api key. Used for musi APIs giantbombkey The giantbomb api key. Used for game lookups. giantbombkey APIs anidbkey The Anidb api key. Used for Anime lookups. anidbkey APIs fanarttvkey The Fanart.tv api key. Used for Fanart.tv lookups. Fanart.tv would appreciate it if you use this service to help them out by adding high quality images not already available on TMDB. fanarttvkey -APIs omdbkey OmdbAPI key obtained from Omdb.Used for Omdb API lookups omdbkey +APIs omdbkey OmdbAPIkey obtained from Omdb.Used for Omdb API lookups omdbkey APIs rottentomatokey qxbxyngtujprvw7jxam2m6na The api key used for access to rotten tomatoes. rottentomatokey APIs tmdbkey 9a4e16adddcd1e86da19bcaf5ff3c2a3 The API key used for access to TMDb. tmdbkey APIs trakttvclientkey The Trakt.tv API v2 Client ID (SHA256 hash - 64 characters long string). Used for movie and tv lookups. trakttvclientkey diff --git a/resources/db/schema/mysql-ddl.sql b/resources/db/schema/mysql-ddl.sql index c877d1642..2233534d2 100755 --- a/resources/db/schema/mysql-ddl.sql +++ b/resources/db/schema/mysql-ddl.sql @@ -224,7 +224,7 @@ CREATE TABLE collections ( subject VARCHAR(255) NOT NULL DEFAULT '', fromname VARCHAR(255) NOT NULL DEFAULT '', date DATETIME DEFAULT NULL, - xref VARCHAR(255) NOT NULL DEFAULT '', + xref VARCHAR(1024) NOT NULL DEFAULT '', totalfiles INT(11) UNSIGNED NOT NULL DEFAULT '0', groups_id INT(11) UNSIGNED NOT NULL DEFAULT '0', collectionhash VARCHAR(255) NOT NULL DEFAULT '0', @@ -539,7 +539,7 @@ CREATE TABLE multigroup_collections ( subject VARCHAR(255) NOT NULL DEFAULT '', fromname VARCHAR(255) NOT NULL DEFAULT '', date DATETIME DEFAULT NULL, - xref VARCHAR(510) NOT NULL DEFAULT '', + xref VARCHAR(1024) NOT NULL DEFAULT '', totalfiles INT(11) UNSIGNED NOT NULL DEFAULT '0', groups_id INT(11) UNSIGNED NOT NULL DEFAULT '0', collectionhash VARCHAR(255) NOT NULL DEFAULT '0', @@ -1364,7 +1364,7 @@ CREATE TABLE xxxinfo ( productinfo TEXT DEFAULT NULL, trailers TEXT DEFAULT NULL, directurl VARCHAR(2000) NOT NULL, - classused VARCHAR(4) NOT NULL DEFAULT 'ade', + classused VARCHAR(20) NOT NULL DEFAULT '', cover TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', backdrop TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', createddate DATETIME NOT NULL, diff --git a/tests/Install/InstallTest.php b/tests/Install/InstallTest.php index 4dd4ddda8..5bb7ad001 100644 --- a/tests/Install/InstallTest.php +++ b/tests/Install/InstallTest.php @@ -53,8 +53,8 @@ class InstallTest extends \PHPUnit\Framework\TestCase } // Check if user selected right DB type. - if (getenv('DB_SYSTEM') !== 'mysql') { - ColorCLI::doEcho(ColorCLI::error('Invalid database system. Must be: mysql ; Not: ' . getenv('DB_SYSTEM'))); + if (env('DB_SYSTEM') !== 'mysql') { + ColorCLI::doEcho(ColorCLI::error('Invalid database system. Must be: mysql ; Not: ' . env('DB_SYSTEM'))); $error = true; } else { // Connect to the SQL server. @@ -64,13 +64,13 @@ class InstallTest extends \PHPUnit\Framework\TestCase [ 'checkVersion' => true, 'createDb' => true, - 'dbhost' => getenv('DB_HOST'), - 'dbname' => getenv('DB_NAME'), - 'dbpass' => getenv('DB_PASSWORD'), - 'dbport' => getenv('DB_PORT'), - 'dbsock' => getenv('DB_SOCKET'), - 'dbtype' => getenv('DB_SYSTEM'), - 'dbuser' => getenv('DB_USER'), + 'dbhost' => env('DB_HOST'), + 'dbname' => env('DB_NAME'), + 'dbpass' => env('DB_PASSWORD'), + 'dbport' => env('DB_PORT'), + 'dbsock' => env('DB_SOCKET'), + 'dbtype' => env('DB_SYSTEM'), + 'dbuser' => env('DB_USER'), ] ); $dbConnCheck = true; @@ -106,7 +106,7 @@ class InstallTest extends \PHPUnit\Framework\TestCase $error = true; ColorCLI::doEcho(ColorCLI::error( 'You are using an unsupported version of ' . - getenv('DB_SYSTEM') . + env('DB_SYSTEM') . ' the minimum allowed version is ' . NN_MINIMUM_MYSQL_VERSION ) @@ -179,13 +179,13 @@ class InstallTest extends \PHPUnit\Framework\TestCase } } //Insert admin user into database - if (getenv('ADMIN_USER') === '' || getenv('ADMIN_PASS') === '' || getenv('ADMIN_EMAIL') === '') { + if (env('ADMIN_USER') === '' || env('ADMIN_PASS') === '' || env('ADMIN_EMAIL') === '') { $error = true; ColorCLI::doEcho(ColorCLI::error('Admin user data cannot be empty! Please edit .env file and fill in admin user details and run this script again!')); exit(); } - switch (getenv('DB_SYSTEM')) { + switch (env('DB_SYSTEM')) { case 'mysql': $adapter = 'MySql'; break; @@ -197,10 +197,10 @@ class InstallTest extends \PHPUnit\Framework\TestCase } if ($adapter !== null) { - if (empty(getenv('DB_SOCKET'))) { - $host = empty(getenv('DB_PORT')) ? getenv('DB_HOST') : getenv('DB_HOST') . ':' . getenv('DB_PORT'); + if (empty(env('DB_SOCKET'))) { + $host = empty(env('DB_PORT')) ? env('DB_HOST') : env('DB_HOST') . ':' . env('DB_PORT'); } else { - $host = getenv('DB_SOCKET'); + $host = env('DB_SOCKET'); } \lithium\data\Connections::add('default', @@ -208,9 +208,9 @@ class InstallTest extends \PHPUnit\Framework\TestCase 'type' => 'database', 'adapter' => $adapter, 'host' => $host, - 'login' => getenv('DB_USER'), - 'password' => getenv('DB_PASSWORD'), - 'database' => getenv('DB_NAME'), + 'login' => env('DB_USER'), + 'password' => env('DB_PASSWORD'), + 'database' => env('DB_NAME'), 'encoding' => 'UTF-8', 'persistent' => false, ] @@ -218,20 +218,20 @@ class InstallTest extends \PHPUnit\Framework\TestCase } $user = new Users(); - if (!$user->isValidUsername(getenv('ADMIN_USER'))) { + if (!$user->isValidUsername(env('ADMIN_USER'))) { $error = true; } else { - $usrCheck = $user->getByUsername(getenv('ADMIN_USER')); + $usrCheck = $user->getByUsername(env('ADMIN_USER')); if ($usrCheck) { $error = true; } } - if (!$user->isValidEmail(getenv('ADMIN_EMAIL'))) { + if (!$user->isValidEmail(env('ADMIN_EMAIL'))) { $error = true; } if (!$error) { - $adminCheck = $user->add(getenv('ADMIN_USER'), getenv('ADMIN_PASS'), getenv('ADMIN_EMAIL'), 2, '', ''); + $adminCheck = $user->add(env('ADMIN_USER'), env('ADMIN_PASS'), env('ADMIN_EMAIL'), 2, '', ''); if (!is_numeric($adminCheck)) { $error = true; } diff --git a/www/admin/collection_regexes-test.php b/www/admin/collection_regexes-test.php index a60043af1..cb890129e 100644 --- a/www/admin/collection_regexes-test.php +++ b/www/admin/collection_regexes-test.php @@ -6,9 +6,7 @@ use nntmux\Regexes; $page = new AdminPage(); -$page->title = "Collections Regex Test"; - -$page->smarty->assign('tpg', $tpg); +$page->title = 'Collections Regex Test'; $group = trim(isset($_POST['group']) && !empty($_POST['group']) ? $_POST['group'] : ''); $regex = trim(isset($_POST['regex']) && !empty($_POST['regex']) ? $_POST['regex'] : ''); diff --git a/www/admin/site-edit.php b/www/admin/site-edit.php index fe0118384..b5c335aa6 100644 --- a/www/admin/site-edit.php +++ b/www/admin/site-edit.php @@ -170,7 +170,7 @@ $page->smarty->assign('book_reqids_selected', $books_selected); $page->smarty->assign('themelist', Utility::getThemesList()); -if (strpos(getenv('NNTP_SERVER'), "astra") === false) { +if (strpos(env('NNTP_SERVER'), "astra") === false) { $page->smarty->assign('compress_headers_warning', "compress_headers_warning"); } diff --git a/www/themes/shared/templates/admin/collection_regexes-test.tpl b/www/themes/shared/templates/admin/collection_regexes-test.tpl index 127041bce..dba35eb16 100644 --- a/www/themes/shared/templates/admin/collection_regexes-test.tpl +++ b/www/themes/shared/templates/admin/collection_regexes-test.tpl @@ -2,45 +2,42 @@

This page is used for testing regex for grouping usenet collections.
Enter the group name to test and a regex. Limit is how many collections to show max on the page, 0 for no limit(slow).

-{if $tpg} -
- -
- -
- -
- -
- {if isset($data)} +
+ +
+ +
+ +
+ +
+{if isset($data)} - {foreach from=$data key=hash item=collection} - - - + {foreach from=$data key=hash item=collection} +
{$hash}
Current Files: {count($collection)}
+ + + +
{$hash}
Current Files: {count($collection)}
+ + + + + + + + + {foreach from=$collection item=row} + + + + + + -
namecurrent partstotal partsposterold hash
{$row.file_name}{$row.file_current_parts}{$row.file_total_parts}{$row.collection_poster}{$row.old_collection_hash}
- - - - - - - - - {foreach from=$collection item=row} - - - - - - - - {/foreach} -
namecurrent partstotal partsposterold hash
{$row.file_name}{$row.file_current_parts}{$row.file_total_parts}{$row.collection_poster}{$row.old_collection_hash}
- {/foreach} - {/if} -{else} -

The Table Per Group setting is required to be on to use this page, for performance reasons.

+ {/foreach} + + {/foreach} {/if} +