b59003e559
This update contains code reformatting to meet PHP standards.
67 lines
2.2 KiB
PHP
67 lines
2.2 KiB
PHP
<?php
|
||
if (!DEFINED('EGP'))
|
||
exit(header('Refresh: 0; URL=http://' . $_SERVER['SERVER_NAME'] . '/404'));
|
||
|
||
class control_scan_servers_admins extends cron
|
||
{
|
||
function __construct()
|
||
{
|
||
global $sql, $argv, $start_point;
|
||
|
||
$servers = $argv;
|
||
|
||
unset($servers[0], $servers[1], $servers[2]);
|
||
|
||
$game = $servers[3];
|
||
|
||
if (!array_key_exists($game, cron::$admins_file))
|
||
return NULL;
|
||
|
||
$sql->query('SELECT `address` FROM `control` WHERE `id`="' . $servers[4] . '" LIMIT 1');
|
||
if (!$sql->num())
|
||
return NULL;
|
||
|
||
$unit = $sql->get();
|
||
|
||
unset($servers[3], $servers[4]);
|
||
|
||
$sql->query('SELECT `unit` FROM `control_servers` WHERE `id`="' . $servers[5] . '" LIMIT 1');
|
||
$server = $sql->get();
|
||
|
||
$sql->query('SELECT `address`, `passwd` FROM `control` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
|
||
$unit = $sql->get();
|
||
|
||
include(LIB . 'ssh.php');
|
||
|
||
// Проверка ssh соедниения пу с локацией
|
||
if (!$ssh->auth($unit['passwd'], $unit['address']))
|
||
return NULL;
|
||
|
||
foreach ($servers as $id) {
|
||
$sql->query('SELECT `uid` FROM `control_servers` WHERE `id`="' . $id . '" LIMIT 1');
|
||
$server = $sql->get();
|
||
|
||
$admins = $sql->query('SELECT `id`, `text` FROM `control_admins_' . $game . '` WHERE `server`="' . $id . '" AND `active`="1" AND `time`<"' . $start_point . '"');
|
||
|
||
if (!$sql->num($admins))
|
||
continue;
|
||
|
||
$cmd = 'cd /servers/' . $server['uid'] . ';';
|
||
|
||
while ($admin = $sql->get($admins)) {
|
||
$cmd .= 'sed -i -e \'s/' . escapeshellcmd(htmlspecialchars_decode($admin['text'])) . '//g\' ' . cron::$admins_file[$game] . ';';
|
||
|
||
$sql->query('UPDATE `admins_' . $game . '` set `active`="0" WHERE `id`="' . $admin['id'] . '" LIMIT 1');
|
||
}
|
||
|
||
$cmd .= 'sed -i ' . "'/./!d'" . ' ' . cron::$admins_file[$game] . '; echo -e "\n" >> ' . cron::$admins_file[$game] . ';';
|
||
$cmd .= 'chown server' . $server['uid'] . ':1000 ' . cron::$admins_file[$game];
|
||
|
||
$ssh->set($cmd);
|
||
}
|
||
|
||
return NULL;
|
||
}
|
||
}
|
||
|
||
?>
|