Merge pull request #73 from EngineGPDev/develop
Final changes of EngineGP v4.0.1.3
This commit is contained in:
commit
7ac4dc19fa
|
@ -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');
|
||||
|
|
27
cron.php
27
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 <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');
|
||||
|
|
25
index.php
25
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 <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');
|
||||
|
|
|
@ -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);
|
||||
|
||||
// Парсинг адреса
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
// Парсинг адреса
|
||||
|
|
|
@ -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'));
|
||||
?>
|
|
@ -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'));
|
||||
?>
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
// Подгрузка трейта
|
||||
|
|
|
@ -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 <u>' . $namefile . '.html</u> not found in: <u>' . $dir . '</u>');
|
||||
}
|
||||
|
||||
$this->template = file_get_contents($this->dir . '/' . $name . '.html');
|
||||
$this->select_template = $this->template;
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -101,12 +101,7 @@ class sys
|
|||
$html->set('home', $cfg['http']);
|
||||
|
||||
if (is_array($notice)) {
|
||||
global $device;
|
||||
|
||||
if ($device == '!mobile')
|
||||
$html->set('notice', '<div class="informer ' . $notice['color'] . ' topifon">' . $notice['text'] . '</div><div class="space"></div>');
|
||||
else
|
||||
$html->set('notice', '<div class="heading-style-1 container"><div class="smaller-text color-' . $notice['color'] . '-light">' . $notice['text'] . '</div><div class="heading-decoration bg-' . $notice['color'] . '-light" style="margin-top: 0px"></div></div>');
|
||||
$html->set('notice', '<div class="informer ' . $notice['color'] . ' topifon">' . $notice['text'] . '</div><div class="space"></div>');
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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('Ошибка загрузки: убедитесь, что изображение не повреждено и имеет правильный формат.');
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue