Example #1
0
 /**
  * Check the Admin settings for yEnc and process them accordingly.
  *
  * @void
  *
  * @access protected
  */
 protected function _initiateYEncSettings()
 {
     // Check if the user wants to use yyDecode or the simple_php_yenc_decode extension.
     $this->_yyDecoderPath = $this->pdo->getSetting('yydecoderpath') != '' ? (string) $this->pdo->getSetting('yydecoderpath') : false;
     if (strpos((string) $this->_yyDecoderPath, 'simple_php_yenc_decode') !== false) {
         if (extension_loaded('simple_php_yenc_decode')) {
             $this->_yEncExtension = true;
         } else {
             $this->_yyDecoderPath = false;
         }
     } else {
         if ($this->_yyDecoderPath !== false) {
             $this->_yEncSilence = \newznab\utility\Utility::isWindows() ? '' : ' > /dev/null 2>&1';
             $this->_yEncTempInput = NN_TMP . 'yEnc' . DS;
             $this->_yEncTempOutput = $this->_yEncTempInput . 'output';
             $this->_yEncTempInput .= 'input';
             // Test if the user can read/write to the yEnc path.
             if (!is_file($this->_yEncTempInput)) {
                 @file_put_contents($this->_yEncTempInput, 'x');
             }
             if (!is_file($this->_yEncTempInput) || !is_readable($this->_yEncTempInput) || !is_writable($this->_yEncTempInput)) {
                 $this->_yyDecoderPath = false;
             }
             if (is_file($this->_yEncTempInput)) {
                 @unlink($this->_yEncTempInput);
             }
         }
     }
 }
Example #2
0
 /**
  * Run CLI command.
  *
  * @param string $command
  * @param bool   $debug
  *
  * @return array
  */
 public static function runCmd($command, $debug = false)
 {
     $nl = PHP_EOL;
     if (Utility::isWindows() && strpos(phpversion(), "5.2") !== false) {
         $command = "\"" . $command . "\"";
     }
     if ($debug) {
         echo '-Running Command: ' . $nl . '   ' . $command . $nl;
     }
     $output = [];
     $status = 1;
     @exec($command, $output, $status);
     if ($debug) {
         echo '-Command Output: ' . $nl . '   ' . implode($nl . '  ', $output) . $nl;
     }
     return $output;
 }