diff --git a/cron.php b/cron.php
index 557372d..df8dfd9 100644
--- a/cron.php
+++ b/cron.php
@@ -1,43 +1,48 @@
connect('127.0.0.1', 11211) OR exit('Ошибка: не удалось создать связь с Memcache.'.PHP_EOL);
+$mcache = new Memcache;
+$mcache->connect('127.0.0.1', 11211) OR exit('Ошибка: не удалось создать связь с Memcache.'.PHP_EOL);
- // Настройки
- include(DATA.'config.php');
+// Composer
+if (!file_exists(ROOT.'vendor/autoload.php')) {
+ die('Please install composer and run composer install
');
+}
+require(ROOT.'vendor/autoload.php');
- /*if($argv[1] != $cfg['cron_key'])
- exit('error key.'.PHP_EOL);
-*/
- $task = $argv[2];
+// Настройки
+include(DATA.'config.php');
+include(DATA.'engine.php');
+include(DATA.'mysql.php');
+include(DATA.'params.php');
- include(DATA.'engine.php');
- include(DATA.'mysql.php');
- include(DATA.'params.php');
+// Проверка ключа и указания параметра
+if($argv[1] != $cfg['cron_key'])
+ exit('Invalid cron key' . PHP_EOL);
+$task = $argv[2];
- // Библиотеки
- include(LIB.'sql.php');
- include(LIB.'html.php');
- include(LIB.'system.php');
- include(LIB.'cron.php');
+// Библиотеки
+include(LIB.'sql.php');
+include(LIB.'html.php');
+include(LIB.'system.php');
+include(LIB.'cron.php');
?>
\ No newline at end of file
diff --git a/system/library/cron.php b/system/library/cron.php
index 406c5d2..b00b5c5 100644
--- a/system/library/cron.php
+++ b/system/library/cron.php
@@ -1,77 +1,80 @@
pushHandler(new \Whoops\Handler\PrettyPageHandler);
+$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)))])));
+$whoops->pushHandler($loggingInFile);
- $device = '!mobile';
- $user = array('id' => 0, 'group' => 'admin');
+// Подгрузка трейта
+if(!file_exists(CRON.$task.'.php'))
+ exit('Invalid cron method' . PHP_EOL);
- class cron
+$device = '!mobile';
+$user = array('id' => 0, 'group' => 'admin');
+
+class cron
+{
+ public static $seping = 5;
+ public static $process = array(
+ 'cs' => 'hlds_',
+ 'cssold' => 'srcds_i686',
+ 'css' => 'srcds_',
+ 'csgo' => 'srcds_',
+ 'samp' => 'samp',
+ 'crmp' => 'samp',
+ 'mta' => 'mta',
+ 'mc' => 'java'
+ );
+
+ public static $quakestat = array(
+ 'cs' => 'a2s',
+ 'cssold' => 'a2s',
+ 'css' => 'a2s',
+ 'csgo' => 'a2s',
+ 'mta' => 'eye'
+ );
+
+ public static $admins_file = array(
+ 'cs' => 'cstrike/addons/amxmodx/configs/users.ini',
+ 'cssold' => 'cstrike/addons/sourcemod/configs/admins_simple.ini',
+ 'css' => 'cstrike/addons/sourcemod/configs/admins_simple.ini',
+ 'csgo' => 'csgo/addons/sourcemod/configs/admins_simple.ini'
+ );
+
+ public static function thread($num, $type, $aData)
{
- public static $seping = 5;
+ $threads = array();
- public static $process = array(
- 'cs' => 'hlds_',
- 'cssold' => 'srcds_i686',
- 'css' => 'srcds_',
- 'csgo' => 'srcds_',
- 'samp' => 'samp',
- 'crmp' => 'samp',
- 'mta' => 'mta',
- 'mc' => 'java'
- );
-
- public static $quakestat = array(
- 'cs' => 'a2s',
- 'cssold' => 'a2s',
- 'css' => 'a2s',
- 'csgo' => 'a2s',
- 'mta' => 'eye'
- );
-
- public static $admins_file = array(
- 'cs' => 'cstrike/addons/amxmodx/configs/users.ini',
- 'cssold' => 'cstrike/addons/sourcemod/configs/admins_simple.ini',
- 'css' => 'cstrike/addons/sourcemod/configs/admins_simple.ini',
- 'csgo' => 'csgo/addons/sourcemod/configs/admins_simple.ini'
- );
-
- public static function thread($num, $type, $aData)
+ for($n = 1; $n <= $num; $n+=1)
{
- $threads = array();
-
- for($n = 1; $n <= $num; $n+=1)
+ $data = '';
+ $i = 0;
+ foreach($aData as $key => $val)
{
- $data = '';
-
- $i = 0;
-
- foreach($aData as $key => $val)
- {
- if($i == cron::$seping)
- break;
-
+ if($i == cron::$seping)
+ break;
$data .= $val.' ';
-
unset($aData[$key]);
-
$i+=1;
- }
-
- $aData = array_values($aData);
-
- $threads[] = $type.' '.substr($data, 0, -1);
}
- return $threads;
+ $aData = array_values($aData);
+
+ $threads[] = $type.' '.substr($data, 0, -1);
}
+
+ return $threads;
}
+}
- include(CRON.$task.'.php');
+include(CRON.$task.'.php');
- new $task();
+new $task();
?>
\ No newline at end of file