Changing file routing

Removed unnecessary ROOT constant
The DIR constant has been changed
All dependencies have been edited
This commit is contained in:
Sergei Solovev 2023-09-03 15:08:57 +03:00
parent ef6bdc398e
commit a45b4fab62
17 changed files with 60 additions and 62 deletions

View file

@ -7,17 +7,17 @@ date_default_timezone_set('Europe/Moscow');
@ini_set('html_errors', FALSE);
@ini_set('error_reporting', E_ALL);
DEFINE('EGP', TRUE);
DEFINE('ROOT', '../');
DEFINE('SYS', ROOT . 'system/');
DEFINE('ACP', ROOT . 'system/acp/');
DEFINE('TPL', ROOT . 'acp/template/');
DEFINE('TEMP', ROOT . 'temp/');
DEFINE('FILES', ROOT . 'files/');
DEFINE('DATA', SYS . 'data/');
DEFINE('LIB', SYS . 'library/');
DEFINE('ENG', SYS . 'acp/engine/');
DEFINE('SEC', SYS . 'acp/sections/');
define('EGP', TRUE);
define('DIR', '../');
define('SYS', DIR . 'system/');
define('ACP', DIR . 'system/acp/');
define('TPL', DIR . 'acp/template/');
define('TEMP', DIR . 'temp/');
define('FILES', DIR . 'files/');
define('DATA', SYS . 'data/');
define('LIB', SYS . 'library/');
define('ENG', SYS . 'acp/engine/');
define('SEC', SYS . 'acp/sections/');
$start_point = $_SERVER['REQUEST_TIME'];
@ -28,10 +28,10 @@ $mcache = new Memcache;
$mcache->connect('127.0.0.1', 11211) or exit('Ошибка подключения Memcache');
// Composer
if (!file_exists(ROOT . 'vendor/autoload.php')) {
if (!file_exists(DIR . 'vendor/autoload.php')) {
die('Please <a href="https://getcomposer.org/download/" target="_blank" rel="noreferrer" style="color:#0a25bb;">install composer</a> and run <code style="background:#222;color:#00e01f;padding:2px 6px;border-radius:3px;">composer install</code>');
}
require(ROOT . 'vendor/autoload.php');
require(DIR . 'vendor/autoload.php');
// Настройки
include(DATA . 'config.php');

View file

@ -5,18 +5,17 @@ date_default_timezone_set('Europe/Moscow');
@ini_set('html_errors', TRUE);
@ini_set('error_reporting', E_ALL);
DEFINE('EGP', TRUE);
DEFINE('DIR', __DIR__);
DEFINE('ROOT', DIR . '/');
DEFINE('SYS', ROOT . 'system/');
DEFINE('TPL', ROOT . 'template/');
DEFINE('TEMP', ROOT . 'temp/');
DEFINE('FILES', ROOT . 'files/');
DEFINE('DATA', SYS . 'data/');
DEFINE('LIB', SYS . 'library/');
DEFINE('ENG', SYS . 'engine/');
DEFINE('SEC', SYS . 'sections/');
DEFINE('CRON', LIB . 'cron/');
define('EGP', TRUE);
define('DIR', __DIR__ . '/');
define('SYS', DIR . 'system/');
define('TPL', DIR . 'template/');
define('TEMP', DIR . 'temp/');
define('FILES', DIR . 'files/');
define('DATA', SYS . 'data/');
define('LIB', SYS . 'library/');
define('ENG', SYS . 'engine/');
define('SEC', SYS . 'sections/');
define('CRON', LIB . 'cron/');
$start_point = $_SERVER['REQUEST_TIME'];
@ -24,10 +23,10 @@ $mcache = new Memcache;
$mcache->connect('127.0.0.1', 11211) or exit('Ошибка: не удалось создать связь с Memcache.' . PHP_EOL);
// Composer
if (!file_exists(ROOT . 'vendor/autoload.php')) {
if (!file_exists(DIR . 'vendor/autoload.php')) {
die('Please <a href="https://getcomposer.org/download/" target="_blank" rel="noreferrer" style="color:#0a25bb;">install composer</a> and run <code style="background:#222;color:#00e01f;padding:2px 6px;border-radius:3px;">composer install</code>');
}
require(ROOT . 'vendor/autoload.php');
require(DIR . 'vendor/autoload.php');
// Настройки
include(DATA . 'config.php');

View file

@ -8,17 +8,16 @@ date_default_timezone_set('Europe/Moscow');
@ini_set('html_errors', TRUE);
@ini_set('error_reporting', E_ALL);
DEFINE('EGP', TRUE);
DEFINE('DIR', dirname('index.php'));
DEFINE('ROOT', DIR . '/');
DEFINE('SYS', ROOT . 'system/');
DEFINE('TPL', ROOT . 'template/');
DEFINE('TEMP', ROOT . 'temp/');
DEFINE('FILES', ROOT . 'files/');
DEFINE('DATA', SYS . 'data/');
DEFINE('LIB', SYS . 'library/');
DEFINE('ENG', SYS . 'engine/');
DEFINE('SEC', SYS . 'sections/');
define('EGP', TRUE);
define('DIR', __DIR__ . '/');
define('SYS', DIR . 'system/');
define('TPL', DIR . 'template/');
define('TEMP', DIR . 'temp/');
define('FILES', DIR . 'files/');
define('DATA', SYS . 'data/');
define('LIB', SYS . 'library/');
define('ENG', SYS . 'engine/');
define('SEC', SYS . 'sections/');
$start_point = $_SERVER['REQUEST_TIME'];
@ -29,10 +28,10 @@ $mcache = new Memcache;
$mcache->connect('127.0.0.1', 11211) or exit('Ошибка подключения Memcache');
// Composer
if (!file_exists(ROOT . 'vendor/autoload.php')) {
if (!file_exists(DIR . 'vendor/autoload.php')) {
die('Please <a href="https://getcomposer.org/download/" target="_blank" rel="noreferrer" style="color:#0a25bb;">install composer</a> and run <code style="background:#222;color:#00e01f;padding:2px 6px;border-radius:3px;">composer install</code>');
}
require(ROOT . 'vendor/autoload.php');
require(DIR . 'vendor/autoload.php');
// Настройки
include(DATA . 'config.php');

View file

@ -15,7 +15,7 @@ $whoops->pushHandler($loggingInConsole);
// логи в файл
$loggingInFile = new \Whoops\Handler\PlainTextHandler();
$loggingInFile->loggerOnly(true);
$loggingInFile->setLogger((new \Monolog\Logger('EngineGP', [(new \Monolog\Handler\StreamHandler(ROOT . '/logs/enginegp.log'))->setFormatter((new \Monolog\Formatter\LineFormatter(null, null, true)))])));
$loggingInFile->setLogger((new \Monolog\Logger('EngineGP', [(new \Monolog\Handler\StreamHandler(DIR . 'logs/enginegp.log'))->setFormatter((new \Monolog\Formatter\LineFormatter(null, null, true)))])));
$whoops->pushHandler($loggingInFile);
// Парсинг адреса

View file

@ -14,7 +14,7 @@ if (isset($url['delete']) and $url['delete'] == 'all') {
$uploads = $sql->query('SELECT `id`, `name` FROM `help_upload` WHERE `user`="' . $id . '"');
while ($upload = $sql->get($uploads)) {
@unlink(ROOT . 'upload/' . $upload['name']);
@unlink(DIR . 'upload/' . $upload['name']);
$sql->query('DELETE FROM `help_upload` WHERE `id`="' . $upload['id'] . '" LIMIT 1');
}

View file

@ -15,7 +15,7 @@ $whoops->pushHandler($loggingInConsole);
// логи в файл
$loggingInFile = new \Whoops\Handler\PlainTextHandler();
$loggingInFile->loggerOnly(true);
$loggingInFile->setLogger((new \Monolog\Logger('EngineGP', [(new \Monolog\Handler\StreamHandler(ROOT . '/logs/enginegp.log'))->setFormatter((new \Monolog\Formatter\LineFormatter(null, null, true)))])));
$loggingInFile->setLogger((new \Monolog\Logger('EngineGP', [(new \Monolog\Handler\StreamHandler(DIR . 'logs/enginegp.log'))->setFormatter((new \Monolog\Formatter\LineFormatter(null, null, true)))])));
$whoops->pushHandler($loggingInFile);
// Парсинг адреса

View file

@ -3,5 +3,5 @@ if (!DEFINED('EGP'))
exit(header('Refresh: 0; URL=http://' . $_SERVER['SERVER_NAME'] . '/404'));
http_response_code(404);
exit(file_get_contents(ROOT . '404.html'));
exit(file_get_contents(DIR . '404.html'));
?>

View file

@ -6,7 +6,7 @@ if (!isset($url['response']) and !in_array($url['response'], array('success', 'f
exit();
if ($url['response'] == 'success')
sys::out(file_get_contents(ROOT . 'success.html'));
sys::out(file_get_contents(DIR . 'success.html'));
else
sys::out(file_get_contents(ROOT . 'fail.html'));
sys::out(file_get_contents(DIR . 'fail.html'));
?>

View file

@ -699,7 +699,7 @@ class sys
public static function logMessage($message, $logFile = 'enginegp_info', $context = [])
{
$logger = new \Monolog\Logger('EngineGP');
$logger->pushHandler(new \Monolog\Handler\StreamHandler(ROOT . '/logs/' . $logFile . '.log'));
$logger->pushHandler(new \Monolog\Handler\StreamHandler(DIR . 'logs/' . $logFile . '.log'));
$logger->info($message, $context);
}
}

View file

@ -9,7 +9,7 @@ $whoops->register();
// логи в файл
$loggingInFile = new \Whoops\Handler\PlainTextHandler();
$loggingInFile->loggerOnly(true);
$loggingInFile->setLogger((new \Monolog\Logger('EngineGP', [(new \Monolog\Handler\StreamHandler(ROOT . '/logs/cron.log'))->setFormatter((new \Monolog\Formatter\LineFormatter(null, null, true)))])));
$loggingInFile->setLogger((new \Monolog\Logger('EngineGP', [(new \Monolog\Handler\StreamHandler(DIR . 'logs/cron.log'))->setFormatter((new \Monolog\Formatter\LineFormatter(null, null, true)))])));
$whoops->pushHandler($loggingInFile);
// Подгрузка трейта

View file

@ -1445,7 +1445,7 @@ class sys
public static function logMessage($message, $logFile = 'enginegp_info', $context = [])
{
$logger = new \Monolog\Logger('EngineGP');
$logger->pushHandler(new \Monolog\Handler\StreamHandler(ROOT . '/logs/' . $logFile . '.log'));
$logger->pushHandler(new \Monolog\Handler\StreamHandler(DIR . 'logs/' . $logFile . '.log'));
$logger->info($message, $context);
}
}

View file

@ -11,13 +11,13 @@ class users
$file = 'upload/avatars/' . $user . '.';
$link = $cfg['http'] . 'upload/avatars/' . $user . '.';
if (file_exists(ROOT . $file . 'jpg'))
if (file_exists(DIR . $file . 'jpg'))
return $link . 'jpg';
if (file_exists(ROOT . $file . 'png'))
if (file_exists(DIR . $file . 'png'))
return $link . 'png';
if (file_exists(ROOT . $file . 'gif'))
if (file_exists(DIR . $file . 'gif'))
return $link . 'gif';
return $cfg['http'] . 'template/images/avatar.png';

View file

@ -40,11 +40,11 @@ if (isset($section)) {
global $cfg;
$file = 'upload/avatars/' . $resp['uid'] . '.';
$link = $cfg['http'] . 'upload/avatars/' . $resp['uid'] . '.';
if (file_exists(ROOT . $file . 'jpg'))
if (file_exists(DIR . $file . 'jpg'))
$html->set('ava', '/upload/avatars/' . $resp['uid'] . '.jpg');
elseif (file_exists(ROOT . $file . 'png'))
elseif (file_exists(DIR . $file . 'png'))
$html->set('ava', '/upload/avatars/' . $resp['uid'] . '.png');
elseif (file_exists(ROOT . $file . 'gif'))
elseif (file_exists(DIR . $file . 'gif'))
$html->set('ava', '/upload/avatars/' . $resp['uid'] . '.gif');
else
$html->set('ava', $cfg['http'] . 'template/images/avatar.png');
@ -97,11 +97,11 @@ while ($msg = $sql->get($q_Msgs)) {
global $cfg;
$file = 'upload/avatars/' . $msg['uid'] . '.';
$link = $cfg['http'] . 'upload/avatars/' . $msg['uid'] . '.';
if (file_exists(ROOT . $file . 'jpg'))
if (file_exists(DIR . $file . 'jpg'))
$html->set('ava', '/upload/avatars/' . $msg['uid'] . '.jpg');
elseif (file_exists(ROOT . $file . 'png'))
elseif (file_exists(DIR . $file . 'png'))
$html->set('ava', '/upload/avatars/' . $msg['uid'] . '.png');
elseif (file_exists(ROOT . $file . 'gif'))
elseif (file_exists(DIR . $file . 'gif'))
$html->set('ava', '/upload/avatars/' . $msg['uid'] . '.gif');
else
$html->set('ava', $cfg['http'] . 'template/images/avatar.png');

View file

@ -15,7 +15,7 @@ if ($id) {
foreach ($aImg as $img) {
$sql->query('DELETE FROM `help_upload` WHERE `name`="' . $img . '" LIMIT 1');
unlink(ROOT . 'upload/' . $img);
unlink(DIR . 'upload/' . $img);
}
$sql->query('DELETE FROM `help_dialogs` WHERE `id`="' . $dialog['id'] . '" LIMIT 1');

View file

@ -19,7 +19,7 @@ if ($id) {
foreach ($aImg as $img) {
$sql->query('DELETE FROM `help_upload` WHERE `name`="' . $img . '" LIMIT 1');
unlink(ROOT . 'upload/' . $img);
unlink(DIR . 'upload/' . $img);
}
$sql->query('DELETE FROM `help_dialogs` WHERE `id`="' . $msg . '" LIMIT 1');

View file

@ -5,7 +5,7 @@ if (!DEFINED('EGP'))
// Проверка на авторизацию
sys::noauth();
$updir = ROOT . 'upload/';
$updir = DIR . 'upload/';
$file = isset($_POST['value']) ? $_POST['value'] : exit;
$name = isset($_POST['name']) ? $_POST['name'] : exit;

View file

@ -19,7 +19,7 @@ if (isset($url['action']) and in_array($url['action'], array('upload', 'news', '
$aData = explode(',', $file);
if (file_put_contents(ROOT . 'upload/avatars/' . $user['id'] . '.' . $type, base64_decode(str_replace(' ', '+', $aData[1]))))
if (file_put_contents(DIR . 'upload/avatars/' . $user['id'] . '.' . $type, base64_decode(str_replace(' ', '+', $aData[1]))))
exit($user['id'] . ':ok');
exit('Ошибка загрузки: убедитесь, что изображение не повреждено и имеет правильный формат.');