diff --git a/system/acp/engine/index.php b/system/acp/engine/index.php
index b1f08b2..05a6dc0 100644
--- a/system/acp/engine/index.php
+++ b/system/acp/engine/index.php
@@ -35,8 +35,8 @@ if ($html->arr['main'] == '') {
$sql->query('SELECT `id`, `game`, `slots` FROM `servers`');
$servers = $sql->num();
- $aSlots = array('cs' => 0, 'cssold' => 0, 'css' => 0, 'csgo' => 0, 'samp' => 0, 'crmp' => 0, 'mta' => 0, 'mc' => 0);
- $aServers = array('cs' => 0, 'cssold' => 0, 'css' => 0, 'csgo' => 0, 'samp' => 0, 'crmp' => 0, 'mta' => 0, 'mc' => 0);
+ $aSlots = array('cs' => 0, 'cssold' => 0, 'css' => 0, 'csgo' => 0, 'cs2' => 0, 'samp' => 0, 'crmp' => 0, 'mta' => 0, 'mc' => 0);
+ $aServers = array('cs' => 0, 'cssold' => 0, 'css' => 0, 'csgo' => 0, 'cs2' => 0, 'samp' => 0, 'crmp' => 0, 'mta' => 0, 'mc' => 0);
while ($server = $sql->get()) {
$aSlots[$server['game']] += $server['slots'];
diff --git a/system/acp/engine/servers.php b/system/acp/engine/servers.php
index fd508e0..6f5e735 100644
--- a/system/acp/engine/servers.php
+++ b/system/acp/engine/servers.php
@@ -10,6 +10,7 @@ $aSection = array(
'cssold',
'css',
'csgo',
+ 'cs2',
'samp',
'crmp',
'mta',
@@ -48,6 +49,9 @@ $html->set('css', $sql->num());
$sql->query('SELECT `id` FROM `servers` WHERE `user`!="-1" AND `game`="csgo"');
$html->set('csgo', $sql->num());
+$sql->query('SELECT `id` FROM `servers` WHERE `user`!="-1" AND `game`="cs2"');
+$html->set('cs2', $sql->num());
+
$sql->query('SELECT `id` FROM `servers` WHERE `user`!="-1" AND `game`="samp"');
$html->set('samp', $sql->num());
diff --git a/system/acp/sections/servers/cs2.php b/system/acp/sections/servers/cs2.php
new file mode 100644
index 0000000..9d1d6cf
--- /dev/null
+++ b/system/acp/sections/servers/cs2.php
@@ -0,0 +1,75 @@
+ 'Работает',
+ 'off' => 'Выключен',
+ 'start' => 'Запускается',
+ 'restart' => 'Перезапускается',
+ 'change' => 'Смена карты',
+ 'install' => 'Устанавливается',
+ 'reinstall' => 'Переустанавливается',
+ 'update' => 'Обновляется',
+ 'recovery' => 'Восстанавливается',
+ 'overdue' => 'Просрочен',
+ 'blocked' => 'Заблокирован'
+ );
+
+ $select = 'WHERE `user`!="-1"';
+ $url_search = '';
+
+ if (isset($url['search']) and in_array($url['search'], array('unit', 'tarif'))) {
+ $select = 'WHERE `' . $url['search'] . '`="' . sys::int($url[$url['search']]) . '" AND `user`!="-1"';
+ $url_search = '/search/' . $url['search'] . '/' . $url['search'] . '/' . $url[$url['search']];
+ }
+
+ $sql->query('SELECT `id` FROM `servers` ' . $select . ' AND `game`="cs2"');
+
+ $aPage = sys::page($page, $sql->num(), 20);
+
+ sys::page_gen($aPage['ceil'], $page, $aPage['page'], 'acp/servers/section/cs2' . $url_search);
+
+ $servers = $sql->query('SELECT `id`, `unit`, `tarif`, `user`, `address`, `game`, `status`, `slots`, `name`, `time` FROM `servers` ' . $select . ' AND `game`="cs2" ORDER BY `id` ASC LIMIT ' . $aPage['num'] . ', 20');
+ while ($server = $sql->get($servers)) {
+ $sql->query('SELECT `name` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+ $unit = $sql->get();
+
+ $sql->query('SELECT `name` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ $list .= '
';
+ $list .= '' . $server['id'] . ' | ';
+ $list .= '' . $server['name'] . ' | ';
+ $list .= '#' . $server['unit'] . ' ' . $unit['name'] . ' | ';
+ $list .= '' . $server['slots'] . ' шт. | ';
+ $list .= '' . strtoupper($server['game']) . ' | ';
+ $list .= 'Перейти | ';
+ $list .= '
';
+
+ $list .= '';
+ $list .= 'USER_' . $server['user'] . ' | ';
+ $list .= '' . $server['address'] . ' | ';
+ $list .= '#' . $server['tarif'] . ' ' . $tarif['name'] . ' | ';
+ $list .= '' . $status[$server['status']] . ' | ';
+ $list .= '' . date('d.m.Y - H:i:s', $server['time']) . ' | ';
+ $list .= 'Удалить | ';
+ $list .= '
';
+ }
+
+ $html->get('index', 'sections/servers');
+
+ $html->set('list', $list);
+
+ $html->set('url_search', $url_search);
+
+ $html->set('pages', isset($html->arr['pages']) ? $html->arr['pages'] : '');
+
+ $html->pack('main');
+}
+?>
\ No newline at end of file
diff --git a/system/acp/sections/tarifs/add.php b/system/acp/sections/tarifs/add.php
index 80b498b..6870235 100644
--- a/system/acp/sections/tarifs/add.php
+++ b/system/acp/sections/tarifs/add.php
@@ -47,7 +47,7 @@ if ($go) {
if (!$sql->num())
sys::outjs(array('e' => 'Необходимо указать локацию'));
- if (!in_array($aData['game'], array('cs', 'cssold', 'css', 'csgo', 'samp', 'crmp', 'mta', 'mc')))
+ if (!in_array($aData['game'], array('cs', 'cssold', 'css', 'csgo', 'cs2', 'samp', 'crmp', 'mta', 'mc')))
sys::outjs(array('e' => 'Необходимо указать игру'));
$aSlots = explode('-', $aData['slots']);
@@ -328,6 +328,7 @@ if ($go) {
break;
case 'css':
+ case 'cs2':
case 'csgo':
if (count(explode(':', $aData['tickrate'])) != count(explode(':', $aData['price'])))
sys::outjs(array('e' => 'Неправильно указано поле "Цена"'));
diff --git a/system/acp/sections/tarifs/copy.php b/system/acp/sections/tarifs/copy.php
index 92ea1cc..00f2f9c 100644
--- a/system/acp/sections/tarifs/copy.php
+++ b/system/acp/sections/tarifs/copy.php
@@ -6,7 +6,7 @@ $sql->query('SELECT * FROM `tarifs` WHERE `id`="' . $id . '" LIMIT 1');
$tarif = $sql->get();
$games = ''
- . ''
+ . ''
. '';
$fix = $tarif['param_fix'] ? '' : '';
diff --git a/system/acp/sections/tarifs/tarif.php b/system/acp/sections/tarifs/tarif.php
index 62e4e65..1c67d56 100644
--- a/system/acp/sections/tarifs/tarif.php
+++ b/system/acp/sections/tarifs/tarif.php
@@ -50,7 +50,7 @@ if ($go) {
if (!$sql->num())
sys::outjs(array('e' => 'Необходимо указать локацию'));
- if (!in_array($aData['game'], array('cs', 'cssold', 'css', 'csgo', 'samp', 'crmp', 'mta', 'mc')))
+ if (!in_array($aData['game'], array('cs', 'cssold', 'css', 'csgo', 'cs2', 'samp', 'crmp', 'mta', 'mc')))
sys::outjs(array('e' => 'Необходимо указать игру'));
$aSlots = explode('-', $aData['slots']);
@@ -84,7 +84,7 @@ if ($go) {
if ($aData['install'] == '')
sys::outjs(array('e' => 'Необходимо указать путь для установки серверов'));
- if ($aData['update'] == '' and !in_array($aData['game'], array('css', 'csgo')))
+ if ($aData['update'] == '' and !in_array($aData['game'], array('css', 'csgo', 'cs2')))
sys::outjs(array('e' => 'Необходимо указать путь до обновления сборки'));
if (substr($aData['path'], -1) != '/' || substr($aData['install'], -1) != '/' || (substr($aData['update'], -1) != '/' and !in_array($aData['game'], array('css', 'csgo'))))
@@ -332,6 +332,7 @@ if ($go) {
case 'css':
case 'csgo':
+ case 'cs2':
if (count(explode(':', $aData['tickrate'])) != count(explode(':', $aData['price'])))
sys::outjs(array('e' => 'Неправильно указано поле "Цена"'));
@@ -390,7 +391,7 @@ if ($go) {
}
$games = ''
- . ''
+ . ''
. '';
$fix = $tarif['param_fix'] ? '' : '';
diff --git a/system/acp/sections/units/add.php b/system/acp/sections/units/add.php
index bf87811..e7fe7b0 100644
--- a/system/acp/sections/units/add.php
+++ b/system/acp/sections/units/add.php
@@ -16,6 +16,7 @@ if ($go) {
$aData['cssold'] = isset($_POST['cssold']) ? $_POST['cssold'] : 0;
$aData['css'] = isset($_POST['css']) ? $_POST['css'] : 0;
$aData['csgo'] = isset($_POST['csgo']) ? $_POST['csgo'] : 0;
+ $aData['cs2'] = isset($_POST['cs2']) ? $_POST['cs2'] : 0;
$aData['samp'] = isset($_POST['samp']) ? $_POST['samp'] : 0;
$aData['crmp'] = isset($_POST['crmp']) ? $_POST['crmp'] : 0;
$aData['mta'] = isset($_POST['mta']) ? $_POST['mta'] : 0;
@@ -26,7 +27,7 @@ if ($go) {
$aData['sort'] = isset($_POST['sort']) ? sys::int($_POST['sort']) : 0;
$aData['domain'] = isset($_POST['domain']) ? trim($_POST['domain']) : '';
- foreach (array('cs', 'cssold', 'css', 'csgo', 'samp', 'crmp', 'mta', 'mc') as $game)
+ foreach (array('cs', 'cssold', 'css', 'csgo', 'cs2', 'samp', 'crmp', 'mta', 'mc') as $game)
$aData[$game] = (string)$aData[$game] == 'on' ? '1' : '0';
if (in_array('', $aData))
@@ -49,6 +50,7 @@ if ($go) {
. '`cssold`="' . $aData['cssold'] . '",'
. '`css`="' . $aData['css'] . '",'
. '`csgo`="' . $aData['csgo'] . '",'
+ . '`cs2`="' . $aData['csgo'] . '",'
. '`samp`="' . $aData['samp'] . '",'
. '`crmp`="' . $aData['crmp'] . '",'
. '`mta`="' . $aData['mta'] . '",'
diff --git a/system/acp/sections/units/unit.php b/system/acp/sections/units/unit.php
index 133b2dc..4463dbc 100644
--- a/system/acp/sections/units/unit.php
+++ b/system/acp/sections/units/unit.php
@@ -19,6 +19,7 @@ if ($go) {
$aData['cssold'] = isset($_POST['cssold']) ? $_POST['cssold'] : $unit['cssold'];
$aData['css'] = isset($_POST['css']) ? $_POST['css'] : $unit['css'];
$aData['csgo'] = isset($_POST['csgo']) ? $_POST['csgo'] : $unit['csgo'];
+ $aData['cs2'] = isset($_POST['cs2']) ? $_POST['cs2'] : $unit['cs2'];
$aData['samp'] = isset($_POST['samp']) ? $_POST['samp'] : $unit['samp'];
$aData['crmp'] = isset($_POST['crmp']) ? $_POST['crmp'] : $unit['crmp'];
$aData['mta'] = isset($_POST['mta']) ? $_POST['mta'] : $unit['mta'];
@@ -29,7 +30,7 @@ if ($go) {
$aData['sort'] = isset($_POST['sort']) ? sys::int($_POST['sort']) : $unit['sort'];
$aData['domain'] = isset($_POST['domain']) ? trim($_POST['domain']) : $unit['domain'];
- foreach (array('cs', 'cssold', 'css', 'csgo', 'samp', 'crmp', 'mta', 'mc') as $game)
+ foreach (array('cs', 'cssold', 'css', 'csgo', 'cs2', 'samp', 'crmp', 'mta', 'mc') as $game)
$aData[$game] = (string)$aData[$game] == 'on' ? '1' : '0';
if (in_array('', $aData))
@@ -52,6 +53,7 @@ if ($go) {
. '`cssold`="' . $aData['cssold'] . '",'
. '`css`="' . $aData['css'] . '",'
. '`csgo`="' . $aData['csgo'] . '",'
+ . '`cs2`="' . $aData['cs2'] . '",'
. '`samp`="' . $aData['samp'] . '",'
. '`crmp`="' . $aData['crmp'] . '",'
. '`mta`="' . $aData['mta'] . '",'
@@ -70,7 +72,7 @@ $html->get('unit', 'sections/units');
foreach ($unit as $i => $val)
$html->set($i, $val);
-foreach (array('cs', 'cssold', 'css', 'csgo', 'samp', 'crmp', 'mta', 'mc') as $game) {
+foreach (array('cs', 'cssold', 'css', 'csgo', 'cs2', 'samp', 'crmp', 'mta', 'mc') as $game) {
if ($unit[$game])
$html->unit('game_' . $game, 1);
else
diff --git a/system/data/acpengine.php b/system/data/acpengine.php
index aeca6ce..3a9f6c9 100644
--- a/system/data/acpengine.php
+++ b/system/data/acpengine.php
@@ -43,8 +43,9 @@ $aValid = array(
$aGname = array(
'cs' => 'CS: 1.6',
'css' => 'CS: Source',
- 'csgo' => 'CS: Global Offensive',
'cssold' => 'CS: Source v34',
+ 'csgo' => 'CS: Global Offensive',
+ 'csgo' => 'CS: 2',
'mc' => 'MineCraft',
'mta' => 'GTA: MTA',
'samp' => 'GTA: SAMP'
diff --git a/system/data/config.php b/system/data/config.php
index 94a6290..962bfd5 100644
--- a/system/data/config.php
+++ b/system/data/config.php
@@ -127,6 +127,7 @@ $cfg = array(
'cssold' => '60',
'css' => '60',
'csgo' => '60',
+ 'cs2' => '60',
'samp' => '60',
'crmp' => '60',
'mta' => '60',
@@ -138,7 +139,8 @@ $cfg = array(
'cs' => '60',
'cssold' => '60',
'css' => '60',
- 'csgo' => '60'
+ 'csgo' => '60',
+ 'cs2' => '60'
),
// RAM на 1 слот
@@ -147,6 +149,7 @@ $cfg = array(
'cssold' => '32',
'css' => '32',
'csgo' => '32',
+ 'cs2' => '32',
'samp' => '32',
'crmp' => '32',
'mta' => '32'
@@ -158,6 +161,7 @@ $cfg = array(
'cssold' => '99',
'css' => '99',
'csgo' => '99',
+ 'cs2' => '99',
'samp' => '99',
'crmp' => '99',
'mta' => '99',
@@ -169,6 +173,7 @@ $cfg = array(
'cssold' => '99',
'css' => '99',
'csgo' => '99',
+ 'cs2' => '99',
'samp' => '99',
'crmp' => '99',
'mta' => '99',
@@ -183,6 +188,7 @@ $cfg = array(
'cssold' => false,
'css' => false,
'csgo' => false,
+ 'cs2' => false,
'samp' => false,
'crmp' => false,
'mta' => false,
@@ -195,6 +201,7 @@ $cfg = array(
'cssold' => '/cstrike',
'css' => '/cstrike',
'csgo' => '/csgo',
+ 'cs2' => '/csgo',
'samp' => '/',
'crmp' => '/',
'mta' => '/mods/deathmatch',
@@ -207,6 +214,7 @@ $cfg = array(
'cssold' => '/cstrike',
'css' => '/cstrike',
'csgo' => '/csgo',
+ 'cs2' => '/csgo',
'samp' => '/',
'crmp' => '/',
'mta' => '/mods/deathmatch',
@@ -240,6 +248,12 @@ $cfg = array(
'add' => true // Если 'down == true', то при уменьшении кол-во слот, добавлять дни к аренде
),
+ 'cs2' => array(
+ 'days' => false, // При смене кол-ва слот вычитывать/добавлять дни аренды (add == true), если false, то смена (увеличение) на платной основе
+ 'down' => true, // Если 'days == true', то дать возможность уменьшать слоты
+ 'add' => true // Если 'down == true', то при уменьшении кол-во слот, добавлять дни к аренде
+ ),
+
'samp' => array(
'days' => true, // При смене кол-ва слот вычитывать/добавлять дни аренды (add == true), если false, то смена (увеличение) на платной основе
'down' => true, // Если 'days == true', то дать возможность уменьшать слоты
@@ -271,6 +285,7 @@ $cfg = array(
'cssold' => false,
'css' => false,
'csgo' => false,
+ 'cs2' => false,
'samp' => false,
'crmp' => false,
'mta' => false,
@@ -283,6 +298,7 @@ $cfg = array(
'cssold' => true,
'css' => true,
'csgo' => true,
+ 'cs2' => true,
'samp' => true,
'crmp' => true,
'mta' => true,
@@ -299,7 +315,8 @@ $cfg = array(
'bots' => array(
'cssold' => false, // true == разрешены, false == запрещены
'css' => false,
- 'csgo' => false
+ 'csgo' => false,
+ 'cs2' => false
)
);
?>
\ No newline at end of file
diff --git a/system/data/engine.php b/system/data/engine.php
index 57314c2..c230cae 100644
--- a/system/data/engine.php
+++ b/system/data/engine.php
@@ -118,8 +118,9 @@ $tHelp = 0; // 0 - вариант: * минут назад (макс 10мин) |
$aGname = array(
'cs' => 'CS: 1.6',
'css' => 'CS: Source',
- 'csgo' => 'CS: Global Offensive',
'cssold' => 'CS: Source v34',
+ 'csgo' => 'CS: Global Offensive',
+ 'cs2' => 'CS: 2',
'mc' => 'MineCraft',
'mta' => 'GTA: MTA',
'samp' => 'GTA: SAMP',
@@ -144,6 +145,7 @@ $aSLdir = array(
'cssold' => 'cstrike/oldstart',
'css' => 'cstrike/oldstart',
'csgo' => 'csgo/oldstart',
+ 'cs2' => 'csgo/oldstart',
'mc' => 'oldstart',
'mta' => 'mods/deathmatch/oldstart',
'samp' => 'oldstart',
@@ -156,6 +158,7 @@ $aSLdirFtp = array(
'cssold' => 'oldstart',
'css' => 'oldstart',
'csgo' => 'csgo/oldstart',
+ 'cs2' => 'csgo/oldstart',
'mc' => 'oldstart',
'mta' => 'mods/deathmatch/oldstart',
'samp' => 'oldstart',
@@ -168,6 +171,7 @@ $aOwners = array(
'cssold' => array('start', 'stop', 'restart', 'change', 'reinstall', 'update', 'console', 'settings', 'plugins', 'maps', 'filetp', 'tarif', 'copy', 'graph'),
'css' => array('start', 'stop', 'restart', 'change', 'reinstall', 'update', 'console', 'settings', 'plugins', 'maps', 'filetp', 'tarif', 'copy', 'graph'),
'csgo' => array('start', 'stop', 'restart', 'change', 'reinstall', 'update', 'console', 'settings', 'plugins', 'maps', 'filetp', 'tarif', 'copy', 'graph'),
+ 'cs2' => array('start', 'stop', 'restart', 'change', 'reinstall', 'update', 'console', 'settings', 'plugins', 'maps', 'filetp', 'tarif', 'copy', 'graph'),
'mc' => array('start', 'stop', 'restart', 'reinstall', 'console', 'settings', 'plugins', 'filetp', 'tarif', 'copy', 'graph'),
'mta' => array('start', 'stop', 'restart', 'reinstall', 'console', 'settings', 'plugins', 'filetp', 'tarif', 'copy', 'graph'),
'samp' => array('start', 'stop', 'restart', 'reinstall', 'console', 'settings', 'plugins', 'filetp', 'tarif', 'copy', 'graph'),
diff --git a/system/data/filedits.php b/system/data/filedits.php
index 36aef97..2b1d286 100644
--- a/system/data/filedits.php
+++ b/system/data/filedits.php
@@ -91,6 +91,26 @@ $aEdits = array(
)
),
+ 'cs2' => array(
+ 'all' => array(
+ 'files' => array(
+ 'autoexec.cfg',
+ 'fastdl.cfg',
+ 'webapi_authkey.txt',
+ ),
+ 'path' => array(
+ 'autoexec.cfg' => 'csgo/cfg/',
+ 'fastdl.cfg' => 'csgo/cfg/',
+ 'webapi_authkey.txt' => 'csgo/',
+ ),
+ 'desc' => array(
+ 'autoexec.cfg' => 'Автоподключаемый конфигурационный файл.',
+ 'fastdl.cfg' => 'Быстрая закачка файлов с сервера.',
+ 'webapi_authkey.txt' => 'API ключ для установки карт из мастерской WorkShop.',
+ )
+ )
+ ),
+
'mta' => array(
'all' => array(
'files' => array(
diff --git a/system/data/params.php b/system/data/params.php
index d2c7ca1..2a0de76 100644
--- a/system/data/params.php
+++ b/system/data/params.php
@@ -40,6 +40,7 @@ class params
'cssold' => 27015,
'css' => 27015,
'csgo' => 27015,
+ 'cs2' => 27015,
'samp' => 7777,
'crmp' => 7777,
'mta' => 22003,
@@ -144,6 +145,29 @@ class params
)
),
+ 'cs2' => array(
+ 'CopyFull' => 'csgo',
+
+ 'aCopy' => array(
+ 'addons' => 'Директория с дополнениями (модули/плагины)',
+ 'cfg' => 'Файлы настроек (server.cfg/motd.txt/banned_user.cfg/banned_ip.cfg и т.д.)',
+ 'maps' => 'Директория с картами (название.bsp)',
+ 'models' => 'Директория с моделями (название.mdl)',
+ 'sound' => 'Директория со звуками (название.mp3/название.wav)'
+ ),
+
+ 'aCopyDir' => array(
+ 'addons' => 'csgo/addons',
+ 'maps' => 'csgo/maps',
+ 'models' => 'csgo/models',
+ 'sound' => 'csgo/sound'
+ ),
+
+ 'aCopyFile' => array(
+ 'cfg' => 'csgo/cfg/server.cfg csgo/motd.txt csgo/fastdl.cfg csgo/banned_user.cfg csgo/banned_ip.cfg csgo/mapcycle.txt csgo/maplist.txt'
+ )
+ ),
+
'samp' => array(
'CopyFull' => '*',
@@ -228,6 +252,7 @@ class params
'cssold' => 'cstrike',
'css' => 'cstrike',
'csgo' => 'csgo',
+ 'cs2' => 'cs2',
'samp' => '',
'crmp' => '',
'mta' => '',
@@ -240,6 +265,7 @@ class params
'cssold' => 'srcds_run srcds_i486 srcds_i686',
'css' => 'srcds_linux srcds_run',
'csgo' => 'srcds_linux srcds_run',
+ 'cs2' => 'srcds_linux srcds_run',
'samp' => 'samp03svr',
'crmp' => 'samp03svr-cr',
'mta' => 'mta-server',
diff --git a/system/data/scfg/cs2.php b/system/data/scfg/cs2.php
new file mode 100644
index 0000000..a7e3473
--- /dev/null
+++ b/system/data/scfg/cs2.php
@@ -0,0 +1,46 @@
+ 'Название игрового сервера.',
+ 'rcon_password' => 'Пароль для упраления сервером через RCON команды.',
+ 'sv_password' => 'Пароль для входа на сервер.',
+ 'sv_pure' => 'Режим проверки соответствия файлов моделей на клиенте.',
+ 'host_name_store' => 'Передача названия сервера в GOTV.',
+ 'host_info_show' => 'Передача информации о сервере.',
+ 'host_players_show' => 'Передача информации о игроках на сервере.',
+ 'sv_steamgroup' => 'Группа в steam сервера.',
+ 'sv_downloadurl' => 'Место, из которого клиенты могут скачать недостающие файлы.
Использовать, если не включен FastDL.',
+ 'mapgroup' => 'Набор карт на сервере.',
+ 'sv_hibernate_when_empty' => 'Через сколько секунд переводить сервер в спящий режим.
0 = Cпящий режим выключен.',
+ 'sv_setsteamaccount' => 'Токен для игрового сервера (без него на сервер не смогут зайти игроки).'
+);
+
+$aScfg_form = array(
+ 'hostname' => '',
+ 'rcon_password' => '',
+ 'sv_password' => '',
+ 'sv_pure' => '',
+ 'host_name_store' => '',
+ 'host_info_show' => '',
+ 'host_players_show' => '',
+ 'sv_steamgroup' => '',
+ 'sv_downloadurl' => '',
+ 'mapgroup' => '',
+ 'sv_hibernate_when_empty' => '',
+ 'sv_setsteamaccount' => ''
+);
+?>
\ No newline at end of file
diff --git a/system/data/web.php b/system/data/web.php
index 2350023..9ac9de4 100644
--- a/system/data/web.php
+++ b/system/data/web.php
@@ -94,6 +94,13 @@ $aWeb = array(
'hosting' => true
),
+ 'cs2' => array(
+ 'sourcebans' => true,
+
+ 'mysql' => true,
+ 'hosting' => true
+ ),
+
'samp' => array(
'mysql' => true,
'hosting' => true
@@ -146,6 +153,12 @@ $aWebOne = array(
'hosting' => array()
),
+ 'cs2' => array(
+ 'sourcebans' => array(),
+ 'mysql' => array(),
+ 'hosting' => array()
+ ),
+
'samp' => array(
'mysql' => array(),
'hosting' => array()
@@ -213,6 +226,13 @@ $aWebInstall = array(
'hosting' => 'user'
),
+ 'cs2' => array(
+ 'sourcebans' => 'unit',
+
+ 'mysql' => 'server',
+ 'hosting' => 'user'
+ ),
+
'samp' => array(
'mysql' => 'server',
'hosting' => 'user'
@@ -299,6 +319,12 @@ $aWebTypeInfo = array(
'other' => 'Прочее'
),
+ 'cs2' => array(
+ 'bans' => 'Системы управления банами',
+ 'stats' => 'Статистика',
+ 'other' => 'Прочее'
+ ),
+
'samp' => array(
'other' => 'Прочее'
),
diff --git a/system/engine/plugins.php b/system/engine/plugins.php
index 3da2d7a..ab065d0 100644
--- a/system/engine/plugins.php
+++ b/system/engine/plugins.php
@@ -6,7 +6,8 @@ $aGame = array(
'cs' => 'Counter-Strike: 1.6',
'cssold' => 'Counter-Strike: Source v34',
'css' => 'Counter-Strike: Source',
- 'csgo' => 'Counter-Strike: Global Offensive'
+ 'csgo' => 'Counter-Strike: Global Offensive',
+ 'cs2' => 'Counter-Strike: 2'
);
if (!isset($url['game']) || !array_key_exists($url['game'], $aGame))
diff --git a/system/engine/services.php b/system/engine/services.php
index 8d3be5f..ff7a788 100644
--- a/system/engine/services.php
+++ b/system/engine/services.php
@@ -3,7 +3,7 @@ if (!DEFINED('EGP'))
exit(header('Refresh: 0; URL=http://' . $_SERVER['SERVER_NAME'] . '/404'));
// Подключение раздела
-if (!in_array($section, array('cs', 'css', 'csgo', 'cssold', 'mc', 'mta', 'samp', 'crmp', 'hosting', 'privileges', 'control'))) {
+if (!in_array($section, array('cs', 'css', 'cssold', 'csgo', 'cs2', 'mc', 'mta', 'samp', 'crmp', 'hosting', 'privileges', 'control'))) {
$title = 'Список услуг';
$html->nav($title);
@@ -13,8 +13,9 @@ if (!in_array($section, array('cs', 'css', 'csgo', 'cssold', 'mc', 'mta', 'samp'
$aNav = array(
'cs' => 'Counter-Srike: 1.6',
'css' => 'Counter-Srike: Source',
- 'csgo' => 'Counter-Srike: Global Offensive',
'cssold' => 'Counter-Srike: Source v34',
+ 'csgo' => 'Counter-Srike: Global Offensive',
+ 'cs2' => 'Counter-Srike: 2',
'mc' => 'MineCraft',
'mta' => 'GTA: MTA',
'samp' => 'GTA: SA-MP',
diff --git a/system/library/api.php b/system/library/api.php
index 703c253..f949ece 100644
--- a/system/library/api.php
+++ b/system/library/api.php
@@ -74,7 +74,7 @@ class api
{
global $sql, $cfg;
- $aGames = array('cs', 'css', 'cssold', 'csgo', 'mc', 'mta');
+ $aGames = array('cs', 'css', 'cssold', 'csgo', 'cs2', 'mc', 'mta');
$sql->query('SELECT `game` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
if (!$sql->num())
diff --git a/system/library/cron.php b/system/library/cron.php
index 0fe14dc..62708de 100644
--- a/system/library/cron.php
+++ b/system/library/cron.php
@@ -19,6 +19,7 @@ class cron
'cssold' => 'srcds_i686',
'css' => 'srcds_',
'csgo' => 'srcds_',
+ 'cs2' => 'srcds_',
'samp' => 'samp',
'crmp' => 'samp',
'mta' => 'mta',
@@ -30,6 +31,7 @@ class cron
'cssold' => 'a2s',
'css' => 'a2s',
'csgo' => 'a2s',
+ 'cs2' => 'a2s',
'mta' => 'eye'
);
@@ -37,7 +39,8 @@ class cron
'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'
+ 'csgo' => 'csgo/addons/sourcemod/configs/admins_simple.ini',
+ 'cs2' => 'csgo/addons/sourcemod/configs/admins_simple.ini'
);
public static function thread($num, $type, $aData)
diff --git a/system/library/games/cs2/action.php b/system/library/games/cs2/action.php
new file mode 100644
index 0000000..d5c8e98
--- /dev/null
+++ b/system/library/games/cs2/action.php
@@ -0,0 +1,295 @@
+query('SELECT `uid`, `unit`, `tarif`, `game`, `address`, `slots_start`, `name`, `tickrate`, `map_start`, `vac`, `time_start`, `core_fix`, `pingboost` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+ $server = $sql->get();
+
+ $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ include(LIB . 'ssh.php');
+
+ $sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+ $unit = $sql->get();
+
+ // Проверка ssh соедниения пу с локацией
+ if (!$ssh->auth($unit['passwd'], $unit['address']))
+ return array('e' => sys::text('error', 'ssh'));
+
+ list($ip, $port) = explode(':', $server['address']);
+
+ // Убить процессы
+ $ssh->set('kill -9 `ps aux | grep s_' . $server['uid'] . ' | grep -v grep | awk ' . "'{print $2}'" . ' | xargs;'
+ . 'lsof -i@' . $server['address'] . ' | awk ' . "'{print $2}'" . ' | grep -v PID | xargs`; sudo -u server' . $server['uid'] . ' screen -wipe');
+
+ $taskset = '';
+
+ // Если включена система автораспределения и не установлен фиксированный поток
+ if ($cfg['cpu_route'] and !$server['core_fix']) {
+ $proc_stat = array();
+
+ $proc_stat[0] = $ssh->get('cat /proc/stat');
+ }
+
+ // Проверка наличия стартовой карты
+ $ssh->set('cd ' . $tarif['install'] . $server['uid'] . '/csgo/maps/ && du -ah | grep -e "\.bsp$" | awk \'{print $2}\'');
+
+ include_once(LIB . 'games/games.php');
+
+ if (games::map($server['map_start'], $ssh->get()))
+ return array('e' => sys::updtext(sys::text('servers', 'nomap'), array('map' => $server['map_start'] . '.bsp')));
+
+ // Если система автораспределения продолжить парсинг загрузки процессора
+ if (isset($proc_stat)) {
+ $proc_stat[1] = $ssh->get('cat /proc/stat');
+
+ // Ядро/поток, на котором будет запущен игровой сервер (поток выбран с рассчетом наименьшей загруженности в момент запуска игрового сервера)
+ $core = sys::cpu_idle($proc_stat, $server['unit'], false); // число от 1 до n (где n число ядер/потоков в процессоре (без нулевого)
+
+ if (!is_numeric($core))
+ return array('e' => sys::text('error', 'cpu'));
+
+ $taskset = 'taskset -c ' . $core;
+ }
+
+ if ($server['core_fix']) {
+ $core = $server['core_fix'] - 1;
+ $taskset = 'taskset -c ' . $core;
+ }
+
+ // Античит VAC
+ $vac = $server['vac'] == 0 ? '-insecure' : '-secure';
+
+ // Боты
+ $bots = $cfg['bots'][$server['game']] ? '' : '-nobots';
+
+ // TV
+ $tv = $server['tv'] ? '+tv_enable 1 +tv_maxclients 30 +tv_port ' . ($port + 10000) : '-nohltv';
+
+ $check = explode('/', $server['map_start']);
+
+ // Стартовая карта
+ $map = $check[0] == 'workshop' ? '+workshop_start_map ' . $check[1] : '+map \'' . $server['map_start'] . '\'';
+
+ // Игровой режим
+ $mods = array(
+ 1 => '+game_type 0 +game_mode 0',
+ 2 => '+game_type 0 +game_mode 1',
+ 3 => '+game_type 1 +game_mode 0',
+ 4 => '+game_type 1 +game_mode 1',
+ 5 => '+game_type 1 +game_mode 2'
+ );
+
+ $mod = !$server['pingboost'] ? $mods[2] : $mods[$server['pingboost']];
+
+ // Параметры запуска
+ $bash = './srcds_run -debug -game csgo -norestart -condebug console.log -usercon -tickrate ' . $server['tickrate'] . ' ' . $mod . ' +servercfgfile server.cfg ' . $map . ' -maxplayers_override ' . $server['slots_start'] . ' +ip ' . $ip . ' +net_public_adr ' . $ip . ' +port ' . $port . ' -sv_lan 0 ' . $vac . ' ' . $bots . ' ' . $tv;
+
+ // Временный файл
+ $temp = sys::temp($bash);
+
+ // Обновление файла start.sh
+ $ssh->setfile($temp, $tarif['install'] . $server['uid'] . '/start.sh', 0500);
+
+ // Строка запуска
+ $ssh->set('cd ' . $tarif['install'] . $server['uid'] . ';' // переход в директорию игрового сервера
+ . 'rm *.pid;' // Удаление *.pid файлов
+ . 'sudo -u server' . $server['uid'] . ' mkdir -p csgo/oldstart;' // Создание папки логов
+ . 'cat csgo/console.log >> csgo/oldstart/' . date('d.m.Y_H:i:s', $server['time_start']) . '.log; rm csgo/console.log; rm csgo/oldstart/01.01.1970_03:00:00.log;' // Перемещение лога предыдущего запуска
+ . 'chown server' . $server['uid'] . ':1000 start.sh;' // Обновление владельца файла start.sh
+ . 'sudo -u server' . $server['uid'] . ' screen -dmS s_' . $server['uid'] . ' ' . $taskset . ' sh -c "./start.sh"'); // Запуск игровго сервера
+
+ $core = !isset($core) ? 0 : $core + 1;
+
+ // Обновление информации в базе
+ $sql->query('UPDATE `servers` set `status`="' . $type . '", `online`="0", `players`="", `core_use`="' . $core . '", `time_start`="' . $start_point . '", `stop`="1" WHERE `id`="' . $id . '" LIMIT 1');
+
+ unlink($temp);
+
+ // Сброс кеша
+ actions::clmcache($id);
+
+ sys::reset_mcache('server_scan_mon_pl_' . $id, $id, array('name' => $server['name'], 'game' => $server['game'], 'status' => $type, 'online' => 0, 'players' => ''));
+ sys::reset_mcache('server_scan_mon_' . $id, $id, array('name' => $server['name'], 'game' => $server['game'], 'status' => $type, 'online' => 0));
+
+ return array('s' => 'ok');
+ }
+
+ public static function change($id, $map = false)
+ {
+ global $cfg, $sql, $html, $user, $mcache;
+
+ // Если в кеше есть карты
+ if ($mcache->get('server_maps_change_' . $id) != '' and !$map)
+ return array('maps' => $mcache->get('server_maps_change_' . $id));
+
+ include(LIB . 'ssh.php');
+
+ include(LIB . 'games/games.php');
+
+ $sql->query('SELECT `uid`, `unit`, `game`, `tarif`, `online`, `players`, `name` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+ $server = $sql->get();
+
+ $sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+ $unit = $sql->get();
+
+ $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ // Проверка ssh соедниения пу с локацией
+ if (!$ssh->auth($unit['passwd'], $unit['address']))
+ return array('e' => sys::text('error', 'ssh'));
+
+ // Массив карт игрового сервера (папка "maps")
+ $aMaps = explode("\n", $ssh->get('cd ' . $tarif['install'] . $server['uid'] . '/csgo/maps/ && du -ah | grep -e "\.bsp$" | awk \'{print $2}\''));
+
+ // Удаление пустого элемента
+ unset($aMaps[count($aMaps) - 1]);
+
+ // Удаление ".bsp"
+ $aMaps = str_ireplace(array('./', '.bsp'), '', $aMaps);
+
+ // Если выбрана карта
+ if ($map) {
+ $map = str_replace('|', '/', $map);
+
+ // Проверка наличия выбранной карты
+ if (games::map($map, $aMaps))
+ return array('e' => sys::updtext(sys::text('servers', 'change'), array('map' => $map . '.bsp')));
+
+ // Отправка команды changelevel
+ $ssh->set('sudo -u server' . $server['uid'] . ' screen -p 0 -S s_' . $server['uid'] . ' -X eval ' . "'stuff \"changelevel " . sys::cmd($map) . "\"\015'");
+
+ // Обновление информации в базе
+ $sql->query('UPDATE `servers` set `status`="change" WHERE `id`="' . $id . '" LIMIT 1');
+
+ // Сброс кеша
+ actions::clmcache($id);
+
+ sys::reset_mcache('server_scan_mon_pl_' . $id, $id, array('name' => $server['name'], 'game' => $server['game'], 'status' => 'change', 'online' => $server['online'], 'players' => base64_decode($server['players'])));
+ sys::reset_mcache('server_scan_mon_' . $id, $id, array('name' => $server['name'], 'game' => $server['game'], 'status' => 'change', 'online' => $server['online']));
+
+ return array('s' => 'ok');
+ }
+
+ // Сортировка списка карт
+ sort($aMaps);
+ reset($aMaps);
+
+ // Генерация списка карт для выбора
+ foreach ($aMaps as $map) {
+ $aName = explode('/', $map);
+ $name = end($aName);
+
+ $html->get('change_list', 'sections/servers/cs2');
+
+ $html->set('img', file_exists(DIR . '/maps/' . $server['game'] . '/' . $name . '.jpg') ? $cfg['http'] . 'maps/' . $server['game'] . '/' . $name . '.jpg' : $cfg['http'] . 'template/images/status/none.jpg');
+ $html->set('map', str_replace('/', '|', $map));
+ $html->set('name', $name);
+ $html->set('id', $id);
+
+ if (count($aName) > 1)
+ $html->unit('workshop', true);
+ else
+ $html->unit('workshop');
+
+ $html->pack('maps');
+ }
+
+ // Запись карт в кеш
+ $mcache->set('server_maps_change_' . $id, $html->arr['maps'], false, 60);
+
+ return array('maps' => $html->arr['maps']);
+ }
+
+ public static function update($id)
+ {
+ global $cfg, $sql, $user, $start_point;
+
+ include(LIB . 'ssh.php');
+
+ $sql->query('SELECT `uid`, `unit`, `tarif`, `game`, `name`, `ftp`, `update`, `core_fix` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+ $server = $sql->get();
+
+ // Проверка времени обновления
+ $update = $server['update'] + $cfg['update'][$server['game']] * 60;
+
+ if ($update > $start_point and $user['group'] != 'admin')
+ return array('e' => sys::updtext(sys::text('servers', 'update'), array('time' => sys::date('max', $update))));
+
+ $sql->query('SELECT `address`, `passwd`, `sql_login`, `sql_passwd`, `sql_port`, `sql_ftp` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+ $unit = $sql->get();
+
+ $sql->query('SELECT `install`, `plugins_install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ // Проверка ssh соедниения пу с локацией
+ if (!$ssh->auth($unit['passwd'], $unit['address']))
+ return array('e' => sys::text('error', 'ssh'));
+
+ $taskset = '';
+
+ // Если включена система автораспределения и не установлен фиксированный поток
+ if ($cfg['cpu_route'] and !$server['core_fix']) {
+ $proc_stat = array();
+
+ $proc_stat[0] = $ssh->get('cat /proc/stat');
+ }
+
+ // Директория игрового сервера
+ $install = $tarif['install'] . $server['uid'];
+
+ // Если система автораспределения продолжить парсинг загрузки процессора
+ if (isset($proc_stat)) {
+ $proc_stat[1] = $ssh->get('cat /proc/stat');
+
+ // Ядро/поток, на котором будет запущен игровой сервер (поток выбран с рассчетом наименьшей загруженности в момент запуска игрового сервера)
+ $core = sys::cpu_idle($proc_stat, $server['unit'], false); // число от 1 до n (где n число ядер/потоков в процессоре (без нулевого)
+
+ if (!is_numeric($core))
+ return array('e' => 'Не удается выполнить операцию, нет свободного потока.');
+
+ $taskset = 'taskset -c ' . $core;
+ }
+
+ if ($server['core_fix']) {
+ $core = $server['core_fix'] - 1;
+ $taskset = 'taskset -c ' . $core;
+ }
+
+ $ssh->set('cd ' . $cfg['steamcmd'] . ' && ' . $taskset . ' screen -dmS u_' . $server['uid'] . ' sh -c "'
+ . './steamcmd.sh +login anonymous +force_install_dir "' . $install . '" +app_update 740 +quit;'
+ . 'cd ' . $install . ';'
+ . 'chown -R server' . $server['uid'] . ':servers .;'
+ . 'find . -type d -exec chmod 700 {} \;;'
+ . 'find . -type f -exec chmod 600 {} \;;'
+ . 'chmod 500 ' . params::$aFileGame[$server['game']] . '"');
+
+ $core = !isset($core) ? 0 : $core + 1;
+
+ // Обновление информации в базе
+ $sql->query('UPDATE `servers` set `status`="update", `update`="' . $start_point . '", `core_use`="' . $core . '" WHERE `id`="' . $id . '" LIMIT 1');
+
+ // Логирование
+ $sql->query('INSERT INTO `logs_sys` set `user`="' . $user['id'] . '", `server`="' . $id . '", `text`="' . sys::text('syslogs', 'update') . '", `time`="' . $start_point . '"');
+
+ // Сброс кеша
+ actions::clmcache($id);
+
+ sys::reset_mcache('server_scan_mon_pl_' . $id, $id, array('name' => $server['name'], 'game' => $server['game'], 'status' => 'update', 'online' => 0, 'players' => ''));
+ sys::reset_mcache('server_scan_mon_' . $id, $id, array('name' => $server['name'], 'game' => $server['game'], 'status' => 'update', 'online' => 0));
+
+ return array('s' => 'ok');
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/system/library/games/cs2/rcon.php b/system/library/games/cs2/rcon.php
new file mode 100644
index 0000000..59f48c3
--- /dev/null
+++ b/system/library/games/cs2/rcon.php
@@ -0,0 +1,112 @@
+Connect($ip, $port, 3, SourceQuery::SOURCE);
+
+ $sq->SetRconPassword(rcon::rcon_passwd($server));
+
+ $out = $sq->Rcon($cmd);
+
+ $sq->Disconnect();
+
+ return $out;
+ }
+
+ public static function players($data)
+ {
+ $aPlayers = array();
+ $n = 1;
+
+ $lines = explode("\n", $data);
+
+ foreach ($lines as $line) {
+ if (strpos($line, '#') === FALSE)
+ continue;
+
+ $start = strpos($line, '"') + 1;
+ $end = strrpos($line, '"');
+
+ $userid = sys::int(substr($line, 0, $start));
+
+ $name = htmlspecialchars(substr($line, $start, $end - $start));
+
+ $line = trim(substr($line, $end + 1));
+
+ $aData = array_values(array_diff(explode(' ', $line), array('', ' ')));
+
+ $steamid = trim($aData[0]);
+ $ip = trim(sys::first(explode(':', $aData[5])));
+
+ if ((sys::valid($steamid, 'steamid') and sys::valid($steamid, 'steamid3')) || sys::valid($ip, 'ip'))
+ continue;
+
+ $aPlayers[$n]['userid'] = $userid;
+ $aPlayers[$n]['name'] = $name;
+ $aPlayers[$n]['steamid'] = $steamid;
+ $aPlayers[$n]['time'] = trim($aData[1]);
+ $aPlayers[$n]['ping'] = trim($aData[2]);
+ $aPlayers[$n]['ip'] = $ip;
+
+ $whois = rcon::country($ip);
+
+ $aPlayers[$n]['ico'] = $whois['ico'];
+ $aPlayers[$n]['country'] = $whois['name'];
+
+ $n += 1;
+ }
+
+ return $aPlayers;
+ }
+
+ public static function rcon_passwd($server)
+ {
+ global $cfg, $sql, $user;
+
+ include(LIB . 'ssh.php');
+
+ $sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+ $unit = $sql->get();
+
+ if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::outjs(array('e' => sys::text('error', 'ssh')));
+
+ $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ $ssh->set('cat ' . $tarif['install'] . '/' . $server['uid'] . '/csgo/cfg/server.cfg | grep rcon_password');
+ $get = explode(' ', str_replace('"', '', trim($ssh->get())));
+ $rcon = trim(end($get));
+
+ if (!isset($rcon{0}))
+ sys::outjs(array('r' => 'Необходимо установить rcon пароль (rcon_password).', 'url' => $cfg['http'] . 'servers/id/' . $server['id'] . '/section/settings/subsection/server'), $nmch);
+
+ return $rcon;
+ }
+
+ public static function country($ip)
+ {
+ global $SxGeo;
+
+ $cData = $SxGeo->getCityFull($ip);
+ $ico = sys::country($cData['country']['iso']);
+
+ return array('ico' => $ico, 'name' => empty($cData['country']['name_ru']) ? 'Не определена' : $cData['country']['name_ru']);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/system/library/games/cs2/scan.php b/system/library/games/cs2/scan.php
new file mode 100644
index 0000000..e74c779
--- /dev/null
+++ b/system/library/games/cs2/scan.php
@@ -0,0 +1,138 @@
+get($nmch)))
+ return $mcache->get($nmch);
+
+ $out = array();
+
+ $info = scan::info($sq, $id);
+
+ $sql->query('SELECT `game`, `name`, `map`, `online`, `players`, `status`, `time`, `overdue` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+ $server = $sql->get();
+
+ $out['time'] = 'Арендован до: ' . date('d.m.Y - H:i', $server['time']);
+
+ if ($server['status'] == 'overdue')
+ $out['time_end'] = 'Удаление через: ' . sys::date('min', $server['overdue'] + $cfg['server_delete'] * 86400);
+ else
+ $out['time_end'] = 'Осталось: ' . sys::date('min', $server['time']);
+
+ if (!$info['status']) {
+ $out['name'] = $server['name'];
+ $out['status'] = sys::status($server['status'], $server['game'], $server['map']);
+ $out['online'] = $server['online'];
+ $out['image'] = '';
+ $out['buttons'] = sys::buttons($id, $server['status']);
+
+ if ($players_get)
+ $out['players'] = base64_decode($server['players']);
+
+ $mcache->set($nmch, $out, false, $cfg['mcache_server_mon']);
+
+ return $out;
+ }
+
+ if ($players_get)
+ $players = scan::info($sq, $id, true);
+
+ $out['name'] = htmlspecialchars($info['name']);
+ $out['status'] = sys::status('working', $server['game'], $info['map']);
+ $out['online'] = $info['online'];
+ $out['image'] = '';
+ $out['buttons'] = sys::buttons($id, 'working');
+ $out['players'] = '';
+
+ if ($players_get) {
+ foreach ($players as $index => $player) {
+ $html->get($server['game'], 'sections/servers/players');
+
+ $html->set('i', $player['i']);
+ $html->set('name', $player['name']);
+ $html->set('score', $player['score']);
+ $html->set('time', $player['time']);
+
+ $html->pack('list');
+ }
+
+ $out['players'] = isset($html->arr['list']) ? $html->arr['list'] : '';
+ }
+
+ $sql->query('UPDATE `servers` set '
+ . '`name`="' . $out['name'] . '", '
+ . '`online`="' . $out['online'] . '", '
+ . '`map`="' . $info['map'] . '", '
+ . '`status`="working" WHERE `id`="' . $id . '" LIMIT 1');
+
+ if ($players_get)
+ $sql->query('UPDATE `servers` set `players`="' . base64_encode($out['players']) . '" WHERE `id`="' . $id . '" LIMIT 1');
+
+ $mcache->set($nmch, $out, false, $cfg['mcache_server_mon']);
+
+ return $out;
+ }
+
+ public static function info($sq, $id, $pl = false)
+ {
+ global $sql;
+
+ $sql->query('SELECT `address` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+ $server = $sql->get();
+
+ list($ip, $port) = explode(':', $server['address']);
+
+ $sq->Connect($ip, $port, 1, SourceQuery::SOURCE);
+
+ if ($pl) {
+ $players = $sq->GetPlayers();
+
+ $i = 1;
+ $data = array();
+
+ foreach ($players as $n => $player) {
+ $data[$i]['i'] = $i;
+ $data[$i]['name'] = $player['Name'] == '' ? 'Подключается' : $player['Name'];
+ $data[$i]['score'] = $player['Frags'];
+ $data[$i]['time'] = $player['TimeF'];
+
+ $i += 1;
+ }
+
+ return $data;
+ }
+
+ $data = $sq->GetInfo();
+
+ $map = explode('/', $data['Map']);
+
+ $server['name'] = $data['HostName'];
+ $server['map'] = end($map);
+ $server['online'] = $data['Players'];
+ $server['status'] = strlen($server['map']) > 3 ? true : false;
+
+ return $server;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/system/library/games/cs2/service.php b/system/library/games/cs2/service.php
new file mode 100644
index 0000000..090f736
--- /dev/null
+++ b/system/library/games/cs2/service.php
@@ -0,0 +1,354 @@
+query('SELECT `address`, `test` FROM `units` WHERE `id`="' . $aData['unit'] . '" AND `cs2`="1" AND `show`="1" LIMIT 1');
+ if (!$sql->num())
+ sys::outjs(array('e' => 'Локация не найдена.'));
+
+ $unit = $sql->get();
+
+ // Проверка тарифа
+ $sql->query('SELECT `id` FROM `tarifs` WHERE `id`="' . $aData['tarif'] . '" AND `unit`="' . $aData['unit'] . '" AND `show`="1" LIMIT 1');
+ if (!$sql->num())
+ sys::outjs(array('e' => 'Тариф не найден.'));
+
+ $sql->query('SELECT '
+ . '`slots_min`,'
+ . '`slots_max`,'
+ . '`port_min`,'
+ . '`port_max`,'
+ . '`hostname`,'
+ . '`packs`,'
+ . '`tickrate`,'
+ . '`time`,'
+ . '`test`,'
+ . '`tests`,'
+ . '`discount`,'
+ . '`map`,'
+ . '`ftp`,'
+ . '`plugins`,'
+ . '`console`,'
+ . '`stats`,'
+ . '`copy`,'
+ . '`web`,'
+ . '`plugins_install`,'
+ . '`hdd`,'
+ . '`autostop`,'
+ . '`core_fix`,'
+ . '`ip`,'
+ . '`price`'
+ . ' FROM `tarifs` WHERE `id`="' . $aData['tarif'] . '" LIMIT 1');
+
+ $tarif = $sql->get();
+
+ // Проверка сборки
+ if (!array_key_exists($aData['pack'], sys::b64djs($tarif['packs'], true)))
+ sys::outjs(array('e' => 'Сборка не найдена.'));
+
+ // Проверка TickRate
+ if (!in_array($aData['tickrate'], explode(':', $tarif['tickrate'])))
+ sys::outjs(array('e' => 'Переданные данные tickrate неверны.'));
+
+ $test = 0;
+
+ // Проверка периода на тест
+ if ($aData['test']) {
+ if (!$tarif['test'] || !$unit['test'])
+ sys::outjs(array('e' => 'Тестовый период недоступен.'));
+
+
+ // Проверка на повторный запрос
+ $sql->query('SELECT `id`, `game` FROM `tests` WHERE `user`="' . $user['id'] . '" LIMIT 1');
+ if ($sql->num()) {
+ $test_info = $sql->get();
+
+ if (!$cfg['tests']['game'] || $test_info['game'] == 'cs2')
+ sys::outjs(array('e' => 'Тестовый период предоставляется один раз.'));
+
+ $sql->query('SELECT `id` FROM `servers` WHERE `user`="' . $user['id'] . '" AND `test`="1" LIMIT 1');
+ if ($sql->num() and !$cfg['tests']['sametime'])
+ sys::outjs(array('e' => 'Чтобы получить тестовый период другой игры, дождитесь окончания текущего.'));
+ }
+
+ // Проверка наличия мест на локации
+ $sql->query('SELECT `id` FROM `servers` WHERE `unit`="' . $aData['unit'] . '" AND `test`="1" AND `time`>"' . $start_point . '" LIMIT ' . $unit['test']);
+ if ($sql->num() == $unit['test'])
+ sys::outjs(array('e' => 'Свободного места для тестового периода нет.'));
+
+ // Проверка наличия мест для выбранного тарифа
+ $sql->query('SELECT `id` FROM `servers` WHERE `tarif`="' . $aData['tarif'] . '" AND `test`="1" AND `time`>"' . $start_point . '" LIMIT ' . $tarif['tests']);
+ if ($sql->num() == $tarif['tests'])
+ sys::outjs(array('e' => 'Свободного места для тестового периода выбранного тарифа нет.'));
+
+ $test = 1;
+ } else
+ // Проверка периода
+ if (!$cfg['settlement_period'] and !in_array($aData['time'], explode(':', $tarif['time'])))
+ sys::outjs(array('e' => 'Переданные данные периода неверны.'));
+
+ // Проверка слот
+ if ($aData['slots'] < $tarif['slots_min'] || $aData['slots'] > $tarif['slots_max'])
+ sys::outjs(array('e' => 'Переданные данные слот неверны.'));
+
+ // Определение цены
+ $aPrice = explode(':', $tarif['price']);
+ $price = $aPrice[array_search($aData['tickrate'], explode(':', $tarif['tickrate']))];
+
+ // Определение суммы
+ if ($cfg['settlement_period']) {
+ // Цена аренды за расчетный период
+ $sum = games::define_sum($tarif['discount'], $price, $aData['slots'], $start_point);
+
+ $aData['time'] = games::define_period('buy', params::$aDayMonth);
+ } else
+ $sum = games::define_sum($tarif['discount'], $price, $aData['slots'], $aData['time']);
+
+ // Проверка промо-кода
+ $promo = games::define_promo(
+ $aData['promo'],
+ array(
+ 'tarif' => $aData['tarif'],
+ 'tickrate' => $aData['tickrate'],
+ 'slots' => $aData['slots'],
+ 'time' => $aData['time'],
+ 'user' => $user['id']
+ ),
+ $tarif['discount'],
+ $sum
+ );
+
+ $days = $aData['time']; // Кол-во дней аренды
+
+ // Использование промо-кода
+ if (is_array($promo)) {
+ if (array_key_exists('sum', $promo))
+ $sum = $promo['sum'];
+ else
+ $days += $promo['days']; // Кол-во дней аренды с учетом подарочных (промо-код)
+ }
+
+ // Проверка баланса
+ if ($user['balance'] < $sum)
+ sys::outjs(array('e' => 'У вас не хватает ' . (round($sum - $user['balance'], 2)) . ' ' . $cfg['currency']));
+
+ // Выделенный адрес игрового сервера
+ if (!empty($tarif['ip'])) {
+ $aIp = explode(':', $tarif['ip']);
+
+ $ip = false;
+ $port = params::$aDefPort['cs2'];
+
+ // Проверка наличия свободного адреса
+ foreach ($aIp as $adr) {
+ $adr = trim($adr);
+
+ $sql->query('SELECT `id` FROM `servers` WHERE `unit`="' . $aData['unit'] . '" AND `address` LIKE "' . $adr . ':%" LIMIT 1');
+ if (!$sql->num()) {
+ $ip = $adr;
+
+ break;
+ }
+ }
+ } else {
+ $ip = sys::first(explode(':', $unit['address']));
+ $port = false;
+
+ // Проверка наличия свободного порта
+ for ($tarif['port_min']; $tarif['port_min'] <= $tarif['port_max']; $tarif['port_min'] += 1) {
+ $sql->query('SELECT `id` FROM `servers` WHERE `unit`="' . $aData['unit'] . '" AND (`address`="' . $ip . ':' . $tarif['port_min'] . '" OR `port`="' . $tarif['port_min'] . '") LIMIT 1');
+ if (!$sql->num()) {
+ $port = $tarif['port_min'];
+
+ break;
+ }
+ }
+ }
+
+ if (!$ip || !$port) {
+ $sql->query('UPDATE `tarifs` set `show`="0" WHERE `id`="' . $aData['tarif'] . '" LIMIT 1');
+
+ sys::outjs(array('e' => 'К сожалению нет доступных мест, обратитесь в тех.поддержку.'));
+ }
+
+ if ($test)
+ $aData['time'] = games::time($start_point, $tarif['test']);
+ else
+ $aData['time'] = games::time($start_point, $days);
+
+ $fix_one = 0;
+ $core = 0;
+
+ if ($tarif['core_fix'] != '') {
+ $aCore = explode(',', $tarif['core_fix']);
+
+ foreach ($aCore as $cpu) {
+ $sql->query('SELECT `id` FROM `servers` WHERE `unit`="' . $aData['unit'] . '" AND `tarif`="' . $aData['tarif'] . '" AND `core_fix`="' . $cpu . '" AND `core_fix_one`="1" LIMIT 1');
+
+ if ($sql->num())
+ continue;
+
+ $fix_one = 1;
+ $core = $cpu;
+
+ break;
+ }
+
+ if (!$core) {
+ $sql->query('UPDATE `tarifs` set `show`="0" WHERE `id`="' . $aData['tarif'] . '" LIMIT 1');
+
+ sys::outjs(array('e' => 'К сожалению нет доступных мест, обратитесь в тех.поддержку.'));
+ }
+ }
+
+ $ram = $tarif['param_fix'] ? $aData['ram'] : $cfg['ram']['cs2'] * $aSDATA['slots'];
+
+ // Массив данных
+ $aSDATA = array(
+ 'unit' => $aData['unit'], // идентификатор локации
+ 'tarif' => $aData['tarif'], // идентификатор тарифа
+ 'ram' => $ram, // значение ram
+ 'param_fix' => $tarif['param_fix'], // фиксированные параметры
+ 'tickrate' => $aData['tickrate'], // значение tickrate
+ 'pack' => $aData['pack'], // Выбранная сборка для установки
+ 'time' => $aData['time'], // Время аренды
+ 'days' => $days, // Число дней
+ 'sum' => $sum, // Сумма списания
+ 'test' => $test, // тестовый период
+ 'address' => $ip . ':' . $port, // адрес игрового сервера
+ 'port' => $port, // порт игрового сервера
+ 'slots' => $aData['slots'], // Кол-во слот
+ 'map' => $tarif['map'], // Фиксированное значение слот
+ 'autostop' => $tarif['autostop'], // Выключение при 0 онлайне
+ 'ftp' => $tarif['ftp'], // Использование ftp
+ 'plugins' => $tarif['plugins'], // Использование плагинов
+ 'console' => $tarif['console'], // Использование консоли
+ 'stats' => $tarif['stats'], // Использование графиков (ведение статистики)
+ 'copy' => $tarif['copy'], // Использование резервных копий
+ 'web' => $tarif['web'], // Использование доп услуг
+ 'plugins_install' => $tarif['plugins_install'], // Список установленных плагинов
+ 'hdd' => $tarif['hdd'], // Дисковое пространство
+ 'core_fix' => $core, // Выделенный поток
+ 'core_fix_one' => $fix_one, // Выделенный поток
+ 'promo' => $promo // Использование промо-кода
+ );
+
+ return $aSDATA;
+ }
+
+ public static function install($aSDATA = array())
+ {
+ global $cfg, $sql, $user, $start_point;
+
+ include(LIB . 'ssh.php');
+
+ // Массив данных локации (адрес,пароль)
+ $sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $aSDATA['unit'] . '" LIMIT 1');
+ $unit = $sql->get();
+
+ // Проверка ssh соединения с локацией
+ if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::outjs(array('e' => sys::text('error', 'ssh')));
+
+ // Массив данных тарифа (путь сборки,путь установки)
+ $sql->query('SELECT `path`, `install`, `hostname` FROM `tarifs` WHERE `id`="' . $aSDATA['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ // Получение идентификаторов игрового сервера
+ $sql->query('INSERT INTO `servers` set uid="1"');
+ $id = $sql->id();
+ $uid = $id + 1000;
+
+ // Директория сборки
+ $path = $tarif['path'] . $aSDATA['pack'];
+
+ // Директория игрового сервера
+ $install = $tarif['install'] . $uid;
+
+ $ssh->set('mkdir ' . $install . ';' // Создание директории
+ . 'useradd -s /bin/false -d ' . $install . ' -g servers -u ' . $uid . ' server' . $uid . ';' // Создание пользователя сервера на локации
+ . 'chown server' . $uid . ':1000 ' . $install . ';' // Изменение владельца и группы директории
+ . 'cd ' . $install . ' && sudo -u server' . $uid . ' screen -dmS i_' . $uid . ' sh -c "cp -r ' . $path . '/. .;' // Копирование файлов сборки для сервера
+ . 'find . -type d -exec chmod 700 {} \;;'
+ . 'find . -type f -exec chmod 600 {} \;;'
+ . 'chmod 500 ' . params::$aFileGame['cs2'] . '"');
+
+ // Запись данных нового сервера
+ $sql->query('UPDATE `servers` set
+ `uid`="' . $uid . '",
+ `unit`="' . $aSDATA['unit'] . '",
+ `tarif`="' . $aSDATA['tarif'] . '",
+ `user`="' . $user['id'] . '",
+ `address`="' . $aSDATA['address'] . '",
+ `port`="' . $aSDATA['port'] . '",
+ `game`="cs2",
+ `slots`="' . $aSDATA['slots'] . '",
+ `slots_start`="' . $aSDATA['slots'] . '",
+ `status`="install",
+ `name`="' . $tarif['hostname'] . '",
+ `pack`="' . $aSDATA['pack'] . '",
+ `plugins_use`="' . $aSDATA['plugins'] . '",
+ `ftp_use`="' . $aSDATA['ftp'] . '",
+ `console_use`="' . $aSDATA['console'] . '",
+ `stats_use`="' . $aSDATA['stats'] . '",
+ `copy_use`="' . $aSDATA['copy'] . '",
+ `web_use`="' . $aSDATA['web'] . '",
+ `tickrate`="' . $aSDATA['tickrate'] . '",
+ `map_start`="' . $aSDATA['map'] . '",
+ `vac`="1",
+ `hdd`="' . $aSDATA['hdd'] . '",
+ `time`="' . $aSDATA['time'] . '",
+ `date`="' . $start_point . '",
+ `test`="' . $aSDATA['test'] . '",
+ `ram`="' . $aSDATA['ram'] . '",
+ `core_fix`="' . $aSDATA['core_fix'] . '",
+ `core_fix_one`="' . $aSDATA['core_fix_one'] . '",
+ `autostop`="' . $aSDATA['autostop'] . '" WHERE `id`="' . $id . '" LIMIT 1');
+
+ // Запись установленных плагинов
+ if ($aSDATA['plugins']) {
+ // Массив идентификаторов плагинов
+ $aPlugins = sys::b64djs($aSDATA['plugins_install']);
+
+ if (isset($aPlugins[$aSDATA['pack']])) {
+ $plugins = explode(',', $aPlugins[$aSDATA['pack']]);
+
+ foreach ($plugins as $plugin)
+ if ($plugin)
+ $sql->query('INSERT INTO `plugins_install` set `server`="' . $id . '", `plugin`="' . $plugin . '", `time`="' . $start_point . '"');
+ }
+ }
+
+ // Списание средств с баланса пользователя
+ $sql->query('UPDATE `users` set `balance`="' . ($user['balance'] - $aSDATA['sum']) . '" WHERE `id`="' . $user['id'] . '" LIMIT 1');
+
+ // Запись получения тестового периода
+ if ($aSDATA['test']) {
+ $sql->query('INSERT INTO `tests` set `server`="' . $id . '", `unit`="' . $aSDATA['unit'] . '", `game`="cs2", `user`="' . $user['id'] . '", `time`="' . $start_point . '"');
+ $sql->query('INSERT INTO `logs` set `user`="' . $user['id'] . '", `text`="' . sys::updtext(sys::text('logs', 'buy_server_test'), array('id' => $id)) . '", `date`="' . $start_point . '", `type`="buy", `money`="0"');
+ } else {
+ // Реф. система
+ games::part($user['id'], $aSDATA['sum']);
+
+ // Запись логов
+ if (!is_array($aSDATA['promo']))
+ $sql->query('INSERT INTO `logs` set `user`="' . $user['id'] . '", `text`="' . sys::updtext(sys::text('logs', 'buy_server'), array('days' => games::parse_day($aSDATA['days'], true), 'money' => $aSDATA['sum'], 'id' => $id)) . '", `date`="' . $start_point . '", `type`="buy", `money`="' . $aSDATA['sum'] . '"');
+ else {
+ $sql->query('UPDATE `servers` set `benefit`="' . $aSDATA['time'] . '" WHERE `id`="' . $id . '" LIMIT 1');
+ $sql->query('INSERT INTO `promo_use` set `promo`="' . $aSDATA['promo']['id'] . '", `user`="' . $user['id'] . '", `time`="' . $start_point . '"');
+ $sql->query('INSERT INTO `logs` set `user`="' . $user['id'] . '", `text`="' . sys::updtext(sys::text('logs', 'buy_server_promo'), array('days' => games::parse_day($aSDATA['days'], true), 'money' => $aSDATA['sum'], 'promo' => $aSDATA['promo']['cod'], 'id' => $id)) . '", `date`="' . $start_point . '", `type`="buy", `money`="' . $aSDATA['sum'] . '"');
+ }
+ }
+
+ return $id;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/system/library/games/cs2/tarif.php b/system/library/games/cs2/tarif.php
new file mode 100644
index 0000000..d620d03
--- /dev/null
+++ b/system/library/games/cs2/tarif.php
@@ -0,0 +1,220 @@
+get('extend', 'sections/servers/games/tarif');
+
+ if (isset($html->arr['extend_address'])) {
+ $html->unit('extend_address', 1);
+ $html->set('extend_address', $html->arr['extend_address']);
+ } else
+ $html->unit('extend_address');
+
+ $html->set('id', $sid);
+ $html->set('time', sys::date('min', $server['time']));
+ $html->set('options', '' . $options);
+ $html->set('slots', $server['slots']);
+ $html->set('info', $server['tickrate'] . ' TickRate');
+ $html->set('tarif', $tarif_name);
+ $html->set('cur', $cfg['currency']);
+
+ $html->pack('main');
+
+ return NULL;
+ }
+
+ public static function extend_sp($server, $tarif, $sid)
+ {
+ global $cfg, $sql, $html, $start_point;
+
+ tarifs::extend_address($server['game'], $sid);
+
+ $aPrice = explode(':', $tarif['price']);
+ $aTICK = explode(':', $tarif['tickrate']);
+
+ $sum = $tarif['slots'] ? $aPrice[array_search($server['tickrate'], $aTICK)] : $aPrice[array_search($server['tickrate'], $aTICK)] * $server['slots'];
+
+ $html->get('extend_sp', 'sections/servers/games/tarif');
+
+ if (isset($html->arr['extend_address'])) {
+ $html->unit('extend_address', 1);
+ $html->set('extend_address', $html->arr['extend_address']);
+ } else
+ $html->unit('extend_address');
+
+ $html->set('id', $sid);
+ $html->set('time', sys::date('min', $server['time']));
+ $html->set('date', $server['time'] > $start_point ? 'Сервер продлен до: ' . date('d.m.Y', $server['time']) : 'Текущая дата: ' . date('d.m.Y', $start_point));
+ $html->set('options', '' . $options);
+ $html->set('slots', $server['slots']);
+ $html->set('info', $server['tickrate'] . ' TickRate');
+ $html->set('tarif', $tarif['name']);
+ $html->set('sum', $sum);
+ $html->set('cur', $cfg['currency']);
+
+ $html->pack('main');
+
+ return NULL;
+ }
+
+ public static function plan($server, $tarif_name, $sid)
+ {
+ global $cfg, $sql, $html;
+
+ $sql->query('SELECT `tickrate`, `price` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+
+ if (!$sql->num())
+ return NULL;
+
+ $tarif = $sql->get();
+
+ $options = '';
+
+ $aPrice = explode(':', $tarif['price']);
+ $aTick = explode(':', $tarif['tickrate']);
+
+ // Если есть выбор
+ if (count($aTick) > 1) {
+ // Удалить при наличии tickrate сервера из выбора
+ if (in_array($server['tickrate'], $aTick))
+ unset($aTick[array_search($server['tickrate'], $aTick)]);
+
+ foreach ($aTick as $index => $tickrate)
+ $options .= '';
+ } else
+ return NULL;
+
+ $html->get('plan', 'sections/servers/games/tarif');
+
+ $html->set('id', $sid);
+ $html->set('options', $options);
+ $html->set('info', $server['tickrate'] . ' TickRate');
+ $html->set('tarif', $tarif_name);
+
+ $html->pack('main');
+
+ return NULL;
+ }
+
+ public static function unit($server, $unit_name, $tarif_name, $sid)
+ {
+ global $cfg, $sql, $html;
+
+ if (!$cfg['change_unit'][$server['game']])
+ return NULL;
+
+ $tarifs = $sql->query('SELECT `unit`, `tickrate` FROM `tarifs` WHERE `game`="' . $server['game'] . '" AND `name`="' . $tarif_name . '" AND `id`!="' . $server['tarif'] . '" AND `show`="1" ORDER BY `unit`');
+ if (!$sql->num($tarifs))
+ return NULL;
+
+ $units = 0;
+
+ $options = '';
+
+ while ($tarif = $sql->get($tarifs)) {
+ if (!in_array($server['tickrate'], explode(':', $tarif['tickrate'])))
+ continue;
+
+ $sql->query('SELECT `id`, `name` FROM `units` WHERE `id`="' . $tarif['unit'] . '" AND `show`="1" LIMIT 1');
+ if (!$sql->num())
+ continue;
+
+ $unit = $sql->get();
+
+ $options .= '';
+
+ $units += 1;
+ }
+
+ if (!$units)
+ return NULL;
+
+ $html->get('unit', 'sections/servers/games/tarif');
+
+ $html->set('id', $sid);
+ $html->set('options', $options);
+ $html->set('slots', $server['slots']);
+ $html->set('info', $server['tickrate'] . ' TickRate');
+ $html->set('unit', $unit_name);
+ $html->set('tarif', $tarif_name);
+
+ $html->pack('main');
+
+ return NULL;
+ }
+
+ public static function unit_new($tarif, $unit, $server, $mcache)
+ {
+ global $ssh, $sql, $user, $start_point;
+
+ // Проверка ssh соединения с локацией
+ if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::outjs(array('e' => sys::text('error', 'ssh')));
+
+ // Директория сборки
+ $path = $tarif['path'] . $tarif['pack'];
+
+ // Директория игрового сервера
+ $install = $tarif['install'] . $server['uid'];
+
+ // Пользователь сервера
+ $uS = 'server' . $server['uid'];
+
+ $ssh->set('mkdir ' . $install . ';' // Создание директории
+ . 'useradd -d ' . $install . ' -g servers -u ' . $server['uid'] . ' ' . $uS . ';' // Создание пользователя сервера на локации
+ . 'chown ' . $uS . ':1000 ' . $install . ';' // Изменение владельца и группы директории
+ . 'cd ' . $install . ' && sudo -u ' . $uS . ' screen -dmS i_' . $server['uid'] . ' cp -r ' . $path . '/. .'); // Копирование файлов сборки для сервера
+
+ $address = explode(':', $server['address']);
+
+ $fix_one = $tarif['core_fix'] ? 1 : 0;
+
+ // Обновление данных нового сервера
+ $sql->query('UPDATE `servers` set
+ `unit`="' . $tarif['unit'] . '",
+ `tarif`="' . $tarif['id'] . '",
+ `address`="' . $server['address'] . '",
+ `port`="' . $address[1] . '",
+ `status`="install",
+ `name`="' . $tarif['hostname'] . '",
+ `pack`="' . $tarif['pack'] . '",
+ `map_start`="' . $tarif['map'] . '",
+ `vac`="1",
+ `hdd`="' . $tarif['hdd'] . '",
+ `time`="' . $tarif['time'] . '",
+ `autostop`="' . $tarif['autostop'] . '",
+ `core_fix`="' . $tarif['core_fix'] . '",
+ `core_fix_one`="' . $fix_one . '",
+ `reinstall`="' . $start_point . '" WHERE `id`="' . $server['id'] . '" LIMIT 1');
+
+ // Запись установленных плагинов
+ if ($tarif['plugins']) {
+ // Массив идентификаторов плагинов
+ $aPlugins = sys::b64js($tarif['plugins_install']);
+
+ if (isset($aPlugins[$tarif['pack']])) {
+ $plugins = explode(',', $aPlugins[$tarif['pack']]);
+
+ foreach ($plugins as $plugin)
+ if ($plugin)
+ $sql->query('INSERT INTO `plugins_install` set `server`="' . $server['id'] . '", `plugin`="' . $plugin . '", `time`="' . $start_point . '"');
+ }
+ }
+
+ return NULL;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/console.php b/system/sections/servers/cs2/console.php
new file mode 100644
index 0000000..6a2daed
--- /dev/null
+++ b/system/sections/servers/cs2/console.php
@@ -0,0 +1,63 @@
+query('SELECT `uid`, `unit`, `tarif`, `time_start` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+$server = array_merge($server, $sql->get());
+
+if ($go) {
+ $sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+ $unit = $sql->get();
+
+ $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ include(LIB . 'ssh.php');
+
+ $command = isset($_POST['command']) ? sys::cmd($_POST['command']) : '';
+
+ if ($server['status'] == 'off') {
+ if ($command)
+ sys::outjs(array('e' => sys::text('servers', 'off')));
+
+ sys::out(sys::text('servers', 'off'));
+ }
+
+ if (!$ssh->auth($unit['passwd'], $unit['address'])) {
+ if ($command)
+ sys::outjs(array('e' => sys::text('error', 'ssh')));
+
+ sys::out(sys::text('error', 'ssh'));
+ }
+
+ $dir = $tarif['install'] . $server['uid'] . '/csgo/';
+
+ $filecmd = $dir . 'console.log';
+
+ if ($command) {
+ if (strtolower($command) == 'clear')
+ $ssh->set('sudo -u server' . $server['uid'] . ' sh -c "echo \"Очистка консоли\n\" > ' . $filecmd . '"');
+ else
+ $ssh->set('sudo -u server' . $server['uid'] . ' screen -p 0 -S s_' . $server['uid'] . ' -X eval \'stuff "' . $command . '"\015\';'
+ . 'sudo -u server' . $server['uid'] . ' screen -p 0 -S s_' . $server['uid'] . ' -X eval \'stuff \015\'');
+
+ sys::outjs(array('s' => 'ok'));
+ }
+
+ $filecmd_copy = $dir . 'oldstart/' . date('d.m.Y_H:i:s', $server['time_start']) . '.log';
+
+ $weight = sys::int($ssh->get('du --block-size=1 ' . $filecmd . ' | awk \'{print $1}\''));
+
+ if ($weight > 524288)
+ $ssh->set('sudo -u server' . $server['uid'] . ' sh -c "mkdir -p ' . $dir . 'oldstart; cat ' . $filecmd . ' >> ' . $filecmd_copy . '; echo \"Выполнена очистка консоли, слишком большой объем данных\n\" > ' . $filecmd . '"');
+
+ sys::out(htmlspecialchars($ssh->get('cat ' . $filecmd), NULL, ''));
+}
+
+$html->nav($server['address'], $cfg['http'] . 'servers/id/' . $id);
+$html->nav('Консоль');
+
+$html->get('console', 'sections/servers/' . $server['game']);
+$html->set('id', $id);
+$html->pack('main');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/copy.php b/system/sections/servers/cs2/copy.php
new file mode 100644
index 0000000..928d192
--- /dev/null
+++ b/system/sections/servers/cs2/copy.php
@@ -0,0 +1,80 @@
+ 'Игровой сервер должен быть выключен'), $nmch);
+
+ $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ $sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+ $unit = $sql->get();
+
+ include(LIB . 'ssh.php');
+
+ if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::outjs(array('e' => sys::text('error', 'ssh')), $nmch);
+
+ include(SEC . 'servers/games/copy/' . $url['subsection'] . '.php');
+ }
+}
+
+$html->nav($server['address'], $cfg['http'] . 'servers/id/' . $id);
+$html->nav('Резервные копии');
+
+if ($mcache->get('server_copy_' . $id) != '')
+ $html->arr['main'] = $mcache->get('server_copy_' . $id);
+else {
+ // Построение списка создания копии
+ foreach (params::$section_copy[$server['game']]['aCopy'] as $name => $info) {
+ $html->get('list', 'sections/servers/games/copy');
+
+ $html->set('name', $name);
+ $html->set('info', $info);
+
+ $html->pack('list');
+ }
+
+ // Построение списка созданных копий
+ $sql->query('SELECT `id`, `server`, `info`, `date`, `status` FROM `copy` WHERE `user`="' . $server['user'] . '_' . $server['unit'] . '" AND `game`="' . $server['game'] . '" ORDER BY `id` ASC');
+ while ($copy = $sql->get()) {
+ $html->get('copy', 'sections/servers/games/copy');
+
+ $html->set('id', $copy['id']);
+ $html->set('info', $copy['info']);
+ $html->set('server', $copy['server']);
+ $html->set('date', sys::today($copy['date']));
+
+ if ($copy['status']) {
+ $html->unit('created', 1);
+ $html->unit('!created');
+ } else {
+ $html->unit('created');
+ $html->unit('!created', 1);
+ }
+
+ $html->pack('copy');
+ }
+
+ $html->get('copy', 'sections/servers/' . $server['game']);
+
+ $html->set('id', $id);
+
+ $html->set('list', isset($html->arr['list']) ? $html->arr['list'] : '');
+ $html->set('copy', isset($html->arr['copy']) ? $html->arr['copy'] : 'Резервные копии отсутствуют.');
+
+ $html->pack('main');
+
+ $mcache->set('server_copy_' . $id, $html->arr['main'], false, 4);
+}
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/graph.php b/system/sections/servers/cs2/graph.php
new file mode 100644
index 0000000..0240a95
--- /dev/null
+++ b/system/sections/servers/cs2/graph.php
@@ -0,0 +1,68 @@
+query('SELECT `key` FROM `graph` WHERE `server`="' . $id . '" LIMIT 1');
+ $graph = $sql->get();
+
+ $nmch = 'server_graph_full_' . $id;
+
+ $time = isset($url['time']) ? $url['time'] : 'day';
+
+ if (!in_array($time, array('day', 'week', 'month')))
+ $time = 'day';
+
+ // Выхлоп кеш графика
+ if ($mcache->get($nmch) and file_exists(TEMP . (md5($graph['key'] . 'full_' . $time)) . '.png')) {
+ header('Content-type: image/png');
+ exit(file_get_contents(TEMP . (md5($graph['key'] . 'full_' . $time)) . '.png'));
+ }
+
+ include(LIB . 'games/graph/pData.php');
+ include(LIB . 'games/graph/pDraw.php');
+ include(LIB . 'games/graph/pImage.php');
+
+ include(LIB . 'games/graph.php');
+
+ graph::full($id, $server['slots_start'], $graph['key'], $time);
+
+ $mcache->set($nmch, true, false, 300);
+
+ header('Content-type: image/png');
+ exit(file_get_contents(TEMP . (md5($graph['key'] . 'full_' . $time)) . '.png'));
+}
+
+$html->nav($server['address'], $cfg['http'] . 'servers/id/' . $id);
+$html->nav('Графики');
+
+if ($mcache->get('server_graph_' . $id) != '')
+ $html->arr['main'] = $mcache->get('server_graph_' . $id);
+else {
+ $sql->query('SELECT `key` FROM `graph` WHERE `server`="' . $id . '" LIMIT 1');
+
+ // Если отсутствует ключ, создать
+ if (!$sql->num()) {
+ // Генерация ключа
+ $key = md5($id . sys::key('graph'));
+
+ $sql->query('INSERT INTO `graph` set `server`="' . $id . '", `key`="' . $key . '", `time`="0"');
+ } else {
+ $graph = $sql->get();
+
+ $key = $graph['key'];
+ }
+
+ $html->get('graph', 'sections/servers/games');
+
+ $html->set('id', $id);
+
+ $html->set('key', $key);
+ $html->set('address', $server['address']);
+ $html->set('_img', '[img]');
+
+ $html->pack('main');
+
+ $mcache->set('server_graph_' . $id, $html->arr['main'], false, 4);
+}
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/index.php b/system/sections/servers/cs2/index.php
new file mode 100644
index 0000000..5a675ed
--- /dev/null
+++ b/system/sections/servers/cs2/index.php
@@ -0,0 +1,44 @@
+query('SELECT `unit`, `tarif`, `slots_start`, `online`, `players`, `name`, `pack`, `tickrate`, `map`, `time`, `date`, `overdue` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+$server = array_merge($server, $sql->get());
+
+$html->nav($server['address']);
+
+$sql->query('SELECT `name` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$unit = $sql->get();
+
+$sql->query('SELECT `name`, `packs` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+$btn = sys::buttons($id, $server['status']);
+
+$time_end = $server['status'] == 'overdue' ? 'Удаление через: ' . sys::date('min', $server['overdue'] + $cfg['server_delete'] * 86400) : 'Осталось: ' . sys::date('min', $server['time']);
+
+$html->get('index', 'sections/servers/' . $server['game']);
+
+$html->set('id', $id);
+$html->set('unit', $unit['name']);
+$html->set('tarif', $tarif['name'] . ' / ' . $server['tickrate'] . ' TickRate');
+
+$tarif['packs'] = sys::b64djs($tarif['packs']);
+
+$html->set('pack', $tarif['packs'][$server['pack']]);
+$html->set('address', $server['address']);
+$html->set('game', $aGname[$server['game']]);
+$html->set('slots', $server['slots_start']);
+$html->set('online', $server['online']);
+$html->set('players', base64_decode($server['players']));
+$html->set('name', $server['name']);
+$html->set('status', sys::status($server['status'], $server['game'], $server['map']));
+$html->set('img', sys::status($server['status'], $server['game'], $server['map'], 'img'));
+$html->set('time_end', $time_end);
+$html->set('time', sys::today($server['time']));
+$html->set('date', sys::today($server['date']));
+
+$html->set('btn', $btn);
+
+$html->pack('main');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/maps.php b/system/sections/servers/cs2/maps.php
new file mode 100644
index 0000000..8b5aa77
--- /dev/null
+++ b/system/sections/servers/cs2/maps.php
@@ -0,0 +1,94 @@
+query('SELECT `unit`, `tarif` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+$server = array_merge($server, $sql->get());
+
+$html->nav($server['address'], $cfg['http'] . 'servers/id/' . $id);
+
+// Подразделы
+$aSub = array('install', 'delete', 'list', 'listing', 'search');
+
+// Если выбран подраздел
+if (isset($url['subsection']) and in_array($url['subsection'], $aSub)) {
+ $html->nav('Карты', $cfg['http'] . 'servers/id/' . $id . '/section/maps');
+
+ $nmch = sys::rep_act('server_maps_go_' . $id, 10);
+
+ include(SEC . 'servers/' . $server['game'] . '/maps/' . $url['subsection'] . '.php');
+} else {
+ $html->nav('Карты');
+
+ // Построение списка установленных карт
+ $sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+ $unit = $sql->get();
+
+ if (!isset($ssh))
+ include(LIB . 'ssh.php');
+
+ if (!$ssh->auth($unit['passwd'], $unit['address'])) {
+ if ($go)
+ sys::outjs(array('e' => sys::text('error', 'ssh')), $nmch);
+
+ sys::back($cfg['http'] . 'servers/id/' . $id);
+ }
+
+ $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ $ssh->set('cd ' . $tarif['install'] . $server['uid'] . '/csgo/maps/ && du -ah | grep -e "\.bsp$" | awk \'{print $2}\'');
+
+ $maps = $ssh->get();
+
+ $aMaps = explode("\n", str_ireplace('.bsp', '', $maps));
+
+ // Сортировка карт
+ sort($aMaps);
+ reset($aMaps);
+
+ $mapsjs = '';
+ $i = 0;
+
+ foreach ($aMaps as $index => $map) {
+ if (!isset($map[3]))
+ continue;
+
+ $map = str_replace('./', '', $map);
+
+ $mapjs = str_replace('$', '-_-', $map);
+
+ $aName = explode('/', $map);
+ $name = end($aName);
+
+ $html->get('map_server', 'sections/servers/cs2/maps');
+ $html->set('img', sys::img($name, $server['game']));
+ $html->set('map', $mapjs);
+ $html->set('name', $name);
+
+ if (count($aName) > 1)
+ $html->unit('workshop', true, true);
+ else {
+ $i += 1;
+ $mapsjs .= $i . ' : "' . $mapjs . '",';
+
+ $html->unit('workshop', false, true);
+ }
+ $html->pack('maps');
+ }
+
+ // Если есть кеш
+ if ($mcache->get('server_maps_' . $id) != '')
+ $html->arr['main'] = $mcache->get('server_maps_' . $id);
+ else {
+ $html->get('maps', 'sections/servers/games');
+ $html->set('id', $id);
+ $html->set('types', isset($html->arr['types']) ? $html->arr['types'] : '');
+ $html->set('maps', isset($html->arr['maps']) ? $html->arr['maps'] : '');
+ $html->set('mapsjs', $mapsjs);
+ $html->pack('main');
+
+ $mcache->set('server_maps_' . $id, $html->arr['main'], false, 3);
+ }
+}
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/maps/delete.php b/system/sections/servers/cs2/maps/delete.php
new file mode 100644
index 0000000..be0613e
--- /dev/null
+++ b/system/sections/servers/cs2/maps/delete.php
@@ -0,0 +1,69 @@
+query('SELECT `unit`, `tarif`, `map_start` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+$server = array_merge($server, $sql->get());
+
+$sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$unit = $sql->get();
+
+if (!isset($ssh))
+ include(LIB . 'ssh.php');
+
+if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::outjs(array('e' => sys::text('error', 'ssh')), $nmch);
+
+$sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+$dir = $tarif['install'] . $server['uid'] . '/csgo/';
+
+// Генерация списка карт
+$ssh->set('cd ' . $dir . 'maps/ && ls | grep -iE "\.bsp$"');
+
+$maps = $ssh->get();
+
+$aMaps = explode("\n", str_ireplace('.bsp', '', $maps));
+
+// Массив переданных карт
+$in_aMaps = isset($_POST['maps']) ? $_POST['maps'] : array();
+
+// Обработка выборки
+foreach ($in_aMaps as $name => $sel)
+ if ($sel) {
+ $map = str_replace(array("\\", "'", "'", '-_-'), array('', '', '', '$'), $name);
+
+ // Проверка наличия карты
+ if (!in_array($map, $aMaps))
+ continue;
+
+ // Проверка: является ли карта стартовой
+ if ($server['map_start'] == $map)
+ continue;
+
+ $ssh->set('cd /path/maps/' . $server['game'] . '/' . sys::map($map) . ' && du -a | grep -iE "\.[a-z]{1,3}$" | awk \'{print $2}\'');
+
+ $aFiles = explode("\n", str_replace('./', '', $ssh->get()));
+
+ if (isset($aFiles[count($aFiles) - 1]) and $aFiles[count($aFiles) - 1] == '')
+ unset($aFiles[count($aFiles) - 1]);
+
+ $files = '';
+
+ foreach ($aFiles as $file)
+ $files .= $dir . $file . ' ';
+
+ $rm = '';
+ $aFlrm = explode(' ', $dir . 'maps/' . $map . '.* ' . trim($files));
+
+ foreach ($aFlrm as $flrm)
+ $rm .= sys::map($flrm) . ' ';
+
+ $ssh->set('sudo -u server' . $server['uid'] . ' screen -dmS md' . $start_point . $id . ' sh -c \'rm ' . trim($rm) . '\'');
+ }
+
+sys::outjs(array('s' => 'ok'), $nmch);
+?>
diff --git a/system/sections/servers/cs2/maps/install.php b/system/sections/servers/cs2/maps/install.php
new file mode 100644
index 0000000..e0c651f
--- /dev/null
+++ b/system/sections/servers/cs2/maps/install.php
@@ -0,0 +1,55 @@
+query('SELECT `unit`, `tarif`, `hdd` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+$server = array_merge($server, $sql->get());
+
+$sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$unit = $sql->get();
+
+if (!isset($ssh))
+ include(LIB . 'ssh.php');
+
+if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::outjs(array('e' => sys::text('error', 'ssh')), $nmch);
+
+$sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+$dir = $tarif['install'] . $server['uid'] . '/csgo/';
+
+// Проверить наличие свободного места
+$ssh->set('cd ' . $dir . ' && du -ms');
+$hdd = ceil(sys::int($ssh->get()) / ($server['hdd'] / 100));
+$hdd = $hdd > 100 ? 100 : $hdd;
+
+if ($hdd == 100)
+ sys::outjs(array('e' => 'Невозможно выполнить установку, нет свободного места'), $nmch);
+
+// Массив переданных карт
+$in_aMaps = isset($_POST['maps']) ? $_POST['maps'] : array();
+
+// Обработка выборки
+foreach ($in_aMaps as $mid => $sel)
+ if ($sel) {
+ $map = sys::int($mid);
+
+ // Проверка наличия карты
+ $sql->query('SELECT `id`, `name` FROM `maps` WHERE `id`="' . $map . '" AND `unit`="' . $server['unit'] . '" AND `game`="' . $server['game'] . '" LIMIT 1');
+ if (!$sql->num())
+ continue;
+
+ $map = $sql->get();
+
+ $cp = 'cp /path/maps/' . $server['game'] . '/' . sys::map($map['name']) . '.* ' . $dir . 'maps/;'
+ . 'cd /path/maps/' . $server['game'] . '/' . sys::map($map['name']) . '/ && cp -r * ' . $dir;
+
+ $ssh->set('sudo -u server' . $server['uid'] . ' screen -dmS mc' . $start_point . $id . ' sh -c \'' . $cp . '\'');
+ }
+
+sys::outjs(array('s' => 'ok'), $nmch);
+?>
diff --git a/system/sections/servers/cs2/maps/list.php b/system/sections/servers/cs2/maps/list.php
new file mode 100644
index 0000000..43d0628
--- /dev/null
+++ b/system/sections/servers/cs2/maps/list.php
@@ -0,0 +1,61 @@
+nav('Установка карт');
+
+// Категории для быстрой сортировки
+$html->get('types', 'sections/servers/' . $server['game'] . '/maps');
+
+$html->set('id', $id);
+
+$html->pack('types');
+
+$type = false;
+
+if (isset($url['type']) and in_array($url['type'], array('de', 'cs', 'aim', 'awp', 'bhop', 'csde', 'deathrun', 'jail')))
+ $type = '^' . $url['type'] . '\_';
+
+if ($type)
+ $sql->query('SELECT `id`, `name` FROM `maps` WHERE `unit`="' . $server['unit'] . '" AND `game`="' . $server['game'] . '" AND `name` REGEXP FROM_BASE64(\'' . base64_encode($type) . '\') ORDER BY `name` ASC LIMIT 72');
+else {
+ $sql->query('SELECT `id` FROM `maps` WHERE `unit`="' . $server['unit'] . '" AND `game`="' . $server['game'] . '"');
+
+ // Массив для построения страниц
+ $aPage = sys::page($page, $sql->num(), 30);
+
+ // Генерация массива ($html->arr['pages']) страниц
+ sys::page_gen($aPage['ceil'], $page, $aPage['page'], 'servers/id/' . $id . '/section/maps/subsection/list');
+
+ $sql->query('SELECT `id`, `name` FROM `maps` WHERE `unit`="' . $server['unit'] . '" AND `game`="' . $server['game'] . '" ORDER BY `name` ASC LIMIT ' . $aPage['num'] . ', 30');
+}
+
+$mapsjs = '';
+$i = 0;
+
+while ($map = $sql->get()) {
+ $i += 1;
+
+ $mapsjs .= $i . ' : "' . $map['id'] . '",';
+
+ $html->get('map_install', 'sections/servers/games/maps');
+
+ $html->set('id', $map['id']);
+ $html->set('img', sys::img($map['name'], $server['game']));
+ $html->set('name', $map['name']);
+
+ $html->pack('maps');
+}
+
+$html->get('install', 'sections/servers/games/maps');
+
+$html->set('id', $id);
+
+$html->set('types', isset($html->arr['types']) ? $html->arr['types'] : '');
+$html->set('maps', isset($html->arr['maps']) ? $html->arr['maps'] : 'К сожалению карты не найдены в базе');
+$html->set('amaps', $mapsjs);
+$html->set('pages', isset($html->arr['pages']) ? $html->arr['pages'] : '');
+$html->set('cdn', $cfg['cdn']);
+
+$html->pack('main');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/maps/listing.php b/system/sections/servers/cs2/maps/listing.php
new file mode 100644
index 0000000..7b5e124
--- /dev/null
+++ b/system/sections/servers/cs2/maps/listing.php
@@ -0,0 +1,90 @@
+nav('Списки карт');
+
+$sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$unit = $sql->get();
+
+if (!isset($ssh))
+ include(LIB . 'ssh.php');
+
+if (!$ssh->auth($unit['passwd'], $unit['address'])) {
+ if ($go)
+ sys::outjs(array('e' => sys::text('error', 'ssh')), $nmch);
+
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/maps');
+}
+
+$sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+// Директория сервера
+$dir = $tarif['install'] . $server['uid'] . '/csgo/';
+
+// Генерация списка
+if ($go and isset($url['gen'])) {
+ $ssh->set('cd ' . $dir . 'maps/ && du -ah | grep -e "\.bsp$" | awk \'{print $2}\'');
+
+ $maps = $ssh->get();
+
+ $aMaps = explode("\n", str_ireplace(array('./', '.bsp'), '', $maps));
+
+ sort($aMaps);
+ reset($aMaps);
+
+ $list = '';
+
+ foreach ($aMaps as $index => $map) {
+ $aMap = explode('/', $map);
+ $name = end($aMap);
+ if (strlen($name) < 4)
+ continue;
+
+ $list .= $map . "\n";
+ }
+
+ sys::outjs(array('s' => $list), $nmch);
+}
+
+$aFiles = array(
+ 'mapcycle' => 'mapcycle.txt',
+ 'maps' => 'maplist.txt'
+);
+
+// Сохранение
+if ($go and isset($url['file'])) {
+ if (!array_key_exists($url['file'], $aFiles))
+ exit;
+
+ $data = isset($_POST['data']) ? $_POST['data'] : '';
+
+ $temp = sys::temp($data);
+
+ // Отправление файла на сервер
+ $ssh->setfile($temp, $dir . $aFiles[$url['file']], 0644);
+
+ // Смена владельца/группы файла
+ $ssh->set('chown server' . $server['uid'] . ':servers ' . $dir . $aFiles[$url['file']]);
+
+ unlink($temp);
+
+ sys::outjs(array('s' => 'ok'), $nmch);
+}
+
+$ssh->set('sudo -u server' . $server['uid'] . ' sh -c "touch ' . $dir . $aFiles['mapcycle'] . '; cat ' . $dir . $aFiles['mapcycle'] . '"');
+$mapcycle = $ssh->get();
+
+$ssh->set('sudo -u server' . $server['uid'] . ' sh -c "touch ' . $dir . $aFiles['maps'] . '; cat ' . $dir . $aFiles['maps'] . '"');
+$maps = $ssh->get();
+
+$html->get('listing', 'sections/servers/' . $server['game'] . '/maps');
+
+$html->set('id', $id);
+
+$html->set('mapcycle', $mapcycle);
+$html->set('maps', $maps);
+
+$html->pack('main');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/maps/search.php b/system/sections/servers/cs2/maps/search.php
new file mode 100644
index 0000000..5ede4b5
--- /dev/null
+++ b/system/sections/servers/cs2/maps/search.php
@@ -0,0 +1,59 @@
+get($mkey);
+
+if (is_array($cache)) {
+ if ($go)
+ sys::outjs($cache, $nmch);
+
+ sys::outjs($cache);
+}
+
+if (!isset($text{2})) {
+ if ($go)
+ sys::outjs(array('e' => 'Для выполнения поиска, необходимо больше данных'), $nmch);
+
+ sys::outjs(array('e' => ''));
+}
+
+// Поиск по картам
+if ($text{0} == '^') {
+ $sql->query('SELECT `id`, `name` FROM `maps` WHERE `unit`="' . $server['unit'] . '" AND `game`="' . $server['game'] . '" AND `name` REGEXP FROM_BASE64(\'' . base64_encode(str_replace('_', '\_', $text) . '') . '\') ORDER BY `name` ASC LIMIT 12');
+ $text = substr($text, 1);
+} else
+ $sql->query('SELECT `id`, `name` FROM `maps` WHERE `unit`="' . $server['unit'] . '" AND `game`="' . $server['game'] . '" AND `name` LIKE FROM_BASE64(\'' . base64_encode('%' . str_replace('_', '\_', $text) . '%') . '\') ORDER BY `name` ASC LIMIT 12');
+
+if (!$sql->num()) {
+ if ($go)
+ sys::outjs(array('e' => 'По вашему запросу ничего не найдено'), $nmch);
+
+ sys::outjs(array('e' => 'По вашему запросу ничего не найдено'));
+}
+
+$i = 0;
+$mapsjs = '';
+
+while ($map = $sql->get()) {
+ $i += 1;
+
+ $mapsjs[$i] = 's' . $map['id'];
+
+ $html->get('map_search', 'sections/servers/games/maps');
+
+ $html->set('id', 's' . $map['id']);
+ $html->set('img', sys::img($map['name'], $server['game']));
+ $html->set('name', sys::find($map['name'], $text));
+
+ $html->pack('maps');
+}
+
+$mcache->set($mkey, array('maps' => $html->arr['maps'], 'mapsjs' => $mapsjs), false, 15);
+
+sys::outjs(array('maps' => $html->arr['maps'], 'mapsjs' => $mapsjs));
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/owners.php b/system/sections/servers/cs2/owners.php
new file mode 100644
index 0000000..9f931a3
--- /dev/null
+++ b/system/sections/servers/cs2/owners.php
@@ -0,0 +1,165 @@
+ 'Включение',
+ 'stop' => 'Выключение',
+ 'restart' => 'Перезагрузка',
+ 'change' => 'Смена карты',
+ 'reinstall' => 'Переустановка',
+ 'update' => 'Обновление',
+ 'console' => 'Раздел "Консоль"',
+ 'settings' => 'Раздел "Настройки"',
+ 'plugins' => 'Раздел "Плагины"',
+ 'maps' => 'Раздел "Карты"'
+);
+
+$aAccess = array('start', 'stop', 'restart', 'change', 'reinstall', 'update', 'console', 'settings', 'plugins', 'maps');
+
+// Проверка прав
+if (isset($url['rights']) and $url['rights'] > 0) {
+ $sql->query('SELECT `rights` FROM `owners` WHERE `id`="' . sys::int($url['rights']) . '" AND `server`="' . $id . '" LIMIT 1');
+
+ if (!$sql->num())
+ sys::outjs(array('e' => 'Совладелец не найден.'));
+
+ $owner = $sql->get();
+
+ $aRights = sys::b64djs($owner['rights']);
+
+ $rights = '';
+
+ foreach ($aAccess as $access)
+ if ($aRights[$access]) $rights .= $aAccessI[$access] . ', ';
+
+ sys::outjs(array('s' => substr($rights, 0, -2)));
+}
+
+// Удаление совладельца
+if (isset($url['delete']) and $url['delete'] > 0) {
+ $sql->query('SELECT `rights` FROM `owners` WHERE `id`="' . sys::int($url['delete']) . '" AND `server`="' . $id . '" LIMIT 1');
+
+ if ($sql->num())
+ $sql->query('DELETE FROM `owners` WHERE `id`="' . sys::int($url['delete']) . '" AND `server`="' . $id . '" LIMIT 1');
+
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/owners');
+}
+
+// Добавление совладельца
+if ($go) {
+ $nmch = sys::rep_act('server_owners_go_' . $id, 5);
+
+ $aData = (isset($_POST['owner']) and is_array($_POST['owner'])) ? $_POST['owner'] : array();
+
+ $aDate = isset($aData['\'time\'']) ? explode('.', $aData['\'time\'']) : explode('.', date('d.m.Y', $start_point));
+ $aTime = explode(':', date('H:i:s', $start_point));
+
+ if (!isset($aDate[1], $aDate[0], $aDate[2]) || !checkdate($aDate[1], $aDate[0], $aDate[2]))
+ sys::outjs(array('e' => 'Дата доступа указана неверно.'), $nmch);
+
+ $time = mktime($aTime[0], $aTime[1], $aTime[2], $aDate[1], $aDate[0], $aDate[2]) + 3600;
+
+ if ($time < $start_point)
+ sys::outjs(array('e' => 'Время доступа не может быть меньше 60 минут.'), $nmch);
+
+ // Проверка пользователя
+ if (!isset($aData['\'user\'']))
+ sys::outjs(array('e' => 'Необходимо указать пользователя.'), $nmch);
+
+ if (is_numeric($aData['\'user\'']))
+ $sql->query('SELECT `id` FROM `users` WHERE `id`="' . $aData['\'user\''] . '" LIMIT 1');
+ else {
+ if (sys::valid($aData['\'user\''], 'other', $aValid['login']))
+ sys::outjs(array('e' => sys::text('input', 'login_valid')), $nmch);
+
+ $sql->query('SELECT `id` FROM `users` WHERE `login`="' . $aData['\'user\''] . '" LIMIT 1');
+ }
+
+ if (!$sql->num())
+ sys::outjs(array('e' => 'Пользователь не найден в базе.'), $nmch);
+
+ $uowner = $sql->get();
+
+ $owner = $sql->query('SELECT `id` FROM `owners` WHERE `server`="' . $id . '" AND `user`="' . $uowner['id'] . '" LIMIT 1');
+
+ // Если не обновление доступа совладельца, проверить кол-во
+ if (!$sql->num($owner)) {
+ $sql->query('SELECT `id` FROM `owners` WHERE `server`="' . $id . '" LIMIT 5');
+
+ if ($sql->num() == 5)
+ sys::outjs(array('e' => 'Вы добавили максимально число совладельцев.'), $nmch);
+ }
+
+ $sql->query('SELECT `id` FROM `servers` WHERE `id`="' . $id . '" AND `user`="' . $uowner['id'] . '" LIMIT 1');
+ if ($sql->num())
+ sys::outjs(array('e' => 'Владельца сервера нельзя добавить в совладельцы.'), $nmch);
+
+ $aRights = array();
+
+ $check = 0;
+
+ foreach ($aAccess as $access) {
+ $aRights[$access] = isset($aData['\'' . $access . '\'']) ? 1 : 0;
+
+ $check += $aRights[$access];
+ }
+
+ if (!$check)
+ sys::outjs(array('e' => 'Необходимо включить минимум одно разрешение.'), $nmch);
+
+
+ if ($sql->num($owner))
+ $sql->query('UPDATE `owners` set `rights`="' . sys::b64js($aRights) . '", `time`="' . $time . '" WHERE `server`="' . $id . '" AND `user`="' . $uowner['id'] . '" LIMIT 1');
+ else
+ $sql->query('INSERT INTO `owners` set `server`="' . $id . '", `user`="' . $uowner['id'] . '", `rights`="' . sys::b64js($aRights) . '", `time`="' . $time . '"');
+
+ sys::outjs(array('s' => 'ok'), $nmch);
+}
+
+$html->nav($server['address'], $cfg['http'] . 'servers/id/' . $id);
+
+$html->nav('Друзья');
+
+$cache = $mcache->get('server_owners_' . $id);
+
+if ($cache != '')
+ $html->arr['main'] = $cache;
+else {
+ $owners = $sql->query('SELECT `id`, `user`, `rights`, `time` FROM `owners` WHERE `server`="' . $id . '" AND `time`>"' . $start_point . '" ORDER BY `id` ASC LIMIT 5');
+
+ if ($sql->num())
+ include(LIB . 'games/games.php');
+
+ while ($owner = $sql->get($owners)) {
+ $sql->query('SELECT `login` FROM `users` WHERE `id`="' . $owner['user'] . '" LIMIT 1');
+ if (!$sql->num())
+ continue;
+
+ $uowner = $sql->get();
+
+ $rights = games::owners(sys::b64djs($owner['rights']));
+
+ $html->get('owners_list', 'sections/servers/games');
+
+ $html->set('id', $id);
+ $html->set('oid', $owner['id']);
+ $html->set('user', $uowner['login']);
+ $html->set('rights', $rights);
+ $html->set('time', date('d.m.Y - H:i', $owner['time']));
+
+ $html->pack('owners');
+ }
+
+ $html->get('owners', 'sections/servers/' . $server['game']);
+
+ $html->set('id', $id);
+ $html->set('time', date('d.m.Y', $start_point));
+
+ $html->set('owners', isset($html->arr['owners']) ? $html->arr['owners'] : 'Для данного сервера совладельцы отсутсвуют.');
+
+ $html->pack('main');
+
+ $mcache->set('server_owners_' . $id, $html->arr['main'], false, 1);
+}
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/plugins.php b/system/sections/servers/cs2/plugins.php
new file mode 100644
index 0000000..ac3fa9a
--- /dev/null
+++ b/system/sections/servers/cs2/plugins.php
@@ -0,0 +1,149 @@
+query('SELECT `unit`, `tarif`, `pack` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+$server = array_merge($server, $sql->get());
+
+$html->nav($server['address'], $cfg['http'] . 'servers/id/' . $id);
+
+// Подразделы
+$aSub = array('install', 'delete', 'update', 'plugin', 'config', 'search');
+
+// Если выбран подраздел
+if (isset($url['subsection']) and in_array($url['subsection'], $aSub)) {
+ $html->nav('Плагины', $cfg['http'] . 'servers/id/' . $id . '/section/plugins');
+
+ $nmch = sys::rep_act('server_plugins_go_' . $id, 10);
+
+ include(SEC . 'servers/games/plugins/' . $url['subsection'] . '.php');
+} else {
+ $html->nav('Плагины');
+
+ // Если есть кеш
+ if ($mcache->get('server_plugins_' . $id) != '')
+ $html->arr['main'] = $mcache->get('server_plugins_' . $id);
+ else {
+ include(LIB . 'games/plugins.php');
+
+ // Категории
+ $cats = $sql->query('SELECT `id`, `name` FROM `plugins_category` WHERE `game`="' . $server['game'] . '" ORDER BY `sort` ASC');
+ while ($cat = $sql->get($cats)) {
+ // Плагины
+ $plugins = $sql->query('SELECT `id`, `name`, `desc`, `images`, `status`, `upd`, `packs`, `price` FROM `plugins` WHERE `cat`="' . $cat['id'] . '" ORDER BY `sort`, `id` ASC');
+ while ($plugin = $sql->get($plugins)) {
+ // Проверка, установлен ли плагин на сервер
+ $sql->query('SELECT `id` FROM `plugins_install` WHERE `server`="' . $id . '" AND `plugin`="' . $plugin['id'] . '" LIMIT 1');
+ if ($sql->num())
+ continue;
+
+ // Проверка наличия обновленной версии плагина
+ if ($plugin['upd']) {
+ $idp = $plugin['id'];
+
+ $sql->query('SELECT `name`, `desc`, `images`, `status`, `packs`, `price` FROM `plugins_update` WHERE `plugin`="' . $plugin['id'] . '" ORDER BY `id` DESC LIMIT 1');
+ if ($sql->num()) {
+ $plugin = $sql->get();
+
+ $plugin['id'] = $idp;
+ } else
+ $plugin['upd'] = 0;
+ }
+
+ // Проверка на доступность плагина к установленной на сервере сборке
+ $packs = strpos($plugin['packs'], ':') ? explode(':', $plugin['packs']) : array($plugin['packs']);
+ if (!in_array($server['pack'], $packs) and $plugin['packs'] != 'all')
+ continue;
+
+ $images = plugins::images($plugin['images'], $plugin['id']);
+
+ if ($plugin['price']) {
+ $sql->query('SELECT `id` FROM `plugins_buy` WHERE `plugin`="' . $plugin['id'] . '" AND `server`="' . $id . '" LIMIT 1');
+ $buy = $sql->num();
+ }
+
+ // Шаблон плагина
+ $html->get('plugin', 'sections/servers/games/plugins');
+
+ $html->set('id', $id);
+ $html->set('plugin', $plugin['id']);
+
+ plugins::status($plugin['status']);
+
+ $html->set('name', htmlspecialchars_decode($plugin['name']));
+ $html->set('desc', htmlspecialchars_decode($plugin['desc']));
+
+ if (!empty($images)) {
+ $html->unit('images', 1);
+ $html->set('images', $images);
+ } else
+ $html->unit('images');
+
+ if (!$buy and $plugin['price']) {
+ $html->unit('price', true, true);
+ $html->set('price', $plugin['price']);
+ } else
+ $html->unit('price', false, true);
+
+ $html->pack('plugins');
+ }
+
+ // Шаблон блока плагинов
+ $html->get('category', 'sections/servers/games/plugins');
+
+ $html->set('name', $cat['name']);
+ $html->set('plugins', isset($html->arr['plugins']) ? $html->arr['plugins'] : 'Доступных для установки плагинов нет.', 1);
+
+ $html->pack('addons');
+ }
+
+ unset($cats, $cat, $plugins, $plugin);
+
+ // Список установленных плагинов на сервер (отдельный блок)
+ $pl_ins = $sql->query('SELECT `plugin`, `upd`, `time` FROM `plugins_install` WHERE `server`="' . $id . '" ORDER BY `plugin`');
+ while ($plugin = $sql->get($pl_ins)) {
+ $sql->query('SELECT `id` FROM `plugins` WHERE `id`="' . $plugin['plugin'] . '" LIMIT 1');
+ if (!$sql->num())
+ continue;
+
+ $isUpd = $plugin['upd'];
+
+ // Если установлен обновленный плагин
+ if ($isUpd)
+ $sql->query('SELECT `name`, `desc`, `status`, `cfg`, `upd` FROM `plugins_update` WHERE `id`="' . $isUpd . '" LIMIT 1');
+ else
+ $sql->query('SELECT `name`, `desc`, `status`, `cfg`, `upd` FROM `plugins` WHERE `id`="' . $plugin['plugin'] . '" LIMIT 1');
+
+ $plugin = array_merge($plugin, $sql->get());
+
+ // Шаблон плагина
+ $html->get('plugin_install', 'sections/servers/games/plugins');
+
+ $html->set('id', $id);
+ $html->set('plugin', $plugin['plugin']);
+
+ plugins::status($plugin['status']);
+
+ if ($plugin['cfg']) $html->unit('config', 1); else $html->unit('config');
+
+ if ($plugin['upd']) $html->unit('update', 1); else $html->unit('update');
+
+ $html->set('name', htmlspecialchars_decode($plugin['name']));
+ $html->set('time', sys::today($plugin['time']));
+ $html->set('desc', htmlspecialchars_decode($plugin['desc']));
+
+ $html->pack('install');
+ }
+
+ $html->get('plugins', 'sections/servers/games');
+
+ $html->set('id', $id);
+ $html->set('addons', isset($html->arr['addons']) ? $html->arr['addons'] : '');
+ $html->set('install', isset($html->arr['install']) ? $html->arr['install'] : 'Установленные плагины отсутствуют.');
+
+ $html->pack('main');
+
+ $mcache->set('server_plugins_' . $id, $html->arr['main'], false, 60);
+ }
+}
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/rcon.php b/system/sections/servers/cs2/rcon.php
new file mode 100644
index 0000000..0a6b8f3
--- /dev/null
+++ b/system/sections/servers/cs2/rcon.php
@@ -0,0 +1,51 @@
+ 'Необходимо выбрать игрока.'));
+
+ if ($url['action'] == 'kick')
+ rcon::cmd(array_merge($server, array('id' => $id)), 'kickid "' . $player . '" "EGP Panel"');
+ else
+ rcon::cmd(array_merge($server, array('id' => $id)), 'sm_slay "' . $player . '"');
+
+ sys::outjs(array('s' => 'ok'));
+ }
+
+ include(LIB . 'geo.php');
+ $SxGeo = new SxGeo(DATA . 'SxGeoCity.dat');
+
+ $aPlayers = rcon::players(rcon::cmd(array_merge($server, array('id' => $id))));
+
+ foreach ($aPlayers as $i => $aPlayer) {
+ $html->get('player', 'sections/servers/' . $server['game'] . '/rcon');
+
+ $html->set('i', $i);
+ $html->set('userid', $aPlayer['userid']);
+ $html->set('name', $aPlayer['name']);
+ $html->set('steamid', $aPlayer['steamid']);
+ $html->set('time', $aPlayer['time']);
+ $html->set('ping', $aPlayer['ping']);
+ $html->set('ip', $aPlayer['ip']);
+ $html->set('ico', $aPlayer['ico']);
+ $html->set('country', $aPlayer['country']);
+
+ $html->pack('players');
+ }
+
+ sys::outjs(array('s' => isset($html->arr['players']) ? $html->arr['players'] : ''));
+}
+
+$html->nav($server['address'], $cfg['http'] . 'servers/id/' . $id);
+$html->nav('Rcon управление игроками');
+
+$html->get('rcon', 'sections/servers/' . $server['game']);
+
+$html->set('id', $id);
+
+$html->pack('main');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/settings.php b/system/sections/servers/cs2/settings.php
new file mode 100644
index 0000000..776191c
--- /dev/null
+++ b/system/sections/servers/cs2/settings.php
@@ -0,0 +1,74 @@
+query('SELECT `uid`, `unit`, `tarif`, `pack`, `ddos` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+$server = array_merge($server, $sql->get());
+
+$html->nav($server['address'], $cfg['http'] . 'servers/id/' . $id);
+
+$aSub = array('start', 'server', 'admins', 'bans', 'firewall', 'crontab', 'startlogs', 'debug', 'logs', 'smlogs', 'pack', 'file', 'antiddos', 'api');
+
+// Если выбран подраздел
+if (isset($url['subsection']) and in_array($url['subsection'], $aSub)) {
+ $html->nav('Настройки', $cfg['http'] . 'servers/id/' . $id . '/section/settings');
+
+ if ($go)
+ $nmch = sys::rep_act('server_settings_go_' . $id, 10);
+
+ if (in_array($url['subsection'], $aRouteSub['settings']))
+ include(SEC . 'servers/games/settings/' . $url['subsection'] . '.php');
+ else
+ include(SEC . 'servers/' . $server['game'] . '/settings/' . $url['subsection'] . '.php');
+} else {
+ $html->nav('Настройки');
+
+ if ($mcache->get('server_settings_' . $id) != '')
+ $html->arr['main'] = $mcache->get('server_settings_' . $id);
+ else {
+ $sql->query('SELECT `name`, `packs` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ $aEditslist = 1;
+ include(DATA . 'filedits.php');
+
+ // Построение списка доступных сборок
+ $aPacks = sys::b64djs($tarif['packs']);
+
+ $packs = '';
+ unset($aPacks[$server['pack']]);
+
+ foreach ($aPacks as $pack => $desc)
+ $packs .= '';
+
+ $antiddos = ''
+ . ''
+ . '';
+
+ include(SEC . 'servers/' . $server['game'] . '/settings/start.php');
+
+ $html->get('settings', 'sections/servers/' . $server['game']);
+ $html->set('id', $id);
+ $html->set('packs', $packs);
+ $html->set('antiddos', str_replace($server['ddos'], $server['ddos'] . '" selected="select', $antiddos));
+ $html->set('start', $html->arr['start']);
+ if (isset($html->arr['edits'])) {
+ $html->set('edits', $html->arr['edits']);
+ $html->unit('edits', 1);
+ } else
+ $html->unit('edits');
+
+ $sql->query('SELECT `key` FROM `api` WHERE `server`="' . $id . '" LIMIT 1');
+ if ($sql->num()) {
+ $api = $sql->get();
+
+ $html->set('api', $api['key']);
+ $html->unit('api', 1, 1);
+ } else
+ $html->unit('api', 0, 1);
+ $html->pack('main');
+
+ $mcache->set('server_settings_' . $id, $html->arr['main'], false, 60);
+ }
+}
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/settings/admins.php b/system/sections/servers/cs2/settings/admins.php
new file mode 100644
index 0000000..6759274
--- /dev/null
+++ b/system/sections/servers/cs2/settings/admins.php
@@ -0,0 +1,110 @@
+nav('Управление администраторами');
+
+if ($go) {
+ $sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+ $unit = $sql->get();
+
+ $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ include(LIB . 'ssh.php');
+
+ if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::outjs(array('e' => sys::text('error', 'ssh')), $nmch);
+
+ $aData = array();
+
+ $aData['active'] = isset($_POST['active']) ? $_POST['active'] : '';
+ $aData['value'] = isset($_POST['value']) ? $_POST['value'] : '';
+ $aData['passwd'] = isset($_POST['passwd']) ? $_POST['passwd'] : '';
+ $aData['flags'] = isset($_POST['flags']) ? $_POST['flags'] : '';
+ $aData['immunity'] = isset($_POST['immunity']) ? sys::int($_POST['immunity']) : '';
+ $aData['time'] = isset($_POST['time']) ? $_POST['time'] : '';
+ $aData['info'] = isset($_POST['info']) ? $_POST['info'] : '';
+
+ // Удаление текущих записей
+ $sql->query('DELETE FROM `admins_' . $server['game'] . '` WHERE `server`="' . $id . '"');
+
+ $usini = '';
+
+ foreach ($aData['value'] as $index => $val) {
+ if ($val != '') {
+ $aDate = isset($aData['time'][$index]) ? explode('.', $aData['time'][$index]) : explode('.', date('d.m.Y', $start_point));
+
+ if (!isset($aDate[1], $aDate[0], $aDate[2]) || !checkdate($aDate[1], $aDate[0], $aDate[2]))
+ $aDate = explode('.', date('d.m.Y', $start_point));
+
+ $time = mktime(0, 0, 0, $aDate[1], $aDate[0], $aDate[2]);
+
+ $aData['active'][$index] = isset($aData['active'][$index]) ? 1 : 0;
+ $aData['passwd'][$index] = isset($aData['passwd'][$index]) ? $aData['passwd'][$index] : '';
+ $aData['flags'][$index] = isset($aData['flags'][$index]) ? $aData['flags'][$index] : '';
+ $aData['info'][$index] = isset($aData['info'][$index]) ? $aData['info'][$index] : '';
+
+ $text = '"' . $val . '" "' . $aData['immunity'][$index] . ':' . $aData['flags'][$index] . '" "' . $aData['passwd'][$index] . '"';
+
+ $sql->query('INSERT INTO `admins_' . $server['game'] . '` set'
+ . '`server`="' . $id . '",'
+ . '`value`="' . htmlspecialchars($val) . '",'
+ . '`active`="' . $aData['active'][$index] . '",'
+ . '`passwd`="' . htmlspecialchars($aData['passwd'][$index]) . '",'
+ . '`flags`="' . htmlspecialchars($aData['flags'][$index]) . '",'
+ . '`immunity`="' . $aData['immunity'][$index] . '",'
+ . '`time`="' . $time . '",'
+ . '`text`="' . htmlspecialchars($text) . '",'
+ . '`info`="' . htmlspecialchars($aData['info'][$index]) . '"');
+
+ if ($aData['active'][$index])
+ $usini .= $text . PHP_EOL;
+ }
+ }
+
+ $temp = sys::temp($usini);
+
+ $ssh->setfile($temp, $tarif['install'] . $server['uid'] . '/csgo/addons/sourcemod/configs/admins_simple.ini', 0644);
+
+ unlink($temp);
+
+ $ssh->set('chown server' . $server['uid'] . ':servers ' . $tarif['install'] . $server['uid'] . '/csgo/addons/sourcemod/configs/admins_simple.ini');
+
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \" sm_reloadadmins\"\015'");
+
+ sys::outjs(array('s' => 'ok'), $nmch);
+}
+
+// Построение списка добавленных админов
+$sql->query('SELECT `id`, `value`, `active`, `passwd`, `flags`, `immunity`, `time`, `info` FROM `admins_' . $server['game'] . '` WHERE `server`="' . $id . '" ORDER BY `id` ASC');
+while ($admin = $sql->get()) {
+ $html->get('list', 'sections/servers/' . $server['game'] . '/settings/admins');
+
+ if ($admin['active'])
+ $html->unit('active', 1);
+ else
+ $html->unit('active');
+
+ $html->set('id', $admin['id']);
+ $html->set('value', $admin['value']);
+ $html->set('passwd', $admin['passwd']);
+ $html->set('flags', $admin['flags']);
+ $html->set('immunity', $admin['immunity']);
+ $html->set('time', date('d.m.y', $admin['time']));
+ $html->set('info', $admin['info']);
+
+ $html->pack('admins');
+}
+
+$sql->query('SELECT `id` FROM `admins_' . $server['game'] . '` WHERE `server`="' . $id . '" ORDER BY `id` DESC LIMIT 1');
+$max = $sql->get();
+
+$html->get('admins', 'sections/servers/' . $server['game'] . '/settings');
+
+$html->set('id', $id);
+$html->set('admins', isset($html->arr['admins']) ? $html->arr['admins'] : '');
+$html->set('index', $max['id'] < 1 ? 0 : $max['id']);
+
+$html->pack('main');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/settings/bans.php b/system/sections/servers/cs2/settings/bans.php
new file mode 100644
index 0000000..bc162fd
--- /dev/null
+++ b/system/sections/servers/cs2/settings/bans.php
@@ -0,0 +1,154 @@
+nav('Бан листы');
+
+$sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$unit = $sql->get();
+
+$sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+include(LIB . 'ssh.php');
+
+if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings');
+
+// Путь к файлам (banned_user.cfg / banned_ip.cfg)
+$folder = $tarif['install'] . $server['uid'] . '/csgo';
+
+// Если бан/разбан/проверка
+if ($go) {
+ $aData = array();
+
+ $aData['value'] = isset($_POST['value']) ? trim($_POST['value']) : sys::outjs(array('e' => sys::text('servers', 'bans')), $nmch);
+ $aData['userid'] = isset($_POST['userid']) ? sys::int($_POST['userid']) : false;
+ $aData['amxbans'] = isset($_POST['amxbans']) ? true : false;
+
+ // Проверка входных данных
+ if (sys::valid($aData['value'], 'steamid') and sys::valid($aData['value'], 'steamid3') and sys::valid($aData['value'], 'ip'))
+ sys::outjs(array('e' => sys::text('servers', 'bans')), $nmch);
+
+ // Если указан steamid
+ if (sys::valid($aData['value'], 'ip')) {
+ // бан
+ if (isset($url['action']) and $url['action'] == 'ban') {
+ // Если включен sourcebans
+ if ($aData['amxbans'] and $aData['userid'])
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \"sm_ban 0 " . $aData['userid'] . " EGP\"\015'");
+ else
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \"banid 0.0 " . $aData['value'] . " kick\"\015'");
+
+ $ssh->set('cd ' . $folder . ' && sudo -u server' . $server['uid'] . ' fgrep ' . $aData['value'] . ' banned_user.cfg | awk \'{print $3}\'');
+
+ if ($aData['value'] != trim($ssh->get()))
+ $ssh->set('sudo -u server' . $server['uid'] . ' sh -c "echo \"banid 0.0 ' . $aData['value'] . '\" >> ' . $folder . '/banned_user.cfg"');
+
+ sys::outjs(array('s' => 'ok'), $nmch);
+
+ // разбан
+ } elseif (isset($url['action']) and $url['action'] == 'unban') {
+ // Убираем запись из banned_user.cfg
+ $ssh->set('cd ' . $folder . ' && sudo -u server' . $server['uid'] . ' sh -c "cat banned_user.cfg | grep -v ' . $aData['value'] . ' > temp_banned.cfg; echo "" >> temp_banned.cfg && cat temp_banned.cfg > banned_user.cfg; rm temp_banned.cfg"');
+
+ // Если включен sourcebans
+ if ($aData['amxbans'])
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \"sm_unban " . $aData['value'] . "\"\015'");
+ else {
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \"removeid " . $aData['value'] . "\"\015'");
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \"writeid\"\015'");
+ }
+
+ sys::outjs(array('s' => 'ok'), $nmch);
+ // проверка
+ } else {
+ $ssh->set('cd ' . $folder . ' && sudo -u server' . $server['uid'] . ' fgrep ' . $aData['value'] . ' banned_user.cfg | awk \'{print $3}\'');
+
+ if ($aData['value'] == trim($ssh->get()))
+ sys::outjs(array('ban' => 'Данный SteamID найден в файле banned_user.cfg'), $nmch);
+
+ sys::outjs(array('unban' => 'Данный SteamID не найден в файле banned_user.cfg'), $nmch);
+ }
+ } else {
+ // бан
+ if (isset($url['action']) and $url['action'] == 'ban') {
+ // Если включен sourcebans
+ if ($aData['amxbans'])
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \"sm_ban 0 " . $aData['value'] . " EGP\"\015'");
+ else
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \"addip 0.0 " . $aData['value'] . " EGP\"\015'");
+
+ $ssh->set('cd ' . $folder . ' && sudo -u server' . $server['uid'] . ' fgrep ' . $aData['value'] . ' banned_ip.cfg | awk \'{print $3}\'');
+
+ if ($aData['value'] != trim($ssh->get()))
+ $ssh->set('sudo -u server' . $server['uid'] . ' sh -c "echo \"addip 0.0 ' . $aData['value'] . '\" >> ' . $folder . '/banned_ip.cfg"');
+
+ sys::outjs(array('s' => 'ok'), $nmch);
+
+ // разбан
+ } elseif (isset($url['action']) and $url['action'] == 'unban') {
+ // Убираем запись из banned_ip.cfg
+ $ssh->set('cd ' . $folder . ' && sudo -u server' . $server['uid'] . ' sh -c "cat banned_ip.cfg | grep -v ' . $aData['value'] . ' > temp_listip.cfg; echo "" >> temp_listip.cfg && cat temp_listip.cfg > banned_ip.cfg; rm temp_listip.cfg"');
+
+ // Если включен sourcebans
+ if ($aData['amxbans'])
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \"amx_unban " . $aData['value'] . "\"\015'");
+ else {
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \"removeip " . $aData['value'] . "\"\015'");
+ $ssh->set("sudo -u server" . $server['uid'] . " screen -p 0 -S s_" . $server['uid'] . " -X eval 'stuff \"writeip\"\015'");
+ }
+
+ sys::outjs(array('s' => 'ok'), $nmch);
+ // проверка
+ } else {
+ $ssh->set('cd ' . $folder . ' && sudo -u server' . $server['uid'] . ' fgrep ' . $aData['value'] . ' banned_ip.cfg | awk \'{print $3}\'');
+
+ if ($aData['value'] == trim($ssh->get()))
+ sys::outjs(array('ban' => 'Данный IP найден в файле banned_ip.cfg'), $nmch);
+
+ sys::outjs(array('unban' => 'Данный IP не найден в файле banned_ip.cfg'), $nmch);
+ }
+ }
+}
+
+// Содержимое banned_user.cfg
+$ssh->set('cd ' . $folder . ' && cat banned_user.cfg | awk \'{print $3}\' | egrep "^\[U:[01]:[0-9]{3,12}\]$"');
+$aBanned = explode("\n", $ssh->get());
+
+// Содержимое banned_ip.cfg
+$ssh->set('cd ' . $folder . ' && cat banned_ip.cfg | awk \'{print $3}\' | egrep "(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{2}|[0-9])(\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{2}|[0-9])){3}"');
+$aListip = explode("\n", $ssh->get());
+
+if (isset($aBanned[count($aBanned) - 1]) and $aBanned[count($aBanned) - 1] == '')
+ unset($aBanned[count($aBanned) - 1]);
+
+if (isset($aListip[count($aListip) - 1]) and $aListip[count($aListip) - 1] == '')
+ unset($aListip[count($aListip) - 1]);
+
+// Построение списка забаненых по steamid
+foreach ($aBanned as $line => $steam) {
+ $html->get('bans_list', 'sections/servers/games/settings');
+
+ $html->set('value', trim($steam));
+
+ $html->pack('banned');
+}
+
+// Построение списка забаненых по ip
+foreach ($aListip as $line => $ip) {
+ $html->get('bans_list', 'sections/servers/games/settings');
+
+ $html->set('value', trim($ip));
+
+ $html->pack('listip');
+}
+
+$html->get('bans', 'sections/servers/' . $server['game'] . '/settings');
+
+$html->set('id', $id);
+$html->set('banned', isset($html->arr['banned']) ? $html->arr['banned'] : '');
+$html->set('listip', isset($html->arr['listip']) ? $html->arr['listip'] : '');
+
+$html->pack('main');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/settings/debug.php b/system/sections/servers/cs2/settings/debug.php
new file mode 100644
index 0000000..1610ab1
--- /dev/null
+++ b/system/sections/servers/cs2/settings/debug.php
@@ -0,0 +1,28 @@
+nav('Отладочный лог');
+
+$sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$unit = $sql->get();
+
+$sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+include(LIB . 'ssh.php');
+
+if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings');
+
+// Чтение файла - oldstart.log
+$file = $tarif['install'] . $server['uid'] . '/debug.log';
+
+$ssh->set('echo "" >> ' . $file . ' && cat ' . $file . ' | grep "CRASH: " | grep -ve "^#\|^[[:space:]]*$"');
+
+$html->get('debug', 'sections/servers/games/settings');
+
+$html->set('log', htmlspecialchars($ssh->get()));
+
+$html->pack('main');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/settings/logs.php b/system/sections/servers/cs2/settings/logs.php
new file mode 100644
index 0000000..513db79
--- /dev/null
+++ b/system/sections/servers/cs2/settings/logs.php
@@ -0,0 +1,86 @@
+nav('Логи');
+
+$sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$unit = $sql->get();
+
+$sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+include(LIB . 'ssh.php');
+
+if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings');
+
+// Путь к логам
+$folder = $tarif['install'] . $server['uid'] . '/csgo/logs';
+
+// Если выбран лог
+if (isset($url['log'])) {
+ if (sys::valid($url['log'], 'other', $aValid['cslogs']))
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings/subsection/logs');
+
+ $ssh->set('sudo -u server' . $server['uid'] . ' cat ' . $folder . '/' . $url['log']);
+
+ $html->get('view', 'sections/servers/games/settings/logs');
+
+ $html->set('id', $id);
+ $html->set('name', $url['log']);
+ $html->set('log', htmlspecialchars($ssh->get()));
+ $html->set('uri', 'logs');
+
+ $html->pack('main');
+} else {
+ if (isset($url['delall'])) {
+ $ssh->set('cd ' . $folder . ' && rm *.log');
+
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings/subsection/logs');
+ }
+
+ $ssh->set('cd ' . $folder . ' && du -ab --time | grep -e .log$ | awk \'{print $2" "$3"\/"$1"\/"$4}\' | sort -Mr');
+
+ // Массив данных
+ $aData = explode("\n", $ssh->get());
+
+ if (isset($aData[count($aData) - 1]))
+ unset($aData[count($aData) - 1]);
+
+ // Построение списка
+ foreach ($aData as $line => $log) {
+ $aLog = explode('\/', $log);
+
+ // Название
+ $name = explode('/', $aLog[2]);
+
+ if (count($name) > 2)
+ continue;
+
+ // Дата
+ $date = sys::unidate($aLog[0]);
+
+ // Вес
+ $size = sys::size($aLog[1]);
+
+ $html->get('list', 'sections/servers/games/settings/logs');
+
+ $html->set('id', $id);
+ $html->set('name', end($name));
+ $html->set('uri', 'logs/log/' . end($name));
+ $html->set('date', $date);
+ $html->set('size', $size);
+
+ $html->pack('logs');
+ }
+
+ $html->get('logs', 'sections/servers/games/settings');
+
+ $html->set('id', $id);
+ $html->set('uri', '');
+ $html->set('logs', isset($html->arr['logs']) ? $html->arr['logs'] : '');
+
+ $html->pack('main');
+}
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/settings/server.php b/system/sections/servers/cs2/settings/server.php
new file mode 100644
index 0000000..e6a9df3
--- /dev/null
+++ b/system/sections/servers/cs2/settings/server.php
@@ -0,0 +1,113 @@
+nav('Параметры server.cfg');
+
+$sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$unit = $sql->get();
+
+$sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+include(LIB . 'ssh.php');
+
+if (!$ssh->auth($unit['passwd'], $unit['address'])) {
+ if ($go)
+ sys::outjs(array('e' => sys::text('error', 'ssh')), $nmch);
+
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings');
+}
+
+include(DATA . 'scfg/' . $server['game'] . '.php');
+
+// Сохранение изменений
+if ($go) {
+ $servercfg = isset($_POST['config']) ? $_POST['config'] : '';
+
+ $config = '';
+
+ $config_end = $servercfg['\'other\''];
+
+ unset($servercfg['\'other\'']);
+
+ foreach ($servercfg as $cvar => $val)
+ if ($val != '')
+ $config .= str_replace("'", '', $cvar) . ' "' . $val . '"' . "\n";
+
+ // Временый файл
+ $temp = sys::temp($config . $config_end);
+
+ $ssh->setfile($temp, $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg', 0644);
+
+ $ssh->set('chown server' . $server['uid'] . ':servers ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg');
+
+ unlink($temp);
+
+ sys::outjs(array('s' => 'ok'), $nmch);
+}
+
+// Чтение файла - server.cfg
+$file = $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg';
+
+$ssh->set('echo "" >> ' . $file . ' && cat ' . $file . ' | grep -ve "^#\|^[[:space:]]*$"');
+
+$fScfg = explode("\n", strip_tags($ssh->get()));
+
+$servercfg = array();
+$other = '';
+
+// Убираем пробелы и генерируем массив
+foreach ($fScfg as $line) {
+ // имя квара
+ $cvar = sys::first(explode(' ', $line));
+
+ if ($cvar == '')
+ continue;
+
+ // убираем имя квара и оставляем только значение
+ $value = str_replace($cvar . ' ', "", $line);
+
+ // выбираем только то, что нам нужно
+ preg_match_all('~([^"]+)~', $value, $cvar_value, PREG_SET_ORDER);
+
+ // Исключаем комментарии
+ if ($cvar == '//')
+ continue;
+
+ $val = sys::first(explode(' //', $cvar_value[0][1]));
+
+ // Добавляем данные в массив
+ if (array_key_exists($cvar, $aScfg))
+ $servercfg[$cvar] = trim($val);
+ else
+ $other .= $line . "\n";
+}
+
+foreach ($aScfg as $name => $desc) {
+ if (!isset($servercfg[$name]))
+ $servercfg[$name] = '';
+
+ // Формирование формы
+ if (strpos($aScfg_form[$name], 'select'))
+ $form = str_replace('value="' . $servercfg[$name] . '"', 'value="' . $servercfg[$name] . '" selected="select"', $aScfg_form[$name]);
+ else
+ $form = str_replace('[' . $name . ']', $servercfg[$name], $aScfg_form[$name]);
+
+ $html->get('servercfg_list', 'sections/servers/games/settings');
+
+ $html->set('name', $name);
+ $html->set('desc', $desc);
+ $html->set('form', $form);
+
+ $html->pack('list');
+}
+
+$html->get('servercfg', 'sections/servers/' . $server['game'] . '/settings');
+
+$html->set('id', $id);
+$html->set('cfg', $html->arr['list']);
+$html->set('other', $other);
+
+$html->pack('main');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/settings/smlogs.php b/system/sections/servers/cs2/settings/smlogs.php
new file mode 100644
index 0000000..3576bf0
--- /dev/null
+++ b/system/sections/servers/cs2/settings/smlogs.php
@@ -0,0 +1,86 @@
+nav('Логи SourceMod');
+
+$sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$unit = $sql->get();
+
+$sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+include(LIB . 'ssh.php');
+
+if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings');
+
+// Путь к логам
+$folder = $tarif['install'] . $server['uid'] . '/csgo/addons/sourcemod/logs';
+
+// Если выбран лог
+if (isset($url['log'])) {
+ if (sys::valid($url['log'], 'other', $aValid['csssmlogs']))
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings/subsection/smlogs');
+
+ $ssh->set('sudo -u server' . $server['uid'] . ' cat ' . $folder . '/' . $url['log']);
+
+ $html->get('view', 'sections/servers/games/settings/logs');
+
+ $html->set('id', $id);
+ $html->set('name', $url['log']);
+ $html->set('log', htmlspecialchars($ssh->get()));
+ $html->set('uri', 'smlogs');
+
+ $html->pack('main');
+} else {
+ if (isset($url['delall'])) {
+ $ssh->set('cd ' . $folder . ' && rm *.log');
+
+ sys::back($cfg['http'] . 'servers/id/' . $id . '/section/settings/subsection/smlogs');
+ }
+
+ $ssh->set('cd ' . $folder . ' && du -ab --time | grep -e .log$ | awk \'{print $2" "$3"\/"$1"\/"$4}\' | sort -Mr');
+
+ // Массив данных
+ $aData = explode("\n", $ssh->get());
+
+ if (isset($aData[count($aData) - 1]))
+ unset($aData[count($aData) - 1]);
+
+ // Построение списка
+ foreach ($aData as $line => $log) {
+ $aLog = explode('\/', $log);
+
+ // Название
+ $name = explode('/', $aLog[2]);
+
+ if (count($name) > 2)
+ continue;
+
+ // Дата
+ $date = sys::unidate($aLog[0]);
+
+ // Вес
+ $size = sys::size($aLog[1]);
+
+ $html->get('list', 'sections/servers/games/settings/logs');
+
+ $html->set('id', $id);
+ $html->set('name', end($name));
+ $html->set('uri', 'smlogs/log/' . end($name));
+ $html->set('date', $date);
+ $html->set('size', $size);
+
+ $html->pack('logs');
+ }
+
+ $html->get('logs', 'sections/servers/games/settings');
+
+ $html->set('id', $id);
+ $html->set('uri', 'sm');
+ $html->set('logs', isset($html->arr['logs']) ? $html->arr['logs'] : '');
+
+ $html->pack('main');
+}
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/settings/start.php b/system/sections/servers/cs2/settings/start.php
new file mode 100644
index 0000000..75d9419
--- /dev/null
+++ b/system/sections/servers/cs2/settings/start.php
@@ -0,0 +1,164 @@
+query('SELECT `uid`, `slots`, `slots_start`, `map_start`, `vac`, `fastdl`, `autorestart`, `fps`, `tickrate`, `pingboost` FROM `servers` WHERE `id`="' . $id . '" LIMIT 1');
+$server = array_merge($server, $sql->get());
+
+$sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$unit = $sql->get();
+
+$sql->query('SELECT `install`, `tickrate`, `price` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+include(LIB . 'games/games.php');
+include(LIB . 'games/tarifs.php');
+include(LIB . 'games/' . $server['game'] . '/tarif.php');
+
+// Вывод списка карт
+if (isset($url['maps']))
+ games::maplist($id, $unit, $tarif['install'] . $server['uid'] . '/csgo/maps', $server['map_start'], false);
+
+// Сохранение
+if ($go and $url['save']) {
+ $value = isset($url['value']) ? sys::int($url['value']) : sys::outjs(array('s' => 'ok'), $nmch);
+
+ switch ($url['save']) {
+ case 'map':
+ $map = isset($url['value']) ? trim($url['value']) : sys::outjs(array('s' => 'ok'), $nmch);
+
+ if ($map != $server['map_start'])
+ games::maplist($id, $unit, $tarif['install'] . $server['uid'] . '/csgo/maps', $map, true, $nmch);
+
+ $mcache->delete('server_settings_' . $id);
+ sys::outjs(array('s' => 'ok'), $nmch);
+
+ case 'vac':
+ if ($value != $server['vac'])
+ $sql->query('UPDATE `servers` set `vac`="' . $value . '" WHERE `id`="' . $id . '" LIMIT 1');
+
+ $mcache->delete('server_settings_' . $id);
+ sys::outjs(array('s' => 'ok'), $nmch);
+
+ case 'mod':
+ if (in_array($value, array(1, 2, 3, 4, 5)))
+ $sql->query('UPDATE `servers` set `pingboost`="' . $value . '" WHERE `id`="' . $id . '" LIMIT 1');
+
+ $mcache->delete('server_settings_' . $id);
+ sys::outjs(array('s' => 'ok'), $nmch);
+
+ case 'slots':
+ $slots = $value > $server['slots'] ? $server['slots'] : $value;
+ $slots = $value < 2 ? 2 : $slots;
+
+ if ($slots != $server['slots_start'])
+ $sql->query('UPDATE `servers` set `slots_start`="' . $slots . '" WHERE `id`="' . $id . '" LIMIT 1');
+
+ $mcache->delete('server_settings_' . $id);
+ sys::outjs(array('s' => 'ok'), $nmch);
+
+ case 'autorestart':
+ if ($value != $server['autorestart'])
+ $sql->query('UPDATE `servers` set `autorestart`="' . $value . '" WHERE `id`="' . $id . '" LIMIT 1');
+
+ $mcache->delete('server_settings_' . $id);
+ sys::outjs(array('s' => 'ok'), $nmch);
+
+ case 'tickrate':
+ if (!tarif::price($tarif['price']) and in_array($value, explode(':', $tarif['tickrate'])))
+ $sql->query('UPDATE `servers` set `tickrate`="' . $value . '" WHERE `id`="' . $id . '" LIMIT 1');
+
+ $mcache->delete('server_settings_' . $id);
+ sys::outjs(array('s' => 'ok'), $nmch);
+
+ case 'fastdl':
+ include(LIB . 'ssh.php');
+
+ if (!$ssh->auth($unit['passwd'], $unit['address']))
+ sys::outjs(array('e' => sys::text('error', 'ssh')), $nmch);
+
+ if ($value) {
+ $fastdl = 'sv_downloadurl "http://' . sys::first(explode(':', $unit['address'])) . ':8080/fast_' . $server['uid'] . '"' . PHP_EOL
+ . 'sv_consistency 1' . PHP_EOL
+ . 'sv_allowupload 1' . PHP_EOL
+ . 'sv_allowdownload 1';
+
+ // Временый файл
+ $temp = sys::temp($fastdl);
+
+ $ssh->setfile($temp, $tarif['install'] . $server['uid'] . '/csgo/cfg/fastdl.cfg', 0644);
+
+ $ssh->set('chown server' . $server['uid'] . ':servers ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/fastdl.cfg;'
+ . 'ln -s ' . $tarif['install'] . $server['uid'] . '/csgo /var/nginx/fast_' . $server['uid'] . ';'
+ . 'sed -i ' . "'s/exec fastdl.cfg//g'" . ' ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg;'
+ . 'echo "exec fastdl.cfg" >> ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg');
+
+ unlink($temp);
+ } else
+ $ssh->set('sed -i ' . "'s/exec fastdl.cfg//g'" . ' ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/server.cfg;'
+ . 'rm ' . $tarif['install'] . $server['uid'] . '/csgo/cfg/fastdl.cfg; rm /var/nginx/fast_' . $server['uid']);
+
+ $sql->query('UPDATE `servers` set `fastdl`="' . $value . '" WHERE `id`="' . $id . '" LIMIT 1');
+
+ $mcache->delete('server_settings_' . $id);
+ sys::outjs(array('s' => 'ok'), $nmch);
+ }
+}
+
+// Генерация списка слот
+$slots = '';
+
+for ($slot = 2; $slot <= $server['slots']; $slot += 1)
+ $slots .= '';
+
+// Античит VAC
+$vac = $server['vac'] ? '' : '';
+
+// Быстрая скачака
+$fastdl = $server['fastdl'] ? '' : '';
+
+// Авторестарт при зависании
+$autorestart = $server['autorestart'] ? '' : '';
+
+$tickrate = '';
+
+if (!tarif::price($tarif['price'])) {
+ $aTick = explode(':', $tarif['tickrate']);
+
+ unset($aTick[array_search($server['tickrate'], $aTick)]);
+
+ if (count($aTick))
+ foreach ($aTick as $value)
+ $tickrate .= '';
+}
+
+// Игровой режим
+$mods = ''
+ . ''
+ . ''
+ . ''
+ . '';
+
+if (!$server['pingboost'])
+ $server['pingboost'] = 2;
+
+$mod = str_replace('value="' . $server['pingboost'], 'value="' . $server['pingboost'] . '" selected="select', $mods);
+
+$html->get('start', 'sections/servers/' . $server['game'] . '/settings');
+
+$html->set('id', $id);
+$html->set('map', $server['map_start']);
+$html->set('vac', $vac);
+$html->set('fastdl', $fastdl);
+$html->set('autorestart', $autorestart);
+$html->set('mod', $mod);
+$html->set('slots', str_replace('"' . $server['slots_start'] . '"', '"' . $server['slots_start'] . '" selected="select"', $slots));
+
+if (!tarif::price($tarif['price'])) {
+ $html->unit('tickrate', true);
+ $html->set('tickrate', $tickrate);
+} else
+ $html->unit('tickrate');
+
+$html->pack('start');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/tarif.php b/system/sections/servers/cs2/tarif.php
new file mode 100644
index 0000000..edf8b85
--- /dev/null
+++ b/system/sections/servers/cs2/tarif.php
@@ -0,0 +1,12 @@
+query('SELECT `name`, `slots_min`, `slots_max`, `install`, `fps`, `tickrate`, `ram`, `timext`, `discount`, `price` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
+$tarif = $sql->get();
+
+// Подразделы
+$aSub = array('extend', 'plan', 'address', 'addextend', 'unit', 'slots');
+
+include(SEC . 'servers/games/tarif.php');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/tarif/extend.php b/system/sections/servers/cs2/tarif/extend.php
new file mode 100644
index 0000000..4e13600
--- /dev/null
+++ b/system/sections/servers/cs2/tarif/extend.php
@@ -0,0 +1,50 @@
+ 'Переданы не все данные'), $nmch);
+
+ // Проверка периода
+ if (!in_array($aData['time'], explode(':', $tarif['timext'])))
+ sys::outjs(array('e' => 'Переданы неверные данные'), $nmch);
+
+}
+
+$aData['promo'] = isset($_POST['promo']) ? $_POST['promo'] : '';
+$aData['address'] = isset($_POST['address']) ? $_POST['address'] : false;
+$aData['server'] = $id;
+$aData['user'] = $server['user'];
+$aData['tarif'] = $server['tarif'];
+$aData['tickrate'] = $server['tickrate'];
+$aData['slots'] = $server['slots'];
+
+// Цена за выделенный адрес
+$add_sum = tarifs::address_add_sum($aData['address'], $server);
+
+$aPrice = explode(':', $tarif['price']);
+
+// Цена за 30 дней 1 слота
+$price = $aPrice[array_search($server['tickrate'], explode(':', $tarif['tickrate']))];
+
+// Если расчетный период
+if ($cfg['settlement_period'])
+ $aData['time'] = $server['time'];
+
+// Цена аренды
+$sum = games::define_sum($tarif['discount'], $price, $server['slots'], $aData['time'], 'extend') + $add_sum;
+
+// Если расчетный период
+if ($cfg['settlement_period'])
+ $aData['time'] = games::define_period('extend', params::$aDayMonth, $server['time']);
+
+$days = params::$aDayMonth[date('n', $server['time'])] == $aData['time'] ? 'месяц' : games::parse_day($aData['time'], true);
+
+include(SEC . 'servers/games/tarif/extend.php');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/tarif/plan.php b/system/sections/servers/cs2/tarif/plan.php
new file mode 100644
index 0000000..10c8fcb
--- /dev/null
+++ b/system/sections/servers/cs2/tarif/plan.php
@@ -0,0 +1,64 @@
+ 'Переданые не все данные'), $nmch);
+
+$aPrice = explode(':', $tarif['price']);
+$aTICK = explode(':', $tarif['tickrate']);
+
+// Проверка плана
+if (array_search($plan, $aTICK) === FALSE)
+ sys::outjs(array('e' => 'Переданы неверные данные'), $nmch);
+
+if ($plan == $server['tickrate'])
+ sys::outjs(array('e' => 'Смысла в этой операции нет'), $nmch);
+
+if (!tarif::price($tarif['price']))
+ sys::outjs(array('e' => 'Чтобы изменить тариф, перейдите в настройки запуска'), $nmch);
+
+if ($server['time'] < $start_point + 86400)
+ $time = $server['time'];
+else {
+ // Цена за 1 день аренды (по новому тарифному плану)
+ $price = $aPrice[array_search($plan, $aTICK)] / 30 * $server['slots'];
+
+ // Цена за 1 день аренды (по старому тарифному плану)
+ $price_old = $aPrice[array_search($server['tickrate'], $aTICK)] / 30 * $server['slots'];
+
+ // Остаток дней аренды
+ $days = ($server['time'] - $start_point) / 86400;
+
+ $time = date('H:i:s', $server['time']);
+ $date = date('d.m.Y', round($start_point + $days * $price_old / $price * 86400 - 86400));
+
+ $aDate = explode('.', $date);
+ $aTime = explode(':', $time);
+
+ $time = mktime($aTime[0], $aTime[1], $aTime[2], $aDate[1], $aDate[0], $aDate[2]);
+}
+
+// Выполнение смена тарифного плана
+if ($go) {
+ sys::benefitblock($id, $nmch);
+
+ $sql->query('UPDATE `servers` set `time`="' . $time . '", `tickrate`="' . $plan . '" WHERE `id`="' . $id . '" LIMIT 1');
+
+ if (in_array($server['status'], array('working', 'start', 'restart', 'change'))) {
+ include(LIB . 'games/' . $server['game'] . '/action.php');
+
+ action::start($id, 'restart');
+ }
+
+ // Запись логов
+ $sql->query('INSERT INTO `logs_sys` set `user`="' . $user['id'] . '", `server`="' . $id . '", `text`="' . sys::text('syslogs', 'change_plan') . '", `time`="' . $start_point . '"');
+
+ sys::outjs(array('s' => 'ok'), $nmch);
+}
+
+// Выхлоп информации
+sys::outjs(array('s' => date('d.m.Y - H:i', $time) . ' (' . sys::date('min', $time) . ')'), $nmch);
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/tarif/slots.php b/system/sections/servers/cs2/tarif/slots.php
new file mode 100644
index 0000000..037ae6d
--- /dev/null
+++ b/system/sections/servers/cs2/tarif/slots.php
@@ -0,0 +1,33 @@
+ 'На данном тарифе нельзя изменить количество слот.'), $nmch);
+
+$slots = isset($url['slots']) ? sys::int($url['slots']) : sys::outjs(array('e' => 'Переданы не все данные.'), $nmch);
+
+$aPrice = explode(':', $tarif['price']);
+$aTICK = explode(':', $tarif['tickrate']);
+
+$overdue = $server['time'] < $start_point;
+
+if ($cfg['change_slots'][$server['game']]['days'] || $overdue) {
+ // Цена за 1 день
+ $price = $aPrice[array_search($server['tickrate'], $aTICK)] / 30;
+
+ // Цена аренды за остаток дней (с текущим кол-вом слот)
+ $price_old = ($server['time'] - $start_point) / 86400 * $price * $server['slots'];
+}
+
+$max = $tarif['slots_max'] - $server['slots'];
+
+// Сумма за добавляемые слоты
+$sum = round(($server['time'] - $start_point) / 86400 * ($aPrice[array_search($server['tickrate'], $aTICK)] / 30) * $slots, 2);
+
+include(SEC . 'servers/games/tarif/slots.php');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/tarif/unit.php b/system/sections/servers/cs2/tarif/unit.php
new file mode 100644
index 0000000..d042c13
--- /dev/null
+++ b/system/sections/servers/cs2/tarif/unit.php
@@ -0,0 +1,50 @@
+ 'Переданы не все данные.'), $nmch);
+
+if (!$cfg['change_unit'][$server['game']] || $server['time'] < $start_point + 86400 || $server['test'])
+ exit;
+
+$sql->query('SELECT `id`, `unit`, `packs`, `tickrate`, `price` FROM `tarifs` WHERE `unit`="' . $uid . '" AND `game`="' . $server['game'] . '" AND `name`="' . $tarif['name'] . '" AND `id`!="' . $server['tarif'] . '" AND `show`="1" ORDER BY `unit`');
+if (!$sql->num())
+ sys::outjs(array('e' => 'Не найден подходящий тариф.'), $nmch);
+
+$oldTarif = $tarif;
+
+$tarif = $sql->get();
+
+$sql->query('SELECT `address`, `passwd`, `sql_login`, `sql_passwd`, `sql_port`, `sql_ftp` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
+$oldUnit = $sql->get();
+
+$aPriceold = explode(':', $oldTarif['price']);
+$aTICKold = explode(':', $oldTarif['tickrate']);
+
+$sql->query('SELECT `id` FROM `units` WHERE `id`="' . $tarif['unit'] . '" AND `show`="1" LIMIT 1');
+if (!$sql->num())
+ sys::outjs(array('e' => 'Выбранная локация не доступна.'), $nmch);
+
+$aPrice = explode(':', $tarif['price']);
+$aTICK = explode(':', $tarif['tickrate']);
+
+if (!in_array($server['tickrate'], $aTICK))
+ sys::outjs(array('e' => 'Не найден подходящий тарифный план.'), $nmch);
+
+// Цена за 1 день (при новом тарифном плане)
+$price = $aPrice[array_search($server['tickrate'], $aTICK)] / 30 * $server['slots'];
+
+// Цена аренды за остаток дней (с текущим тарифным планом)
+$oldprice = ($server['time'] - $start_point) / 86400 * ($aPriceold[array_search($server['tickrate'], $aTICKold)] / 30 * $server['slots']);
+
+$date = date('H.i.s.d.m.Y', round($start_point + $oldprice / $price * 86400 - 86400));
+
+$aDate = explode('.', $date);
+
+$time = mktime($aDate[0], $aDate[1], $aDate[2], $aDate[4], $aDate[3], $aDate[5]);
+
+include(SEC . 'servers/games/tarif/unit.php');
+?>
\ No newline at end of file
diff --git a/system/sections/servers/cs2/web.php b/system/sections/servers/cs2/web.php
new file mode 100644
index 0000000..4335726
--- /dev/null
+++ b/system/sections/servers/cs2/web.php
@@ -0,0 +1,81 @@
+nav($server['address'], $cfg['http'] . 'servers/id/' . $id);
+
+include(DATA . 'web.php');
+
+// Если выбран подраздел
+if (isset($url['subsection']) and in_array($url['subsection'], $aSub) and in_array($url['action'], array_merge($aAction[$url['subsection']], array('install', 'manage')))) {
+ if ($go)
+ $nmch = sys::rep_act('server_web_go_' . $id, 10);
+ else
+ $html->nav('Web', $cfg['http'] . 'servers/id/' . $id . '/section/web');
+
+ include(SEC . 'web/' . $url['subsection'] . '/free/' . $url['action'] . '.php');
+} else {
+ $html->nav('Web');
+
+ if ($mcache->get('server_web_' . $id) != '')
+ $html->arr['main'] = $mcache->get('server_web_' . $id);
+ else {
+ // Услуги
+ foreach ($aWeb[$server['game']] as $service => $active) {
+ if ($active) {
+ if ($service == 'hosting') {
+ if (!$aWebVHTtype && !in_array($server['tarif'], $aWebVHT))
+ continue;
+
+ if ($aWebVHTtype && in_array($server['tarif'], $aWebVHT))
+ continue;
+ }
+
+ // Проверка на установку
+ switch ($aWebInstall[$server['game']][$service]) {
+ case 'server':
+ $sql->query('SELECT `id` FROM `web` WHERE `type`="' . $service . '" AND `server`="' . $id . '" LIMIT 1');
+ break;
+
+ case 'user':
+ $sql->query('SELECT `id` FROM `web` WHERE `type`="' . $service . '" AND `user`="' . $server['user'] . '" LIMIT 1');
+ break;
+
+ case 'unit':
+ $sql->query('SELECT `id` FROM `web` WHERE `type`="' . $service . '" AND `user`="' . $server['user'] . '" AND `unit`="' . $server['unit'] . '" LIMIT 1');
+ }
+
+ if ($sql->num())
+ $html->get('list_install', 'sections/servers/games/web');
+ else
+ $html->get('list', 'sections/servers/games/web');
+
+ $html->set('id', $id);
+ $html->set('service', $service);
+ $html->set('name', $aWebname[$service]);
+ $html->set('desc', $aWebDesc[$service]);
+
+ $html->pack($aWebType[$service]);
+ }
+ }
+
+ // Блоки услуг
+ foreach ($aWebTypeInfo[$server['game']] as $type => $name) {
+ if (!isset($html->arr[$type]))
+ continue;
+
+ $html->get('block', 'sections/servers/games/web');
+ $html->set('name', $name);
+ $html->set('list', $html->arr[$type]);
+ $html->pack('web');
+ }
+
+ $html->get('web', 'sections/servers/' . $server['game']);
+ $html->set('id', $id);
+ $html->set('web', isset($html->arr['web']) ? $html->arr['web'] : 'Дополнительные услуги отсутствуют');
+ $html->pack('main');
+
+ $mcache->set('server_web_' . $id, $html->arr['main'], false, 4);
+ }
+}
+?>
\ No newline at end of file
diff --git a/system/sections/services/cs2.php b/system/sections/services/cs2.php
new file mode 100644
index 0000000..2fd11d6
--- /dev/null
+++ b/system/sections/services/cs2.php
@@ -0,0 +1,145 @@
+get('buy_server'))
+ sleep(1.5);
+
+ $mcache->set('buy_server', true, false, 3);
+
+ include(LIB . 'games/' . $section . '/service.php');
+
+ // Входные данные
+ $aData = array(
+ 'unit' => isset($_POST['unit']) ? sys::int($_POST['unit']) : 0,
+ 'tarif' => isset($_POST['tarif']) ? sys::int($_POST['tarif']) : 0,
+ 'pack' => isset($_POST['pack']) ? $_POST['pack'] : '',
+ 'tickrate' => isset($_POST['tickrate']) ? sys::int($_POST['tickrate']) : 0,
+ 'slots' => isset($_POST['slots']) ? sys::int($_POST['slots']) : 0,
+ 'time' => isset($_POST['time']) ? sys::int($_POST['time']) : 30,
+ 'test' => (isset($_POST['time']) and $_POST['time'] == 'test') ? true : false,
+ 'promo' => isset($_POST['promo']) ? $_POST['promo'] : false,
+ );
+
+ // Массвив данных
+ $aSDATA = service::buy($aData);
+
+ // Процесс выдачи игрового сервера
+ $id = service::install($aSDATA);
+
+ sys::outjs(array('s' => 'ok', 'id' => $id));
+}
+
+include(LIB . 'games/services.php');
+
+$check = false;
+
+// Проверка наличия доступной локации
+$sql->query(services::unit($section));
+if ($sql->num()) {
+ // Выбранная локация
+ if (isset($url['get']) and in_array($url['get'], array('tarifs', 'data')))
+ $sql->query('SELECT `id`, `test` FROM `units` WHERE `id`="' . $id . '" LIMIT 1');
+
+ $select_unit = $sql->get();
+
+ // Генерация списка локаций
+ $units = services::units($section);
+
+ // Генерация списка тарифов
+ $tarifs = services::tarifs($section, $select_unit['id']);
+
+ if (isset($url['get']) and in_array($url['get'], array('price', 'promo'))) {
+ $aGet = array(
+ 'tarif' => sys::int($url['tarif']),
+ 'tickrate' => sys::int($url['tickrate']),
+ 'slots' => sys::int($url['slots']),
+ 'time' => sys::int($url['time']),
+ 'user' => $user['id']
+ );
+
+ $sql->query('SELECT `price`, `tickrate`, `discount` FROM `tarifs` WHERE `id`="' . $aGet['tarif'] . '" LIMIT 1');
+ $tarif = $sql->get();
+
+ $aPrice = explode(':', $tarif['price']);
+
+ // Определение цены
+ $price = $aPrice[array_search($aGet['tickrate'], explode(':', $tarif['tickrate']))];
+
+ // Выхлоп цены за выбранные параметры
+ if ($url['get'] == 'price') {
+ // Если выбран тестовый период
+ if ($url['time'] == 'test')
+ sys::outjs(array('sum' => 0));
+
+ sys::outjs(array(
+ 'sum' => games::define_sum($tarif['discount'], $price, $aGet['slots'], $aGet['time'])
+ ));
+ }
+
+ // Выхлоп цены с учетом промо-кода
+ if ($url['get'] == 'promo')
+ games::define_promo(
+ $url['cod'],
+ $aGet,
+ $tarif['discount'],
+ games::define_sum($tarif['discount'], $price, $aGet['slots'], $aGet['time'])
+ );
+ }
+
+ // Генерация сборок/слот/периодов
+ if (isset($url['get']) and $url['get'] == 'data')
+ $sql->query('SELECT `id`, `name`, `price`, `slots_min`, `slots_max`, `packs`, `tickrate`, `time`, `test`, `discount` FROM `tarifs` WHERE `id`="' . sys::int($url['tarif']) . '" LIMIT 1');
+ else
+ $sql->query('SELECT `id`, `name`, `price`, `slots_min`, `slots_max`, `packs`, `tickrate`, `time`, `test`, `discount` FROM `tarifs` WHERE `game`="' . $section . '" AND `unit`="' . $select_unit['id'] . '" AND `show`="1" ORDER BY `sort` ASC LIMIT 1');
+
+ if ($sql->num()) {
+ $select_tarif = $sql->get();
+
+ $aTarif = games::parse_tarif($select_tarif, $select_unit);
+
+ if (isset($url['get'])) {
+ // Выхлоп при выборе локации
+ if ($url['get'] == 'tarifs')
+ sys::outjs(array_merge(array('tarifs' => $tarifs), $aTarif));
+
+ // Выхлоп при выборе тарифа
+ if ($url['get'] == 'data')
+ sys::outjs($aTarif);
+ }
+
+ $html->get($section, 'sections/services/games');
+ $html->set('units', $units);
+ $html->set('tarifs', $tarifs);
+ $html->set('packs', $aTarif['packs']);
+ $html->set('tickrate', $aTarif['tickrate']);
+ $html->set('slots', $aTarif['slots']);
+ $html->set('time', $aTarif['time']);
+ $html->set('cur', $cfg['currency']);
+ $html->set('date', date('d.m.Y', $start_point));
+
+ if ($cfg['settlement_period'])
+ $html->unit('settlement_period', true, true);
+ else
+ $html->unit('settlement_period', false, true);
+
+ $html->unit('informer', false, true);
+ $html->pack('main');
+
+ $check = true;
+ }
+}
+
+if (!$check) {
+ $html->get($section, 'sections/services/games');
+ $html->unit('informer', true, true);
+ $html->pack('main');
+}
+?>
\ No newline at end of file
diff --git a/template/acp/main.html b/template/acp/main.html
index 86ca6fb..ebf9f40 100644
--- a/template/acp/main.html
+++ b/template/acp/main.html
@@ -54,6 +54,11 @@
[csgo] шт. |
[slots_csgo] шт. |
+
+ Counter-Strike: 2 |
+ [cs2] шт. |
+ [slots_cs2] шт. |
+
GTA: SA-MP |
[samp] шт. |
diff --git a/template/acp/sections/servers/menu.html b/template/acp/sections/servers/menu.html
index a8603f0..e86d7bd 100644
--- a/template/acp/sections/servers/menu.html
+++ b/template/acp/sections/servers/menu.html
@@ -11,6 +11,7 @@
CS: Global
Offensive [csgo]
+ CS: 2 [cs2]
GTA: MTA
[mta]
GTA: SAMP [samp]
diff --git a/template/acp/sections/tarifs/add.html b/template/acp/sections/tarifs/add.html
index c24a969..65a044e 100644
--- a/template/acp/sections/tarifs/add.html
+++ b/template/acp/sections/tarifs/add.html
@@ -19,6 +19,7 @@
+
diff --git a/template/acp/sections/units/add.html b/template/acp/sections/units/add.html
index 580290c..6cd407d 100644
--- a/template/acp/sections/units/add.html
+++ b/template/acp/sections/units/add.html
@@ -57,6 +57,10 @@
CS:GO
+
+