From 55e8ab34d2956f73c88479a1da404a4e42468afd Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 21 Dec 2017 12:41:28 +0100 Subject: [PATCH] Remove custom logging from nntmux, laravel handles errors now --- Changelog | 1 + app/Extensions/util/yenc/adapter/Php.php | 15 - cli/data/predb_import_daily_batch.php | 29 - misc/update/tmux/monitor.php | 3 - nntmux/Backfill.php | 30 - nntmux/Binaries.php | 27 +- nntmux/Console.php | 9 - nntmux/Logger.php | 484 ----------- nntmux/LoggerException.php | 27 - nntmux/Movie.php | 40 - nntmux/NNTP.php | 86 +- nntmux/NZB.php | 11 - nntmux/config/Configure.php | 12 +- nntmux/config/settings.example.php | 152 +--- nntmux/db/DB.php | 50 -- nntmux/db/DbUpdate.php | 5 +- nntmux/db/PreDb.php | 60 +- nntmux/db/populate/AniDB.php | 16 - nntmux/processing/PostProcess.php | 3 - nntmux/processing/post/AniDB.php | 12 - nntmux/processing/post/ProcessAdditional.php | 813 ++++++++++--------- nntmux/processing/tv/TV.php | 7 - public/pages/BasePage.php | 2 +- 23 files changed, 450 insertions(+), 1444 deletions(-) delete mode 100755 nntmux/Logger.php delete mode 100755 nntmux/LoggerException.php diff --git a/Changelog b/Changelog index 442a616c2..d68c0c80a 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-12-21 DariusIII + * Chg: Remove custom logging from nntmux, laravel handles errors now * Chg: Update laravel/framework and watson/rememberable to their latest versions * Fix: Fix users_id column length in all tables * Chg: Update ProcessReleases collections/binaries/parts tables handling diff --git a/app/Extensions/util/yenc/adapter/Php.php b/app/Extensions/util/yenc/adapter/Php.php index 503a722ba..a5af0bde7 100644 --- a/app/Extensions/util/yenc/adapter/Php.php +++ b/app/Extensions/util/yenc/adapter/Php.php @@ -19,8 +19,6 @@ namespace App\Extensions\util\yenc\adapter; -use nntmux\Logger; - /** * Class Php. */ @@ -50,10 +48,6 @@ class Php // Make sure the header and trailer file sizes match up. if ($headerSize != $trailerSize) { $message = 'Header and trailer file sizes do not match. This is a violation of the yEnc specification.'; - if (NN_LOGGING || NN_DEBUG) { - (new Logger())->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); - } - throw new \RuntimeException($message); } @@ -71,9 +65,6 @@ class Php // Make sure the decoded file size is the same as the size specified in the header. if (strlen($decoded) != $headerSize) { $message = 'Header file size ('.$headerSize.') and actual file size ('.strlen($decoded).') do not match. The file is probably corrupt.'; - if (NN_LOGGING || NN_DEBUG) { - (new Logger())->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); - } throw new \RuntimeException($message); } @@ -81,9 +72,6 @@ class Php // Check the CRC value if ($crc !== '' && (strtolower($crc) !== strtolower(sprintf('%04X', crc32($decoded))))) { $message = 'CRC32 checksums do not match. The file is probably corrupt.'; - if (NN_LOGGING || NN_DEBUG) { - (new Logger())->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); - } throw new \RuntimeException($message); } @@ -146,9 +134,6 @@ class Php if ($lineLength < 1) { $message = $lineLength.' is not a valid line length.'; - if (NN_LOGGING || NN_DEBUG) { - (new Logger())->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); - } throw new \RuntimeException($message); } diff --git a/cli/data/predb_import_daily_batch.php b/cli/data/predb_import_daily_batch.php index 8b18f645a..a1701b64e 100755 --- a/cli/data/predb_import_daily_batch.php +++ b/cli/data/predb_import_daily_batch.php @@ -28,9 +28,6 @@ use nntmux\db\PreDb; use nntmux\utility\Utility; if (! Utility::isWin()) { - if (NN_DEBUG) { - echo "Checking resource path\n"; - } $canExeRead = Utility::canExecuteRead(NN_RES); if (is_string($canExeRead)) { exit($canExeRead); @@ -38,9 +35,6 @@ if (! Utility::isWin()) { unset($canExeRead); } -if (NN_DEBUG) { - echo "Checking directory is writable\n"; -} if (! is_writable(NN_RES)) { exit('The ('.NN_RES.') folder must be writable.'.PHP_EOL); } @@ -60,17 +54,10 @@ if (! isset($argv[1]) || (! is_numeric($argv[1]) && $argv[1] !== 'progress') || 'Argument 3: Show output of queries or not, true | false'.PHP_EOL ); } -if (NN_DEBUG) { - echo "Parameter check completed\n"; -} $url = 'https://api.github.com/repos/nZEDb/nZEDbPre_Dumps/contents/dumps/'; $filePattern = '(?P(?P\d+)_predb_dump\.csv\.gz)'; -if (NN_DEBUG) { - echo "Fetching predb_dump directory list from GitHub\n"; -} - $result = getDirListing($url); $dirs = json_decode($result, true); @@ -80,10 +67,6 @@ if (is_null($dirs) || exit("Error: $result"); } -if (NN_DEBUG) { - echo "Fetching predb_dump lists from GitHub\n"; -} - foreach ($dirs as $dir) { if ($dir['name'] == '0README.txt') { continue; @@ -91,10 +74,6 @@ foreach ($dirs as $dir) { $result = getDirListing($url.$dir['name'].'/'); - if (NN_DEBUG) { - echo "Extracting filenames from list.\n"; - } - $temp = json_decode($result, true); if (is_null($temp)) { exit("Error: $result"); @@ -140,10 +119,6 @@ foreach ($data as $dir => $files) { echo "Error downloading dump {$match[2]} you can try manually importing it.". PHP_EOL; continue; - } else { - if (NN_DEBUG) { - echo "Dump {$match[2]} downloaded\n"; - } } // Make sure we didn't get an HTML page. @@ -222,10 +197,6 @@ foreach ($data as $dir => $files) { } else { echo "Ignoring: {$file['download_url']}\n"; } - } else { - if (NN_DEBUG) { - echo "^https://raw.githubusercontent.com/nZEDb/nZEDbPre_Dumps/master/dumps/$dir/$filePattern$\n {$file['download_url']}\n"; - } } } } diff --git a/misc/update/tmux/monitor.php b/misc/update/tmux/monitor.php index bd1f43541..a0295d122 100644 --- a/misc/update/tmux/monitor.php +++ b/misc/update/tmux/monitor.php @@ -32,10 +32,7 @@ $PHP = 'php'; $PYTHON = ($tRun->command_exist('python3') ? 'python3 -OOu' : 'python -OOu'); //assign shell commands -$show_time = (NN_DEBUG ? '/usr/bin/time' : ''); -$runVar['commands']['_php'] = $show_time." nice -n{$tmux_niceness} $PHP"; $runVar['commands']['_phpn'] = "nice -n{$tmux_niceness} $PHP"; -$runVar['commands']['_python'] = $show_time." nice -n{$tmux_niceness} $PYTHON"; $runVar['commands']['_sleep'] = "{$runVar['commands']['_phpn']} {$runVar['paths']['misc']}update/tmux/bin/showsleep.php"; //spawn IRCScraper as soon as possible diff --git a/nntmux/Backfill.php b/nntmux/Backfill.php index 423ce3b12..8bb7d9524 100755 --- a/nntmux/Backfill.php +++ b/nntmux/Backfill.php @@ -106,15 +106,6 @@ class Backfill ? $options['NNTP'] : new NNTP(['Settings' => $this->pdo]) ); - $this->_debug = (NN_LOGGING || NN_DEBUG); - if ($this->_debug) { - try { - $this->_debugging = ($options['Logger'] instanceof Logger ? $options['Logger'] : new Logger(['ColorCLI' => $this->pdo->log])); - } catch (LoggerException $error) { - $this->_debug = false; - } - } - $this->_compressedHeaders = (int) Settings::settingValue('..compressedheaders') === 1; $this->_safeBackFillDate = Settings::settingValue('..safebackfilldate') !== '' ? (string) Settings::settingValue('safebackfilldate') : '2008-08-14'; $this->_safePartRepair = (int) Settings::settingValue('..safepartrepair') === 1 ? 'update' : 'backfill'; @@ -153,9 +144,6 @@ class Backfill ' group(s) - Using compression? '. ($this->_compressedHeaders ? 'Yes' : 'No') ); - if ($this->_debug) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $dMessage, Logger::LOG_INFO); - } if ($this->_echoCLI) { ColorCLI::doEcho(ColorCLI::header($dMessage), true); @@ -173,9 +161,6 @@ class Backfill foreach ($res as $groupArr) { if ($groupName === '') { $dMessage = 'Starting group '.$counter.' of '.$groupCount; - if ($this->_debug) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $dMessage, Logger::LOG_INFO); - } if ($this->_echoCLI) { ColorCLI::doEcho(ColorCLI::header($dMessage), true); @@ -186,18 +171,12 @@ class Backfill } $dMessage = 'Backfilling completed in '.number_format(microtime(true) - $allTime, 2).' seconds.'; - if ($this->_debug) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $dMessage, Logger::LOG_INFO); - } if ($this->_echoCLI) { ColorCLI::doEcho(ColorCLI::primary($dMessage)); } } else { $dMessage = 'No groups specified. Ensure groups are added to database for updating.'; - if ($this->_debug) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $dMessage, Logger::LOG_FATAL); - } if ($this->_echoCLI) { ColorCLI::doEcho(ColorCLI::warning($dMessage), true); @@ -230,9 +209,6 @@ class Backfill 'You need to run update_binaries on '. $groupName. '. Otherwise the group is dead, you must disable it.'; - if ($this->_debug) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $dMessage, Logger::LOG_ERROR); - } if ($this->_echoCLI) { ColorCLI::doEcho(ColorCLI::error($dMessage)); @@ -278,9 +254,6 @@ class Backfill $groupName. ($this->_disableBackfillGroup ? ', disabling backfill on it.' : ', skipping it, consider disabling backfill on it.'); - if ($this->_debug) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $dMessage, Logger::LOG_NOTICE); - } if ($this->_disableBackfillGroup) { $this->_groups->updateGroupStatus($groupArr['id'], 'backfill', 0); @@ -417,9 +390,6 @@ class Backfill 'No groups to backfill, they are all at the target date '. $this->_safeBackFillDate. ', or you have not enabled them to be backfilled in the groups page.'.PHP_EOL; - if ($this->_debug) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $dMessage, Logger::LOG_FATAL); - } exit($dMessage); } $this->backfillAllGroups($groupname['name'], $articles); diff --git a/nntmux/Binaries.php b/nntmux/Binaries.php index 5cfea55ae..d5cb13b6c 100755 --- a/nntmux/Binaries.php +++ b/nntmux/Binaries.php @@ -302,7 +302,6 @@ class Binaries $this->log( 'Updating: '.$groupCount.' group(s) - Using compression? '.($this->_compressedHeaders ? 'Yes' : 'No'), __FUNCTION__, - Logger::LOG_INFO, 'header' ); @@ -311,7 +310,6 @@ class Binaries $this->log( 'Starting group '.$counter.' of '.$groupCount, __FUNCTION__, - Logger::LOG_INFO, 'header' ); $this->updateGroup($group, $maxHeaders); @@ -321,14 +319,12 @@ class Binaries $this->log( 'Updating completed in '.number_format(microtime(true) - $allTime, 2).' seconds.', __FUNCTION__, - Logger::LOG_INFO, 'primary' ); } else { $this->log( 'No groups specified. Ensure groups are added to NNTmux\'s database for updating.', __FUNCTION__, - Logger::LOG_NOTICE, 'warning' ); } @@ -665,7 +661,6 @@ class Binaries $this->log( "Code {$headers->code}: $message\nSkipping group: {$this->groupMySQL['name']}", __FUNCTION__, - Logger::LOG_WARNING, 'error' ); @@ -800,7 +795,6 @@ class Binaries $this->log( $notInsertedCount.' articles failed to insert!', __FUNCTION__, - Logger::LOG_WARNING, 'warning' ); } @@ -1353,21 +1347,6 @@ class Binaries $date = strtotime($date); } - if ($this->_debug) { - $this->_debugging->log( - __CLASS__, - __FUNCTION__, - 'Article ('. - $post. - "'s) date is (". - $date. - ') ('. - $this->daysOld($date). - ' days old)', - Logger::LOG_INFO - ); - } - return $date; } @@ -1735,7 +1714,7 @@ class Binaries * @param int $level Logger severity level constant. * @param string $color ColorCLI method name. */ - private function log($message, $method, $level, $color): void + private function log($message, $method, $color): void { if ($this->_echoCLI) { ColorCLI::doEcho( @@ -1743,10 +1722,6 @@ class Binaries true ); } - - if ($this->_debug) { - $this->_debugging->log(__CLASS__, $method, $message, $level); - } } /** diff --git a/nntmux/Console.php b/nntmux/Console.php index 2472a3df8..f962a21c3 100755 --- a/nntmux/Console.php +++ b/nntmux/Console.php @@ -447,10 +447,6 @@ class Console similar_text(strtolower($gameInfo['title']), strtolower($con['title']), $titlepercent); similar_text(strtolower($gameInfo['platform']), strtolower($con['platform']), $platformpercent); - if (NN_DEBUG) { - echo PHP_EOL."Matched: Title Percentage 1: $titlepercent% between ".$gameInfo['title'].' and '.$con['title'].PHP_EOL; - } - // Since Wii Ware games and XBLA have inconsistent original platforms, as long as title is 50% its ok. if (preg_match('/wiiware|xbla/i', trim($gameInfo['platform'])) && $titlepercent >= 50) { $titlepercent = 100; @@ -468,11 +464,6 @@ class Console similar_text(strtolower($gameInfo['title']), strtolower($con['title']), $titlepercent); } - if (NN_DEBUG) { - echo "Matched: Title Percentage 2: $titlepercent% between ".$gameInfo['title'].' and '.$con['title'].PHP_EOL; - echo "Matched: Platform Percentage: $platformpercent% between ".$gameInfo['platform'].' and '.$con['platform'].PHP_EOL; - } - // Platform must equal 100%. if ($platformpercent === 100 && $titlepercent >= 70) { $matched = true; diff --git a/nntmux/Logger.php b/nntmux/Logger.php deleted file mode 100755 index 1fdf388f3..000000000 --- a/nntmux/Logger.php +++ /dev/null @@ -1,484 +0,0 @@ -Logger->start("MyClassName", "MyMethodName", "My debug message.", LOG_INFO); - */ -class Logger -{ - // You can use these constants when using the start method. - const LOG_FATAL = 1; // Fatal error, the program exited. - const LOG_ERROR = 2; // Recoverable error. - const LOG_WARNING = 3; // Warnings. - const LOG_NOTICE = 4; // Notices. - const LOG_INFO = 5; // Info message, not important. - const LOG_SQL = 6; // Full SQL query when it fails. - - /** - * Name of class we are currently logging. - * @var string - */ - private $class; - - /** - * Name of method we are currently logging. - * @var string - */ - private $method; - - /** - * The log message. - * @var string - */ - private $logMessage = ''; - - /** - * Severity level. - * @var string - */ - private $severity = ''; - - /** - * @var Monolog - */ - private $logger; - - /** - * @var LineFormatter - */ - private $formatter; - - /** - * @var bool - */ - private $outputCLI; - - /** - * Is this the windows O/S? - * @var bool - */ - private $isWindows; - - /** - * Unix time instance was created. - * @var int - */ - private $timeStart; - - /** - * How many old logs can we have max in the logs folder. - * (per log type, ex.: debug can have x logs, not_yEnc can have x logs, etc). - * @var int - */ - private $maxLogs; - - /** - * Max log size in MegaBytes. - * @var int - */ - private $maxLogSize; - - /** - * Current name of the log file. - * @var string - */ - private $currentLogName; - - /** - * Current folder to store log files. - * @var string - */ - private $currentLogFolder; - - /** - * Show memory usage in log/cli out? - * @var bool - */ - private $showMemoryUsage; - - /** - * Show CPU load in log/cli out? - * @var bool - */ - private $showCPULoad; - - /** - * Show running time of script on log/cli out? - * @var bool - */ - private $showRunningTime; - - /** - * Show resource usages on log/cli out?. - * @var bool - */ - private $showResourceUsage; - - /** - * Constructor. - * - * @param array $options (Optional) Class instances. - * (Optional) Folder to store log files in. - * (Optional) Filename of log, must be alphanumeric (a-z 0-9) and contain no file extensions. - * - * @throws LoggerException - * @throws \Exception - * @throws \InvalidArgumentException - */ - public function __construct(array $options = []) - { - if (! NN_LOGGING && ! NN_DEBUG) { - return; - } - - $defaults = [ - 'ColorCLI' => null, - 'LogFolder' => '', - 'LogFileName' => '', - ]; - $options += $defaults; - - $this->getSettings(); - - $this->currentLogFolder = ( - ! empty($options['LogFolder']) - ? $options['LogFolder'] - : $this->currentLogFolder - ); - - $this->currentLogName = ( - ! empty($options['LogFileName']) - ? $options['LogFileName'] - : $this->currentLogName - ).'.log'; - - $this->outputCLI = (strtolower(PHP_SAPI) === 'cli'); - $this->isWindows = stripos(PHP_OS, 'win') === 0; - $this->timeStart = time(); - - $this->logger = new Monolog('nntmux'); - $this->formatter = new LineFormatter(null, 'd/M/Y H:i', false, true); - $this->introspection = new IntrospectionProcessor(); - $this->gitprocessor = new GitProcessor(); - $this->memoryUsage = new MemoryUsageProcessor(); - $this->streamHandler = new StreamHandler($this->currentLogFolder.$this->currentLogName, Monolog::DEBUG); - $this->streamHandler->setFormatter($this->formatter); - $this->logger->pushHandler($this->streamHandler); - $this->logger->pushProcessor($this->introspection); - $this->logger->pushProcessor($this->gitprocessor); - if ($this->showMemoryUsage === true) { - $this->logger->pushProcessor($this->memoryUsage); - } - } - - /** - * Public method for logging and/or echoing log messages. - * - * @param string $class The name of the class. - * @param string $method The method this is coming from. - * @param string $message The message to log/echo. - * @param int $severity How severe is this message? - * 1 Fatal - The program had to stop (exit). - * 2 Error - Something went very wrong but we recovered. - * 3 Warning - Not an error, but something we can probably fix. - * 4 Notice - User errors - the user did not enable any groups for example. - * 5 Info - General info, like we logged in to usenet for example. - * 6 Query - Failed SQL queries. (the full query). - */ - public function log($class, $method, $message, $severity): void - { - // Check if echo debugging or logging is on. - if (! NN_DEBUG && ! NN_LOGGING) { - return; - } - - $this->severity = $severity; - // Check the severity of the message, if disabled return, if enabled create part of the log message. - if (! $this->checkSeverity()) { - return; - } - - $this->class = $class; - $this->method = $method; - $this->logMessage = $message; - - $this->formLogMessage(); - $this->echoMessage(); - $this->logMessage(); - } - - /** - * Get resource usage string. - * - * @return bool|string - */ - public function getResUsage() - { - if (! $this->isWindows) { - $usage = getrusage(); - - return - 'USR: '.$this->formatTimeString($usage['ru_utime.tv_sec']). - ' SYS: '.$this->formatTimeString($usage['ru_stime.tv_sec']). - ' FAULTS: '.$usage['ru_majflt']. - ' SWAPS: '.$usage['ru_nswap']; - } - - return false; - } - - /** - * Get system load. - * - * @return string|bool - */ - public function getSystemLoad() - { - if (! $this->isWindows) { - $string = ''; - // Fix for single digits (2) or single float (2.1). - foreach (sys_getloadavg() as $load) { - $strLen = strlen($load); - if ($strLen === 1) { - $string .= $load.'.00,'; - } elseif ($strLen === 3) { - $string .= str_pad($load, 4, '0', STR_PAD_RIGHT).','; - } else { - $string .= $load.','; - } - } - - return substr($string, 0, -1); - } - - return false; - } - - /** - * Changes the location of the log file. - * - * @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). - * - * @throws \nntmux\LoggerException - */ - public function changeLogFileLocation($folder, $fileName): void - { - $this->currentLogFolder = $folder; - $this->currentLogName = $fileName; - } - - /** - * Get the log folder, log name and full path to the default log. - * - * @return array - * @static - */ - public static function getDefaultLogPaths() - { - $defaultLogName = (defined('NN_LOGGING_LOG_NAME') ? NN_LOGGING_LOG_NAME : 'nntmux'); - $defaultLogName = (ctype_alnum($defaultLogName) ? $defaultLogName : 'nntmux'); - $defaultLogFolder = (defined('NN_LOGGING_LOG_FOLDER') && is_dir(NN_LOGGING_LOG_FOLDER) ? NN_LOGGING_LOG_FOLDER : NN_LOGS); - $defaultLogFolder = (in_array(substr($defaultLogFolder, -1), ['/', '\\'], false) ? $defaultLogFolder : $defaultLogFolder.DS); - - return [ - 'LogFolder' => $defaultLogFolder, - 'LogName' => $defaultLogName, - 'LogPath' => $defaultLogFolder.$defaultLogName.'.log', - ]; - } - - /** - * Get/set all settings. - */ - private function getSettings() - { - $this->maxLogs = (defined('NN_LOGGING_MAX_LOGS') ? NN_LOGGING_MAX_LOGS : 20); - $this->maxLogs = ($this->maxLogs < 1 ? 20 : $this->maxLogs); - $this->maxLogSize = (defined('NN_LOGGING_MAX_SIZE') ? NN_LOGGING_MAX_SIZE : 30); - $this->maxLogSize = ($this->maxLogSize < 1 ? 30 : $this->maxLogSize); - $this->showMemoryUsage = (bool) (defined('NN_LOGGING_LOG_MEMORY_USAGE') ? NN_LOGGING_LOG_MEMORY_USAGE : true); - $this->showCPULoad = (bool) (defined('NN_LOGGING_LOG_CPU_LOAD') ? NN_LOGGING_LOG_CPU_LOAD : true); - $this->showRunningTime = (bool) (defined('NN_LOGGING_LOG_RUNNING_TIME') ? NN_LOGGING_LOG_RUNNING_TIME : true); - $this->showResourceUsage = (bool) (defined('NN_LOGGING_LOG_RESOURCE_USAGE') ? NN_LOGGING_LOG_RESOURCE_USAGE : false); - $paths = self::getDefaultLogPaths(); - $this->currentLogName = $paths['LogName']; - $this->currentLogFolder = $paths['LogFolder']; - } - - /** - * Log message to file. - */ - private function logMessage() - { - // Check if debug logging is on. - if (! NN_LOGGING) { - return; - } - - $this->logger->debug($this->logMessage); - } - - /** - * Echo log message to CLI or web. - */ - private function echoMessage() - { - if (! NN_DEBUG) { - return; - } - - // Check if this is CLI or web. - if ($this->outputCLI) { - ColorCLI::doEcho(ColorCLI::debug($this->logMessage)); - } else { - echo '
'.$this->logMessage.'

'; - } - } - - /** - * Creates the message object for the log message. - */ - private function formLogMessage() - { - $pid = getmypid(); - - $this->logMessage = - // The severity. - $this->severity. - - // Average system load. - (($this->showCPULoad && ! $this->isWindows) ? ' ['.$this->getSystemLoad().']' : ''). - - // Script running time. - ($this->showRunningTime ? ' ['.$this->formatTimeString(time() - $this->timeStart).']' : ''). - - // Resource usage (user time, system time, major page faults, memory swaps). - (($this->showResourceUsage && ! $this->isWindows) ? ' ['.$this->getResUsage().']' : ''). - - // Running process id. - ($pid ? ' [PID:'.$pid.']' : ''). - - // The class/function. - ' ['.$this->class.'.'.$this->method.']'. - - ' ['. - - // Now reformat the log message, first stripping leading spaces. - trim( - - // Removing 2 or more spaces. - preg_replace( - '/\s{2,}/', - ' ', - - // Removing new lines and carriage returns. - str_replace(["\n", '\n', "\r", '\r'], ' ', $this->logMessage) - ) - ). - - ']'; - - return $this->logMessage; - } - - /** - * Convert seconds to hours minutes seconds string. - * - * @param int $seconds - * - * @return string - */ - private function formatTimeString($seconds) - { - $time = ''; - if ($seconds > 3600) { - $time .= str_pad(round(($seconds % 86400) / 3600), 2, '0', STR_PAD_LEFT).'H:'; - } else { - $time .= '00H:'; - } - if ($seconds > 60) { - $time .= str_pad(round(($seconds % 3600) / 60), 2, '0', STR_PAD_LEFT).'M:'; - } else { - $time .= '00M:'; - } - $time .= str_pad($seconds % 60, 2, '0', STR_PAD_LEFT).'S'; - - return $time; - } - - /** - * Check if the user wants to echo or log this message, form part of the log message at the same time. - * - * @return bool - */ - private function checkSeverity() - { - switch ($this->severity) { - case self::LOG_FATAL: - if (NN_LOGFATAL) { - $this->severity = '[FATAL] '; - - return true; - } - - return false; - case self::LOG_ERROR: - if (NN_LOGERROR) { - $this->severity = '[ERROR] '; - - return true; - } - - return false; - case self::LOG_WARNING: - if (NN_LOGWARNING) { - $this->severity = '[WARN] '; - - return true; - } - - return false; - case self::LOG_NOTICE: - if (NN_LOGNOTICE) { - $this->severity = '[NOTICE]'; - - return true; - } - - return false; - case self::LOG_INFO: - if (NN_LOGINFO) { - $this->severity = '[INFO] '; - - return true; - } - - return false; - case self::LOG_SQL: - if (NN_LOGQUERIES) { - $this->severity = '[SQL] '; - - return true; - } - - return false; - default: - return false; - } - } -} diff --git a/nntmux/LoggerException.php b/nntmux/LoggerException.php deleted file mode 100755 index ec8dfab3c..000000000 --- a/nntmux/LoggerException.php +++ /dev/null @@ -1,27 +0,0 @@ -. - * @author niel - * @copyright 2015 nZEDb - */ - -namespace nntmux; - -class LoggerException extends \Exception -{ -} diff --git a/nntmux/Movie.php b/nntmux/Movie.php index dd4c137f0..bf4b7131b 100755 --- a/nntmux/Movie.php +++ b/nntmux/Movie.php @@ -207,20 +207,10 @@ class Movie $this->searchEngines = true; $this->showPasswords = Releases::showPasswords(); - $this->debug = NN_DEBUG; $this->echooutput = ($options['Echo'] && NN_ECHOCLI && $this->pdo->cli); $this->imgSavePath = NN_COVERS.'movies'.DS; $this->service = ''; $this->catWhere = 'PARTITION (movies)'; - - if (NN_DEBUG || NN_LOGGING) { - $this->debug = true; - try { - $this->debugging = new Logger(); - } catch (LoggerException $error) { - $this->_debug = false; - } - } } /** @@ -842,20 +832,6 @@ class Movie // Check the similarity. similar_text($this->currentTitle, $ret['title'], $percent); if ($percent < 40) { - if ($this->debug) { - $this->debugging->log( - __CLASS__, - __FUNCTION__, - 'Found ('. - $ret['title']. - ') from TMDB, but it\'s only '. - $percent. - '% similar to ('. - $this->currentTitle.')', - Logger::LOG_INFO - ); - } - return false; } } @@ -973,19 +949,6 @@ class Movie // Check the similarity. similar_text($this->currentTitle, $ret['title'], $percent); if ($percent < 40) { - if ($this->debug) { - $this->debugging->log( - __CLASS__, - __FUNCTION__, - 'Found ('. - $ret['title']. - ') from IMDB, but it\'s only '. - $percent. - '% similar to ('. - $this->currentTitle.')', - Logger::LOG_INFO - ); - } return false; } @@ -1544,9 +1507,6 @@ class Movie $name = trim(preg_replace('/\s{2,}/', ' ', $name)); // Check if the name is long enough and not just numbers. if (strlen($name) > 4 && ! preg_match('/^\d+$/', $name)) { - if ($this->debug && $this->echooutput) { - ColorCLI::doEcho("DB name: {$releaseName}", true); - } $this->currentTitle = $name; $this->currentYear = ($year === '' ? false : $year); diff --git a/nntmux/NNTP.php b/nntmux/NNTP.php index 1934b0974..39310db16 100755 --- a/nntmux/NNTP.php +++ b/nntmux/NNTP.php @@ -102,15 +102,6 @@ class NNTP extends \Net_NNTP_Client $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $this->_debugBool = (NN_LOGGING || NN_DEBUG); - if ($this->_debugBool) { - try { - $this->_debugging = ($options['Logger'] instanceof Logger ? $options['Logger'] : new Logger(['ColorCLI' => $this->pdo->log])); - } catch (LoggerException $error) { - $this->_debugBool = false; - } - } - $this->_nntpRetries = Settings::settingValue('..nntpretries') !== '' ? (int) Settings::settingValue('..nntpretries') : 0 + 1; } @@ -209,9 +200,6 @@ class NNTP extends \Net_NNTP_Client $enc. ': '. $cError; - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_ERROR); - } return $this->throwError(ColorCLI::error($message)); } @@ -251,9 +239,6 @@ class NNTP extends \Net_NNTP_Client ' - '. $userName. ' ('.$aError.')'; - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_ERROR); - } return $this->throwError(ColorCLI::error($message)); } @@ -266,9 +251,6 @@ class NNTP extends \Net_NNTP_Client if ($compression === false || (int) Settings::settingValue('..compressedheaders') === 0) { $this->_compressionSupported = false; } - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, 'Connected to '.$this->_currentServer.'.', Logger::LOG_INFO); - } return true; } @@ -282,9 +264,6 @@ 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(__CLASS__, __FUNCTION__, $message, Logger::LOG_ERROR); - } return $this->throwError(ColorCLI::error($message)); } @@ -303,9 +282,6 @@ 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(__CLASS__, __FUNCTION__, 'Disconnecting from '.$this->_currentServer, Logger::LOG_INFO); - } // Disconnect from usenet. return parent::disconnect(); } @@ -591,9 +567,6 @@ class NNTP extends \Net_NNTP_Client if ($body !== '') { return $body; } - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $newBody->getMessage(), Logger::LOG_NOTICE); - } // Return the error. return $newBody; } @@ -623,9 +596,6 @@ class NNTP extends \Net_NNTP_Client // Else return an error. } else { $message = 'Wrong Identifier type, array, int or string accepted. This type of var was passed: '.gettype($identifiers); - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_WARNING); - } return $this->throwError(ColorCLI::error($message)); } @@ -663,9 +633,6 @@ class NNTP extends \Net_NNTP_Client $summary = $this->selectGroup($groupName); // If there was an error selecting the group, return PEAR error object. if ($this->isError($summary)) { - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $summary->getMessage(), Logger::LOG_NOTICE); - } return $summary; } @@ -681,9 +648,6 @@ class NNTP extends \Net_NNTP_Client $article = parent::getArticle($identifier); // If there was an error downloading the article, return a PEAR error object. if ($this->isError($article)) { - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $article->getMessage(), Logger::LOG_NOTICE); - } return $article; } @@ -748,9 +712,6 @@ class NNTP extends \Net_NNTP_Client $summary = $this->selectGroup($groupName); // Return PEAR error object on failure. if ($this->isError($summary)) { - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $summary->getMessage(), Logger::LOG_NOTICE); - } return $summary; } @@ -766,9 +727,6 @@ class NNTP extends \Net_NNTP_Client $header = parent::getHeader($identifier); // If we failed, return PEAR error object. if ($this->isError($header)) { - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $header->getMessage(), Logger::LOG_NOTICE); - } return $header; } @@ -814,9 +772,6 @@ 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(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); - } return $this->throwError(ColorCLI::error($message)); } @@ -829,18 +784,12 @@ class NNTP extends \Net_NNTP_Client // Throw errors if subject or from are more than 510 chars. if (\strlen($subject) > 510) { $message = 'Max length of subject is 510 chars.'; - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_WARNING); - } return $this->throwError(ColorCLI::error($message)); } if (\strlen($from) > 510) { $message = 'Max length of from is 510 chars.'; - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_WARNING); - } return $this->throwError(ColorCLI::error($message)); } @@ -887,9 +836,6 @@ class NNTP extends \Net_NNTP_Client $nntp->doQuit(); // Try reconnecting. This uses another round of max retries. if ($nntp->doConnect($comp) !== true) { - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, 'Unable to reconnect to usenet!', Logger::LOG_NOTICE); - } return $this->throwError('Unable to reconnect to usenet!'); } @@ -898,9 +844,6 @@ class NNTP extends \Net_NNTP_Client $data = $nntp->selectGroup($group); if ($this->isError($data)) { $message = "Code {$data->code}: {$data->message}\nSkipping group: {$group}"; - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); - } if ($this->_echo) { ColorCLI::doEcho(ColorCLI::error($message), true); @@ -980,9 +923,6 @@ class NNTP extends \Net_NNTP_Client // Check if it's good. if ($this->isError($response)) { - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $response->getMessage(), Logger::LOG_NOTICE); - } $this->_compressionSupported = false; return $response; @@ -996,9 +936,7 @@ class NNTP extends \Net_NNTP_Client } } $msg = "Sent 'XFEATURE COMPRESS GZIP' to server, got '$response: ".$this->_currentStatusResponse()."'"; - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $msg, Logger::LOG_NOTICE); - } + $this->_compressionSupported = false; return false; @@ -1095,9 +1033,7 @@ class NNTP extends \Net_NNTP_Client return $deComp; } $message = 'Decompression of OVER headers failed.'; - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); - } + $message = $this->throwError(ColorCLI::error($message), 1000); return $message; @@ -1117,9 +1053,7 @@ class NNTP extends \Net_NNTP_Client // If wet got nothing again, return error. if (empty($buffer)) { $message = 'Error fetching data from usenet server while downloading OVER headers.'; - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); - } + $message = $this->throwError(ColorCLI::error($message), 1000); return $message; @@ -1137,9 +1071,6 @@ class NNTP extends \Net_NNTP_Client } $message = 'Unspecified error while downloading OVER headers.'; - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_NOTICE); - } $message = $this->throwError(ColorCLI::error($message), 1000); return $message; @@ -1191,9 +1122,6 @@ class NNTP extends \Net_NNTP_Client $summary = $this->selectGroup($groupName); // If there was an error selecting the group, return PEAR error object. if ($this->isError($summary)) { - if ($this->_debugBool) { - $this->_debugging->log(__CLASS__, __FUNCTION__, $summary->getMessage(), Logger::LOG_WARNING); - } return $summary; } @@ -1228,14 +1156,6 @@ class NNTP extends \Net_NNTP_Client // Check if the line terminates the text response. if ($line === ".\r\n") { - if ($this->_debugBool) { - $this->_debugging->log( - __CLASS__, - __FUNCTION__, - 'Fetched body for article '.$identifier, - Logger::LOG_INFO - ); - } // Attempt to yEnc decode and return the body. return Yenc::decodeIgnore($body); diff --git a/nntmux/NZB.php b/nntmux/NZB.php index 7c59309ed..3e64f2ad5 100755 --- a/nntmux/NZB.php +++ b/nntmux/NZB.php @@ -123,17 +123,6 @@ class NZB 'NZB downloaded from %s', Settings::settingValue('site.main.title') ); - - $this->_debug = (NN_DEBUG || NN_LOGGING); - - if (NN_DEBUG || NN_LOGGING) { - $this->_debug = true; - try { - $this->debugging = new Logger(['ColorCLI' => $this->pdo->log]); - } catch (LoggerException $error) { - $this->_debug = false; - } - } } /** diff --git a/nntmux/config/Configure.php b/nntmux/config/Configure.php index cf86e425e..8106dd166 100755 --- a/nntmux/config/Configure.php +++ b/nntmux/config/Configure.php @@ -99,7 +99,7 @@ class Configure if (is_file($settings_file)) { require_once $settings_file; if (PHP_SAPI === 'cli') { - $current_settings_file_version = 6; // Update this when updating settings.example.php + $current_settings_file_version = 7; // Update this when updating settings.example.php if (! defined('NN_SETTINGS_FILE_VERSION') || NN_SETTINGS_FILE_VERSION !== $current_settings_file_version ) { @@ -113,22 +113,12 @@ class Configure define('ITEMS_PER_PAGE', '50'); define('ITEMS_PER_COVER_PAGE', '20'); define('NN_ECHOCLI', true); - define('NN_DEBUG', false); - define('NN_LOGGING', false); - define('NN_LOGINFO', false); - define('NN_LOGNOTICE', false); - define('NN_LOGWARNING', false); - define('NN_LOGERROR', false); - define('NN_LOGFATAL', false); - define('NN_LOGQUERIES', false); - define('NN_LOGAUTOLOADER', false); define('NN_QUERY_STRIP_WHITESPACE', false); define('NN_RENAME_PAR2', true); define('NN_RENAME_MUSIC_MEDIAINFO', true); define('NN_CACHE_EXPIRY_SHORT', 300); define('NN_CACHE_EXPIRY_MEDIUM', 600); define('NN_CACHE_EXPIRY_LONG', 900); - define('NN_PREINFO_OPEN', false); define('NN_FLOOD_CHECK', false); define('NN_FLOOD_WAIT_TIME', 5); define('NN_FLOOD_MAX_REQUESTS_PER_SECOND', 5); diff --git a/nntmux/config/settings.example.php b/nntmux/config/settings.example.php index d25f54b54..2317ac9ea 100755 --- a/nntmux/config/settings.example.php +++ b/nntmux/config/settings.example.php @@ -16,9 +16,9 @@ * * @note Developers: When updating settings.example.php, up this version * and $current_settings_file_version in nntmux\config\Configure.php - * @version 5 + * @version 7 */ -define('NN_SETTINGS_FILE_VERSION', 6); +define('NN_SETTINGS_FILE_VERSION', 7); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// Web Settings ////////////////////////////////////////////////////////// @@ -49,13 +49,6 @@ define('ITEMS_PER_COVER_PAGE', '20'); */ define('NN_MAX_PAGER_RESULTS', '125000'); -/* - * If the PRE API page (preinfo) is open to the public or only accessible by registered / api users. - * - * @default false - */ -define('NN_PREINFO_OPEN', false); - /* * Whether to check if a person is trying to send too many requests in a given amount of time, * lock out the person of the site for a amount of time. @@ -79,16 +72,6 @@ define('NN_FLOOD_WAIT_TIME', 5); */ define('NN_FLOOD_MAX_REQUESTS_PER_SECOND', 5); -/* - * The higher this number, the more secure the password algorithm for the website will be, at the cost - * of server resources. - * To find a good number for your server, run the misc/testing/Various/find_password_hash_cost.php script. - * - * @note It is not recommended to set this under 11. - * @default 11 - */ -define('NN_PASSWORD_HASH_COST', 11); - /* * The type of search system to use on the site. * @@ -245,136 +228,6 @@ define('NN_CACHE_EXPIRY_SHORT', 300); define('NN_CACHE_EXPIRY_MEDIUM', 600); define('NN_CACHE_EXPIRY_LONG', 900); -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////// Log Settings ////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -/* - * Display debug messages on console or web page. - * - * @default false - */ -define('NN_DEBUG', false); - -/* - * Log debug messages to newznab/resources/debug.log - * - * @default false - */ -define('NN_LOGGING', false); - -/* - * var_dump missing autoloader files. - * - * @note Dev setting. - * @default false - */ -define('NN_LOGAUTOLOADER', false); - -/* - * How many log files to keep in the log folder. - * - * @default 20 - */ -define('NN_LOGGING_MAX_LOGS', 20); - -/* - * How large can the log files be in MegaBytes before we create a new one? The old files are compressed. - * - * @default 30 - */ -define('NN_LOGGING_MAX_SIZE', 30); - -/* - * The folder to put the log files in. Put quotes, example : '/var/log/NN/' - * The default is in the NN root folder /resources/logs/ - * - * @example '/var/log/NN/' - * @default NN_LOGS - */ -define('NN_LOGGING_LOG_FOLDER', NN_LOGS); - -/* - * The name of the log file. - * Must be alphanumeric (a-z 0-9) and contain no file extensions. - * - * @default 'newznab' - */ -define('NN_LOGGING_LOG_NAME', 'nntmux'); - -/* - * Display memory usage in log file and debug message output? - * - * @default true - */ -define('NN_LOGGING_LOG_MEMORY_USAGE', true); - -/* - * Display CPU load in log file and debug message output? - * - * @default true - */ -define('NN_LOGGING_LOG_CPU_LOAD', true); - -/* - * Display running time in log file and debug message output? - * - * @default true - */ -define('NN_LOGGING_LOG_RUNNING_TIME', true); - -/* - * Display resource usage in log file and debug message output? - * - * @default false - */ -define('NN_LOGGING_LOG_RESOURCE_USAGE', false); - -/********************************************************************************* - * The following options require either NN_DEBUG OR NN_LOGGING to be true: * - *********************************************************************************/ - -/* - * Log and/or echo debug Info messages. - * - * @default false - */ -define('NN_LOGINFO', false); - -/* - * Log and/or echo debug Notice messages. - * - * @default false - */ -define('NN_LOGNOTICE', false); - -/* - * Log and/or echo debug Warning messages. - * - * @default false - */ -define('NN_LOGWARNING', false); - -/* - * Log and/or echo debug Error messages. - * - * @default false - */ -define('NN_LOGERROR', false); - -/* - * Log and/or echo debug Fatal messages. - * - * @default false - */ -define('NN_LOGFATAL', false); - -/* - * Log and/or echo debug failed SQL queries. - * - * @default false - */ -define('NN_LOGQUERIES', false); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// SQL Settings ////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -473,6 +326,7 @@ if (extension_loaded('xdebug')) { * //////////////////////////////////////////////// Change log //////////////////////////////////////////////////////////// * //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * + * 2017-12-21 v7 Remove custom logging settings, Laravel is handling errors now * 2017-10-11 v6 Remove settings for PHP web/CLI SAPI's as these are now handled by Laravel * 2015-08-26 v4 Add settings for PHP web/CLI SAPI's. * Add settings for Xdebug. diff --git a/nntmux/db/DB.php b/nntmux/db/DB.php index ef73f3868..3878c37e7 100755 --- a/nntmux/db/DB.php +++ b/nntmux/db/DB.php @@ -2,13 +2,11 @@ namespace nntmux\db; -use nntmux\Logger; use nntmux\ColorCLI; use Ramsey\Uuid\Uuid; use App\Models\Settings; use nntmux\ConsoleTools; use nntmux\libraries\Cache; -use nntmux\LoggerException; use nntmux\utility\Utility; use nntmux\libraries\CacheException; @@ -151,15 +149,6 @@ class DB extends \PDO $this->ct = $this->opts['ct']; $this->log = $this->opts['log']; - $this->_debug = (NN_DEBUG || NN_LOGGING); - if ($this->_debug) { - try { - $this->debugging = new Logger(['ColorCLI' => $this->log]); - } catch (LoggerException $error) { - $this->_debug = false; - } - } - if ($this->opts['checkVersion']) { $this->fetchDbVersion(); } @@ -236,22 +225,6 @@ class DB extends \PDO return $result->fetchAll(\PDO::FETCH_ASSOC); } - public function debugDisable() - { - unset($this->debugging); - $this->_debug = false; - } - - public function debugEnable() - { - $this->_debug = true; - try { - $this->debugging = new Logger(['ColorCLI' => $this->log]); - } catch (LoggerException $error) { - $this->_debug = false; - } - } - public function getTableList() { $result = $this->pdo->query('SHOW DATABASES'); @@ -463,10 +436,6 @@ class DB extends \PDO return $result; } } - if ($this->_debug) { - $this->echoError($error, 'queryInsert', 4); - $this->debugging->log(__CLASS__, __FUNCTION__, $query, Logger::LOG_SQL); - } return false; } @@ -523,10 +492,6 @@ class DB extends \PDO return $result; } } - if ($silent === false && $this->_debug) { - $this->echoError($error, 'queryExec', 4); - $this->debugging->log(__CLASS__, __FUNCTION__, $query, Logger::LOG_SQL); - } return false; } @@ -613,9 +578,6 @@ class DB extends \PDO } elseif (! $silent) { $this->echoError($e->getMessage(), 'Exec', 4, false); - if ($this->_debug) { - $this->debugging->log(__CLASS__, __FUNCTION__, $query, Logger::LOG_SQL); - } } return false; @@ -789,9 +751,6 @@ class DB extends \PDO } else { if ($ignore === false) { $this->echoError($e->getMessage(), 'queryDirect', 4, false); - if ($this->_debug) { - $this->debugging->log(__CLASS__, __FUNCTION__, $query, Logger::LOG_SQL); - } } $result = false; } @@ -944,9 +903,6 @@ class DB extends \PDO if ($web === false) { echo ColorCLI::primary($message); } - if ($this->_debug) { - $this->debugging->log(__CLASS__, __FUNCTION__, $message, Logger::LOG_INFO); - } } /** @@ -1181,9 +1137,6 @@ class DB extends \PDO try { $PDOstatement = $this->pdo->prepare($query, $options); } catch (\PDOException $e) { - if ($this->_debug) { - $this->debugging->log(__CLASS__, __FUNCTION__, $e->getMessage(), Logger::LOG_INFO); - } echo ColorCLI::error("\n".$e->getMessage()); $PDOstatement = false; } @@ -1205,9 +1158,6 @@ class DB extends \PDO try { $result = $this->pdo->getAttribute($attribute); } catch (\PDOException $e) { - if ($this->_debug) { - $this->debugging->log(__CLASS__, __FUNCTION__, $e->getMessage(), Logger::LOG_INFO); - } echo ColorCLI::error("\n".$e->getMessage()); $result = false; } diff --git a/nntmux/db/DbUpdate.php b/nntmux/db/DbUpdate.php index c4fe40160..d2d801f10 100755 --- a/nntmux/db/DbUpdate.php +++ b/nntmux/db/DbUpdate.php @@ -94,7 +94,7 @@ class DbUpdate ]; $options += $defaults; - $show = (Utility::isCLI() || NN_DEBUG); + $show = Utility::isCLI(); $files = empty($options['files']) ? Utility::getDirFiles($options) : $options['files']; natsort($files); @@ -343,9 +343,6 @@ class DbUpdate // Check for non default delimiters ($$ for example). if (preg_match('#^\s*DELIMITER\s+(?P.+)\s*$#i', $line, $matches)) { $delimiter = $matches['delimiter']; - if (NN_DEBUG) { - echo ColorCLI::debug("DEBUG: Delimiter switched to $delimiter"); - } if ($delimiter !== $options['delimiter']) { continue; } diff --git a/nntmux/db/PreDb.php b/nntmux/db/PreDb.php index 40e67c4ef..906d7913e 100755 --- a/nntmux/db/PreDb.php +++ b/nntmux/db/PreDb.php @@ -27,15 +27,15 @@ class PreDb extends DB * @var array Prepared Statement objects */ protected $ps = [ - 'AddGroups' => null, - 'DeleteShort' => null, - 'Export' => null, - 'Import' => null, - 'Insert' => null, - 'LoadData' => null, - 'Truncate' => null, - 'UpdateGroupID' => null, - ]; + 'AddGroups' => null, + 'DeleteShort' => null, + 'Export' => null, + 'Import' => null, + 'Insert' => null, + 'LoadData' => null, + 'Truncate' => null, + 'UpdateGroupID' => null, + ]; public function __construct(array $options = []) { @@ -79,13 +79,13 @@ class PreDb extends DB public function executeExport(array $options = null) { $defaults = [ - 'enclosedby' => '', - 'fields' => '\t', - 'limit' => 0, - 'lines' => '\r\n', // use Windows style endings so that text can contain \n - 'local' => false, - 'path' => null, - ]; + 'enclosedby' => '', + 'fields' => '\t', + 'limit' => 0, + 'lines' => '\r\n', // use Windows style endings so that text can contain \n + 'local' => false, + 'path' => null, + ]; $options += $defaults; if (empty($options['path'])) { @@ -105,9 +105,6 @@ SELECT title, nfo, size, files, filename, nuked, nukereason, category, predate, FIELDS TERMINATED BY '{$options['fields']}' $enclosedby LINES TERMINATED BY '{$options['lines']}'; SQL_EXPORT; - if (NN_DEBUG) { - echo "$sql\n"; - } return $this->queryDirect($sql); } @@ -124,8 +121,8 @@ SQL_EXPORT; public function executeLoadData(array $options = null) { $defaults = [ - 'path' => null, - ]; + 'path' => null, + ]; $options += $defaults; if (empty($options['path'])) { @@ -180,9 +177,9 @@ SQL_EXPORT; public function progress($settings = null, array $options = []) { $defaults = [ - 'path' => NN_ROOT.'cli'.DS.'data'.DS.'predb_progress.txt', - 'read' => true, - ]; + 'path' => NN_ROOT.'cli'.DS.'data'.DS.'predb_progress.txt', + 'read' => true, + ]; $options += $defaults; if (! $options['read'] || ! is_file($options['path'])) { @@ -263,12 +260,12 @@ SQL_INSERT; { $enclosedby = ''; $defaults = [ - 'enclosedby' => "'", - 'fields' => '\t', - 'lines' => '\r\n', // Windows' style EOL to allow \n to be used in text. - 'local' => false, - 'optional' => true, - ]; + 'enclosedby' => "'", + 'fields' => '\t', + 'lines' => '\r\n', // Windows' style EOL to allow \n to be used in text. + 'local' => false, + 'optional' => true, + ]; $options += $defaults; $local = $options['local'] === false ? 'LOCAL' : ''; @@ -283,9 +280,6 @@ LOAD DATA $local INFILE :path LINES TERMINATED BY '{$options['lines']}' (title, nfo, size, files, filename, nuked, nukereason, category, predate, source, requestid, groupname); SQL_LOAD_DATA; - if (NN_DEBUG) { - echo "$sql\n"; - } $this->prepareSQLStatement($sql, 'LoadData'); } diff --git a/nntmux/db/populate/AniDB.php b/nntmux/db/populate/AniDB.php index eff4b2e8d..2eda6def6 100755 --- a/nntmux/db/populate/AniDB.php +++ b/nntmux/db/populate/AniDB.php @@ -467,14 +467,6 @@ class AniDB ); } else { $this->updateAniChildTables($AniDBAPIArray, $anidb['anidbid']); - if (NN_DEBUG) { - ColorCLI::doEcho( - ColorCLI::headerOver( - 'Added/Updated AniDB ID: '.$anidb['anidbid'] - ), - true - ); - } } sleep(random_int(120, 240)); } @@ -500,14 +492,6 @@ class AniDB ); } else { $this->updateAniChildTables($AniDBAPIArray, $anidbId); - if (NN_DEBUG) { - ColorCLI::doEcho( - ColorCLI::headerOver( - 'Added/Updated AniDB ID: '.$anidbId - ), - true - ); - } } } } diff --git a/nntmux/processing/PostProcess.php b/nntmux/processing/PostProcess.php index ce0f24064..17ca79d4c 100755 --- a/nntmux/processing/PostProcess.php +++ b/nntmux/processing/PostProcess.php @@ -11,7 +11,6 @@ use nntmux\Games; use nntmux\Movie; use nntmux\Music; use nntmux\Groups; -use nntmux\Logger; use nntmux\Console; use nntmux\Sharing; use nntmux\Category; @@ -116,7 +115,6 @@ class PostProcess $this->pdo = (($options['Settings'] instanceof DB) ? $options['Settings'] : new DB()); $this->groups = (($options['Groups'] instanceof Groups) ? $options['Groups'] : new Groups(['Settings' => $this->pdo])); $this->_par2Info = new Par2Info(); - $this->debugging = ($options['Logger'] instanceof Logger ? $options['Logger'] : new Logger(['ColorCLI' => $this->pdo->log])); $this->nameFixer = (($options['NameFixer'] instanceof NameFixer) ? $options['NameFixer'] : new NameFixer(['Echo' => $this->echooutput, 'Settings' => $this->pdo, 'Groups' => $this->groups])); $this->Nfo = (($options['Nfo'] instanceof Nfo) ? $options['Nfo'] : new Nfo(['Echo' => $this->echooutput, 'Settings' => $this->pdo])); $this->releaseFiles = (($options['ReleaseFiles'] instanceof ReleaseFiles) ? $options['ReleaseFiles'] : new ReleaseFiles($this->pdo)); @@ -387,7 +385,6 @@ class PostProcess // If we found some files. if ($filesAdded > 0) { - $this->debugging->log(__CLASS__, __FUNCTION__, 'Added '.$filesAdded.' release_files from PAR2 for '.$query['searchname'], Logger::LOG_INFO); // Update the file count with the new file count + old file count. Release::query()->where('id', $relID)->increment('rarinnerfilecount', $filesAdded); diff --git a/nntmux/processing/post/AniDB.php b/nntmux/processing/post/AniDB.php index 1b85509cf..456459840 100755 --- a/nntmux/processing/post/AniDB.php +++ b/nntmux/processing/post/AniDB.php @@ -177,12 +177,6 @@ class AniDB ) { $matches['epno'] = 1; } else { - if (NN_DEBUG) { - ColorCLI::doEcho( - PHP_EOL."Could not parse searchname {$cleanName}.", - true - ); - } $this->status = self::PROC_EXTFAIL; } @@ -274,12 +268,6 @@ class AniDB $matched = true; } else { - if (NN_DEBUG) { - ColorCLI::doEcho( - PHP_EOL.'Could not match searchname:'.$release['searchname'], - true - ); - } $this->status = self::PROC_NOMATCH; } } diff --git a/nntmux/processing/post/ProcessAdditional.php b/nntmux/processing/post/ProcessAdditional.php index 4cc9ce994..f9c9fe0cc 100755 --- a/nntmux/processing/post/ProcessAdditional.php +++ b/nntmux/processing/post/ProcessAdditional.php @@ -383,23 +383,22 @@ class ProcessAdditional public function __construct(array $options = []) { $defaults = [ - 'Echo' => false, - 'Categorize' => null, - 'Groups' => null, - 'NameFixer' => null, - 'Nfo' => null, - 'NNTP' => null, - 'NZB' => null, - 'ReleaseExtra' => null, - 'ReleaseFiles' => null, - 'ReleaseImage' => null, - 'Settings' => null, - 'SphinxSearch' => null, - ]; + 'Echo' => false, + 'Categorize' => null, + 'Groups' => null, + 'NameFixer' => null, + 'Nfo' => null, + 'NNTP' => null, + 'NZB' => null, + 'ReleaseExtra' => null, + 'ReleaseFiles' => null, + 'ReleaseImage' => null, + 'Settings' => null, + 'SphinxSearch' => null, + ]; $options += $defaults; $this->_echoCLI = ($options['Echo'] && NN_ECHOCLI && (strtolower(PHP_SAPI) === 'cli')); - $this->_echoDebug = NN_DEBUG; $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); $this->_nntp = ($options['NNTP'] instanceof NNTP ? $options['NNTP'] : new NNTP(['Echo' => $this->_echoCLI, 'Settings' => $this->pdo])); @@ -439,39 +438,39 @@ class ProcessAdditional $this->_killString = '"'; if (Settings::settingValue('apps..timeoutpath') != '' && Settings::settingValue('..timeoutseconds') > 0) { $this->_killString = ( - '"'.Settings::settingValue('apps..timeoutpath'). - '" --foreground --signal=KILL '. - Settings::settingValue('..timeoutseconds').' "' - ); + '"'.Settings::settingValue('apps..timeoutpath'). + '" --foreground --signal=KILL '. + Settings::settingValue('..timeoutseconds').' "' + ); } $this->_showCLIReleaseID = (PHP_BINARY.' '.__DIR__.DS.'ProcessAdditional.php ReleaseID: '); // Maximum amount of releases to fetch per run. $this->_queryLimit = - (Settings::settingValue('..maxaddprocessed') != '') ? (int) Settings::settingValue('..maxaddprocessed') : 25; + (Settings::settingValue('..maxaddprocessed') != '') ? (int) Settings::settingValue('..maxaddprocessed') : 25; // Maximum message ID's to download per file type in the NZB (video, jpg, etc). $this->_segmentsToDownload = - (Settings::settingValue('..segmentstodownload') != '') ? (int) Settings::settingValue('..segmentstodownload') : 2; + (Settings::settingValue('..segmentstodownload') != '') ? (int) Settings::settingValue('..segmentstodownload') : 2; // Maximum message ID's to download for a RAR file. $this->_maximumRarSegments = - (Settings::settingValue('..maxpartsprocessed') != '') ? (int) Settings::settingValue('..maxpartsprocessed') : 3; + (Settings::settingValue('..maxpartsprocessed') != '') ? (int) Settings::settingValue('..maxpartsprocessed') : 3; // Maximum RAR files to check for a password before stopping. $this->_maximumRarPasswordChecks = - (Settings::settingValue('..passchkattempts') != '') ? (int) Settings::settingValue('..passchkattempts') : 1; + (Settings::settingValue('..passchkattempts') != '') ? (int) Settings::settingValue('..passchkattempts') : 1; $this->_maximumRarPasswordChecks = ($this->_maximumRarPasswordChecks < 1 ? 1 : $this->_maximumRarPasswordChecks); // Maximum size of releases in GB. $this->_maxSize = - (Settings::settingValue('..maxsizetopostprocess') != '') ? (int) Settings::settingValue('..maxsizetopostprocess') : 100; + (Settings::settingValue('..maxsizetopostprocess') != '') ? (int) Settings::settingValue('..maxsizetopostprocess') : 100; $this->_maxSize = ($this->_maxSize > 0 ? ('AND r.size < '.($this->_maxSize * 1073741824)) : ''); // Minimum size of releases in MB. $this->_minSize = - (Settings::settingValue('..minsizetopostprocess') != '') ? (int) Settings::settingValue('..minsizetopostprocess') : 100; + (Settings::settingValue('..minsizetopostprocess') != '') ? (int) Settings::settingValue('..minsizetopostprocess') : 100; $this->_minSize = ($this->_minSize > 0 ? ('AND r.size > '.($this->_minSize * 1048576)) : ''); // Use the alternate NNTP provider for downloading Message-ID's ? @@ -493,9 +492,9 @@ class ProcessAdditional $this->_processMediaInfo = (Settings::settingValue('apps..mediainfopath') == '') ? false : true; $this->_processAudioInfo = $this->_processMediaInfo; $this->_processPasswords = ( - (((Settings::settingValue('..checkpasswordedrar') == 0) ? false : true)) && - ((Settings::settingValue('apps..unrarpath') == '') ? false : true) - ); + (((Settings::settingValue('..checkpasswordedrar') == 0) ? false : true)) && + ((Settings::settingValue('apps..unrarpath') == '') ? false : true) + ); $this->_audioSavePath = NN_COVERS.'audiosample'.DS; @@ -595,13 +594,13 @@ class ProcessAdditional { if ($this->_mainTmpPath != '') { $this->_recursivePathDelete( - $this->_mainTmpPath, - // These are folders we don't want to delete. - [ - // This is the actual temp folder. - $this->_mainTmpPath, - ] - ); + $this->_mainTmpPath, + // These are folders we don't want to delete. + [ + // This is the actual temp folder. + $this->_mainTmpPath, + ] + ); } } @@ -616,7 +615,8 @@ class ProcessAdditional protected function _fetchReleases($groupID, &$guidChar) { $this->_releases = $this->pdo->query( - sprintf(' + sprintf( + ' SELECT r.id, r.id AS releases_id, r.guid, r.name, r.size, r.groups_id, r.nfostatus, r.fromname, r.completion, r.categories_id, r.searchname, r.predb_id, c.disablepreview @@ -629,13 +629,13 @@ class ProcessAdditional AND c.disablepreview = 0 ORDER BY r.passwordstatus ASC, r.postdate DESC LIMIT %d', - $this->_maxSize, - $this->_minSize, - ($groupID === '' ? '' : 'AND r.groups_id = '.$groupID), - ($guidChar === '' ? '' : 'AND r.leftguid = '.$this->pdo->escapeString($guidChar)), - $this->_queryLimit - ) - ); + $this->_maxSize, + $this->_minSize, + ($groupID === '' ? '' : 'AND r.groups_id = '.$groupID), + ($guidChar === '' ? '' : 'AND r.leftguid = '.$this->pdo->escapeString($guidChar)), + $this->_queryLimit + ) + ); if (is_array($this->_releases)) { $this->_totalReleases = count($this->_releases); @@ -654,15 +654,17 @@ class ProcessAdditional { if ($this->_totalReleases > 1 && $this->_echoCLI) { $this->_echo( - PHP_EOL. - 'Additional post-processing, started at: '. - date('D M d, Y G:i a'). - PHP_EOL. - 'Downloaded: (xB) = yEnc article, f= Failed ;Processing: z = ZIP file, r = RAR file'. - PHP_EOL. - 'Added: s = Sample image, j = JPEG image, A = Audio sample, a = Audio MediaInfo, v = Video sample'. - PHP_EOL. - 'Added: m = Video MediaInfo, n = NFO, ^ = File details from inside the RAR/ZIP', 'header'); + PHP_EOL. + 'Additional post-processing, started at: '. + date('D M d, Y G:i a'). + PHP_EOL. + 'Downloaded: (xB) = yEnc article, f= Failed ;Processing: z = ZIP file, r = RAR file'. + PHP_EOL. + 'Added: s = Sample image, j = JPEG image, A = Audio sample, a = Audio MediaInfo, v = Video sample'. + PHP_EOL. + 'Added: m = Video MediaInfo, n = NFO, ^ = File details from inside the RAR/ZIP', + 'header' + ); } } @@ -673,11 +675,11 @@ class ProcessAdditional { foreach ($this->_releases as $this->_release) { $this->_echo( - PHP_EOL.'['.$this->_release['id'].']['. - $this->_readableBytesString($this->_release['size']).']', - 'primaryOver', - false - ); + PHP_EOL.'['.$this->_release['id'].']['. + $this->_readableBytesString($this->_release['size']).']', + 'primaryOver', + false + ); cli_set_process_title($this->_showCLIReleaseID.$this->_release['id']); @@ -704,13 +706,13 @@ class ProcessAdditional } if ($this->_processPasswords === true || - $this->_processThumbnails === true || - $this->_processMediaInfo === true || - $this->_processAudioInfo === true || - $this->_processVideo === true - ) { + $this->_processThumbnails === true || + $this->_processMediaInfo === true || + $this->_processAudioInfo === true || + $this->_processVideo === true + ) { - // Process usenet Message-ID downloads. + // Process usenet Message-ID downloads. $this->_processMessageIDDownloads(); // Process compressed (RAR/ZIP) files inside the NZB. @@ -837,11 +839,11 @@ class ProcessAdditional protected function _decrementPasswordStatus($return = false) { $this->pdo->queryExec( - sprintf( - 'UPDATE releases SET passwordstatus = passwordstatus - 1 WHERE id = %d', - $this->_release['id'] - ) - ); + sprintf( + 'UPDATE releases SET passwordstatus = passwordstatus - 1 WHERE id = %d', + $this->_release['id'] + ) + ); return $return; } @@ -869,27 +871,27 @@ class ProcessAdditional $totalBookFiles = 0; foreach ($this->_nzbContents as $this->_currentNZBFile) { - // Check if it's not a nfo, nzb, par2 etc... + // Check if it's not a nfo, nzb, par2 etc... if (preg_match($this->_supportFileRegex.'|nfo\b|inf\b|ofn\b)($|[ ")\]-])(?!.{20,})/i', $this->_currentNZBFile['title'])) { continue; } // Check if it's a rar/zip. if ($this->_NZBHasCompressedFile === false && - preg_match( - '/\.(part\d+|r\d+|rar|0+|0*10?|zipr\d{2,3}|zipx?)(\s*\.rar)*($|[ ")\]-])|"[a-f0-9]{32}\.[1-9]\d{1,2}".*\(\d+\/\d{2,}\)$/i', - $this->_currentNZBFile['title'] - ) - ) { + preg_match( + '/\.(part\d+|r\d+|rar|0+|0*10?|zipr\d{2,3}|zipx?)(\s*\.rar)*($|[ ")\]-])|"[a-f0-9]{32}\.[1-9]\d{1,2}".*\(\d+\/\d{2,}\)$/i', + $this->_currentNZBFile['title'] + ) + ) { $this->_NZBHasCompressedFile = true; } // Look for a video sample, make sure it's not an image. if ($this->_processThumbnails === true && - empty($this->_sampleMessageIDs) && - preg_match('/sample/i', $this->_currentNZBFile['title']) && - ! preg_match('/\.jpe?g/i', $this->_currentNZBFile['title']) - ) { + empty($this->_sampleMessageIDs) && + preg_match('/sample/i', $this->_currentNZBFile['title']) && + ! preg_match('/\.jpe?g/i', $this->_currentNZBFile['title']) + ) { if (isset($this->_currentNZBFile['segments'])) { // Get the amount of segments for this file. $segCount = (count($this->_currentNZBFile['segments']) - 1); @@ -905,10 +907,10 @@ class ProcessAdditional // Look for a JPG picture, make sure it's not a CD cover. if ($this->_processJPGSample === true && - empty($this->_JPGMessageIDs) && - ! preg_match('/flac|lossless|mp3|music|inner-sanctum|sound/i', $this->_releaseGroupName) && - preg_match('/\.jpe?g[. ")\]]/i', $this->_currentNZBFile['title']) - ) { + empty($this->_JPGMessageIDs) && + ! preg_match('/flac|lossless|mp3|music|inner-sanctum|sound/i', $this->_releaseGroupName) && + preg_match('/\.jpe?g[. ")\]]/i', $this->_currentNZBFile['title']) + ) { if (isset($this->_currentNZBFile['segments'])) { // Get the amount of segments for this file. $segCount = (count($this->_currentNZBFile['segments']) - 1); @@ -924,10 +926,10 @@ class ProcessAdditional // Look for a video file, make sure it's not a sample, for MediaInfo. if ($this->_processMediaInfo === true && - empty($this->_MediaInfoMessageIDs) && - ! preg_match('/sample/i', $this->_currentNZBFile['title']) && - preg_match('/'.$this->_videoFileRegex.'[. ")\]]/i', $this->_currentNZBFile['title']) - ) { + empty($this->_MediaInfoMessageIDs) && + ! preg_match('/sample/i', $this->_currentNZBFile['title']) && + preg_match('/'.$this->_videoFileRegex.'[. ")\]]/i', $this->_currentNZBFile['title']) + ) { if (isset($this->_currentNZBFile['segments'][0])) { $this->_MediaInfoMessageIDs = (string) $this->_currentNZBFile['segments'][0]; } @@ -935,9 +937,9 @@ class ProcessAdditional // Look for a audio file. if ($this->_processAudioInfo === true && - empty($this->_AudioInfoMessageIDs) && - preg_match('/'.$this->_audioFileRegex.'[. ")\]]/i', $this->_currentNZBFile['title'], $type) - ) { + empty($this->_AudioInfoMessageIDs) && + preg_match('/'.$this->_audioFileRegex.'[. ")\]]/i', $this->_currentNZBFile['title'], $type) + ) { if (isset($this->_currentNZBFile['segments'])) { // Get the extension. $this->_AudioInfoExtension = $type[1]; @@ -994,10 +996,10 @@ class ProcessAdditional // Probably not a rar/zip. if (! preg_match( - '/\.(part\d+|r\d+|rar|0+|0*10?|zipr\d{2,3}|zipx?)(\s*\.rar)*($|[ ")\]-])|"[a-f0-9]{32}\.[1-9]\d{1,2}".*\(\d+\/\d{2,}\)$/i', - $nzbFile['title'] - ) - ) { + '/\.(part\d+|r\d+|rar|0+|0*10?|zipr\d{2,3}|zipx?)(\s*\.rar)*($|[ ")\]-])|"[a-f0-9]{32}\.[1-9]\d{1,2}".*\(\d+\/\d{2,}\)$/i', + $nzbFile['title'] + ) + ) { continue; } @@ -1030,7 +1032,7 @@ class ProcessAdditional if ($fetchedBinary !== false) { - // Echo we downloaded compressed file. + // Echo we downloaded compressed file. if ($this->_echoCLI) { $this->_echo('(cB)', 'primaryOver', false); } @@ -1089,40 +1091,40 @@ class ProcessAdditional } switch ($dataSummary['main_type']) { - case ArchiveInfo::TYPE_RAR: - if ($this->_echoCLI) { - $this->_echo('r', 'primaryOver', false); - } + case ArchiveInfo::TYPE_RAR: + if ($this->_echoCLI) { + $this->_echo('r', 'primaryOver', false); + } - if ($this->_extractUsingRarInfo === false && $this->_unrarPath !== false) { - $fileName = $this->tmpPath.uniqid().'.rar'; - file_put_contents($fileName, $compressedData); - Utility::runCmd( - $this->_killString.$this->_unrarPath. - '" e -ai -ep -c- -id -inul -kb -or -p- -r -y "'. - $fileName.'" "'.$this->tmpPath.'unrar/"' - ); - unlink($fileName); - } - break; - case ArchiveInfo::TYPE_ZIP: - if ($this->_echoCLI) { - $this->_echo('z', 'primaryOver', false); - } + if ($this->_extractUsingRarInfo === false && $this->_unrarPath !== false) { + $fileName = $this->tmpPath.uniqid().'.rar'; + file_put_contents($fileName, $compressedData); + Utility::runCmd( + $this->_killString.$this->_unrarPath. + '" e -ai -ep -c- -id -inul -kb -or -p- -r -y "'. + $fileName.'" "'.$this->tmpPath.'unrar/"' + ); + unlink($fileName); + } + break; + case ArchiveInfo::TYPE_ZIP: + if ($this->_echoCLI) { + $this->_echo('z', 'primaryOver', false); + } - if ($this->_extractUsingRarInfo === false && $this->_7zipPath !== false) { - $fileName = $this->tmpPath.uniqid().'.zip'; - file_put_contents($fileName, $compressedData); - Utility::runCmd( - $this->_killString.$this->_7zipPath.'" x "'. - $fileName.'" -bd -y -o"'.$this->tmpPath.'unzip/"' - ); - unlink($fileName); - } - break; - default: - return false; - } + if ($this->_extractUsingRarInfo === false && $this->_7zipPath !== false) { + $fileName = $this->tmpPath.uniqid().'.zip'; + file_put_contents($fileName, $compressedData); + Utility::runCmd( + $this->_killString.$this->_7zipPath.'" x "'. + $fileName.'" -bd -y -o"'.$this->tmpPath.'unzip/"' + ); + unlink($fileName); + } + break; + default: + return false; + } return $this->_processCompressedFileList(); } @@ -1175,9 +1177,9 @@ class ProcessAdditional // Extract files from the rar. if (isset($file['compressed']) && $file['compressed'] == 0) { @file_put_contents( - ($this->tmpPath.random_int(10, 999999).'_'.$fileName), - $this->_archiveInfo->getFileData($file['name'], $file['source']) - ); + ($this->tmpPath.random_int(10, 999999).'_'.$fileName), + $this->_archiveInfo->getFileData($file['name'], $file['source']) + ); } // If the files are compressed, use a binary extractor. else { $this->_archiveInfo->extractFile($file['name'], $this->tmpPath.random_int(10, 999999).'_'.$fileName); @@ -1204,10 +1206,10 @@ class ProcessAdditional { // Don't add rar/zip files to the DB. if (! isset($file['error']) && isset($file['source']) && - ! preg_match($this->_supportFileRegex.'|part\d+|r\d{1,3}|zipr\d{2,3}|\d{2,3}|zipx|zip|rar)(\s*\.rar)?$/i', $file['name']) - ) { + ! preg_match($this->_supportFileRegex.'|part\d+|r\d{1,3}|zipr\d{2,3}|\d{2,3}|zipx|zip|rar)(\s*\.rar)?$/i', $file['name']) + ) { - // Cache the amount of files we find in the RAR or ZIP, return this to say we did find RAR or ZIP content. + // Cache the amount of files we find in the RAR or ZIP, return this to say we did find RAR or ZIP content. // This is so we don't download more RAR or ZIP files for no reason. $this->_totalFileInfo++; @@ -1215,17 +1217,19 @@ class ProcessAdditional * Also make sure we don't add too many files, some releases have 100's of files, like PS3 releases. */ if ($this->_addedFileInfo < 11 && - $this->pdo->queryOneRow( - sprintf( - ' + $this->pdo->queryOneRow( + sprintf( + ' SELECT releases_id FROM release_files WHERE releases_id = %d AND name = %s AND size = %d', - $this->_release['id'], $this->pdo->escapeString($file['name']), $file['size'] - ) - ) === false - ) { + $this->_release['id'], + $this->pdo->escapeString($file['name']), + $file['size'] + ) + ) === false + ) { if ($this->_releaseFiles->add($this->_release['id'], $file['name'], '', $file['size'], $file['date'], $file['pass'])) { $this->_addedFileInfo++; @@ -1235,8 +1239,8 @@ class ProcessAdditional // Check for "codec spam" if (preg_match('/alt\.binaries\.movies($|\.divx$)/', $this->_releaseGroupName) && - preg_match('/[\/\\\\]Codec[\/\\\\]Setup\.exe/i', $file['name']) - ) { + preg_match('/[\/\\\\]Codec[\/\\\\]Setup\.exe/i', $file['name']) + ) { $this->_debug('Codec spam found, setting release to potentially passworded.'.PHP_EOL); $this->_releaseHasPassword = true; $this->_passwordStatus[] = Releases::PASSWD_POTENTIAL; @@ -1261,7 +1265,7 @@ class ProcessAdditional // Go through all the files in the temp folder, look for compressed files, extract them and the nested ones. while ($nestedLevels < $this->_maxNestedLevels) { - // Break out if we checked more than x compressed files. + // Break out if we checked more than x compressed files. if ($this->_compressedFilesChecked >= self::maxCompressedFilesToCheck) { break; } @@ -1274,7 +1278,7 @@ class ProcessAdditional if ($files instanceof \Traversable) { foreach ($files as $file) { - // Check if the file exists. + // Check if the file exists. if (is_file($file[0])) { $rarData = @file_get_contents($file[0]); if ($rarData !== false) { @@ -1309,7 +1313,7 @@ class ProcessAdditional if (is_file($file)) { - // Process PAR2 files. + // Process PAR2 files. if ($this->_foundPAR2Info === false && preg_match('/\.par2$/', $file)) { $this->_siftPAR2Info($file); } // Process NFO files. @@ -1317,10 +1321,10 @@ class ProcessAdditional $this->_processNfoFile($file); } // Process audio files. elseif ( - ($this->_foundAudioInfo === false || - $this->_foundAudioSample === false) && - preg_match('/(.*)'.$this->_audioFileRegex.'$/i', $file, $fileType) - ) { + ($this->_foundAudioInfo === false || + $this->_foundAudioSample === false) && + preg_match('/(.*)'.$this->_audioFileRegex.'$/i', $file, $fileType) + ) { // Try to get audio sample/audio media info. @rename($file, $this->tmpPath.'audiofile.'.$fileType[2]); $this->_getAudioInfo($this->tmpPath.'audiofile.'.$fileType[2], $fileType[2]); @@ -1331,14 +1335,14 @@ class ProcessAdditional @unlink($file); } // Video sample // video clip // video media info. elseif (($this->_foundSample === false || $this->_foundVideo === false || $this->_foundMediaInfo === false) && - preg_match('/(.*)'.$this->_videoFileRegex.'$/i', $file) - ) { + preg_match('/(.*)'.$this->_videoFileRegex.'$/i', $file) + ) { $this->_processVideoFile($file); } // Check if it's alt.binaries.u4e file. elseif (in_array($this->_releaseGroupName, ['alt.binaries.u4e', 'alt.binaries.mom']) && - preg_match('/Linux_2rename\.sh/i', $file) && - ($this->_release['categories_id'] == Category::OTHER_HASHED || $this->_release['categories_id'] == Category::OTHER_MISC) - ) { + preg_match('/Linux_2rename\.sh/i', $file) && + ($this->_release['categories_id'] == Category::OTHER_HASHED || $this->_release['categories_id'] == Category::OTHER_MISC) + ) { $this->_processU4ETitle($file); } @@ -1348,40 +1352,40 @@ class ProcessAdditional if (! empty($output)) { switch (true) { - case $this->_foundJPGSample === false && preg_match('/^JPE?G/i', $output): - $this->_getJPGSample($file); - @unlink($file); - break; + case $this->_foundJPGSample === false && preg_match('/^JPE?G/i', $output): + $this->_getJPGSample($file); + @unlink($file); + break; - case - ($this->_foundMediaInfo === false || $this->_foundSample === false || $this->_foundVideo === false) - && preg_match('/Matroska data|MPEG v4|MPEG sequence, v2|\WAVI\W/i', $output): - $this->_processVideoFile($file); - break; + case + ($this->_foundMediaInfo === false || $this->_foundSample === false || $this->_foundVideo === false) + && preg_match('/Matroska data|MPEG v4|MPEG sequence, v2|\WAVI\W/i', $output): + $this->_processVideoFile($file); + break; - case - ($this->_foundAudioSample === false || $this->_foundAudioInfo === false) && - preg_match('/^FLAC|layer III|Vorbis audio/i', $output, $fileType): - switch ($fileType[0]) { - case 'FLAC': - $fileType = 'FLAC'; - break; - case 'layer III': - $fileType = 'MP3'; - break; - case 'Vorbis audio': - $fileType = 'OGG'; - break; - } - @rename($file, $this->tmpPath.'audiofile.'.$fileType); - $this->_getAudioInfo($this->tmpPath.'audiofile.'.$fileType, $fileType); - @unlink($this->tmpPath.'audiofile.'.$fileType); - break; + case + ($this->_foundAudioSample === false || $this->_foundAudioInfo === false) && + preg_match('/^FLAC|layer III|Vorbis audio/i', $output, $fileType): + switch ($fileType[0]) { + case 'FLAC': + $fileType = 'FLAC'; + break; + case 'layer III': + $fileType = 'MP3'; + break; + case 'Vorbis audio': + $fileType = 'OGG'; + break; + } + @rename($file, $this->tmpPath.'audiofile.'.$fileType); + $this->_getAudioInfo($this->tmpPath.'audiofile.'.$fileType, $fileType); + @unlink($this->tmpPath.'audiofile.'.$fileType); + break; - case $this->_foundPAR2Info === false && preg_match('/^Parity/i', $output): - $this->_siftPAR2Info($file); - break; - } + case $this->_foundPAR2Info === false && preg_match('/^Parity/i', $output): + $this->_siftPAR2Info($file); + break; + } } } } @@ -1413,7 +1417,7 @@ class ProcessAdditional if ($this->_foundSample === false || $this->_foundVideo === false) { if (! empty($this->_sampleMessageIDs)) { - // Download it from usenet. + // Download it from usenet. $sampleBinary = $this->_nntp->getMessages($this->_releaseGroupName, $this->_sampleMessageIDs, $this->_alternateNNTP); if ($this->_nntp->isError($sampleBinary)) { $sampleBinary = false; @@ -1441,10 +1445,10 @@ class ProcessAdditional } // Try to get media info. Don't get it here if $mediaMsgID is not empty. - // 2014-06-28 -> Commented out, since the media info of a sample video is not indicative of the actual release.si - /*if ($this->_foundMediaInfo === false && empty($mediaMsgID)) { - $this->_foundMediaInfo = $this->_getMediaInfo($fileLocation); - }*/ + // 2014-06-28 -> Commented out, since the media info of a sample video is not indicative of the actual release.si + /*if ($this->_foundMediaInfo === false && empty($mediaMsgID)) { + $this->_foundMediaInfo = $this->_getMediaInfo($fileLocation); + }*/ } } elseif ($this->_echoCLI) { $this->_echo('f', 'warningOver', false); @@ -1464,7 +1468,7 @@ class ProcessAdditional if ($this->_foundMediaInfo === false || $this->_foundSample === false || $this->_foundVideo === false) { if ($this->_foundMediaInfo === false && ! empty($this->_MediaInfoMessageIDs)) { - // Try to download it from usenet. + // Try to download it from usenet. $mediaBinary = $this->_nntp->getMessages($this->_releaseGroupName, $this->_MediaInfoMessageIDs, $this->_alternateNNTP); if ($this->_nntp->isError($mediaBinary)) { // If error set it to false. @@ -1548,7 +1552,7 @@ class ProcessAdditional // Download JPG file. if ($this->_foundJPGSample === false && ! empty($this->_JPGMessageIDs)) { - // Try to download it. + // Try to download it. $jpgBinary = $this->_nntp->getMessages($this->_releaseGroupName, $this->_JPGMessageIDs, $this->_alternateNNTP); if ($this->_nntp->isError($jpgBinary)) { $jpgBinary = false; @@ -1564,24 +1568,27 @@ class ProcessAdditional // Try to resize and move it. $this->_foundJPGSample = ( - $this->_releaseImage->saveImage( - $this->_release['guid'].'_thumb', $this->tmpPath.'samplepicture.jpg', - $this->_releaseImage->jpgSavePath, 650, 650 - ) === 1 ? true : false - ); + $this->_releaseImage->saveImage( + $this->_release['guid'].'_thumb', + $this->tmpPath.'samplepicture.jpg', + $this->_releaseImage->jpgSavePath, + 650, + 650 + ) === 1 ? true : false + ); if ($this->_foundJPGSample !== false) { // Update the DB to say we got it. $this->pdo->queryExec( - sprintf( - ' + sprintf( + ' UPDATE releases SET jpgstatus = %d WHERE id = %d', - 1, - $this->_release['id'] - ) - ); + 1, + $this->_release['id'] + ) + ); if ($this->_echoCLI) { $this->_echo('j', 'primaryOver', false); @@ -1618,15 +1625,15 @@ class ProcessAdditional // Get the amount of files we found inside the RAR/ZIP files. $releaseFiles = $this->pdo->queryOneRow( - sprintf( - ' + sprintf( + ' SELECT COUNT(release_files.releases_id) AS count, SUM(release_files.size) AS size FROM release_files WHERE releases_id = %d', - $this->_release['id'] - ) - ); + $this->_release['id'] + ) + ); if ($releaseFiles === false) { $releaseFiles['count'] = $releaseFiles['size'] = 0; @@ -1642,28 +1649,28 @@ class ProcessAdditional // If we failed to get anything from the RAR/ZIPs, decrement the passwordstatus, if the rar/zip has no password. if ($this->_releaseHasPassword === false && $this->_NZBHasCompressedFile && $releaseFiles['count'] == 0) { $query = sprintf( - 'UPDATE releases + 'UPDATE releases SET passwordstatus = passwordstatus - 1, rarinnerfilecount = %d %s %s %s WHERE id = %d', - $releaseFiles['count'], - $iSQL, - $vSQL, - $jSQL, - $this->_release['id'] - ); + $releaseFiles['count'], + $iSQL, + $vSQL, + $jSQL, + $this->_release['id'] + ); } // Else update the release with the password status (if the admin enabled the setting). else { $query = sprintf( - 'UPDATE releases + 'UPDATE releases SET passwordstatus = %d, rarinnerfilecount = %d %s %s %s WHERE id = %d', - ($this->_processPasswords === true ? $this->_passwordStatus : Releases::PASSWD_NONE), - $releaseFiles['count'], - $iSQL, - $vSQL, - $jSQL, - $this->_release['id'] - ); + ($this->_processPasswords === true ? $this->_passwordStatus : Releases::PASSWD_NONE), + $releaseFiles['count'], + $iSQL, + $vSQL, + $jSQL, + $this->_release['id'] + ); } $this->pdo->queryExec($query); @@ -1686,16 +1693,16 @@ class ProcessAdditional try { if ($pattern !== '') { return new \RegexIterator( - new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($path) - ), - $pattern, - \RecursiveRegexIterator::GET_MATCH - ); + new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($path) + ), + $pattern, + \RecursiveRegexIterator::GET_MATCH + ); } else { return new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($path) - ); + new \RecursiveDirectoryIterator($path) + ); } } catch (\Exception $e) { $this->_debug('ERROR: Could not open temp dir: '.$e->getMessage().PHP_EOL); @@ -1729,39 +1736,39 @@ class ProcessAdditional // Make sure the category is music or other. $rQuery = $this->pdo->queryOneRow( - sprintf( - 'SELECT searchname, fromname, categories_id AS id, groups_id FROM releases WHERE proc_pp = 0 AND id = %d', - $this->_release['id'] - ) - ); + sprintf( + 'SELECT searchname, fromname, categories_id AS id, groups_id FROM releases WHERE proc_pp = 0 AND id = %d', + $this->_release['id'] + ) + ); $musicParent = (string) Category::MUSIC_ROOT; if ($rQuery === false || ! preg_match( - sprintf( - '/%d\d{3}|%d|%d|%d/', - $musicParent[0], - Category::OTHER_MISC, - Category::MOVIE_OTHER, - Category::TV_OTHER - ), - $rQuery['id'] - ) - ) { + sprintf( + '/%d\d{3}|%d|%d|%d/', + $musicParent[0], + Category::OTHER_MISC, + Category::MOVIE_OTHER, + Category::TV_OTHER + ), + $rQuery['id'] + ) + ) { return false; } if (is_file($fileLocation)) { - // Check if media info is enabled. + // Check if media info is enabled. if ($retVal === false) { - // Get the media info for the file. + // Get the media info for the file. $xmlArray = Utility::runCmd( - $this->_killString.Settings::settingValue('apps..mediainfopath').'" --Output=XML "'.$fileLocation.'"' - ); + $this->_killString.Settings::settingValue('apps..mediainfopath').'" --Output=XML "'.$fileLocation.'"' + ); if (is_array($xmlArray)) { - // Convert to array. + // Convert to array. $arrXml = Utility::objectsIntoArray(@simplexml_load_string(implode("\n", $xmlArray))); if (isset($arrXml['File']['track'])) { @@ -1790,31 +1797,31 @@ class ProcessAdditional $newTitle = $this->pdo->escapeString(substr($newName, 0, 255)); // Update the search name. $this->pdo->queryExec( - sprintf( - ' + sprintf( + ' UPDATE releases SET searchname = %s, categories_id = %d, iscategorized = 1, isrenamed = 1, proc_pp = 1 WHERE id = %d', - $newTitle, - $newCat, - $this->_release['id'] - ) - ); + $newTitle, + $newCat, + $this->_release['id'] + ) + ); $this->sphinx->updateRelease($this->_release['id'], $this->pdo); // Echo the changed name. if ($this->_echoCLI) { NameFixer::echoChangedReleaseName( - [ - 'new_name' => $newName, - 'old_name' => $rQuery['searchname'], - 'new_category' => $newCat, - 'old_category' => $rQuery['id'], - 'group' => $rQuery['groups_id'], - 'releases_id' => $this->_release['id'], - 'method' => 'ProcessAdditional->_getAudioInfo', - ] - ); + [ + 'new_name' => $newName, + 'old_name' => $rQuery['searchname'], + 'new_category' => $newCat, + 'old_category' => $rQuery['id'], + 'group' => $rQuery['groups_id'], + 'releases_id' => $this->_release['id'], + 'method' => 'ProcessAdditional->_getAudioInfo', + ] + ); } } @@ -1836,24 +1843,24 @@ class ProcessAdditional // Check if creating audio samples is enabled. if ($audVal === false) { - // File name to store audio file. + // File name to store audio file. $audioFileName = ($this->_release['guid'].'.ogg'); // Create an audio sample. Utility::runCmd( - $this->_killString. - Settings::settingValue('apps..ffmpegpath'). - '" -t 30 -i "'. - $fileLocation. - '" -acodec libvorbis -loglevel quiet -y "'. - $this->tmpPath.$audioFileName. - '"' - ); + $this->_killString. + Settings::settingValue('apps..ffmpegpath'). + '" -t 30 -i "'. + $fileLocation. + '" -acodec libvorbis -loglevel quiet -y "'. + $this->tmpPath.$audioFileName. + '"' + ); // Check if the new file was created. if (is_file($this->tmpPath.$audioFileName)) { - // Try to move the temp audio file. + // Try to move the temp audio file. $renamed = rename($this->tmpPath.$audioFileName, $this->_audioSavePath.$audioFileName); if (! $renamed) { @@ -1874,14 +1881,14 @@ class ProcessAdditional // Update DB to said we got a audio sample. $this->pdo->queryExec( - sprintf( - ' + sprintf( + ' UPDATE releases SET audiostatus = 1 WHERE id = %d', - $this->_release['id'] - ) - ); + $this->_release['id'] + ) + ); $audVal = $this->_foundAudioSample = true; @@ -1904,24 +1911,27 @@ class ProcessAdditional { // Try to resize/move the image. $this->_foundJPGSample = ( - $this->_releaseImage->saveImage( - $this->_release['guid'].'_thumb', - $fileLocation, $this->_releaseImage->jpgSavePath, 650, 650 - ) === 1 ? true : false - ); + $this->_releaseImage->saveImage( + $this->_release['guid'].'_thumb', + $fileLocation, + $this->_releaseImage->jpgSavePath, + 650, + 650 + ) === 1 ? true : false + ); // If it's successful, tell the DB. if ($this->_foundJPGSample !== false) { $this->pdo->queryExec( - sprintf( - ' + sprintf( + ' UPDATE releases SET jpgstatus = %d WHERE id = %d', - 1, - $this->_release['id'] - ) - ); + 1, + $this->_release['id'] + ) + ); } } @@ -1944,13 +1954,13 @@ class ProcessAdditional $tmpVideo = ($this->tmpPath.uniqid().$extension); // Get the real duration of the file. $time = Utility::runCmd( - $this->_killString. - Settings::settingValue('apps..ffmpegpath'). - '" -i "'.$videoLocation. - '" -vcodec copy -y 2>&1 "'. - $tmpVideo.'"', - false - ); + $this->_killString. + Settings::settingValue('apps..ffmpegpath'). + '" -i "'.$videoLocation. + '" -vcodec copy -y 2>&1 "'. + $tmpVideo.'"', + false + ); @unlink($tmpVideo); if (empty($time) || ! preg_match('/time=(\d{1,2}:\d{1,2}:)?(\d{1,2})\.(\d{1,2})\s*bitrate=/i', implode(' ', $time), $numbers)) { @@ -1983,32 +1993,34 @@ class ProcessAdditional if (is_file($fileLocation)) { - // Create path to temp file. + // Create path to temp file. $fileName = ($this->tmpPath.'zzzz'.random_int(5, 12).random_int(5, 12).'.jpg'); $time = $this->getVideoTime($fileLocation); // Create the image. Utility::runCmd( - $this->_killString. - Settings::settingValue('apps..ffmpegpath'). - '" -i "'. - $fileLocation. - '" -ss '.($time === '' ? '00:00:03.00' : $time). - ' -vframes 1 -loglevel quiet -y "'. - $fileName. - '"' - ); + $this->_killString. + Settings::settingValue('apps..ffmpegpath'). + '" -i "'. + $fileLocation. + '" -ss '.($time === '' ? '00:00:03.00' : $time). + ' -vframes 1 -loglevel quiet -y "'. + $fileName. + '"' + ); // Check if the file exists. if (is_file($fileName)) { - // Try to resize/move the image. + // Try to resize/move the image. $saved = $this->_releaseImage->saveImage( - $this->_release['guid'].'_thumb', - $fileName, - $this->_releaseImage->imgSavePath, 800, 600 - ); + $this->_release['guid'].'_thumb', + $fileName, + $this->_releaseImage->imgSavePath, + 800, + 600 + ); // Delete the temp file we created. @unlink($fileName); @@ -2043,7 +2055,7 @@ class ProcessAdditional // Try to find an avi file. if (is_file($fileLocation)) { - // Create a filename to store the temp file. + // Create a filename to store the temp file. $fileName = ($this->tmpPath.'zzzz'.$this->_release['guid'].'.ogv'); $newMethod = false; @@ -2070,52 +2082,52 @@ class ProcessAdditional // Form the time string. $end = '.'.$numbers[2]; switch (strlen($lowestLength)) { - case 1: - $lowestLength = ('00:00:0'.(string) $lowestLength.$end); - break; - case 2: - $lowestLength = ('00:00:'.(string) $lowestLength.$end); - break; - default: - $lowestLength = '00:00:60.00'; - } + case 1: + $lowestLength = ('00:00:0'.(string) $lowestLength.$end); + break; + case 2: + $lowestLength = ('00:00:'.(string) $lowestLength.$end); + break; + default: + $lowestLength = '00:00:60.00'; + } } // Try to get the sample (from the end instead of the start). Utility::runCmd( - $this->_killString. - Settings::settingValue('apps..ffmpegpath'). - '" -i "'. - $fileLocation. - '" -ss '.$lowestLength. - ' -t '.$this->_ffMPEGDuration. - ' -vcodec libtheora -filter:v scale=320:-1 '. - ' -acodec libvorbis -loglevel quiet -y "'. - $fileName. - '"' - ); + $this->_killString. + Settings::settingValue('apps..ffmpegpath'). + '" -i "'. + $fileLocation. + '" -ss '.$lowestLength. + ' -t '.$this->_ffMPEGDuration. + ' -vcodec libtheora -filter:v scale=320:-1 '. + ' -acodec libvorbis -loglevel quiet -y "'. + $fileName. + '"' + ); } } if ($newMethod === false) { // If longer than 60 or we could not get the video length, run the old way. Utility::runCmd( - $this->_killString. - Settings::settingValue('apps..ffmpegpath'). - '" -i "'. - $fileLocation. - '" -vcodec libtheora -filter:v scale=320:-1 -t '. - $this->_ffMPEGDuration. - ' -acodec libvorbis -loglevel quiet -y "'. - $fileName. - '"' - ); + $this->_killString. + Settings::settingValue('apps..ffmpegpath'). + '" -i "'. + $fileLocation. + '" -vcodec libtheora -filter:v scale=320:-1 -t '. + $this->_ffMPEGDuration. + ' -acodec libvorbis -loglevel quiet -y "'. + $fileName. + '"' + ); } // Until we find the video file. if (is_file($fileName)) { - // Create a path to where the file should be moved. + // Create a path to where the file should be moved. $newFile = ($this->_releaseImage->vidSavePath.$this->_release['guid'].'.ogv'); // Try to move the file to the new path. @@ -2139,14 +2151,14 @@ class ProcessAdditional // Update query to say we got the video. $this->pdo->queryExec( - sprintf( - ' + sprintf( + ' UPDATE releases SET videostatus = 1 WHERE guid = %s', - $this->pdo->escapeString($this->_release['guid']) - ) - ); + $this->pdo->escapeString($this->_release['guid']) + ) + ); if ($this->_echoCLI) { $this->_echo('v', 'primaryOver', false); } @@ -2174,15 +2186,15 @@ class ProcessAdditional // Look for the video file. if (is_file($fileLocation)) { - // Run media info on it. + // Run media info on it. $xmlArray = Utility::runCmd( - $this->_killString.Settings::settingValue('apps..mediainfopath').'" --Output=XML "'.$fileLocation.'"' - ); + $this->_killString.Settings::settingValue('apps..mediainfopath').'" --Output=XML "'.$fileLocation.'"' + ); // Check if we got it. if (is_array($xmlArray)) { - // Convert it to string. + // Convert it to string. $xmlArray = implode("\n", $xmlArray); if (! preg_match('//i', $xmlArray)) { @@ -2218,14 +2230,14 @@ class ProcessAdditional } $releaseInfo = $this->pdo->queryOneRow( - sprintf( - ' + sprintf( + ' SELECT UNIX_TIMESTAMP(postdate) AS postdate, proc_pp FROM releases WHERE id = %d', - $this->_release['id'] - ) - ); + $this->_release['id'] + ) + ); if ($releaseInfo === false) { return; @@ -2234,12 +2246,12 @@ class ProcessAdditional // Only get a new name if the category is OTHER. $foundName = true; if (NN_RENAME_PAR2 && - $releaseInfo['proc_pp'] === 0 && - in_array( - (int) $this->_release['categories_id'], - Category::OTHERS_GROUP - ) - ) { + $releaseInfo['proc_pp'] === 0 && + in_array( + (int) $this->_release['categories_id'], + Category::OTHERS_GROUP + ) + ) { $foundName = false; } @@ -2259,15 +2271,16 @@ class ProcessAdditional // Add to release files. if ($this->_addPAR2Files) { if ($filesAdded < 11 && - $this->pdo->queryOneRow( - sprintf( - 'SELECT releases_id FROM release_files WHERE releases_id = %d AND name = %s', - $this->_release['id'], $this->pdo->escapeString($file['name']) - ) - ) === false - ) { + $this->pdo->queryOneRow( + sprintf( + 'SELECT releases_id FROM release_files WHERE releases_id = %d AND name = %s', + $this->_release['id'], + $this->pdo->escapeString($file['name']) + ) + ) === false + ) { - // Try to add the files to the DB. + // Try to add the files to the DB. if ($this->_releaseFiles->add($this->_release['id'], $file['name'], $file['hash_16K'], $file['size'], $releaseInfo['postdate'], 0)) { $filesAdded++; } @@ -2287,12 +2300,12 @@ class ProcessAdditional } // Update the file count with the new file count + old file count. $this->pdo->queryExec( - sprintf( - 'UPDATE releases SET rarinnerfilecount = rarinnerfilecount + %d WHERE id = %d', - $filesAdded, - $this->_release['id'] - ) - ); + sprintf( + 'UPDATE releases SET rarinnerfilecount = rarinnerfilecount + %d WHERE id = %d', + $filesAdded, + $this->_release['id'] + ) + ); $this->_foundPAR2Info = true; } @@ -2355,7 +2368,7 @@ class ProcessAdditional // Check if we find the word if (stripos($buffer, 'mkdir') !== false) { - // Get a new name. + // Get a new name. $newName = trim(str_replace('mkdir ', '', $buffer)); // Check if it's a empty string or not. @@ -2369,32 +2382,32 @@ class ProcessAdditional $newTitle = $this->pdo->escapeString(substr($newName, 0, 255)); // Update the release with the data. $this->pdo->queryExec( - sprintf( - 'UPDATE releases + sprintf( + 'UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, predb_id = 0, searchname = %s, isrenamed = 1, iscategorized = 1, proc_files = 1, categories_id = %d WHERE id = %d', - $newTitle, - $newCategory, - $this->_release['id'] - ) - ); + $newTitle, + $newCategory, + $this->_release['id'] + ) + ); $this->sphinx->updateRelease($this->_release['id'], $this->pdo); // Echo the changed name to CLI. if ($this->_echoCLI) { NameFixer::echoChangedReleaseName( - [ - 'new_name' => $newName, - 'old_name' => $this->_release['searchname'], - 'new_category' => $newCategory, - 'old_category' => $this->_release['categories_id'], - 'group' => $this->_release['groups_id'], - 'releases_id' => $this->_release['id'], - 'method' => 'ProcessAdditional->_processU4ETitle', - ] - ); + [ + 'new_name' => $newName, + 'old_name' => $this->_release['searchname'], + 'new_category' => $newCategory, + 'old_category' => $this->_release['categories_id'], + 'group' => $this->_release['groups_id'], + 'releases_id' => $this->_release['id'], + 'method' => 'ProcessAdditional->_processU4ETitle', + ] + ); } // Break out of the loop. @@ -2549,8 +2562,6 @@ class ProcessAdditional */ protected function _debug($string, $newline = true) { - if ($this->_echoDebug) { - $this->_echo('DEBUG: '.$string, 'debug', $newline); - } + $this->_echo('DEBUG: '.$string, 'debug', $newline); } } diff --git a/nntmux/processing/tv/TV.php b/nntmux/processing/tv/TV.php index 5f87bebad..55b54caf0 100755 --- a/nntmux/processing/tv/TV.php +++ b/nntmux/processing/tv/TV.php @@ -483,9 +483,6 @@ abstract class TV extends Videos return $showInfo; } } - if (NN_DEBUG) { - ColorCLI::doEcho('Failed to parse release: '.$relname, true); - } return false; } @@ -696,10 +693,6 @@ abstract class TV extends Videos { similar_text($ourName, $scrapeName, $matchpct); - if (NN_DEBUG) { - echo PHP_EOL.sprintf('Match Percentage: %d percent between %s and %s', $matchpct, $ourName, $scrapeName).PHP_EOL; - } - if ($matchpct >= $probability) { return $matchpct; } diff --git a/public/pages/BasePage.php b/public/pages/BasePage.php index 26cbf303e..5ad200ecd 100644 --- a/public/pages/BasePage.php +++ b/public/pages/BasePage.php @@ -131,7 +131,7 @@ class BasePage SMARTY_DIR.'plugins/', ] ); - $this->smarty->error_reporting = (NN_DEBUG ? E_ALL : E_ALL - E_NOTICE); + $this->smarty->error_reporting = E_ALL - E_NOTICE; if (isset($_SERVER['SERVER_NAME'])) { $this->serverurl = (