diff --git a/acp/index.php b/acp/index.php index 33dbdc8..617deb8 100644 --- a/acp/index.php +++ b/acp/index.php @@ -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 install composer and run composer install'); } -require(ROOT . 'vendor/autoload.php'); +require(DIR . 'vendor/autoload.php'); // Настройки include(DATA . 'config.php'); diff --git a/cron.php b/cron.php index 1ac428d..31fc5eb 100644 --- a/cron.php +++ b/cron.php @@ -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 install composer and run composer install'); } -require(ROOT . 'vendor/autoload.php'); +require(DIR . 'vendor/autoload.php'); // Настройки include(DATA . 'config.php'); diff --git a/index.php b/index.php index 4e44839..b93e0cf 100644 --- a/index.php +++ b/index.php @@ -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 install composer and run composer install'); } -require(ROOT . 'vendor/autoload.php'); +require(DIR . 'vendor/autoload.php'); // Настройки include(DATA . 'config.php'); diff --git a/system/acp/distributor.php b/system/acp/distributor.php index 0e6c532..19d5309 100644 --- a/system/acp/distributor.php +++ b/system/acp/distributor.php @@ -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); // Парсинг адреса diff --git a/system/acp/sections/users/delete.php b/system/acp/sections/users/delete.php index 0805d3d..9048ba5 100644 --- a/system/acp/sections/users/delete.php +++ b/system/acp/sections/users/delete.php @@ -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'); } diff --git a/system/distributor.php b/system/distributor.php index 78ea99a..15c5e12 100644 --- a/system/distributor.php +++ b/system/distributor.php @@ -2,7 +2,6 @@ if (!DEFINED('EGP')) exit(header('Refresh: 0; URL=http://' . $_SERVER['SERVER_NAME'] . '/404')); -$device = '!mobile'; // Подключение filp/whoops $whoops = new \Whoops\Run; $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler); @@ -15,7 +14,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); // Парсинг адреса diff --git a/system/engine/404.php b/system/engine/404.php index e6d6abd..6fe78ad 100644 --- a/system/engine/404.php +++ b/system/engine/404.php @@ -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')); ?> \ No newline at end of file diff --git a/system/engine/replenish.php b/system/engine/replenish.php index 16b5327..baa798c 100644 --- a/system/engine/replenish.php +++ b/system/engine/replenish.php @@ -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')); ?> \ No newline at end of file diff --git a/system/library/acpsystem.php b/system/library/acpsystem.php index 9de6457..0c26e8f 100644 --- a/system/library/acpsystem.php +++ b/system/library/acpsystem.php @@ -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); } } diff --git a/system/library/control/control.php b/system/library/control/control.php index 72d0f57..736f127 100644 --- a/system/library/control/control.php +++ b/system/library/control/control.php @@ -215,7 +215,7 @@ class ctrl public static function route($server, $inc, $go) { - global $device, $start_point; + global $start_point; if (in_array($server['status'], array('install', 'reinstall', 'update', 'recovery'))) { if ($go) @@ -232,7 +232,7 @@ class ctrl public static function cpulist($unit, $core, $count = false) { - global $device, $start_point; + global $start_point; include(LIB . 'ssh.php'); diff --git a/system/library/cron.php b/system/library/cron.php index 53315c9..657b52f 100644 --- a/system/library/cron.php +++ b/system/library/cron.php @@ -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); // Подгрузка трейта diff --git a/system/library/html.php b/system/library/html.php index 81a2416..6364077 100644 --- a/system/library/html.php +++ b/system/library/html.php @@ -56,23 +56,11 @@ class html public function get($name, $path = '') { - global $device, $cfg; - - $path_root = $device == '!mobile' ? '' : 'megp/'; - - $path = $path_root . $path; + global $cfg; if ($path != '') $name = str_replace('//', '/', $path . '/' . $name); - if (!file_exists($this->dir . '/' . $name . '.html')) { - $route = explode('/', $name); - $namefile = end($route); - $dir = $this->dir . str_replace($namefile, '', $name); - - die('Error: html file ' . $namefile . '.html not found in: ' . $dir . ''); - } - $this->template = file_get_contents($this->dir . '/' . $name . '.html'); $this->select_template = $this->template; diff --git a/system/library/ssh.php b/system/library/ssh.php index f03c4de..48a4a4f 100644 --- a/system/library/ssh.php +++ b/system/library/ssh.php @@ -17,10 +17,12 @@ class ssh public function connect($address) { - list($host, $port) = explode(':', $address); - - if ($port == '') + if (strpos($address, ':') !== false) { + list($host, $port) = explode(':', $address); + } else { + $host = $address; $port = 22; + } ini_set('default_socket_timeout', '3'); diff --git a/system/library/system.php b/system/library/system.php index 4f57610..a486a28 100644 --- a/system/library/system.php +++ b/system/library/system.php @@ -101,12 +101,7 @@ class sys $html->set('home', $cfg['http']); if (is_array($notice)) { - global $device; - - if ($device == '!mobile') - $html->set('notice', '
' . $notice['text'] . '
'); - else - $html->set('notice', '
' . $notice['text'] . '
'); + $html->set('notice', '
' . $notice['text'] . '
'); } else $html->set('notice', ''); @@ -144,9 +139,9 @@ class sys public static function route($server, $inc, $go, $all = false) { - global $device, $start_point; + global $start_point; - $dir = $device == '!mobile' ? '' : 'megp/'; + $dir = ''; $use = true; if (in_array($inc, array('plugins', 'ftp', 'console', 'graph', 'copy', 'web'))) { @@ -225,12 +220,12 @@ class sys public static function outhtml($text, $time = 3, $url = false, $cache = false) { - global $device, $mcache, $html, $cfg; + global $mcache, $html, $cfg; if ($cache) $mcache->delete($cache); - $tpl = $device == '!mobile' ? '' : '/megp'; + $tpl = ''; $html->get('out'); @@ -451,9 +446,7 @@ class sys if ($go) sys::outjs(array('e' => sys::text('output', 'auth'))); - global $device; - - $link = $device == '!mobile' ? 'user/section/lk' : ''; + $link = 'user/section/lk'; exit(header('Refresh: 0; URL=' . $cfg['http'] . $link)); } @@ -469,9 +462,7 @@ class sys if ($go) sys::outjs(array('e' => sys::text('output', 'noauth'))); - global $device; - - $link = $device == '!mobile' ? 'user/section/auth' : 'auth'; + $link = 'user/section/auth'; exit(header('Refresh: 0; URL=' . $cfg['http'] . $link)); } @@ -1445,7 +1436,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); } } diff --git a/system/library/users.php b/system/library/users.php index 7778073..1de1099 100644 --- a/system/library/users.php +++ b/system/library/users.php @@ -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'; diff --git a/system/sections/chat/chats.php b/system/sections/chat/chats.php index 4f7ba53..945b658 100644 --- a/system/sections/chat/chats.php +++ b/system/sections/chat/chats.php @@ -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'); diff --git a/system/sections/help/action/delete.php b/system/sections/help/action/delete.php index a1989bd..c09f4df 100644 --- a/system/sections/help/action/delete.php +++ b/system/sections/help/action/delete.php @@ -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'); diff --git a/system/sections/help/action/remove.php b/system/sections/help/action/remove.php index 2ad1d17..bc2d64e 100644 --- a/system/sections/help/action/remove.php +++ b/system/sections/help/action/remove.php @@ -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'); diff --git a/system/sections/help/upload.php b/system/sections/help/upload.php index f4ffd16..ceccff2 100644 --- a/system/sections/help/upload.php +++ b/system/sections/help/upload.php @@ -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; diff --git a/system/sections/user/lk/settings.php b/system/sections/user/lk/settings.php index ca1b68e..87d9a4e 100644 --- a/system/sections/user/lk/settings.php +++ b/system/sections/user/lk/settings.php @@ -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('Ошибка загрузки: убедитесь, что изображение не повреждено и имеет правильный формат.'); diff --git a/system/sections/user/recovery.php b/system/sections/user/recovery.php index 7c877ec..db4549b 100644 --- a/system/sections/user/recovery.php +++ b/system/sections/user/recovery.php @@ -50,7 +50,7 @@ if ($go) { $user = $sql->get(); - $link = $device == '!mobile' ? 'user/section/recovery/confirm/' : 'recovery/confirm/'; + $link = 'user/section/recovery/confirm/'; // Проверка подачи запроса на восстановление $sql->query('SELECT `id`, `key` FROM `recovery` WHERE `user`="' . $user['id'] . '" LIMIT 1');