У меня работал код, все было отлично. Но вчера бот отказался работать, а ошибку выдает такую:
Parse error: syntax error, unexpected end of file in /var/www/www-root/data/www/botfrombot3.site/app/controllers/madeline.php on line 145
Не могу понять ошибку, ведь раньше он работал стабильно и без нареканий, а тут резко какую-то ошибку выбил.
Вот код-
<?php
namespace danog\MadelineProto;
if (\defined('MADELINE_PHP')) {
throw new \Exception('Please do not include madeline.php twice!');
}
if (!\defined('MADELINE_ALLOW_COMPOSER') && \class_exists(\Composer\Autoload\ClassLoader::class)) {
throw new \Exception('Composer autoloader detected: madeline.php is incompatible with Composer, please require MadelineProto using composer.');
}
\define('MADELINE_PHP', __FILE__);
class Installer
{
const RELEASE_TEMPLATE = 'https://phar.madelineproto.xyz/release%s?v=new';
const PHAR_TEMPLATE = 'https://github.com/danog/MadelineProto/releases/latest/download/madeline%s.phar?v=%s';
/**
* Phar lock instance.
*
* @var resource|null
*/
private static $lock = null;
/**
* Installer lock instance.
*
* @var resource|null
*/
private $lockInstaller = null;
/**
* PHP version.
*
* @var string
*/
private $version;
/**
* Constructor.
*/
public function __construct()
{
if ((PHP_MAJOR_VERSION === 7 && PHP_MINOR_VERSION < 1) || PHP_MAJOR_VERSION < 7) {
throw new \Exception('MadelineProto requires at least PHP 7.1 to run');
}
if (PHP_INT_SIZE < 8) {
throw new \Exception('A 64-bit build of PHP is required to run MadelineProto, PHP 8.0+ recommended.');
}
$backtrace = \debug_backtrace(0);
if (\count($backtrace) === 1) {
if (isset($GLOBALS['argv']) && !empty($GLOBALS['argv'])) {
$arguments = \array_slice($GLOBALS['argv'], 1);
} elseif (isset($_GET['argv']) && !empty($_GET['argv'])) {
$arguments = $_GET['argv'];
} else {
$arguments = [];
}
if (\count($arguments) >= 2) {
\define(\MADELINE_WORKER_TYPE::class, \array_shift($arguments));
\define(\MADELINE_WORKER_ARGS::class, $arguments);
} else {
die('MadelineProto loader: you must include this file in another PHP script, see https://docs.madelineproto.xyz for more info.'.PHP_EOL);
}
\define('MADELINE_REAL_ROOT', \dirname($backtrace[0]["file"]));
}
$this->version = (string) \min(81, (int) (PHP_MAJOR_VERSION.PHP_MINOR_VERSION));
\define('MADELINE_PHAR_GLOB', \getcwd().DIRECTORY_SEPARATOR."madeline*-{$this->version}.phar");
\define('MADELINE_RELEASE_URL', \sprintf(self::RELEASE_TEMPLATE, $this->version));
}
/**
* Destructor.
*/
public function __destruct()
{
if ($this->lockInstaller) {
\flock($this->lockInstaller, LOCK_UN);
\fclose($this->lockInstaller);
$this->lockInstaller = null;
}
}
/**
* Extract composer package versions from phar.
*
* @param string|null $release
* @return array<string, string>
*/
private static function extractVersions($release)
{
$phar = "madeline-$release.phar";
$packages = ['danog/madelineproto' => 'old'];
if (!\file_exists("phar://$phar/vendor/composer/installed.json")) {
return $packages;
}
$composer = \json_decode(\file_get_contents("phar://$phar/vendor/composer/installed.json"), true) ?: [];
if (!isset($composer['packages'])) {
return $packages;
}
foreach ($composer['packages'] as $dep) {
$name = $dep['name'];
if (\strpos($name, 'phabel/transpiler') === 0) {
$name = \explode('/', $name, 3)[2];
}
$version = $dep['version_normalized'];
if ($name === 'danog/madelineproto' && \substr($version, 0, 2) === '90') {
$version = \substr($version, 2);
}
$packages[$name] = $version;
}
return $packages;
}
/**
* Report installs to composer.
*
* @param string $local_release
* @param string $remote_release
*
* @return void
*/
private static function reportComposer($local_release, $remote_release)
{
$previous = self::extractVersions($local_release);
$current = self::extractVersions($remote_release);
$postData = ['downloads' => []];
foreach ($current as $name => $version) {
if (isset($previous[$name]) && $previous[$name] === $version) {
continue;
}
$postData['downloads'][] = [
'name' => $name,
'version' => $version
];
}
if (\defined('HHVM_VERSION')) {
$phpVersion = 'HHVM '.HHVM_VERSION;
} else {
$phpVersion = 'PHP '.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION;
?>