diff --git a/Changelog b/Changelog index 9b538ca43..898c142a6 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-08-30 DariusIII + * Chg: Add back yydecode support * Chg: Check if user has been logged in already before serving the login page * Chg: Update laravel/framework to version 5.5.0 * Chg: Update rememberme logic for logging in diff --git a/app/Extensions/util/yenc/adapter/Ydecode.php b/app/Extensions/util/yenc/adapter/Ydecode.php new file mode 100644 index 000000000..a8861b32b --- /dev/null +++ b/app/Extensions/util/yenc/adapter/Ydecode.php @@ -0,0 +1,87 @@ +. + * @author niel + * @copyright 2016 nZEDb + */ + +namespace App\Extensions\util\yenc\adapter; + +use App\Extensions\util\Yenc; +use App\Models\Settings; +use nntmux\utility\Utility; + +class Ydecode +{ + /** + * Path to yyDecoder binary. + * + * @var bool|string + * @access protected + */ + protected static $pathBin; + + /** + * If on unix, hide yydecode CLI output. + * + * @var string + * @access protected + */ + protected static $silent; + + public static function decode(&$text, $ignore = false) + { + $result = preg_match('/^(=yBegin.*=yEnd[^$]*)$/ims', $text, $input); + switch (true) { + case !$result: + throw new \RuntimeException('Text does not look like yEnc.'); + case self::$pathBin === false: + throw new \InvalidArgumentException('No valid path to yydecoder binary found!'); + default: + } + + $ignoreFlag = $ignore ? '-b ' : ''; + $data = shell_exec( + "echo '{$input[1]}' | {" . self::$pathBin . '} -o - ' . $ignoreFlag . self::$silent + ); + if ($data === null) { + throw new \RuntimeException('Error getting data from yydecode.'); + } + + return $data; + } + + public static function decodeIgnore(&$text) + { + self::decode($text, true); + } + + /** + * Determines if this adapter is enabled by checking if the `yydecode` path is enabled. + * + * @return boolean Returns `true` if enabled, otherwise `false`. + */ + public static function enabled() + { + return !empty(self::$pathBin); + } + + public static function encode($data, $filename, $lineLength, $crc32) + { + return Yenc::encode($data, $filename, $lineLength, $crc32, ['name' => 'Php']); + } +} + +?> diff --git a/bootstrap/yenc.php b/bootstrap/yenc.php index 1069ade45..6200085b1 100644 --- a/bootstrap/yenc.php +++ b/bootstrap/yenc.php @@ -18,6 +18,8 @@ */ +use App\Models\Settings; + if (defined('NN_INSTALLER') && NN_INSTALLER !== false) { $adapter = 'Php'; } else { @@ -37,6 +39,9 @@ if (defined('NN_INSTALLER') && NN_INSTALLER !== false) { ignored. Please update it to use the extension.', E_USER_WARNING ); } + case !empty(Settings::value('apps..yydecoderpath', true)): + $adapter = 'Ydecode'; + break; default: $adapter = 'Php'; }