Пример #1
0
 /**
  * Decode a string of text encoded with yEnc. Ignores all errors.
  *
  * @param  string $data The encoded text to decode.
  *
  * @return string The decoded yEnc string, or the input string, if it's not yEnc.
  *
  * @access protected
  */
 protected function _decodeIgnoreYEnc(&$data)
 {
     if (preg_match('/^(=yBegin.*=yEnd[^$]*)$/ims', $data, $input)) {
         // If there user has no yyDecode path set, use PHP to decode yEnc.
         if ($this->_yyDecoderPath === false) {
             $data = '';
             $input = trim(preg_replace('/\\r\\n/im', '', preg_replace('/(^=yEnd.*)/im', '', preg_replace('/(^=yPart.*\\r\\n)/im', '', preg_replace('/(^=yBegin.*\\r\\n)/im', '', $input[1], 1), 1), 1)));
             $length = strlen($input);
             for ($chr = 0; $chr < $length; $chr++) {
                 $data .= $input[$chr] !== '=' ? chr(ord($input[$chr]) - 42) : chr(ord($input[++$chr]) - 64 - 42);
             }
         } else {
             if ($this->_yEncExtension) {
                 $data = simple_yenc_decode($input[1]);
             } else {
                 $inFile = $this->_yEncTempInput . mt_rand(0, 999999);
                 $ouFile = $this->_yEncTempOutput . mt_rand(0, 999999);
                 file_put_contents($inFile, $input[1]);
                 file_put_contents($ouFile, '');
                 nzedb\utility\runCmd("'" . $this->_yyDecoderPath . "' '" . $inFile . "' -o '" . $ouFile . "' -f -b" . $this->_yEncSilence);
                 $data = file_get_contents($ouFile);
                 if ($data === false) {
                     $data = $this->throwError('Error getting data from yydecode.');
                 }
                 unlink($inFile);
                 unlink($ouFile);
             }
         }
     }
     return $data;
 }
Пример #2
0
 /**
  * Try to get media info xml from a video file.
  *
  * @param string $fileLocation
  *
  * @return bool
  */
 protected function _getMediaInfo($fileLocation)
 {
     if (!$this->_processMediaInfo) {
         return false;
     }
     // Look for the video file.
     if (is_file($fileLocation)) {
         // Run media info on it.
         $xmlArray = \nzedb\utility\runCmd($this->_killString . $this->pdo->getSetting('mediainfopath') . '" --Output=XML "' . $fileLocation . '"');
         // Check if we got it.
         if (is_array($xmlArray)) {
             // Convert it to string.
             $xmlArray = implode("\n", $xmlArray);
             if (!preg_match('/<track type="(Audio|Video)">/i', $xmlArray)) {
                 return false;
             }
             // Insert it into the DB.
             $this->_releaseExtra->addFull($this->_release['id'], $xmlArray);
             $this->_releaseExtra->addFromXml($this->_release['id'], $xmlArray);
             if ($this->_echoCLI) {
                 $this->_echo('m', 'primaryOver', false);
             }
             return true;
         }
     }
     return false;
 }
Пример #3
0
     echo 'ERROR: Could not find the message-id for the rar file' . PHP_EOL;
     continue;
 }
 $sampleBinary = $nntp->getMessages($release['groupname'], $messageID);
 if ($sampleBinary === false) {
     echo 'ERROR: Could not fetch the binary from usenet.' . PHP_EOL;
     continue;
 } else {
     @file_put_contents($tmpPath . 'u4e_l2r.rar', $sampleBinary);
 }
 if (!is_file($tmpPath . 'u4e_l2r.rar')) {
     echo 'ERROR: Could not write RAR file to temp folder!' . PHP_EOL;
     continue;
 }
 // Extract the RAR file.
 nzedb\utility\runCmd('"' . $unrarPath . '" e -ai -ep -c- -id -inul -kb -or -p- -r -y "' . $tmpPath . 'u4e_l2r.rar" "' . $tmpPath . '"');
 @unlink($tmpPath . 'u4e_l2r.rar');
 $files = scandir($tmpPath);
 if ($files === false) {
     echo 'ERROR: Could not get list of files in temp folder!' . PHP_EOL;
     continue;
 }
 $fileName = '';
 foreach ($files as $file) {
     if (preg_match('/linux.*\\.sh/i', $file)) {
         $fileName = $file;
         break;
     }
 }
 if ($fileName === '') {
     echo 'ERROR: Could not find Linux_2rename.sh in the temp folder!' . PHP_EOL;