mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:01:24 +00:00
Make PhpYenc the only yenc available, remove rest of the files used
This commit is contained in:
+4
-4
@@ -3,7 +3,7 @@
|
||||
namespace Blacklight;
|
||||
|
||||
use App\Models\Settings;
|
||||
use App\Extensions\util\Yenc;
|
||||
use App\Extensions\util\PhpYenc;
|
||||
|
||||
/**
|
||||
* Class for connecting to the usenet, retrieving articles and article headers,
|
||||
@@ -653,7 +653,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
}
|
||||
}
|
||||
// Finally we decode the message using yEnc.
|
||||
$ret['Message'] = ($yEnc ? Yenc::decodeIgnore($body) : $body);
|
||||
$ret['Message'] = ($yEnc ? PhpYenc::decodeIgnore($body) : $body);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -771,7 +771,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
// Check if we should encode to yEnc.
|
||||
if ($yEnc) {
|
||||
$bin = $compress ? gzdeflate($body, 4) : $body;
|
||||
$body = Yenc::encode($bin, $subject);
|
||||
$body = PhpYenc::encode($bin, $subject);
|
||||
// If not yEnc, then check if the body is 510+ chars, split it at 510 chars and separate with \r\n
|
||||
} else {
|
||||
$body = $this->_splitLines($body, $compress);
|
||||
@@ -1122,7 +1122,7 @@ class NNTP extends \Net_NNTP_Client
|
||||
if ($line === ".\r\n") {
|
||||
|
||||
// Attempt to yEnc decode and return the body.
|
||||
return Yenc::decodeIgnore($body);
|
||||
return PhpYenc::decodeIgnore($body);
|
||||
}
|
||||
|
||||
// Check for line that starts with double period, remove one.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
2018-11-15 DariusIII
|
||||
* Chg: Make PhpYenc the only yenc available, remove rest of the files used
|
||||
* Chg: Update app/Extensions/util/Versions.php
|
||||
* Chg: Replace nZEDb/Git.php with Cz\Git\GitRepository
|
||||
2018-11-14 DariusIII
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
* @copyright 2016 nZEDb
|
||||
*/
|
||||
|
||||
namespace App\Extensions\util\yenc\adapter;
|
||||
namespace App\Extensions\util;
|
||||
|
||||
/**
|
||||
* Class Php.
|
||||
*/
|
||||
class Php
|
||||
class PhpYenc
|
||||
{
|
||||
/**
|
||||
* @param $text
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program (see LICENSE.txt in the base directory. If
|
||||
* not, see:.
|
||||
*
|
||||
* @link <http://www.gnu.org/licenses/>.
|
||||
* @author niel
|
||||
* @copyright 2016 nZEDb
|
||||
*/
|
||||
|
||||
namespace App\Extensions\util;
|
||||
|
||||
use App\Providers\YencServiceProvider;
|
||||
|
||||
class Yenc extends YencServiceProvider
|
||||
{
|
||||
/**
|
||||
* @param $text yEncoded text to decode back to an 8 bit form.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return string 8 bit decoded version of $text.
|
||||
*/
|
||||
public static function decode(&$text, array $options = [])
|
||||
{
|
||||
$options += [
|
||||
'name' => 'default',
|
||||
'file' => true,
|
||||
];
|
||||
|
||||
return static::config($options)->decode($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $text
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function decodeIgnore(&$text, array $options = [])
|
||||
{
|
||||
$options += [
|
||||
'name' => 'default',
|
||||
'file' => true,
|
||||
];
|
||||
|
||||
return static::config($options)->decodeIgnore($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data 8 bit data to convert to yEncoded text.
|
||||
* @param string $filename Name of file to recreate as.
|
||||
* @param int $line Maximum number of characters in each line.
|
||||
* to use.
|
||||
*
|
||||
* @param bool $crc32
|
||||
* @param array $options
|
||||
*
|
||||
* @return \Exception|string The yEncoded version of $data.
|
||||
*/
|
||||
public static function encode(&$data, $filename, $line = 128, $crc32 = true, array $options = [])
|
||||
{
|
||||
$options += ['name' => 'default'];
|
||||
|
||||
return static::config($options)->encode($data, $filename, $line, $crc32);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program (see LICENSE.txt in the base directory. If
|
||||
* not, see:.
|
||||
*
|
||||
* @link <http://www.gnu.org/licenses/>.
|
||||
* @author niel
|
||||
* @copyright 2016 nZEDb
|
||||
*/
|
||||
|
||||
namespace App\Extensions\util\yenc\adapter;
|
||||
|
||||
use yenc\yenc;
|
||||
|
||||
class NzedbYenc
|
||||
{
|
||||
public static function decode(&$text, $ignore = false, array $options = [])
|
||||
{
|
||||
return (new yenc())->decode($text);
|
||||
}
|
||||
|
||||
public static function decodeIgnore(&$text, array $options = [])
|
||||
{
|
||||
return (new yenc())->decode($text, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this adapter is enabled by checking if the `yenc` extension is loaded.
|
||||
*
|
||||
* @return bool Returns `true` if enabled, otherwise `false`.
|
||||
*/
|
||||
public static function enabled()
|
||||
{
|
||||
return extension_loaded('yenc');
|
||||
}
|
||||
|
||||
public static function encode($data, $filename, $lineLength = 128)
|
||||
{
|
||||
return (new yenc())->encode($data, $filename, $lineLength);
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program (see LICENSE.txt in the base directory. If
|
||||
* not, see:.
|
||||
*
|
||||
* @link <http://www.gnu.org/licenses/>.
|
||||
* @author niel
|
||||
* @copyright 2016 nZEDb
|
||||
*/
|
||||
|
||||
namespace App\Extensions\util\yenc\adapter;
|
||||
|
||||
use App\Extensions\util\Yenc;
|
||||
|
||||
class Ydecode
|
||||
{
|
||||
/**
|
||||
* Path to yyDecoder binary.
|
||||
*
|
||||
* @var bool|string
|
||||
*/
|
||||
protected static $pathBin;
|
||||
|
||||
/**
|
||||
* If on unix, hide yydecode CLI output.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
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 bool 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']);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Extensions\util\yenc\adapter\Php;
|
||||
|
||||
class YencServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*
|
||||
* @return mixed
|
||||
* @internal param $option
|
||||
*/
|
||||
public static function config(array $options = [])
|
||||
{
|
||||
$defaults = [
|
||||
['name' => [
|
||||
'default' => 'Php',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$options += $defaults;
|
||||
|
||||
$namespace = '\App\Extensions\util\yenc\adapter\\';
|
||||
|
||||
$class = $namespace.$options[0]['name']['default'];
|
||||
|
||||
return new $class;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
|
||||
require __DIR__.DIRECTORY_SEPARATOR.'app.php';
|
||||
require_once 'constants.php';
|
||||
require_once __DIR__.DIRECTORY_SEPARATOR.'yenc.php';
|
||||
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'app/Extensions/util/PhpYenc.php';
|
||||
|
||||
use Dotenv\Dotenv;
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program (see LICENSE.txt in the base directory. If
|
||||
* not, see:.
|
||||
*
|
||||
* @link <http://www.gnu.org/licenses/>.
|
||||
* @author niel
|
||||
* @copyright 2016 nZEDb
|
||||
*/
|
||||
if ((defined('NN_INSTALLER') && NN_INSTALLER !== false) || ! file_exists(NN_ROOT.'_install/install.lock')) {
|
||||
$adapter = 'Php';
|
||||
} else {
|
||||
if (extension_loaded('yenc') === true) {
|
||||
if (method_exists('yenc\yEnc', 'version') && version_compare(yenc\yEnc::version(), '1.3.0', '>=')) {
|
||||
$adapter = 'NzedbYenc';
|
||||
}
|
||||
trigger_error('Your version of the php-yenc extension is out of date and will be
|
||||
ignored. Please update it to use the extension.', E_USER_WARNING);
|
||||
$adapter = 'Php';
|
||||
} else {
|
||||
$adapter = 'Php';
|
||||
}
|
||||
}
|
||||
|
||||
\App\Providers\YencServiceProvider::config(
|
||||
[
|
||||
['name' => [
|
||||
'default' => $adapter,
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
Reference in New Issue
Block a user