diff --git a/lib/Enzebe.php b/lib/Enzebe.php index 8ba418cb9..4ee183c3a 100644 --- a/lib/Enzebe.php +++ b/lib/Enzebe.php @@ -317,8 +317,7 @@ class Enzebe return $result; } - $nzb = str_replace("\x0F", '', $nzb); - $xml = @simplexml_load_string($nzb); + $xml = @simplexml_load_string(str_replace("\x0F", '', $nzb)); if (!$xml || strtolower($xml->getName()) !== 'nzb') { return $result; } diff --git a/lib/ProcessAdditional.php b/lib/ProcessAdditional.php index 58c53d53f..318d3bae1 100644 --- a/lib/ProcessAdditional.php +++ b/lib/ProcessAdditional.php @@ -691,15 +691,7 @@ Class ProcessAdditional if (!is_dir($this->tmpPath)) { $this->_echo('Unable to create directory: ' . $this->tmpPath, 'warning'); - - // Decrement password status. - $this->pdo->queryExec( - sprintf( - 'UPDATE releases SET passwordstatus = passwordstatus - 1 WHERE ID = %d', - $this->_release['ID'] - ) - ); - return false; + return $this->_decrementPasswordStatus(); } } return true; @@ -716,41 +708,47 @@ Class ProcessAdditional if ($nzbPath === false) { $this->_echo('NZB not found for GUID: ' . $this->_release['guid'], 'warning'); - - // The nzb was not located. decrement the password status. - $this->pdo->queryExec( - sprintf( - 'UPDATE releases SET passwordstatus = passwordstatus - 1 WHERE ID = %d', - $this->_release['ID'] - ) - ); - return false; + return $this->_decrementPasswordStatus(); } $nzbContents = Utility::unzipGzipFile($nzbPath); + if (!$nzbContents) { + $this->_echo('NZB is empty or broken for GUID: ' . $this->_release['guid'], 'warning'); + return $this->_decrementPasswordStatus(); + } // Get a list of files in the nzb. $this->_nzbContents = $this->_nzb->nzbFileList($nzbContents); if (count($this->_nzbContents) === 0) { - $this->_echo('NZB is empty or broken for GUID: ' . $this->_release['guid'], 'warning'); - - // There does not appear to be any files in the nzb, decrement password status. - $this->pdo->queryExec( - sprintf( - 'UPDATE releases SET passwordstatus = passwordstatus - 1 WHERE ID = %d', - $this->_release['ID'] - ) - ); - return false; + $this->_echo('NZB is potentially broken for GUID: ' . $this->_release['guid'], 'warning'); + return $this->_decrementPasswordStatus(); } // Sort the files inside the NZB. - usort($this->_nzbContents, ['ProcessAdditional', '_sortNZB']); + usort($this->_nzbContents, ['\tmux\lib\ProcessAdditional', '_sortNZB']); return true; } + /** + * Decrement password status for the current release. + * + * @param bool $return Return value. + * + * @return bool + */ + protected function _decrementPasswordStatus($return = false) + { + $this->pdo->queryExec( + sprintf( + 'UPDATE releases SET passwordstatus = passwordstatus - 1 WHERE ID = %d', + $this->_release['ID'] + ) + ); + return $return; + } + /** * Current file we are working on inside a NZB. * @var array diff --git a/lib/copy_this/www/lib/TmuxOutput.php b/lib/copy_this/www/lib/TmuxOutput.php index d8fa0d0de..b6a84429a 100644 --- a/lib/copy_this/www/lib/TmuxOutput.php +++ b/lib/copy_this/www/lib/TmuxOutput.php @@ -117,7 +117,7 @@ class TmuxOutput extends Tmux $buffer = ''; $state = ($this->runVar['settings']['is_running'] == 1) ? 'Running' : 'Disabled'; //$version = $this->_tvers . 'r' . $this->_vers; - $tversion = '0.5r01139'; + $tversion = '0.5r01145'; $buffer .= sprintf($this->tmpMasks[2], "Monitor $state v$tversion @ $this->_tvers [" . $this->_vers ."]: ", diff --git a/lib/copy_this/www/lib/nzb.php b/lib/copy_this/www/lib/nzb.php index 9fc1da929..220ccb500 100644 --- a/lib/copy_this/www/lib/nzb.php +++ b/lib/copy_this/www/lib/nzb.php @@ -146,9 +146,8 @@ class NZB { $result = array(); - $nzb = str_replace("\x0F", "", $nzb); + $xml = @simplexml_load_string(str_replace("\x0F", '', $nzb)); $num_pars = 0; - $xml = @simplexml_load_string($nzb); if (!$xml || strtolower($xml->getName()) != 'nzb') return false; diff --git a/lib/copy_this/www/lib/util.php b/lib/copy_this/www/lib/util.php index d2ce450fa..197b6b776 100644 --- a/lib/copy_this/www/lib/util.php +++ b/lib/copy_this/www/lib/util.php @@ -224,32 +224,27 @@ class Utility */ static public function unzipGzipFile($filePath) { + /* Potential issues with this, so commenting out. $length = Utility::isGZipped($filePath); if ($length === false || $length === null) { return false; - } + }*/ - // String to hold the NZB contents. $string = ''; - // Open the gzip file. $gzFile = @gzopen($filePath, 'rb', 0); if ($gzFile) { - // Append the decompressed data to the string until we find the end of file pointer. while (!gzeof($gzFile)) { $temp = gzread($gzFile, 1024); - // Check for corrupt data, there will be no end of file, so the loop would go on and on taking 100% CPU. - if ($temp) { - $string .= $temp; - } else { - // If the data was corrupt, set the big string empty so we return false and break out of the loop. - $string = ''; + // Check for empty string. + // Without this the loop would be endless and consume 100% CPU. + // Do not set $string empty here, as the data might still be good. + if (!$temp) { break; } + $string .= $temp; } - // Close the gzip file. gzclose($gzFile); } - // Return the string. return ($string === '' ? false : $string); }