diff --git a/Changelog b/Changelog index d781df250..c29abe409 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,16 @@ +2017-04-21 DariusIII + * Chg: Update NNTP class, small refactor of if - else + * Chg: Update Binaries class for PHP7 + * Chg: Make guzzlehttp return codes more service specific + * Chg: Remove duplicated checks in XXX class + * Chg: Update composer with new versions of libraries + * Fix: Anime page layout in Gentele theme 2017-04-20 DariusIII + * Chg: Adjust the renaming logic in NameFixer + * Chg: Change definition of XXX movies array + * Chg: Update PreDB class for PHP7 + * Fix: Fix usage of fixRelNames script + * Mrg: Merge PR #133 from Nightah - Rebase all anime regexes * Chg: Update XXX class for better PHP7 support * Fix: Properly update anidb_episodes table on anidb updates 2017-04-19 DariusIII diff --git a/build/NewPatches.php b/build/NewPatches.php index 8c6eaf7e5..3d3e02855 100644 --- a/build/NewPatches.php +++ b/build/NewPatches.php @@ -33,7 +33,7 @@ $error = false; $git = new Git(); $branch = $git->active_branch(); -if (in_array($branch, $git->mainBranches())) { +if (in_array($branch, $git->mainBranches(), false)) { // Only update patches, etc. on specific branches to lessen conflicts try { // Run DbUpdates to make sure we're up to date. @@ -41,8 +41,8 @@ if (in_array($branch, $git->mainBranches())) { $DbUpdater->newPatches(['safe' => false]); } catch (\Exception $e) { $error = 1; - echo "Error while checking patches!\n"; - echo $e->getMessage() . "\n"; + echo 'Error while checking patches!' . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } } diff --git a/build/nntmux.xml b/build/nntmux.xml index 9732a00ed..2c317aa04 100755 --- a/build/nntmux.xml +++ b/build/nntmux.xml @@ -16,8 +16,8 @@ - 303 - 303 + 304 + 304 diff --git a/composer.lock b/composer.lock index d41ecfa97..778c2a7a9 100644 --- a/composer.lock +++ b/composer.lock @@ -2296,7 +2296,7 @@ }, { "name": "illuminate/contracts", - "version": "v5.4.17", + "version": "v5.4.19", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -2338,16 +2338,16 @@ }, { "name": "illuminate/filesystem", - "version": "v5.4.17", + "version": "v5.4.19", "source": { "type": "git", "url": "https://github.com/illuminate/filesystem.git", - "reference": "3ed8b9a35880a9619141e2965fd5cbbe2e1c0da1" + "reference": "7f656e3421b94d759627e891567380b50586f045" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/filesystem/zipball/3ed8b9a35880a9619141e2965fd5cbbe2e1c0da1", - "reference": "3ed8b9a35880a9619141e2965fd5cbbe2e1c0da1", + "url": "https://api.github.com/repos/illuminate/filesystem/zipball/7f656e3421b94d759627e891567380b50586f045", + "reference": "7f656e3421b94d759627e891567380b50586f045", "shasum": "" }, "require": { @@ -2384,20 +2384,20 @@ ], "description": "The Illuminate Filesystem package.", "homepage": "https://laravel.com", - "time": "2017-03-01T21:44:04+00:00" + "time": "2017-04-07T19:38:05+00:00" }, { "name": "illuminate/support", - "version": "v5.4.17", + "version": "v5.4.19", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "c7e7c9daf5044e76b46085b8351f8235a3e979c6" + "reference": "b8cb37e15331c59da51c8ee5838038baa22d7955" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/c7e7c9daf5044e76b46085b8351f8235a3e979c6", - "reference": "c7e7c9daf5044e76b46085b8351f8235a3e979c6", + "url": "https://api.github.com/repos/illuminate/support/zipball/b8cb37e15331c59da51c8ee5838038baa22d7955", + "reference": "b8cb37e15331c59da51c8ee5838038baa22d7955", "shasum": "" }, "require": { @@ -2441,7 +2441,7 @@ ], "description": "The Illuminate Support package.", "homepage": "https://laravel.com", - "time": "2017-03-28T12:49:45+00:00" + "time": "2017-04-09T14:34:57+00:00" }, { "name": "james-heinrich/getid3", @@ -3700,16 +3700,16 @@ }, { "name": "twig/twig", - "version": "v2.3.1", + "version": "v2.3.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "437efc435619c8e67acacda37b3984344854142c" + "reference": "85e8372c451510165c04bf781295f9d922fa524b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/437efc435619c8e67acacda37b3984344854142c", - "reference": "437efc435619c8e67acacda37b3984344854142c", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/85e8372c451510165c04bf781295f9d922fa524b", + "reference": "85e8372c451510165c04bf781295f9d922fa524b", "shasum": "" }, "require": { @@ -3759,7 +3759,7 @@ "keywords": [ "templating" ], - "time": "2017-04-18T21:50:11+00:00" + "time": "2017-04-21T00:13:02+00:00" }, { "name": "unionofrad/lithium", diff --git a/misc/testing/Releases/fixReleaseNames.php b/misc/testing/Releases/fixReleaseNames.php index 8ad2eec27..40ce4d0b6 100755 --- a/misc/testing/Releases/fixReleaseNames.php +++ b/misc/testing/Releases/fixReleaseNames.php @@ -10,36 +10,33 @@ require_once dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'bootstrap.php'; use app\models\Settings; +use nntmux\ColorCLI; use nntmux\NameFixer; use nntmux\NNTP; use nntmux\PreDb; use nntmux\db\DB; -$n = "\n"; $pdo = new DB(); $namefixer = new NameFixer(['Settings' => $pdo]); $predb = new PreDb(['Echo' => true, 'Settings' => $pdo]); -if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]) && isset($argv[4])) { - $update = ($argv[2] == "true") ? true : false; +if (isset($argv[1], $argv[2], $argv[3], $argv[4])) { + $update = $argv[2] === 'true' ? true : false; $other = 1; if ($argv[3] === 'all') { $other = 2; } else if ($argv[3] === 'predb_id') { $other = 3; } - $setStatus = ($argv[4] == "yes") ? 1 : 2; + $setStatus = $argv[4] === 'yes' ? 1 : 2; - $show = 2; - if (isset($argv[5]) && $argv[5] === 'show') { - $show = 1; - } + $show = isset($argv[5]) && $argv[5] === 'show' ? 1 : 2; $nntp = null; - if ($argv[1] == 7 || $argv[1] == 8) { + if ($argv[1] === 7 || $argv[1] === 8) { $nntp = new NNTP(['Settings' => $pdo]); - if ((Settings::value('..alternate_nntp') == '1' ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { - echo $pdo->log->error("Unable to connect to usenet.\n"); + if ((Settings::value('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { + echo ColorCLI::error('Unable to connect to usenet.'. PHP_EOL); return; } } @@ -94,29 +91,29 @@ if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]) && isset($argv[4])) { $namefixer->fixNamesWithParHash(2, $update, $other, $setStatus, $show); break; default : - exit($pdo->log->error("\nERROR: Wrong argument, type php $argv[0] to see a list of valid arguments." . $n)); + exit(ColorCLI::error(PHP_EOL . 'ERROR: Wrong argument, type php $argv[0] to see a list of valid arguments.' . PHP_EOL)); break; } } else { - exit($pdo->log->error("\nYou must supply 4 arguments.\n" - . "The 2nd argument, false, will display the results, but not change the name, type true to have the names changed.\n" - . "The 3rd argument, other, will only do against other categories, to do against all categories use all, or predb_id to process all not matched to predb.\n" - . "The 4th argument, yes, will set the release as checked, so the next time you run it will not be processed, to not set as checked type no.\n" - . "The 5th argument (optional), show, will display the release changes or only show a counter.\n\n" - . "php $argv[0] 1 false other no ...: Fix release names using the usenet subject in the past 3 hours with predb information.\n" - . "php $argv[0] 2 false other no ...: Fix release names using the usenet subject with predb information.\n" - . "php $argv[0] 3 false other no ...: Fix release names using NFO in the past 6 hours.\n" - . "php $argv[0] 4 false other no ...: Fix release names using NFO.\n" - . "php $argv[0] 5 false other no ...: Fix release names in misc categories using File Name in the past 6 hours.\n" - . "php $argv[0] 6 false other no ...: Fix release names in misc categories using File Name.\n" - . "php $argv[0] 7 false other no ...: Fix release names in misc categories using Par2 Files in the past 6 hours.\n" - . "php $argv[0] 8 false other no ...: Fix release names in misc categories using Par2 Files.\n" - . "php $argv[0] 9 false other no ...: Fix release names in misc categories using UID in the past 6 hours.\n" - . "php $argv[0] 10 false other no ...: Fix release names in misc categories using UID.\n" - . "php $argv[0] 11 false other no ...: Fix SDPORN XXX release names in misc categories using specific File Name in the past 6 hours.\n" - . "php $argv[0] 12 false other no ...: Fix SDPORN XXX release names in misc categories using specific File Name.\n" - . "php $argv[0] 13 false other no ...: Fix release names in misc categories using SRR files in the past 6 hours.\n" - . "php $argv[0] 14 false other no ...: Fix release names in misc categories using SRR files.\n" - . "php $argv[0] 15 false other no ...: Fix release names in misc categories using PAR2 hash_16K block in the past 6 hours.\n" - . "php $argv[0] 16 false other no ...: Fix release names in misc categories using PAR2 hash_16K block.\n")); + exit(ColorCLI::error(PHP_EOL . 'You must supply 4 arguments.' . PHP_EOL + . 'The 2nd argument, false, will display the results, but not change the name, type true to have the names changed.' . PHP_EOL + . 'The 3rd argument, other, will only do against other categories, to do against all categories use all, or predb_id to process all not matched to predb.' . PHP_EOL + . 'The 4th argument, yes, will set the release as checked, so the next time you run it will not be processed, to not set as checked type no.' . PHP_EOL + . 'The 5th argument (optional), show, will display the release changes or only show a counter.\n' . PHP_EOL + . 'php ' . $argv[0] . ' 1 false other no ...: Fix release names using the usenet subject in the past 3 hours with predb information.' . PHP_EOL + . 'php ' . $argv[0] . ' 2 false other no ...: Fix release names using the usenet subject with predb information.' . PHP_EOL + . 'php ' . $argv[0] . ' 3 false other no ...: Fix release names using NFO in the past 6 hours.' . PHP_EOL + . 'php ' . $argv[0] . ' 4 false other no ...: Fix release names using NFO.' . PHP_EOL + . 'php ' . $argv[0] . ' 5 false other no ...: Fix release names in misc categories using File Name in the past 6 hours.' . PHP_EOL + . 'php ' . $argv[0] . ' 6 false other no ...: Fix release names in misc categories using File Name.' . PHP_EOL + . 'php ' . $argv[0] . ' 7 false other no ...: Fix release names in misc categories using Par2 Files in the past 6 hours.' . PHP_EOL + . 'php ' . $argv[0] . ' 8 false other no ...: Fix release names in misc categories using Par2 Files.' . PHP_EOL + . 'php ' . $argv[0] . ' 9 false other no ...: Fix release names in misc categories using UID in the past 6 hours.' . PHP_EOL + . 'php ' . $argv[0] . ' 10 false other no ...: Fix release names in misc categories using UID.' . PHP_EOL + . 'php ' . $argv[0] . ' 11 false other no ...: Fix SDPORN XXX release names in misc categories using specific File Name in the past 6 hours.' . PHP_EOL + . 'php ' . $argv[0] . ' 12 false other no ...: Fix SDPORN XXX release names in misc categories using specific File Name.' . PHP_EOL + . 'php ' . $argv[0] . ' 13 false other no ...: Fix release names in misc categories using SRR files in the past 6 hours.' . PHP_EOL + . 'php ' . $argv[0] . ' 14 false other no ...: Fix release names in misc categories using SRR files.' . PHP_EOL + . 'php ' . $argv[0] . ' 15 false other no ...: Fix release names in misc categories using PAR2 hash_16K block in the past 6 hours.' . PHP_EOL + . 'php ' . $argv[0] . ' 16 false other no ...: Fix release names in misc categories using PAR2 hash_16K block.' . PHP_EOL)); } diff --git a/misc/update/nix/tmux/bin/groupfixrelnames.php b/misc/update/nix/tmux/bin/groupfixrelnames.php index 2d2b8d3ba..129d6aac9 100644 --- a/misc/update/nix/tmux/bin/groupfixrelnames.php +++ b/misc/update/nix/tmux/bin/groupfixrelnames.php @@ -111,7 +111,7 @@ switch (true) { } if ($namefixer->matched === false && !empty($release['filehash']) && preg_match('/[a-fA-F0-9]{32,40}/i', $release['filehash'], $matches)) { echo ColorCLI::primaryOver('h'); - $namefixer->matchPredbHash($matches[0], $release, 1, 1, true, 1); + $namefixer->matchPredbHash($matches[0], $release, true, 1, true, 1); } } @@ -235,7 +235,7 @@ switch (true) { foreach ($pres as $pre) { $namefixer->done = $namefixer->matched = false; $ftmatched = $searched = 0; - $ftmatched = $namefixer->matchPredbFT($pre, 1, 1, true, 1); + $ftmatched = $namefixer->matchPredbFT($pre, true, 1, true, 1); if ($ftmatched > 0) { $searched = 1; } elseif ($ftmatched < 0) { diff --git a/nntmux/ADE.php b/nntmux/ADE.php index 286b7f297..1ed1daca7 100755 --- a/nntmux/ADE.php +++ b/nntmux/ADE.php @@ -341,29 +341,33 @@ class ADE } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on ADE server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('ADE service unavailable')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); + 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 = ""; + $this->directLink = ''; } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on ADE server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('ADE service unavailable')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); + 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())); } } diff --git a/nntmux/ADM.php b/nntmux/ADM.php index b9c0c7132..42e2a44b7 100755 --- a/nntmux/ADM.php +++ b/nntmux/ADM.php @@ -301,13 +301,15 @@ class ADM } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on ADM server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('ADM Service unavailable')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); + 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 { @@ -315,13 +317,15 @@ class ADM } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on ADM server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('ADM service unavailable')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); + 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())); } } diff --git a/nntmux/AEBN.php b/nntmux/AEBN.php index 441858029..85e3c8d81 100755 --- a/nntmux/AEBN.php +++ b/nntmux/AEBN.php @@ -368,13 +368,15 @@ class AEBN } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on AEBN server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('AEBN service unavailable')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); + 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 { @@ -382,13 +384,15 @@ class AEBN } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on AEBN server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('AEBN service unavailable')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); + 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())); } } diff --git a/nntmux/Binaries.php b/nntmux/Binaries.php index 559332a60..d1993c79b 100755 --- a/nntmux/Binaries.php +++ b/nntmux/Binaries.php @@ -2,6 +2,7 @@ namespace nntmux; use app\models\Settings; +use nntmux\ColorCLI; use nntmux\db\DB; use nntmux\processing\ProcessReleasesMultiGroup; @@ -290,7 +291,7 @@ class Binaries * * @return void */ - public function updateAllGroups($maxHeaders = 100000) + public function updateAllGroups($maxHeaders = 100000): void { $groups = $this->_groups->getActive(); @@ -337,7 +338,7 @@ class Binaries /** * When the indexer is started, log the date/time. */ - public function logIndexerStart() + public function logIndexerStart(): void { $this->_pdo->queryExec("UPDATE settings SET value = NOW() WHERE setting = 'last_run_time'"); } @@ -350,7 +351,7 @@ class Binaries * * @return void */ - public function updateGroup($groupMySQL, $maxHeaders = 0) + public function updateGroup($groupMySQL, $maxHeaders = 0): void { $startGroup = microtime(true); @@ -360,7 +361,7 @@ class Binaries $groupNNTP = $this->_nntp->selectGroup($groupMySQL['name']); if ($this->_nntp->isError($groupNNTP)) { $groupNNTP = $this->_nntp->dataError($this->_nntp, $groupMySQL['name']); - if ($groupNNTP->code == 411) { + if ($groupNNTP->code === 411) { $this->_groups->disableIfNotExist($groupMySQL['id']); } if ($this->_nntp->isError($groupNNTP)) { @@ -369,23 +370,23 @@ class Binaries } if ($this->_echoCLI) { - $this->_colorCLI->doEcho($this->_colorCLI->primary('Processing ' . $groupMySQL['name']), true); + ColorCLI::doEcho(ColorCLI::primary('Processing ' . $groupMySQL['name']), true); } // Attempt to repair any missing parts before grabbing new ones. if ($groupMySQL['last_record'] != 0) { if ($this->_partRepair) { if ($this->_echoCLI) { - $this->_colorCLI->doEcho($this->_colorCLI->primary('Part repair enabled. Checking for missing parts.'), true); + ColorCLI::doEcho(ColorCLI::primary('Part repair enabled. Checking for missing parts.'), true); } $this->partRepair($groupMySQL); } else if ($this->_echoCLI) { - $this->_colorCLI->doEcho($this->_colorCLI->primary('Part repair disabled by user.'), true); + ColorCLI::doEcho(ColorCLI::primary('Part repair disabled by user.'), true); } } // Generate postdate for first record, for those that upgraded. - if (is_null($groupMySQL['first_record_postdate']) && $groupMySQL['first_record'] != 0) { + if ($groupMySQL['first_record_postdate'] === null && $groupMySQL['first_record'] != 0) { $groupMySQL['first_record_postdate'] = $this->postdate($groupMySQL['first_record'], $groupNNTP); @@ -427,10 +428,10 @@ class Binaries // Check if the server has more articles than our loop limit x 2. if ($totalCount > ($this->messageBuffer * 2)) { // Get the remainder of $totalCount / $this->message buffer - $leaveOver = round(($totalCount % $this->messageBuffer), 0, PHP_ROUND_HALF_DOWN) + $this->messageBuffer; + $leaveOver = round($totalCount % $this->messageBuffer, 0, PHP_ROUND_HALF_DOWN) + $this->messageBuffer; } else { // Else get half of the available. - $leaveOver = round(($totalCount / 2), 0, PHP_ROUND_HALF_DOWN); + $leaveOver = round($totalCount / 2, 0, PHP_ROUND_HALF_DOWN); } } @@ -459,8 +460,8 @@ class Binaries if ($total > 0) { if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->primary( + ColorCLI::doEcho( + ColorCLI::primary( ($groupMySQL['last_record'] == 0 ? 'New group ' . $groupNNTP['group'] . ' starting with ' . ($this->_newGroupScanByDays @@ -493,8 +494,8 @@ class Binaries $first++; if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->header( + ColorCLI::doEcho( + ColorCLI::header( PHP_EOL . 'Getting ' . number_format($last - $first + 1) . ' articles (' . number_format($first) . ' to ' . number_format($last) . ') from ' . $groupMySQL['name'] . ' - (' . number_format($groupLast - $last) . ' articles in queue).' @@ -509,7 +510,7 @@ class Binaries if (!empty($scanSummary)) { // If new group, update first record & postdate - if (is_null($groupMySQL['first_record_postdate']) && $groupMySQL['first_record'] == 0) { + if ($groupMySQL['first_record_postdate'] === null && $groupMySQL['first_record'] == 0) { $groupMySQL['first_record'] = $scanSummary['firstArticleNumber']; if (isset($scanSummary['firstArticleDate'])) { @@ -566,16 +567,16 @@ class Binaries } if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->primary( + ColorCLI::doEcho( + ColorCLI::primary( PHP_EOL . 'Group ' . $groupMySQL['name'] . ' processed in ' . number_format(microtime(true) - $startGroup, 2) . ' seconds.' ), true ); } } else if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->primary( + ColorCLI::doEcho( + ColorCLI::primary( 'No new articles for ' . $groupMySQL['name'] . ' (first ' . number_format($first) . ', last ' . number_format($last) . ', grouplast ' . number_format($groupMySQL['last_record']) . ', total ' . number_format($total) . ")\n" . 'Server oldest: ' . number_format($groupNNTP['first']) . @@ -596,7 +597,7 @@ class Binaries * * @return array Empty on failure. */ - public function scan($groupMySQL, $first, $last, $type = 'update', $missingParts = null) + public function scan($groupMySQL, $first, $last, $type = 'update', $missingParts = null): array { // Start time of scan method and of fetching headers. $this->startLoop = microtime(true); @@ -702,13 +703,12 @@ class Binaries // If set we are running in partRepair mode. if ($partRepair === true && !is_null($missingParts)) { - if (!in_array($header['Number'], $missingParts)) { + if (!in_array($header['Number'], $missingParts, false)) { // If article isn't one that is missing skip it. continue; - } else { - // We got the part this time. Remove article from part repair. - $headersRepaired[] = $header['Number']; } + // We got the part this time. Remove article from part repair. + $headersRepaired[] = $header['Number']; } /* @@ -814,8 +814,8 @@ class Binaries $this->addMissingParts($rangeNotReceived, $this->tableNames['prname'], $this->groupMySQL['id']); if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->alternate( + ColorCLI::doEcho( + ColorCLI::alternate( 'Server did not return ' . $notReceivedCount . ' articles from ' . $this->groupMySQL['name'] . '.' ), true @@ -835,7 +835,7 @@ class Binaries * @param array $headers The retrieved headers * @param bool $multiGroup Is this task being run in MGR mode? */ - protected function storeHeaders(array $headers, $multiGroup) + protected function storeHeaders(array $headers, $multiGroup): void { $this->multiGroup = $multiGroup; $binariesUpdate = $collectionIDs = $articles = []; @@ -999,8 +999,8 @@ class Binaries // Check if we got any binaries. If we did, try to insert them. if (strlen($binariesCheck . $binariesEnd) === strlen($binariesQuery) ? true : $this->_pdo->queryExec($binariesQuery)) { if ($this->_debug) { - $this->_colorCLI->doEcho( - $this->_colorCLI->debug( + ColorCLI::doEcho( + ColorCLI::debug( 'Sending ' . round(strlen($partsQuery) / 1024, 2) . ' KB of' . ($this->multiGroup ? ' MGR' : '') . ' parts to MySQL' ) @@ -1029,7 +1029,7 @@ class Binaries * @param array $headers * @param int $msgCount */ - protected function getHighLowArticleInfo(array &$returnArray, array $headers, int $msgCount) + protected function getHighLowArticleInfo(array &$returnArray, array $headers, int $msgCount): void { // Get highest and lowest article numbers/dates. $iterator1 = 0; @@ -1060,7 +1060,7 @@ class Binaries /** * Updates Blacklist Regex Timers in DB to reflect last usage */ - protected function updateBlacklistUsage() + protected function updateBlacklistUsage(): void { $this->_pdo->queryExec( sprintf('UPDATE binaryblacklist SET last_activity = NOW() WHERE id IN (%s)', @@ -1073,10 +1073,10 @@ class Binaries /** * Outputs the initial header scan results after yEnc check and blacklist routines */ - protected function outputHeaderInitial() + protected function outputHeaderInitial(): void { - $this->_colorCLI->doEcho( - $this->_colorCLI->primary( + ColorCLI::doEcho( + ColorCLI::primary( 'Received ' . count($this->headersReceived) . ' articles of ' . number_format($this->last - $this->first + 1) . ' requested, ' . $this->headersBlackListed . ' blacklisted, ' . $this->notYEnc . ' not yEnc.' @@ -1087,21 +1087,21 @@ class Binaries /** * Outputs speed metrics of the scan function to CLI */ - protected function outputHeaderDuration() + protected function outputHeaderDuration(): void { $currentMicroTime = microtime(true); if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->alternateOver($this->timeHeaders . 's') . - $this->_colorCLI->primaryOver(' to download articles, ') . - $this->_colorCLI->alternateOver($this->timeCleaning . 's') . - $this->_colorCLI->primaryOver(' to process collections, ') . - $this->_colorCLI->alternateOver($this->timeInsert . 's') . - $this->_colorCLI->primaryOver(' to insert binaries/parts, ') . - $this->_colorCLI->alternateOver(number_format($currentMicroTime - $this->startPR, 2) . 's') . - $this->_colorCLI->primaryOver(' for part repair, ') . - $this->_colorCLI->alternateOver(number_format($currentMicroTime - $this->startLoop, 2) . 's') . - $this->_colorCLI->primary(' total.') + ColorCLI::doEcho( + ColorCLI::alternateOver($this->timeHeaders . 's') . + ColorCLI::primaryOver(' to download articles, ') . + ColorCLI::alternateOver($this->timeCleaning . 's') . + ColorCLI::primaryOver(' to process collections, ') . + ColorCLI::alternateOver($this->timeInsert . 's') . + ColorCLI::primaryOver(' to insert binaries/parts, ') . + ColorCLI::alternateOver(number_format($currentMicroTime - $this->startPR, 2) . 's') . + ColorCLI::primaryOver(' for part repair, ') . + ColorCLI::alternateOver(number_format($currentMicroTime - $this->startLoop, 2) . 's') . + ColorCLI::primary(' total.') ); } } @@ -1115,7 +1115,7 @@ class Binaries * * @access protected */ - protected function _rollbackAddToPartRepair(array $headers) + protected function _rollbackAddToPartRepair(array $headers): array { $headersNotInserted = []; foreach ($headers as $header) { @@ -1134,7 +1134,7 @@ class Binaries * * @return void */ - public function partRepair($groupArr) + public function partRepair($groupArr): void { $tableNames = $this->_groups->getCBPTableNames($groupArr['id']); // Get all parts in partrepair table. @@ -1153,8 +1153,8 @@ class Binaries $missingCount = count($missingParts); if ($missingCount > 0) { if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->primary( + ColorCLI::doEcho( + ColorCLI::primary( 'Attempting to repair ' . number_format($missingCount) . ' parts.' @@ -1237,8 +1237,8 @@ class Binaries } if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->primary( + ColorCLI::doEcho( + ColorCLI::primary( PHP_EOL . number_format($partsRepaired) . ' parts repaired.' @@ -1266,7 +1266,7 @@ class Binaries * * @return int Timestamp. */ - public function postdate($post, array $groupData) + public function postdate($post, array $groupData): int { // Set table names $groupID = $this->_groups->getIDByName($groupData['group']); @@ -1331,7 +1331,7 @@ class Binaries $currentPost = $tempPost; if ($this->_debug) { - $this->_colorCLI->doEcho($this->_colorCLI->debug('Postdate retried ' . $attempts . " time(s).")); + ColorCLI::doEcho(ColorCLI::debug('Postdate retried ' . $attempts . ' time(s).')); } } while ($attempts++ <= 20); @@ -1344,7 +1344,7 @@ class Binaries if ($this->_debug) { $this->_debugging->log( - get_class(), + __CLASS__, __FUNCTION__, 'Article (' . $post . @@ -1389,8 +1389,8 @@ class Binaries } if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->primary( + ColorCLI::doEcho( + ColorCLI::primary( 'Searching for an approximate article number for group ' . $data['group'] . ' ' . $days . ' days back.' ) ); @@ -1449,8 +1449,8 @@ class Binaries $wantedArticle = (int)$wantedArticle; if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->primary( + ColorCLI::doEcho( + ColorCLI::primary( PHP_EOL . 'Found article #' . $wantedArticle . ' which has a date of ' . date('r', $articleTime) . ', vs wanted date of ' . date('r', $goalTime) . '. Difference from goal is ' . round(($goalTime - $articleTime) / 60 / 60 / 24, 1) . ' days.' ) @@ -1481,7 +1481,7 @@ class Binaries * * @return bool */ - private function addMissingParts($numbers, $tableName, $groupID) + private function addMissingParts($numbers, $tableName, $groupID): bool { $insertStr = 'INSERT INTO ' . $tableName . ' (numberid, groups_id) VALUES '; foreach ($numbers as $number) { @@ -1499,7 +1499,7 @@ class Binaries * * @return void */ - private function removeRepairedParts(array $numbers, $tableName, $groupID) + private function removeRepairedParts(array $numbers, $tableName, $groupID): void { $sql = 'DELETE FROM ' . $tableName . ' WHERE numberid in ('; foreach ($numbers as $number) { @@ -1521,7 +1521,7 @@ class Binaries * * @return void */ - protected function _retrieveBlackList($groupName) + protected function _retrieveBlackList($groupName): void { if (!isset($this->blackList[$groupName])) { $this->blackList[$groupName] = $this->getBlacklist(true, self::OPTYPE_BLACKLIST, $groupName, true); @@ -1540,7 +1540,7 @@ class Binaries * * @return bool */ - public function isBlackListed($msg, $groupName) + public function isBlackListed($msg, $groupName): bool { if (!isset($this->_listsFound[$groupName])) { $this->_retrieveBlackList($groupName); @@ -1594,7 +1594,7 @@ class Binaries * * @return array */ - public function getBlacklist($activeOnly = true, $opType = -1, $groupName = '', $groupRegex = false) + public function getBlacklist($activeOnly = true, $opType = -1, $groupName = '', $groupRegex = false): array { switch ($opType) { case self::OPTYPE_BLACKLIST: @@ -1644,7 +1644,7 @@ class Binaries * * @return bool */ - public function deleteBlacklist($id) + public function deleteBlacklist($id): bool { return $this->_pdo->queryExec(sprintf('DELETE FROM binaryblacklist WHERE id = %d', $id)); } @@ -1656,7 +1656,7 @@ class Binaries * * @return boolean */ - public function updateBlacklist($blacklistArray) + public function updateBlacklist($blacklistArray): bool { return $this->_pdo->queryExec( sprintf(' @@ -1683,7 +1683,7 @@ class Binaries * * @return bool */ - public function addBlacklist($blacklistArray) + public function addBlacklist($blacklistArray): bool { return $this->_pdo->queryInsert( sprintf(' @@ -1711,7 +1711,7 @@ class Binaries * * @return void */ - public function delete($collectionID) + public function delete($collectionID): void { $this->_pdo->queryExec(sprintf('DELETE FROM collections WHERE id = %d', $collectionID)); } @@ -1725,7 +1725,7 @@ class Binaries * * @return void */ - public function purgeGroup($groupID) + public function purgeGroup($groupID): void { $this->_pdo->queryExec(sprintf('DELETE c FROM collections c WHERE c.groups_id = %d', $groupID)); } @@ -1738,16 +1738,16 @@ class Binaries * @param int $level Logger severity level constant. * @param string $color ColorCLI method name. */ - private function log($message, $method, $level, $color) + private function log($message, $method, $level, $color): void { if ($this->_echoCLI) { - $this->_colorCLI->doEcho( - $this->_colorCLI->$color($message . ' [' . get_class() . "::$method]"), true + ColorCLI::doEcho( + ColorCLI::$color($message . ' [' . __CLASS__ . "::$method]"), true ); } if ($this->_debug) { - $this->_debugging->log(get_class(), $method, $message, $level); + $this->_debugging->log(__CLASS__, $method, $message, $level); } } @@ -1761,7 +1761,7 @@ class Binaries * @access protected * */ - protected function _ignoreFileCount($groupName, $subject) + protected function _ignoreFileCount($groupName, $subject): bool { $ignore = false; switch ($groupName) { @@ -1779,7 +1779,7 @@ class Binaries * * @return array */ - protected function getMultiGroupPosters() + protected function getMultiGroupPosters(): array { return $this->_pdo->query(' SELECT poster diff --git a/nntmux/Movie.php b/nntmux/Movie.php index cb2d9a1c2..fdc29da33 100755 --- a/nntmux/Movie.php +++ b/nntmux/Movie.php @@ -954,13 +954,15 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on IMDB server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('IMDB service unavailable')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from IMDB, http error reported: ' . $e->getCode())); } } + } catch (\RuntimeException $e) { + ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); } if (isset($buffer) && $buffer !== false) { @@ -1326,13 +1328,15 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on IMDB server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('IMDB service unavailable')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from IMDB, http error reported: ' . $e->getCode())); } } + } catch (\RuntimeException $e) { + ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); } // Make sure we got some data. @@ -1372,13 +1376,15 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on IMDB server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('IMDB service unavailable')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from IMDB , http error reported: ' . $e->getCode())); } } + } catch (\RuntimeException $e) { + ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); } if (!empty($buffer)) { @@ -1426,13 +1432,15 @@ class Movie } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on IMDB server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('IMDB service unavailable')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, http error reported: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from IMDB, http error reported: ' . $e->getCode())); } } + } catch (\RuntimeException $e) { + ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); } if (!empty($buffer)) { diff --git a/nntmux/NNTP.php b/nntmux/NNTP.php index 5491e1e41..2e4073d44 100755 --- a/nntmux/NNTP.php +++ b/nntmux/NNTP.php @@ -155,10 +155,10 @@ class NNTP extends \Net_NNTP_Client ) { return true; - } else { - $this->doQuit(); } + $this->doQuit(); + $ret = $connected = $cError = $aError = false; // Set variables to connect based on if we are using the alternate provider or not. @@ -222,7 +222,7 @@ class NNTP extends \Net_NNTP_Client ': ' . $cError; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_ERROR); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_ERROR); } return $this->throwError(ColorCLI::error($message)); } @@ -263,7 +263,7 @@ class NNTP extends \Net_NNTP_Client $userName . ' (' . $aError . ')'; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_ERROR); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_ERROR); } return $this->throwError(ColorCLI::error($message)); } @@ -277,7 +277,7 @@ class NNTP extends \Net_NNTP_Client $this->_compressionSupported = false; } if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, 'Connected to ' . $this->_currentServer . '.', Logger::LOG_INFO); + $this->_debugging->log(__CLASS__, __FUNCTION__, 'Connected to ' . $this->_currentServer . '.', Logger::LOG_INFO); } return true; } @@ -292,7 +292,7 @@ class NNTP extends \Net_NNTP_Client // If we somehow got out of the loop, return an error. $message = 'Unable to connect to ' . $this->_currentServer . $enc; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_ERROR); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_ERROR); } return $this->throwError(ColorCLI::error($message)); } @@ -314,7 +314,7 @@ class NNTP extends \Net_NNTP_Client // Check if we are connected to usenet. if ($force === true || parent::_isConnected(false)) { if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, 'Disconnecting from ' . $this->_currentServer, Logger::LOG_INFO); + $this->_debugging->log(__CLASS__, __FUNCTION__, 'Disconnecting from ' . $this->_currentServer, Logger::LOG_INFO); } // Disconnect from usenet. return parent::disconnect(); @@ -329,7 +329,7 @@ class NNTP extends \Net_NNTP_Client * * @access protected */ - protected function _resetProperties() + protected function _resetProperties(): void { $this->_compressionEnabled = false; $this->_compressionSupported = true; @@ -344,7 +344,7 @@ class NNTP extends \Net_NNTP_Client * * @access public */ - public function enableCompression() + public function enableCompression(): void { if (!Settings::value('..compressedheaders') == 1) { return; @@ -373,9 +373,8 @@ class NNTP extends \Net_NNTP_Client if ($force || $this->_currentGroup !== $group || $this->_selectedGroupSummary === null) { $this->_currentGroup = $group; return parent::selectGroup($group, $articles); - } else { - return $this->_selectedGroupSummary; } + return $this->_selectedGroupSummary; } /** @@ -447,17 +446,13 @@ class NNTP extends \Net_NNTP_Client } // Verify the NNTP server got the right command, get the headers data. - switch ($response) { - // 224, RFC2980: 'Overview information follows' - case NET_NNTP_PROTOCOL_RESPONSECODE_OVERVIEW_FOLLOWS: - $data = $this->_getTextResponse(); - if ($this->isError($data)) { - return $data; - } - break; - - default: - return $this->_handleErrorResponse($response); + if ($response === NET_NNTP_PROTOCOL_RESPONSECODE_OVERVIEW_FOLLOWS) { + $data = $this->_getTextResponse(); + if ($this->isError($data)) { + return $data; + } + } else { + return $this->_handleErrorResponse($response); } // Fetch the header overview format (for setting the array keys on the return array). @@ -607,7 +602,7 @@ class NNTP extends \Net_NNTP_Client return $body; } if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $newBody->getMessage(), Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $newBody->getMessage(), Logger::LOG_NOTICE); } // Return the error. return $newBody; @@ -638,7 +633,7 @@ class NNTP extends \Net_NNTP_Client } else { $message = 'Wrong Identifier type, array, int or string accepted. This type of var was passed: ' . gettype($identifiers); if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_WARNING); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_WARNING); } return $this->throwError(ColorCLI::error($message)); } @@ -678,7 +673,7 @@ class NNTP extends \Net_NNTP_Client // If there was an error selecting the group, return PEAR error object. if ($this->isError($summary)) { if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $summary->getMessage(), Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $summary->getMessage(), Logger::LOG_NOTICE); } return $summary; } @@ -695,7 +690,7 @@ class NNTP extends \Net_NNTP_Client // If there was an error downloading the article, return a PEAR error object. if ($this->isError($article)) { if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $article->getMessage(), Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $article->getMessage(), Logger::LOG_NOTICE); } return $article; } @@ -761,7 +756,7 @@ class NNTP extends \Net_NNTP_Client // Return PEAR error object on failure. if ($this->isError($summary)) { if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $summary->getMessage(), Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $summary->getMessage(), Logger::LOG_NOTICE); } return $summary; } @@ -778,7 +773,7 @@ class NNTP extends \Net_NNTP_Client // If we failed, return PEAR error object. if ($this->isError($header)) { if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $header->getMessage(), Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $header->getMessage(), Logger::LOG_NOTICE); } return $header; } @@ -824,7 +819,7 @@ class NNTP extends \Net_NNTP_Client if (!$this->_postingAllowed) { $message = 'You do not have the right to post articles on server ' . $this->_currentServer; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); } return $this->throwError(ColorCLI::error($message)); } @@ -838,7 +833,7 @@ class NNTP extends \Net_NNTP_Client if (strlen($subject) > 510) { $message = 'Max length of subject is 510 chars.'; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_WARNING); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_WARNING); } return $this->throwError(ColorCLI::error($message)); } @@ -846,7 +841,7 @@ class NNTP extends \Net_NNTP_Client if (strlen($from) > 510) { $message = 'Max length of from is 510 chars.'; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_WARNING); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_WARNING); } return $this->throwError(ColorCLI::error($message)); } @@ -895,7 +890,7 @@ class NNTP extends \Net_NNTP_Client // Try reconnecting. This uses another round of max retries. if ($nntp->doConnect($comp) !== true) { if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, 'Unable to reconnect to usenet!', Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, 'Unable to reconnect to usenet!', Logger::LOG_NOTICE); } return $this->throwError('Unable to reconnect to usenet!'); } @@ -905,7 +900,7 @@ class NNTP extends \Net_NNTP_Client if ($this->isError($data)) { $message = "Code {$data->code}: {$data->message}\nSkipping group: {$group}"; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); } if ($this->_echo) { @@ -941,7 +936,7 @@ class NNTP extends \Net_NNTP_Client if ($lineLength < 1) { $message = $lineLength . ' is not a valid line length.'; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); } return $this->throwError($message); } @@ -1015,7 +1010,7 @@ class NNTP extends \Net_NNTP_Client if ($headerSize != $trailerSize) { $message = 'Header and trailer file sizes do not match. This is a violation of the yEnc specification.'; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); } return $this->throwError($message); } @@ -1031,16 +1026,16 @@ class NNTP extends \Net_NNTP_Client if (strlen($decoded) != $headerSize) { $message = 'Header file size and actual file size do not match. The file is probably corrupt.'; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); } return $this->throwError($message); } // Check the CRC value - if ($crc !== '' && (strtolower($crc) !== strtolower(sprintf("%04X", crc32($decoded))))) { + if ($crc !== '' && (strtolower($crc) !== strtolower(sprintf('%04X', crc32($decoded))))) { $message = 'CRC32 checksums do not match. The file is probably corrupt.'; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); } return $this->throwError($message); } @@ -1053,12 +1048,12 @@ class NNTP extends \Net_NNTP_Client * * @deprecated use app\extensions\util\Yenc::decodeIgnore instead. * - * @param string $data The encoded text to decode. + * @param string|bool $data The encoded text to decode. * * @return string The decoded yEnc string, or the input string, if it's not yEnc. * @access protected */ - protected function _decodeIgnoreYEnc(&$data) + protected function _decodeIgnoreYEnc(&$data): string { trigger_error('Deprecated. Use app\extensions\util\Yenc::decodeIgnore instead.' . PHP_EOL); if (preg_match('/^(=yBegin.*=yEnd[^$]*)$/ims', $data, $input)) { @@ -1157,7 +1152,7 @@ class NNTP extends \Net_NNTP_Client * * @access protected */ - protected function _splitLines($string, $compress = false) + protected function _splitLines($string, $compress = false): string { // Check if the length is longer than 510 chars. if (strlen($string) > 510) { @@ -1184,7 +1179,8 @@ class NNTP extends \Net_NNTP_Client { if ($this->_compressionEnabled === true) { return true; - } else if ($this->_compressionSupported === false) { + } + if ($this->_compressionSupported === false) { return false; } @@ -1194,11 +1190,12 @@ class NNTP extends \Net_NNTP_Client // Check if it's good. if ($this->isError($response)) { if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $response->getMessage(), Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $response->getMessage(), Logger::LOG_NOTICE); } $this->_compressionSupported = false; return $response; - } else if ($response !== 290) { + } + if ($response !== 290) { if ($secondTry === false) { // Retry. $this->cmdQuit(); @@ -1208,7 +1205,7 @@ class NNTP extends \Net_NNTP_Client } $msg = "Sent 'XFEATURE COMPRESS GZIP' to server, got '$response: " . $this->_currentStatusResponse() . "'"; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $msg, Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $msg, Logger::LOG_NOTICE); } $this->_compressionSupported = false; @@ -1226,7 +1223,7 @@ class NNTP extends \Net_NNTP_Client * of their _getTextResponse function since it is incompatible at decoding * headers when XFeature GZip compression is enabled server side. * - * @return self Our overridden function when compression is enabled. + * @return self|string Our overridden function when compression is enabled. * parent Parent function when no compression. * * @access protected @@ -1238,9 +1235,8 @@ class NNTP extends \Net_NNTP_Client stripos($this->_currentStatusResponse[1], 'COMPRESS=GZIP') !== false) { return $this->_getXFeatureTextResponse(); - } else { - return parent::_getTextResponse(); } + return parent::_getTextResponse(); } /** @@ -1257,7 +1253,7 @@ class NNTP extends \Net_NNTP_Client * * @access protected */ - protected function &_getXFeatureTextResponse() + protected function &_getXFeatureTextResponse(): string { $possibleTerm = false; $data = null; @@ -1281,7 +1277,8 @@ class NNTP extends \Net_NNTP_Client // Don't sleep on last iteration. if (!empty($buffer)) { break; - } else if ($i < 2) { + } + if ($i < 2) { usleep(10000); } } @@ -1309,7 +1306,7 @@ class NNTP extends \Net_NNTP_Client } else { $message = 'Decompression of OVER headers failed.'; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); } $message = $this->throwError(ColorCLI::error($message), 1000); return $message; @@ -1333,7 +1330,7 @@ class NNTP extends \Net_NNTP_Client if (empty($buffer)) { $message = 'Error fetching data from usenet server while downloading OVER headers.'; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); } $message = $this->throwError(ColorCLI::error($message), 1000); return $message; @@ -1352,7 +1349,7 @@ class NNTP extends \Net_NNTP_Client $message = 'Unspecified error while downloading OVER headers.'; if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $message, Logger::LOG_NOTICE); + $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); } $message = $this->throwError(ColorCLI::error($message), 1000); return $message; @@ -1367,7 +1364,7 @@ class NNTP extends \Net_NNTP_Client * * @access protected */ - protected function _formatMessageID($messageID) + protected function _formatMessageID($messageID): string { $messageID = (string)$messageID; if ($messageID === '') { @@ -1398,7 +1395,7 @@ class NNTP extends \Net_NNTP_Client * * @access protected */ - protected function _getMessage($groupName, $identifier) + protected function _getMessage($groupName, $identifier): ?string { // Make sure the requested group is already selected, if not select it. if (parent::group() !== $groupName) { @@ -1407,7 +1404,7 @@ class NNTP extends \Net_NNTP_Client // If there was an error selecting the group, return PEAR error object. if ($this->isError($summary)) { if ($this->_debugBool) { - $this->_debugging->log(get_class(), __FUNCTION__, $summary->getMessage(), Logger::LOG_WARNING); + $this->_debugging->log(__CLASS__, __FUNCTION__, $summary->getMessage(), Logger::LOG_WARNING); } return $summary; } @@ -1445,7 +1442,7 @@ class NNTP extends \Net_NNTP_Client // Check if the line terminates the text response. if ($line === ".\r\n") { if ($this->_debugBool) { - $this->_debugging->log(get_class(), + $this->_debugging->log(__CLASS__, __FUNCTION__, 'Fetched body for article ' . $identifier, Logger::LOG_INFO ); } diff --git a/nntmux/NameFixer.php b/nntmux/NameFixer.php index d4ca4e8c1..2234bc42f 100755 --- a/nntmux/NameFixer.php +++ b/nntmux/NameFixer.php @@ -691,7 +691,7 @@ class NameFixer */ protected function _echoFoundCount($echo, $type): void { - if ($echo === 1) { + if ($echo === true) { echo ColorCLI::header( PHP_EOL . number_format($this->fixed) . @@ -823,7 +823,7 @@ class NameFixer $newTitle = $this->pdo->escapeString(substr($newName, 0, 255)); - if ($echo === 1) { + if ($echo === true) { if ($nameStatus === 1) { $status = ''; switch ($type) { @@ -851,7 +851,7 @@ class NameFixer $status = 'isrenamed = 1, iscategorized = 1, proc_uid = 1,'; break; } - $end = $this->pdo->queryExec( + $this->pdo->queryExec( sprintf(' UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, @@ -1080,7 +1080,7 @@ class NameFixer echo ColorCLI::header($n . number_format($total) . ' releases to process.'); foreach ($query as $row) { - $success = $this->matchPredbFiles($row, 1, 1, true, $show); + $success = $this->matchPredbFiles($row, true, 1, true, $show); if ($success === 1) { $counted++; } diff --git a/nntmux/PreDb.php b/nntmux/PreDb.php index 2eb145be5..3a5706224 100755 --- a/nntmux/PreDb.php +++ b/nntmux/PreDb.php @@ -56,7 +56,7 @@ Class PreDb * * @param $dateLimit */ - public function checkPre($dateLimit = false) + public function checkPre($dateLimit = false): void { $this->dateLimit = $dateLimit; @@ -120,7 +120,7 @@ Class PreDb */ public function matchPre($cleanerName) { - if ($cleanerName == '') { + if (empty($cleanerName)) { return false; } @@ -161,30 +161,30 @@ Class PreDb * * @return int */ - public function parseTitles($time, $echo, $cats, $namestatus, $show) + public function parseTitles($time, $echo, $cats, $namestatus, $show): int { $namefixer = new NameFixer(['Echo' => $this->echooutput, 'ConsoleTools' => $this->pdo->log, 'Settings' => $this->pdo]); $consoletools = new ConsoleTools(['ColorCLI' => $this->pdo->log]); - $othercats = implode(",", Category::OTHERS_GROUP); + $othercats = implode(',', Category::OTHERS_GROUP); $updated = $checked = 0; $tq = ''; - if ($time == 1) { + if ($time === 1) { $tq = 'AND r.adddate > (NOW() - INTERVAL 3 HOUR) ORDER BY rf.releases_id, rf.size DESC'; } $ct = ''; - if ($cats == 1) { + if ($cats === 1) { $ct = sprintf('AND r.categories_id IN (%s)', $othercats); } if ($this->echooutput) { $te = ''; - if ($time == 1) { + if ($time === 1) { $te = ' in the past 3 hours'; } - echo ColorCLI::header('Fixing search names' . $te . " using the predb hash."); + echo ColorCLI::header('Fixing search names' . $te . ' using the predb hash.'); } - $regex = "AND (r.ishashed = 1 OR rf.ishashed = 1)"; + $regex = 'AND (r.ishashed = 1 OR rf.ishashed = 1)'; if ($cats === 3) { $query = sprintf('SELECT r.id AS releases_id, r.name, r.searchname, r.categories_id, r.groups_id, ' @@ -200,23 +200,23 @@ Class PreDb $res = $this->pdo->queryDirect($query); $total = $res->rowCount(); - echo ColorCLI::primary(number_format($total) . " releases to process."); + echo ColorCLI::primary(number_format($total) . ' releases to process.'); if ($res instanceof \Traversable) { foreach ($res as $row) { if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['name'], $matches)) { - $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show); + $updated += $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show); } else if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['filename'], $matches)) { - $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show); + $updated += $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show); } if ($show === 2) { - $consoletools->overWritePrimary("Renamed Releases: [" . number_format($updated) . "] " . $consoletools->percentString(++$checked, $total)); + $consoletools->overWritePrimary('Renamed Releases: [' . number_format($updated) . '] ' . $consoletools->percentString($checked++, $total)); } } } - if ($echo == 1) { - echo ColorCLI::header("\n" . $updated . " releases have had their names changed out of: " . number_format($checked) . " files."); + if ($echo === 1) { + echo ColorCLI::header(PHP_EOL . $updated . ' releases have had their names changed out of: ' . number_format($checked) . ' files.'); } else { - echo ColorCLI::header("\n" . $updated . " releases could have their names changed. " . number_format($checked) . " files were checked."); + echo ColorCLI::header(PHP_EOL . $updated . ' releases could have their names changed. ' . number_format($checked) . ' files were checked.'); } return $updated; @@ -231,7 +231,7 @@ Class PreDb * * @return array The row count and the query results. */ - public function getAll($offset, $offset2, $search = '') + public function getAll($offset, $offset2, $search = ''): array { if ($search !== '') { $search = explode(' ', trim($search)); @@ -267,7 +267,7 @@ Class PreDb * * @return int */ - public function getCount($search = '') + public function getCount($search = ''): int { $count = $this->pdo->query(" SELECT COUNT(id) AS cnt @@ -285,7 +285,7 @@ Class PreDb * * @return array */ - public function getForRelease($preID) + public function getForRelease($preID): array { return $this->pdo->query(sprintf('SELECT * FROM predb WHERE id = %d', $preID)); } @@ -297,7 +297,7 @@ Class PreDb * * @return array */ - public function getOne($preID) + public function getOne($preID): array { return $this->pdo->queryOneRow(sprintf('SELECT * FROM predb WHERE id = %d', $preID)); } diff --git a/nntmux/ReleaseImage.php b/nntmux/ReleaseImage.php index 868bea44c..854fae558 100755 --- a/nntmux/ReleaseImage.php +++ b/nntmux/ReleaseImage.php @@ -104,6 +104,8 @@ class ReleaseImage ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, server responded with code: ' . $e->getCode())); } } + } catch (\RuntimeException $e) { + ColorCLI::doEcho(ColorCLI::notice('Runtime error: ' . $e->getCode())); } } else if (is_file($imgLoc)) { diff --git a/nntmux/XXX.php b/nntmux/XXX.php index cffa099bf..16c625c3a 100755 --- a/nntmux/XXX.php +++ b/nntmux/XXX.php @@ -1,4 +1,5 @@ pdo->queryOneRow('SELECT COUNT(id) AS num FROM xxxinfo'); + return ($res === false ? 0 : $res['num']); } @@ -176,7 +179,7 @@ class XXX $order = $this->getXXXOrder($orderBy); $xxxmovies = $this->pdo->queryCalc( - sprintf(" + sprintf(" SELECT SQL_CALC_FOUND_ROWS xxx.id, GROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id @@ -188,18 +191,18 @@ class XXX %s %s %s %s GROUP BY xxx.id ORDER BY %s %s %s", - $this->showPasswords, - $this->getBrowseBy(), - $catsrch, - ($maxAge > 0 - ? 'AND r.postdate > NOW() - INTERVAL ' . $maxAge . 'DAY ' - : '' - ), - (count($excludedCats) > 0 ? ' AND r.categories_id NOT IN (' . implode(',', $excludedCats) . ')' : ''), - $order[0], - $order[1], - ($start === false ? '' : ' LIMIT ' . $num . ' OFFSET ' . $start) - ), true, NN_CACHE_EXPIRY_MEDIUM + $this->showPasswords, + $this->getBrowseBy(), + $catsrch, + ($maxAge > 0 + ? 'AND r.postdate > NOW() - INTERVAL ' . $maxAge . 'DAY ' + : '' + ), + (count($excludedCats) > 0 ? ' AND r.categories_id NOT IN (' . implode(',', $excludedCats) . ')' : ''), + $order[0], + $order[1], + ($start === false ? '' : ' LIMIT ' . $num . ' OFFSET ' . $start) + ), true, NN_CACHE_EXPIRY_MEDIUM ); $xxxIDs = $releaseIDs = false; @@ -214,7 +217,7 @@ class XXX $sql = sprintf(" SELECT GROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id, - GROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') as grp_rarinnerfilecount, + GROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') AS grp_rarinnerfilecount, GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, @@ -245,22 +248,23 @@ class XXX %s %s %s %s GROUP BY xxx.id ORDER BY %s %s", - (is_array($xxxIDs) ? implode(',', $xxxIDs) : -1), - $this->showPasswords, - $this->getBrowseBy(), - $catsrch, - ($maxAge > 0 - ? 'AND r.postdate > NOW() - INTERVAL ' . $maxAge . 'DAY ' - : '' - ), - (count($excludedCats) > 0 ? ' AND r.categories_id NOT IN (' . implode(',', $excludedCats) . ')' : ''), - $order[0], - $order[1] + (is_array($xxxIDs) ? implode(',', $xxxIDs) : -1), + $this->showPasswords, + $this->getBrowseBy(), + $catsrch, + ($maxAge > 0 + ? 'AND r.postdate > NOW() - INTERVAL ' . $maxAge . 'DAY ' + : '' + ), + (count($excludedCats) > 0 ? ' AND r.categories_id NOT IN (' . implode(',', $excludedCats) . ')' : ''), + $order[0], + $order[1] ); $return = $this->pdo->query($sql, true, NN_CACHE_EXPIRY_MEDIUM); - if (!empty($return)){ + if (!empty($return)) { $return[0]['_totalcount'] = $xxxmovies['total'] ?? 0; } + return $return; } @@ -317,6 +321,7 @@ class XXX } } } + return $browseBy; } @@ -341,8 +346,8 @@ class XXX if (trim($ta) === '') { continue; } - if ($field === 'genre' ) { - $ta = $this->getGenres(true,$ta); + if ($field === 'genre') { + $ta = $this->getGenres(true, $ta); $ta = $ta['title']; } if ($i > 7) { @@ -351,6 +356,7 @@ class XXX $newArr[] = '' . $ta . ''; $i++; } + return implode(', ', $newArr); } @@ -421,7 +427,7 @@ class XXX if ($iafd->findme() !== false) { - switch($iafd->classUsed) { + switch ($iafd->classUsed) { case 'ade': $mov = new ADE(); $mov->directLink = (string)$iafd->directUrl; @@ -496,83 +502,78 @@ class XXX } } - $mov['trailers'] = !empty($res['trailers']) ? serialize($res['trailers']) : ''; - $mov['extras'] = !empty($res['extras']) ? serialize($res['extras']) : ''; - $mov['productinfo'] = !empty($res['productinfo']) ? serialize($res['productinfo']) : ''; - $mov['backdrop'] = !empty($res['backcover']) ? $res['backcover'] : 0; - $mov['cover'] = !empty($res['boxcover']) ? $res['boxcover'] : 0; $res['cast'] = !empty($res['cast']) ? implode(',', $res['cast']) : ''; $res['genres'] = !empty($res['genres']) ? $this->getGenreID($res['genres']) : ''; - $mov['title'] = !empty($res['title']) ? html_entity_decode($res['title'], ENT_QUOTES, 'UTF-8') : ''; - $mov['plot'] = !empty($res['sypnosis']) ? html_entity_decode($res['sypnosis'], ENT_QUOTES, 'UTF-8') : ''; - $mov['tagline'] = !empty($res['tagline']) ? html_entity_decode($res['tagline'], ENT_QUOTES, 'UTF-8') : ''; - $mov['genre'] = !empty($res['genres']) ? html_entity_decode($res['genres'], ENT_QUOTES, 'UTF-8') : ''; - $mov['director'] = !empty($res['director']) ? html_entity_decode($res['director'], ENT_QUOTES, 'UTF-8') : ''; - $mov['actors'] = !empty($res['cast']) ? html_entity_decode($res['cast'], ENT_QUOTES, 'UTF-8') : ''; - $mov['directurl'] = !empty($res['directurl']) ? html_entity_decode($res['directurl'], ENT_QUOTES, 'UTF-8') : ''; - $mov['classused'] = $this->whichclass; + + $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'])){ + if (isset($check['id'])) { $xxxID = $check['id']; } - if($check === false || $xxxID > 0){ + // 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']; - // 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); } - // Insert New XXX Information - if($check === false){ - $xxxID = $this->pdo->queryInsert( - sprintf(' + // 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 ($xxxID > 0) { - - // 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; - } - + $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: ' : 'Nothing to update for XXX movie: ')) . - ColorCLI::primary($mov['title']) + ColorCLI::headerOver(($xxxID !== false ? 'Added/updated XXX movie: ' . ColorCLI::primary($mov['title']) : 'Nothing to update for XXX movie: ' . ColorCLI::primary($mov['title']))) ); } @@ -679,8 +680,9 @@ class XXX $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)) { + 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); @@ -702,22 +704,25 @@ class XXX if ($activeOnly) { $res = $this->pdo->query('SELECT title FROM genres WHERE disabled = 0 AND type = ' . - Category::XXX_ROOT . ' ORDER BY title'); + Category::XXX_ROOT . ' ORDER BY title' + ); } else { $res = $this->pdo->query('SELECT title FROM genres WHERE disabled = 1 AND type = ' . - Category::XXX_ROOT . ' ORDER BY title'); + Category::XXX_ROOT . ' ORDER BY title' + ); } foreach ($res as $arr => $value) { $ret[] = $value['title']; } + return $ret; } /** * Get Genres for activeonly and/or an ID * - * @param bool $activeOnly + * @param bool $activeOnly * @param null|string $gid * * @return array|bool @@ -733,6 +738,7 @@ class XXX if ($activeOnly) { return $this->pdo->queryOneRow('SELECT title FROM genres WHERE disabled = 0 AND type = ' . Category::XXX_ROOT . $gid); } + return $this->pdo->queryOneRow('SELECT title FROM genres WHERE disabled = 1 AND type = ' . Category::XXX_ROOT . $gid); } @@ -763,7 +769,8 @@ class XXX } } - $ret = ltrim($ret,','); + $ret = ltrim($ret, ','); + return $ret; } @@ -780,6 +787,7 @@ class XXX if ($genre !== null) { $res = $this->pdo->queryInsert(sprintf('INSERT INTO genres (title, type, disabled) VALUES (%s ,%d ,%d)', $this->pdo->escapeString($genre), Category::XXX_ROOT, 0)); } + return $res; } @@ -797,7 +805,7 @@ class XXX if ($whichclass === 'ade') { if (!empty($res)) { $trailers = unserialize($res, 'ade'); - $ret .=""; + $ret .= ""; $ret .= ""; $ret .= ""; @@ -808,7 +816,7 @@ class XXX if (!empty($res)) { $trailers = unserialize($res, 'pop'); $ret .= ""; return $ret; diff --git a/nntmux/libraries/TraktAPI.php b/nntmux/libraries/TraktAPI.php index 0637628ad..cead9447f 100755 --- a/nntmux/libraries/TraktAPI.php +++ b/nntmux/libraries/TraktAPI.php @@ -168,11 +168,13 @@ Class TraktAPI { } catch (RequestException $e) { if ($e->hasResponse()) { if($e->getCode() === 404) { - ColorCLI::doEcho(ColorCLI::notice('Data not available on server')); + ColorCLI::doEcho(ColorCLI::notice('Data not available on TraktTV server')); } else if ($e->getCode() === 503) { - ColorCLI::doEcho(ColorCLI::notice('Service unavailable')); + ColorCLI::doEcho(ColorCLI::notice('TraktTV service unavailable')); + } else if ($e->getCode() === 401) { + ColorCLI::doEcho(ColorCLI::notice('Unauthorized - OAuth must be provided for TraktTV')); } else { - ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data, server responded with code: ' . $e->getCode())); + ColorCLI::doEcho(ColorCLI::notice('Unable to fetch data from TraktTV, server responded with code: ' . $e->getCode())); } } } catch (\RuntimeException $e) { diff --git a/resources/db/patches/mysql/+1~release_naming_regexes.sql b/resources/db/patches/mysql/0304~release_naming_regexes.sql similarity index 86% rename from resources/db/patches/mysql/+1~release_naming_regexes.sql rename to resources/db/patches/mysql/0304~release_naming_regexes.sql index c009c5e85..0eb81c7b1 100644 --- a/resources/db/patches/mysql/+1~release_naming_regexes.sql +++ b/resources/db/patches/mysql/0304~release_naming_regexes.sql @@ -16,7 +16,7 @@ INSERT INTO release_naming_regexes (id, group_regex, regex, status, description, VALUES ( 33, '^alt\\.binaries\\.(anime|multimedia.anime)\\.?(highspeed|repost)?', - '/^[[(]\\d+\\/\\d+[])] - " ?(?P.+?) ?[. ](7z|avi|md5|mkv|mp4|nzb|par|vol)t?\\d+.+yEnc$/, + '/^[[(]\\d+\\/\\d+[])] - " ?(?P.+?) ?[. ](7z|avi|md5|mkv|mp4|nzb|par|vol)t?\\d+.+yEnc$/', 1, '//[01/17] - "[neko-raws] Niji-iro Days 02 [BD][1080p][FLAC][768CC18E]v2.par2" - 590,59 MB yEnc', 5 @@ -32,6 +32,6 @@ VALUES ( '^alt\\.binaries\\.(anime|multimedia.anime)\\.?(highspeed|repost)?', '/^.+\\" ?[ .-]?(?P.+?) ?[ .](7z|avi|md5|mkv|mp4|nfo|nzb|par|vol)t?\\d?+.+[[(]\\d+\\/\\d+[])]$/', 1, - '//My Hero Academia Textless Opening Song 'THE DAY' (BD AVC 1080p FLAC) [6D660059] - "My Hero Academia Textless Opening Song 'THE DAY' (BD AVC 1080p FLAC) [6D660059] nfo" yEnc (01/35)', + '//My Hero Academia Textless Opening Song \'THE DAY\' (BD AVC 1080p FLAC) [6D660059] - "My Hero Academia Textless Opening Song \'THE DAY\' (BD AVC 1080p FLAC) [6D660059] nfo" yEnc (01/35)', 15 ); diff --git a/www/themes/Gentele/templates/viewanime.tpl b/www/themes/Gentele/templates/viewanime.tpl index 825ee5d69..9d0c8e1e7 100755 --- a/www/themes/Gentele/templates/viewanime.tpl +++ b/www/themes/Gentele/templates/viewanime.tpl @@ -1,3 +1,4 @@ + View > Anime @@ -13,16 +14,13 @@ - - - {$animeTitle} + + {$animeTitle} {if isset($isadmin)} Edit {/if} - - - + {if animePicture != ''} AniDB Rating: {$animeRating|escape:"htmlall"}{/if} {if $animeRelated != ''}Related Anime: {$animeRelated|escape:"htmlall"}{/if} - - - - View AniDB - RSS - feed for this Anime + + + View AniDB + RSS + feed for this Anime + @@ -100,8 +98,8 @@ + type="checkbox" class="flat" + value="{$result.guid}"/> {$result.searchname|escape:"htmlall"|replace:".":" "} @@ -137,19 +135,20 @@ data-original-title="Comments"> + id="guid{$result.guid}" class="icon_cart fa fa-shopping-basket" + data-toggle="tooltip" + data-placement="top" title + data-original-title="Send to my Download Basket"> {if isset($sabintegrated) && $sabintegrated !=""} + id="guid{$result.guid}" + class="fa fa-share" + data-toggle="tooltip" + data-placement="top" title + data-original-title="Send to My Queue"> {/if} @@ -163,5 +162,10 @@ {/foreach} + + + + + {/if}