cron.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. if (!DEFINED('EGP'))
  3. exit(header('Refresh: 0; URL=http://' . $_SERVER['SERVER_NAME'] . '/404'));
  4. // Подключение filp/whoops
  5. $whoops = new \Whoops\Run;
  6. $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
  7. $whoops->register();
  8. // логи в файл
  9. $loggingInFile = new \Whoops\Handler\PlainTextHandler();
  10. $loggingInFile->loggerOnly(true);
  11. $loggingInFile->setLogger((new \Monolog\Logger('EngineGP', [(new \Monolog\Handler\StreamHandler(DIR . 'logs/cron.log'))->setFormatter((new \Monolog\Formatter\LineFormatter(null, null, true)))])));
  12. $whoops->pushHandler($loggingInFile);
  13. // Подгрузка трейта
  14. if (!file_exists(CRON . $task . '.php'))
  15. exit('Invalid cron method' . PHP_EOL);
  16. $device = '!mobile';
  17. $user = array('id' => 0, 'group' => 'admin');
  18. class cron
  19. {
  20. public static $seping = 5;
  21. public static $process = array(
  22. 'cs' => 'hlds_',
  23. 'cssold' => 'srcds_i686',
  24. 'css' => 'srcds_',
  25. 'csgo' => 'srcds_',
  26. 'samp' => 'samp',
  27. 'crmp' => 'samp',
  28. 'mta' => 'mta',
  29. 'mc' => 'java'
  30. );
  31. public static $quakestat = array(
  32. 'cs' => 'a2s',
  33. 'cssold' => 'a2s',
  34. 'css' => 'a2s',
  35. 'csgo' => 'a2s',
  36. 'mta' => 'eye'
  37. );
  38. public static $admins_file = array(
  39. 'cs' => 'cstrike/addons/amxmodx/configs/users.ini',
  40. 'cssold' => 'cstrike/addons/sourcemod/configs/admins_simple.ini',
  41. 'css' => 'cstrike/addons/sourcemod/configs/admins_simple.ini',
  42. 'csgo' => 'csgo/addons/sourcemod/configs/admins_simple.ini'
  43. );
  44. public static function thread($num, $type, $aData)
  45. {
  46. $threads = array();
  47. for ($n = 1; $n <= $num; $n += 1) {
  48. $data = '';
  49. $i = 0;
  50. foreach ($aData as $key => $val) {
  51. if ($i == cron::$seping)
  52. break;
  53. $data .= $val . ' ';
  54. unset($aData[$key]);
  55. $i += 1;
  56. }
  57. $aData = array_values($aData);
  58. $threads[] = $type . ' ' . substr($data, 0, -1);
  59. }
  60. return $threads;
  61. }
  62. }
  63. include(CRON . $task . '.php');
  64. new $task();
  65. ?>