Do not use getcwd if disabled
This commit is contained in:
parent
4fa1e606a3
commit
2691055b4d
1
bot.php
1
bot.php
@ -33,6 +33,7 @@ class EventHandler extends \danog\MadelineProto\EventHandler
|
||||
return;
|
||||
}
|
||||
if (isset($update['message']['media'])) {
|
||||
yield $MadelineProto->download_to_dir($update, '/tmp');
|
||||
yield $this->messages->sendMedia(['peer' => $update, 'message' => $update['message']['message'], 'media' => $update]);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class Absolute
|
||||
public static function absolute($file)
|
||||
{
|
||||
if (($file[0] !== '/') && ($file[1] !== ':') && !in_array(substr($file, 0, 4), ['phar', 'http'])) {
|
||||
$file = getcwd().'/'.$file;
|
||||
$file = Magic::getcwd().'/'.$file;
|
||||
}
|
||||
|
||||
return $file;
|
||||
|
@ -74,7 +74,7 @@ class Logger
|
||||
$this->level = $level;
|
||||
|
||||
if ($this->mode === 2 && !file_exists(pathinfo($this->optional, PATHINFO_DIRNAME))) {
|
||||
$this->optional = Absolute::absolute(getcwd().'/MadelineProto.log');
|
||||
$this->optional = Magic::$script_cwd.'/MadelineProto.log';
|
||||
}
|
||||
|
||||
if ($this->mode === 2 && !preg_match('/\.log$/', $this->optional)) {
|
||||
|
@ -517,7 +517,6 @@ class MTProto implements TLCallback
|
||||
|
||||
$app_version = '4.9.1 (13613)';
|
||||
}
|
||||
$backtrace = debug_backtrace(0);
|
||||
|
||||
$this->altervista = isset($_SERVER['SERVER_ADMIN']) && strpos($_SERVER['SERVER_ADMIN'], 'altervista.org');
|
||||
// Set default settings
|
||||
@ -642,7 +641,7 @@ class MTProto implements TLCallback
|
||||
* $message is an array containing the messages the log, $level, is the logging level
|
||||
*/
|
||||
// write to
|
||||
'logger_param' => dirname(end($backtrace)['file']).'/MadelineProto.log',
|
||||
'logger_param' => Magic::$script_cwd.'/MadelineProto.log',
|
||||
'logger' => php_sapi_name() === 'cli' ? 3 : 2,
|
||||
// overwrite previous setting and echo logs
|
||||
'logger_level' => Logger::VERBOSE,
|
||||
@ -743,11 +742,9 @@ class MTProto implements TLCallback
|
||||
RPCErrorException::$rollbar = false;
|
||||
}
|
||||
|
||||
$backtrace = debug_backtrace(0);
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
if (isset($this->settings['logger']['logger_param']) && basename($this->settings['logger']['logger_param']) === 'MadelineProto.log') {
|
||||
$this->settings['logger']['logger_param'] = dirname(end($backtrace)['file']) . "/MadelineProto.log";
|
||||
$this->settings['logger']['logger_param'] = Magic::$script_cwd . "/MadelineProto.log";
|
||||
}
|
||||
}
|
||||
|
||||
@ -760,7 +757,7 @@ class MTProto implements TLCallback
|
||||
try {
|
||||
error_reporting(E_ALL);
|
||||
ini_set("log_errors", 1);
|
||||
ini_set("error_log", dirname(end($backtrace)['file']) . "/MadelineProto.log");
|
||||
ini_set("error_log", Magic::$script_cwd . "/MadelineProto.log");
|
||||
error_log('Enabled PHP logging');
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
$this->logger->logger("Could not enable PHP logging");
|
||||
|
@ -30,7 +30,7 @@ use function Amp\call;
|
||||
*/
|
||||
trait Files
|
||||
{
|
||||
public function upload_async($file, $file_name = '', $cb = null, $encrypted = false, $datacenter = null): \Generator
|
||||
public function upload_async($file, $file_name = '', $cb = null, $encrypted = false): \Generator
|
||||
{
|
||||
if (is_object($file)) {
|
||||
if (!isset(class_implements($file)['danog\MadelineProto\FileCallbackInterface'])) {
|
||||
@ -49,7 +49,7 @@ trait Files
|
||||
if (empty($file_name)) {
|
||||
$file_name = basename($file);
|
||||
}
|
||||
$datacenter = is_null($datacenter) ? $this->settings['connection_settings']['default_dc'] : $datacenter;
|
||||
$datacenter = $this->settings['connection_settings']['default_dc'];
|
||||
if (isset($this->datacenter->sockets[$datacenter.'_media'])) {
|
||||
$datacenter .= '_media';
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user