EngineGP/system/library/cron/control_scan_servers_admins.php
Sergei Solovev 276ec7f3eb Updating the server name reference in code
This change replaces the use of $_SERVER['SERVER_NAME'] with $_SERVER['HTTP_HOST'] throughout the codebase. The modification ensures consistency and compliance with best practices, since $_SERVER['HTTP_HOST'] is often used to extract the host header from an HTTP request. This update may improve compatibility and security, especially in scenarios where the Host header plays a key role in proper server configuration and routing. Please review and test the changes carefully to ensure smooth functionality in different environments.
2023-12-23 04:50:14 +03:00

67 lines
2.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
if (!DEFINED('EGP'))
exit(header('Refresh: 0; URL=http://' . $_SERVER['HTTP_HOST'] . '/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;
}
}
?>