2019-01-07 13:24:29 +01:00
|
|
|
<?php
|
2020-03-11 00:20:14 +01:00
|
|
|
|
2020-02-10 03:26:11 +01:00
|
|
|
use TelegramApiServer\Logger;
|
|
|
|
|
2019-01-21 20:37:24 +01:00
|
|
|
$root = __DIR__;
|
2020-03-11 00:20:14 +01:00
|
|
|
|
|
|
|
//Composer init
|
|
|
|
{
|
|
|
|
if (!file_exists($root . '/vendor/autoload.php')) {
|
|
|
|
if (file_exists(__DIR__ . '/../../..' . '/vendor/autoload.php')) {
|
|
|
|
$root = __DIR__ . '/../../..';
|
|
|
|
} else {
|
|
|
|
system('composer install -o --no-dev');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
define('ROOT_DIR', $root);
|
|
|
|
chdir(ROOT_DIR);
|
|
|
|
require_once ROOT_DIR . '/vendor/autoload.php';
|
2019-01-07 13:24:29 +01:00
|
|
|
}
|
2019-06-09 19:47:46 +02:00
|
|
|
|
2020-03-11 00:20:14 +01:00
|
|
|
//Config init
|
|
|
|
{
|
|
|
|
if (!getenv('SERVER_ADDRESS')) {
|
2020-04-13 15:44:56 +02:00
|
|
|
if ($options['docker']) {
|
2020-03-11 00:20:14 +01:00
|
|
|
$envSource = file_exists(ROOT_DIR . '/.env') ? ROOT_DIR . '/.env' : ROOT_DIR . '/.env.example';
|
|
|
|
$envContent = file_get_contents($envSource);
|
|
|
|
$envContent = str_replace(
|
|
|
|
['SERVER_ADDRESS=127.0.0.1', 'IP_WHITELIST=127.0.0.1'],
|
|
|
|
['SERVER_ADDRESS=0.0.0.0', 'IP_WHITELIST='],
|
|
|
|
$envContent
|
|
|
|
);
|
|
|
|
file_put_contents(ROOT_DIR . '/.env', $envContent);
|
2020-04-13 15:44:56 +02:00
|
|
|
} elseif (!file_exists(ROOT_DIR . '/.env')) {
|
|
|
|
copy( ROOT_DIR . '/.env.example', ROOT_DIR . '/.env');
|
2020-03-11 00:20:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Dotenv\Dotenv::createImmutable(ROOT_DIR)->load();
|
|
|
|
}
|
2019-01-07 13:24:29 +01:00
|
|
|
}
|
2020-02-10 03:26:11 +01:00
|
|
|
|
2020-05-08 00:16:35 +02:00
|
|
|
$memoryLimit = getenv('MEMORY_LIMIT');
|
|
|
|
if ($memoryLimit !== false) {
|
|
|
|
ini_set('memory_limit', $memoryLimit);
|
|
|
|
}
|
|
|
|
|
2020-02-10 03:26:11 +01:00
|
|
|
if (!function_exists('debug')) {
|
|
|
|
function debug(string $message, array $context) {
|
|
|
|
Logger::getInstance()->debug($message, $context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!function_exists('info')) {
|
|
|
|
function info(string $message, array $context = []) {
|
|
|
|
Logger::getInstance()->info($message, $context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!function_exists('notice')) {
|
|
|
|
function notice($message, array $context = []) {
|
|
|
|
Logger::getInstance()->notice($message, $context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!function_exists('warning')) {
|
|
|
|
function warning(string $message, array $context = []) {
|
|
|
|
Logger::getInstance()->warning($message, $context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!function_exists('error')) {
|
|
|
|
function error(string $message, array $context = []) {
|
|
|
|
Logger::getInstance()->error($message, $context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!function_exists('critical')) {
|
|
|
|
function critical(string $message, array $context = []) {
|
|
|
|
Logger::getInstance()->critical($message, $context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!function_exists('alert')) {
|
|
|
|
function alert(string $message, array $context = []) {
|
|
|
|
Logger::getInstance()->alert($message, $context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!function_exists('emergency')) {
|
|
|
|
function emergency(string $message, array $context = []) {
|
|
|
|
Logger::getInstance()->emergency($message, $context);
|
|
|
|
}
|
|
|
|
}
|