diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index bf1eea05..8cf61643 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -223,7 +223,7 @@ parameters: path: src/Cli/CronJobs/CacheEngineCronJob.php - - message: '#^Property CacheEngineCronJob\:\:\$rForce is never read, only written\.$#' + message: '#^Property XcVm\\Cli\\CronJobs\\CacheEngineCronJob\:\:\$rForce is never read, only written\.$#' identifier: property.onlyWritten count: 1 path: src/Cli/CronJobs/CacheEngineCronJob.php diff --git a/src/Cli/CommandInterface.php b/src/Cli/CommandInterface.php index be1681f1..78c8d37e 100644 --- a/src/Cli/CommandInterface.php +++ b/src/Cli/CommandInterface.php @@ -1,5 +1,7 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CommandRegistry.php b/src/Cli/CommandRegistry.php index ab78bec4..ef096d49 100644 --- a/src/Cli/CommandRegistry.php +++ b/src/Cli/CommandRegistry.php @@ -1,5 +1,7 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/Commands/ArchiveCommand.php b/src/Cli/Commands/ArchiveCommand.php index eb31c20c..fa39b2b4 100644 --- a/src/Cli/Commands/ArchiveCommand.php +++ b/src/Cli/Commands/ArchiveCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -44,7 +47,7 @@ class ArchiveCommand implements CommandInterface { */ public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } diff --git a/src/Cli/Commands/BinariesCommand.php b/src/Cli/Commands/BinariesCommand.php index 22525f27..a3290a76 100644 --- a/src/Cli/Commands/BinariesCommand.php +++ b/src/Cli/Commands/BinariesCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -63,7 +66,7 @@ class BinariesCommand implements CommandInterface { $gitRelease = new GitHubReleases(GIT_OWNER, GIT_REPO_BIN, $rChannel); $gitRelease->setTimeout(20); $rReleases = $gitRelease->getReleases(); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Failed to check binaries releases: ' . $e->getMessage() . "\n"; return 1; } diff --git a/src/Cli/Commands/CacheHandlerCommand.php b/src/Cli/Commands/CacheHandlerCommand.php index 393015c6..d4d9c03e 100644 --- a/src/Cli/Commands/CacheHandlerCommand.php +++ b/src/Cli/Commands/CacheHandlerCommand.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -116,7 +120,7 @@ class CacheHandlerCommand implements CommandInterface { LineService::updateLineSignal($rUserID); } sleep(1); - } catch (Exception $e) { + } catch (\Exception $e) { echo "Error!\n"; } } diff --git a/src/Cli/Commands/CertbotCommand.php b/src/Cli/Commands/CertbotCommand.php index f953ca69..44df7500 100644 --- a/src/Cli/Commands/CertbotCommand.php +++ b/src/Cli/Commands/CertbotCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/Commands/CreatedCommand.php b/src/Cli/Commands/CreatedCommand.php index e033d737..621a5cfa 100644 --- a/src/Cli/Commands/CreatedCommand.php +++ b/src/Cli/Commands/CreatedCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -27,7 +30,7 @@ class CreatedCommand implements CommandInterface { public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } diff --git a/src/Cli/Commands/DbMigrateCommand.php b/src/Cli/Commands/DbMigrateCommand.php index 4814dc86..f2c2804d 100644 --- a/src/Cli/Commands/DbMigrateCommand.php +++ b/src/Cli/Commands/DbMigrateCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/Commands/DelayCommand.php b/src/Cli/Commands/DelayCommand.php index 039841b8..47ac6de5 100644 --- a/src/Cli/Commands/DelayCommand.php +++ b/src/Cli/Commands/DelayCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -25,7 +28,7 @@ class DelayCommand implements CommandInterface { public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } diff --git a/src/Cli/Commands/LbInstallFlow.php b/src/Cli/Commands/LbInstallFlow.php index 91e3376b..03acd554 100644 --- a/src/Cli/Commands/LbInstallFlow.php +++ b/src/Cli/Commands/LbInstallFlow.php @@ -1,5 +1,7 @@ query('UPDATE `servers` SET `status` = 4 WHERE `id` = ?;', $rServerID); echo "Invalid MD5 checksum! Exiting\n"; @@ -58,7 +60,7 @@ class LbInstallFlow { echo "Extracting to directory\n"; call_user_func($rRunSSH, $rConn, 'sudo rm -rf ' . MAIN_HOME . 'console.php'); - call_user_func($rRunSSH, $rConn, 'sudo tar -zxvf /tmp/XC_VM.tar.gz -C "' . MAIN_HOME . '"'); + call_user_func($rRunSSH, $rConn, 'sudo tar -zxvf /tmp/\XC_VM.tar.gz -C "' . MAIN_HOME . '"'); $rRemoteCheck = trim(call_user_func($rRunSSH, $rConn, 'test -f ' . MAIN_HOME . 'console.php && echo OK')['output']); if ($rRemoteCheck !== 'OK') { $db->query('UPDATE `servers` SET `status` = 4 WHERE `id` = ?;', $rServerID); @@ -66,7 +68,7 @@ class LbInstallFlow { return false; } - call_user_func($rRunSSH, $rConn, 'sudo rm -f "/tmp/XC_VM.tar.gz"'); + call_user_func($rRunSSH, $rConn, 'sudo rm -f "/tmp/\XC_VM.tar.gz"'); return true; } @@ -104,7 +106,7 @@ class LbInstallFlow { } public static function buildConfig(array $rServers, int $rServerID): string { - return '; XC_VM Configuration' . "\n" . '; -----------------' . "\n\n" . '[XC_VM]' . "\n" . 'hostname = "' . $rServers[SERVER_ID]['server_ip'] . '"' . "\n" . 'database = "xc_vm"' . "\n" . 'port = ' . intval(ConfigReader::get('port')) . "\n" . 'server_id = ' . $rServerID . "\n" . 'is_lb = 1' . "\n\n" . '[Encrypted]' . "\n" . 'username = "' . ConfigReader::get('username') . '"' . "\n" . 'password = "' . ConfigReader::get('password') . '"'; + return '; \XC_VM Configuration' . "\n" . '; -----------------' . "\n\n" . '[\XC_VM]' . "\n" . 'hostname = "' . $rServers[SERVER_ID]['server_ip'] . '"' . "\n" . 'database = "xc_vm"' . "\n" . 'port = ' . intval(ConfigReader::get('port')) . "\n" . 'server_id = ' . $rServerID . "\n" . 'is_lb = 1' . "\n\n" . '[Encrypted]' . "\n" . 'username = "' . ConfigReader::get('username') . '"' . "\n" . 'password = "' . ConfigReader::get('password') . '"'; } public static function configureRuntime($rConn, callable $rSendFileSSH, callable $rRunSSH, array $rServers, int $rServerID): int { diff --git a/src/Cli/Commands/LlodCommand.php b/src/Cli/Commands/LlodCommand.php index dd0b0eed..184acf75 100644 --- a/src/Cli/Commands/LlodCommand.php +++ b/src/Cli/Commands/LlodCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -25,7 +28,7 @@ class LlodCommand implements CommandInterface { public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] !== 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } diff --git a/src/Cli/Commands/LoopbackCommand.php b/src/Cli/Commands/LoopbackCommand.php index 423fe993..c6c54c79 100644 --- a/src/Cli/Commands/LoopbackCommand.php +++ b/src/Cli/Commands/LoopbackCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -25,7 +28,7 @@ class LoopbackCommand implements CommandInterface { public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } diff --git a/src/Cli/Commands/MigrateCommand.php b/src/Cli/Commands/MigrateCommand.php index c9fefa27..f925e887 100644 --- a/src/Cli/Commands/MigrateCommand.php +++ b/src/Cli/Commands/MigrateCommand.php @@ -1,12 +1,15 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/Commands/ModuleInstallCommand.php b/src/Cli/Commands/ModuleInstallCommand.php index 1b7faa62..526ee3f6 100644 --- a/src/Cli/Commands/ModuleInstallCommand.php +++ b/src/Cli/Commands/ModuleInstallCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ class ModuleInstallCommand implements CommandInterface { @@ -106,7 +109,7 @@ class ModuleInstallCommand implements CommandInterface { * Pull a custom module archive from MAIN over the internal system API * (action=getFile). Returns the path to a downloaded temp file. * - * @throws RuntimeException If MAIN cannot be located or the download fails. + * @throws \RuntimeException If MAIN cannot be located or the download fails. */ private function fetchArchiveFromMain(string $rArchivePath): string { $rMain = null; @@ -118,7 +121,7 @@ class ModuleInstallCommand implements CommandInterface { } if (!$rMain || empty($rMain['server_ip'])) { - throw new RuntimeException('Could not locate the MAIN server to fetch the module archive.'); + throw new \RuntimeException('Could not locate the MAIN server to fetch the module archive.'); } $rPass = (string) (SettingsManager::getAll()['live_streaming_pass'] ?? ''); @@ -129,7 +132,7 @@ class ModuleInstallCommand implements CommandInterface { $rTmp = rtrim(sys_get_temp_dir(), '/') . '/xc_lbmod_' . bin2hex(random_bytes(8)) . '.zip'; $rFp = @fopen($rTmp, 'wb'); if (!$rFp) { - throw new RuntimeException('Unable to create temporary archive file.'); + throw new \RuntimeException('Unable to create temporary archive file.'); } $rCh = curl_init(); @@ -149,7 +152,7 @@ class ModuleInstallCommand implements CommandInterface { $rMagic = @file_get_contents($rTmp, false, null, 0, 2); if (!$rOk || $rCode < 200 || $rCode >= 300 || $rMagic !== 'PK') { @unlink($rTmp); - throw new RuntimeException("Failed to download module archive from MAIN (HTTP {$rCode})."); + throw new \RuntimeException("Failed to download module archive from MAIN (HTTP {$rCode})."); } return $rTmp; diff --git a/src/Cli/Commands/MonitorCommand.php b/src/Cli/Commands/MonitorCommand.php index 556d44e2..4e16d19f 100644 --- a/src/Cli/Commands/MonitorCommand.php +++ b/src/Cli/Commands/MonitorCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -37,7 +40,7 @@ class MonitorCommand implements CommandInterface { public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } diff --git a/src/Cli/Commands/OndemandCommand.php b/src/Cli/Commands/OndemandCommand.php index 9aae41d5..4307f7d0 100644 --- a/src/Cli/Commands/OndemandCommand.php +++ b/src/Cli/Commands/OndemandCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -28,7 +31,7 @@ class OndemandCommand implements CommandInterface { public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } diff --git a/src/Cli/Commands/ProxyCommand.php b/src/Cli/Commands/ProxyCommand.php index 0d72643e..ca47d09e 100644 --- a/src/Cli/Commands/ProxyCommand.php +++ b/src/Cli/Commands/ProxyCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -27,7 +30,7 @@ class ProxyCommand implements CommandInterface { public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } @@ -96,7 +99,7 @@ class ProxyCommand implements CommandInterface { $rOptions['http']['header'] .= 'Cookie: ' . $rStreamArguments['cookie']['value'] . "\r\n"; } if (SettingsManager::getAll()['request_prebuffer']) { - $rOptions['http']['header'] .= 'X-XC_VM-Prebuffer: 1' . "\r\n"; + $rOptions['http']['header'] .= 'X-\XC_VM-Prebuffer: 1' . "\r\n"; } $rContext = stream_context_create($rOptions); $rURLs = json_decode($rStreamInfo['stream_source'], true); diff --git a/src/Cli/Commands/ProxyInstallFlow.php b/src/Cli/Commands/ProxyInstallFlow.php index 6f61e21b..78a81dde 100644 --- a/src/Cli/Commands/ProxyInstallFlow.php +++ b/src/Cli/Commands/ProxyInstallFlow.php @@ -1,5 +1,7 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/Commands/RecordCommand.php b/src/Cli/Commands/RecordCommand.php index 2d1f1d3f..3f945912 100644 --- a/src/Cli/Commands/RecordCommand.php +++ b/src/Cli/Commands/RecordCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -25,7 +28,7 @@ class RecordCommand implements CommandInterface { public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } diff --git a/src/Cli/Commands/ScannerCommand.php b/src/Cli/Commands/ScannerCommand.php index 8aa3a115..e9781c6d 100644 --- a/src/Cli/Commands/ScannerCommand.php +++ b/src/Cli/Commands/ScannerCommand.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -117,11 +121,11 @@ class ScannerCommand implements CommandInterface { if ($rStreamArguments[$rID]['argument_key'] != 'headers') { continue; } - $rStreamArguments[$rID]['value'] .= "\r\n" . 'X-XC_VM-Detect:1'; + $rStreamArguments[$rID]['value'] .= "\r\n" . 'X-\XC_VM-Detect:1'; $rProcessed = true; } if (!$rProcessed) { - $rStreamArguments[] = array('value' => 'X-XC_VM-Detect:1', 'argument_key' => 'headers', 'argument_cat' => 'fetch', 'argument_wprotocol' => 'http', 'argument_type' => 'text', 'argument_cmd' => "-headers '%s" . "\r\n" . "'"); + $rStreamArguments[] = array('value' => 'X-\XC_VM-Detect:1', 'argument_key' => 'headers', 'argument_cat' => 'fetch', 'argument_wprotocol' => 'http', 'argument_type' => 'text', 'argument_cmd' => "-headers '%s" . "\r\n" . "'"); } } @@ -131,11 +135,11 @@ class ScannerCommand implements CommandInterface { if ($rStreamArguments[$rID]['argument_key'] != 'headers') { continue; } - $rStreamArguments[$rID]['value'] .= "\r\n" . 'X-XC_VM-Prebuffer:1'; + $rStreamArguments[$rID]['value'] .= "\r\n" . 'X-\XC_VM-Prebuffer:1'; $rProcessed = true; } if (!$rProcessed) { - $rStreamArguments[] = array('value' => 'X-XC_VM-Prebuffer:1', 'argument_key' => 'headers', 'argument_cat' => 'fetch', 'argument_wprotocol' => 'http', 'argument_type' => 'text', 'argument_cmd' => "-headers '%s" . "\r\n" . "'"); + $rStreamArguments[] = array('value' => 'X-\XC_VM-Prebuffer:1', 'argument_key' => 'headers', 'argument_cat' => 'fetch', 'argument_wprotocol' => 'http', 'argument_type' => 'text', 'argument_cmd' => "-headers '%s" . "\r\n" . "'"); } } diff --git a/src/Cli/Commands/ServerInstallCommand.php b/src/Cli/Commands/ServerInstallCommand.php index 5abc4053..5f758091 100644 --- a/src/Cli/Commands/ServerInstallCommand.php +++ b/src/Cli/Commands/ServerInstallCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -31,7 +34,7 @@ class ServerInstallCommand implements CommandInterface { public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } @@ -69,7 +72,7 @@ class ServerInstallCommand implements CommandInterface { $rUpdateSysctl = (empty($rArgs[7]) ? 0 : intval($rArgs[7])); $rPrivateIP = (empty($rArgs[8]) ? 0 : intval($rArgs[8])); $rParentIDs = (empty($rArgs[9]) ? array() : json_decode($rArgs[9], true)); - $rSysCtl = '# XC_VM' . PHP_EOL . PHP_EOL . 'net.ipv4.tcp_congestion_control = bbr' . PHP_EOL . 'net.core.default_qdisc = fq' . PHP_EOL . 'net.ipv4.tcp_rmem = 8192 87380 134217728' . PHP_EOL . 'net.ipv4.udp_rmem_min = 16384' . PHP_EOL . 'net.core.rmem_default = 262144' . PHP_EOL . 'net.core.rmem_max = 268435456' . PHP_EOL . 'net.ipv4.tcp_wmem = 8192 65536 134217728' . PHP_EOL . 'net.ipv4.udp_wmem_min = 16384' . PHP_EOL . 'net.core.wmem_default = 262144' . PHP_EOL . 'net.core.wmem_max = 268435456' . PHP_EOL . 'net.core.somaxconn = 1000000' . PHP_EOL . 'net.core.netdev_max_backlog = 250000' . PHP_EOL . 'net.core.optmem_max = 65535' . PHP_EOL . 'net.ipv4.tcp_max_tw_buckets = 1440000' . PHP_EOL . 'net.ipv4.tcp_max_orphans = 16384' . PHP_EOL . 'net.ipv4.ip_local_port_range = 2000 65000' . PHP_EOL . 'net.ipv4.tcp_no_metrics_save = 1' . PHP_EOL . 'net.ipv4.tcp_slow_start_after_idle = 0' . PHP_EOL . 'net.ipv4.tcp_fin_timeout = 15' . PHP_EOL . 'net.ipv4.tcp_keepalive_time = 300' . PHP_EOL . 'net.ipv4.tcp_keepalive_probes = 5' . PHP_EOL . 'net.ipv4.tcp_keepalive_intvl = 15' . PHP_EOL . 'fs.file-max=20970800' . PHP_EOL . 'fs.nr_open=20970800' . PHP_EOL . 'fs.aio-max-nr=20970800' . PHP_EOL . 'net.ipv4.tcp_timestamps = 1' . PHP_EOL . 'net.ipv4.tcp_window_scaling = 1' . PHP_EOL . 'net.ipv4.tcp_mtu_probing = 1' . PHP_EOL . 'net.ipv4.route.flush = 1' . PHP_EOL . 'net.ipv6.route.flush = 1'; + $rSysCtl = '# \XC_VM' . PHP_EOL . PHP_EOL . 'net.ipv4.tcp_congestion_control = bbr' . PHP_EOL . 'net.core.default_qdisc = fq' . PHP_EOL . 'net.ipv4.tcp_rmem = 8192 87380 134217728' . PHP_EOL . 'net.ipv4.udp_rmem_min = 16384' . PHP_EOL . 'net.core.rmem_default = 262144' . PHP_EOL . 'net.core.rmem_max = 268435456' . PHP_EOL . 'net.ipv4.tcp_wmem = 8192 65536 134217728' . PHP_EOL . 'net.ipv4.udp_wmem_min = 16384' . PHP_EOL . 'net.core.wmem_default = 262144' . PHP_EOL . 'net.core.wmem_max = 268435456' . PHP_EOL . 'net.core.somaxconn = 1000000' . PHP_EOL . 'net.core.netdev_max_backlog = 250000' . PHP_EOL . 'net.core.optmem_max = 65535' . PHP_EOL . 'net.ipv4.tcp_max_tw_buckets = 1440000' . PHP_EOL . 'net.ipv4.tcp_max_orphans = 16384' . PHP_EOL . 'net.ipv4.ip_local_port_range = 2000 65000' . PHP_EOL . 'net.ipv4.tcp_no_metrics_save = 1' . PHP_EOL . 'net.ipv4.tcp_slow_start_after_idle = 0' . PHP_EOL . 'net.ipv4.tcp_fin_timeout = 15' . PHP_EOL . 'net.ipv4.tcp_keepalive_time = 300' . PHP_EOL . 'net.ipv4.tcp_keepalive_probes = 5' . PHP_EOL . 'net.ipv4.tcp_keepalive_intvl = 15' . PHP_EOL . 'fs.file-max=20970800' . PHP_EOL . 'fs.nr_open=20970800' . PHP_EOL . 'fs.aio-max-nr=20970800' . PHP_EOL . 'net.ipv4.tcp_timestamps = 1' . PHP_EOL . 'net.ipv4.tcp_window_scaling = 1' . PHP_EOL . 'net.ipv4.tcp_mtu_probing = 1' . PHP_EOL . 'net.ipv4.route.flush = 1' . PHP_EOL . 'net.ipv6.route.flush = 1'; $rInstallDir = BIN_PATH . 'install/'; if ($rType == 1) { @@ -180,7 +183,7 @@ class ServerInstallCommand implements CommandInterface { } private function updateSystemAndInstallPackages($rConn, callable $rRunSSH, array $rPackages, int $rType): void { - echo "\nStopping any previous version of XC_VM\n"; + echo "\nStopping any previous version of \XC_VM\n"; call_user_func($rRunSSH, $rConn, 'sudo systemctl stop xc_vm'); call_user_func($rRunSSH, $rConn, 'sudo killall -9 -u xc_vm'); @@ -213,7 +216,7 @@ class ServerInstallCommand implements CommandInterface { return; } - echo "Creating XC_VM system user\n"; + echo "Creating \XC_VM system user\n"; call_user_func($rRunSSH, $rConn, 'sudo adduser --system --shell /bin/false --group --disabled-login xc_vm'); call_user_func($rRunSSH, $rConn, 'sudo mkdir ' . MAIN_HOME); call_user_func($rRunSSH, $rConn, 'sudo rm -rf ' . BIN_PATH); @@ -222,7 +225,7 @@ class ServerInstallCommand implements CommandInterface { private function installSystemdService($rConn, callable $rRunSSH, callable $rSendFileSSH, int $rServerID): void { echo "Installing service\n"; call_user_func($rRunSSH, $rConn, 'sudo rm /etc/systemd/system/xc_vm.service'); - $rSystemd = '[Unit]' . "\n" . 'SourcePath=/home/xc_vm/service' . "\n" . 'Description=XC_VM Service' . "\n" . 'After=network.target' . "\n" . 'StartLimitIntervalSec=0' . "\n\n" . '[Service]' . "\n" . 'Type=simple' . "\n" . 'User=root' . "\n" . 'Restart=always' . "\n" . 'RestartSec=1' . "\n" . 'ExecStart=/bin/bash /home/xc_vm/service start' . "\n" . 'ExecRestart=/bin/bash /home/xc_vm/service restart' . "\n" . 'ExecStop=/bin/bash /home/xc_vm/service stop' . "\n\n" . '[Install]' . "\n" . 'WantedBy=multi-user.target'; + $rSystemd = '[Unit]' . "\n" . 'SourcePath=/home/xc_vm/service' . "\n" . 'Description=\XC_VM Service' . "\n" . 'After=network.target' . "\n" . 'StartLimitIntervalSec=0' . "\n\n" . '[Service]' . "\n" . 'Type=simple' . "\n" . 'User=root' . "\n" . 'Restart=always' . "\n" . 'RestartSec=1' . "\n" . 'ExecStart=/bin/bash /home/xc_vm/service start' . "\n" . 'ExecRestart=/bin/bash /home/xc_vm/service restart' . "\n" . 'ExecStop=/bin/bash /home/xc_vm/service stop' . "\n\n" . '[Install]' . "\n" . 'WantedBy=multi-user.target'; file_put_contents(TMP_PATH . 'systemd_' . $rServerID, $rSystemd); call_user_func($rSendFileSSH, $rConn, TMP_PATH . 'systemd_' . $rServerID, '/etc/systemd/system/xc_vm.service', false); call_user_func($rRunSSH, $rConn, 'sudo chmod +x /etc/systemd/system/xc_vm.service'); @@ -251,7 +254,7 @@ class ServerInstallCommand implements CommandInterface { call_user_func($rRunSSH, $rConn, 'sudo chown -R xc_vm:xc_vm ' . MAIN_HOME . 'content/streams'); call_user_func($rRunSSH, $rConn, 'sudo chown -R xc_vm:xc_vm ' . MAIN_HOME); BackupService::grantPrivileges($rHost); - echo "Installation complete! Starting XC_VM\n"; + echo "Installation complete! Starting \XC_VM\n"; call_user_func($rRunSSH, $rConn, 'sudo service xc_vm restart'); } @@ -282,7 +285,7 @@ class ServerInstallCommand implements CommandInterface { if (is_resource($rStream)) { fclose($rStream); } - } catch (Exception $e) { + } catch (\Exception $e) { $rSuccess = false; if (is_resource($rStream)) { fclose($rStream); diff --git a/src/Cli/Commands/ServiceCommand.php b/src/Cli/Commands/ServiceCommand.php index adbba28c..deaf584a 100644 --- a/src/Cli/Commands/ServiceCommand.php +++ b/src/Cli/Commands/ServiceCommand.php @@ -1,7 +1,10 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -23,7 +26,7 @@ class ServiceCommand implements CommandInterface { } public function getDescription(): string { - return 'Manage XC_VM service: start, stop, restart, reload'; + return 'Manage \XC_VM service: start, stop, restart, reload'; } public function execute(array $rArgs): int { @@ -56,7 +59,7 @@ class ServiceCommand implements CommandInterface { return 1; } - echo "Starting XC_VM...\n"; + echo "Starting \XC_VM...\n"; exec('sudo chown -R xc_vm:xc_vm /sys/class/net'); exec('sudo chown -R xc_vm:xc_vm ' . MAIN_HOME . 'content/streams'); @@ -89,7 +92,7 @@ class ServiceCommand implements CommandInterface { return 1; } - echo "Stopping XC_VM...\n"; + echo "Stopping \XC_VM...\n"; exec('sudo killall -u xc_vm'); sleep(1); exec('sudo killall -u xc_vm'); @@ -110,7 +113,7 @@ class ServiceCommand implements CommandInterface { return 1; } - echo "Reloading XC_VM...\n"; + echo "Reloading \XC_VM...\n"; exec('sudo -u xc_vm ' . MAIN_HOME . 'bin/nginx/sbin/nginx -s reload'); exec('sudo -u xc_vm ' . MAIN_HOME . 'bin/nginx_rtmp/sbin/nginx_rtmp -s reload'); return 0; diff --git a/src/Cli/Commands/SignalsCommand.php b/src/Cli/Commands/SignalsCommand.php index e36a4e49..a8d122f5 100644 --- a/src/Cli/Commands/SignalsCommand.php +++ b/src/Cli/Commands/SignalsCommand.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/Commands/StartupCommand.php b/src/Cli/Commands/StartupCommand.php index 6bdd77c2..519c0500 100644 --- a/src/Cli/Commands/StartupCommand.php +++ b/src/Cli/Commands/StartupCommand.php @@ -1,5 +1,11 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -26,8 +32,8 @@ class StartupCommand implements CommandInterface { public function execute(array $rArgs): int { // Сброс кэша автозагрузки — гарантирует актуальную карту классов после обновления - XC_Autoloader::clearCache(); - XC_Autoloader::warmCache(); + \XC_Autoloader::clearCache(); + \XC_Autoloader::warmCache(); $rFixCron = false; if (!empty($rArgs[0]) && intval($rArgs[0]) == 1) { @@ -88,15 +94,15 @@ class StartupCommand implements CommandInterface { private function installRootCrontab(): void { $rCrons = array(); - $rCrons[] = '* * * * * ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:root_signals # XC_VM'; + $rCrons[] = '* * * * * ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:root_signals # \XC_VM'; if (file_exists(MAIN_HOME . 'Cli/CronJobs/RootMysqlCronJob.php')) { - $rCrons[] = '* * * * * ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:root_mysql # XC_VM'; + $rCrons[] = '* * * * * ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:root_mysql # \XC_VM'; } // Renew per-machine ionCube licenses for platform modules before they // expire (runs as xc_vm so the .lic is owned by the panel user). No-op // when no licensed modules are installed. if (file_exists(MAIN_HOME . 'Cli/CronJobs/ModuleLicensesCronJob.php')) { - $rCrons[] = '17 3 * * * sudo -u xc_vm ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:module_licenses # XC_VM'; + $rCrons[] = '17 3 * * * sudo -u xc_vm ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:module_licenses # \XC_VM'; } foreach ((new ModuleLoader())->loadAll()->collectCronEntries() as $rEntry) { @@ -107,7 +113,7 @@ class StartupCommand implements CommandInterface { $rOutput = array(); exec('sudo crontab -l', $rOutput); - // Удаляем старые записи от XC_VM v1.x.x, чтобы не было дубликатов, и проверяем наличие нужных записей + // Удаляем старые записи от \XC_VM v1.x.x, чтобы не было дубликатов, и проверяем наличие нужных записей $rFiltered = array(); foreach ($rOutput as $rLine) { if (strpos($rLine, MAIN_HOME . 'crons/root_') !== false) { diff --git a/src/Cli/Commands/StatusCommand.php b/src/Cli/Commands/StatusCommand.php index 8db1d8ed..2ea681a6 100644 --- a/src/Cli/Commands/StatusCommand.php +++ b/src/Cli/Commands/StatusCommand.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -171,9 +175,9 @@ class StatusCommand implements CommandInterface { private function installRootCrontab(): void { $rCrons = array(); - $rCrons[] = '* * * * * ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:root_signals # XC_VM'; + $rCrons[] = '* * * * * ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:root_signals # \XC_VM'; if (file_exists(MAIN_HOME . 'Cli/CronJobs/RootMysqlCronJob.php')) { - $rCrons[] = '* * * * * ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:root_mysql # XC_VM'; + $rCrons[] = '* * * * * ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:root_mysql # \XC_VM'; } foreach ((new ModuleLoader())->loadAll()->collectCronEntries() as $rEntry) { @@ -337,7 +341,7 @@ class StatusCommand implements CommandInterface { } if ($rOffline === 0) { - echo "All servers are Online and reporting back to XC_VM!\n\n"; + echo "All servers are Online and reporting back to \XC_VM!\n\n"; } else { echo "\n"; } diff --git a/src/Cli/Commands/ThumbnailCommand.php b/src/Cli/Commands/ThumbnailCommand.php index 75e3ccd6..6ace3850 100644 --- a/src/Cli/Commands/ThumbnailCommand.php +++ b/src/Cli/Commands/ThumbnailCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -25,7 +28,7 @@ class ThumbnailCommand implements CommandInterface { public function execute(array $rArgs): int { if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } diff --git a/src/Cli/Commands/ToolsCommand.php b/src/Cli/Commands/ToolsCommand.php index f3f5ca4b..739d7956 100644 --- a/src/Cli/Commands/ToolsCommand.php +++ b/src/Cli/Commands/ToolsCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -82,7 +85,7 @@ class ToolsCommand implements CommandInterface { // xc_vm subcommands if ($rUser !== 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return 1; } @@ -115,7 +118,7 @@ class ToolsCommand implements CommandInterface { $rExtension = strtolower(pathinfo($database, PATHINFO_EXTENSION)); if ($rExtension === 'sql') { echo 'Restoring: ' . $database . "\n"; - XC_VM::db_restore($database, 'xc_vm_migrate'); + \XC_VM::db_restore($database, 'xc_vm_migrate'); echo "Restore started in the background.\n\n"; } else { echo "Error: File must have .sql extension\n"; @@ -197,7 +200,7 @@ class ToolsCommand implements CommandInterface { echo " migration Clear migration database and optionally restore .sql backup\n"; echo " user Create a rescue admin user for the admin panel\n"; echo " mysql Reauthorise load balancers on MySQL\n"; - echo " database Restore blank XC_VM database (requires --confirm)\n"; + echo " database Restore blank \XC_VM database (requires --confirm)\n"; echo " flush Flush all blocked IPs (iptables + database)\n"; } @@ -312,7 +315,7 @@ class ToolsCommand implements CommandInterface { $rImages[] = $rProperties['backdrop_path'][0]; } } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -336,7 +339,7 @@ class ToolsCommand implements CommandInterface { $rImages[] = $rResult['cover_big']; } } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } diff --git a/src/Cli/Commands/UpdateCommand.php b/src/Cli/Commands/UpdateCommand.php index 41c4ab2e..8e2378d7 100644 --- a/src/Cli/Commands/UpdateCommand.php +++ b/src/Cli/Commands/UpdateCommand.php @@ -1,5 +1,8 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/Commands/WatchdogCommand.php b/src/Cli/Commands/WatchdogCommand.php index 752d6bd3..bbe10b8e 100644 --- a/src/Cli/Commands/WatchdogCommand.php +++ b/src/Cli/Commands/WatchdogCommand.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/ActivityCronJob.php b/src/Cli/CronJobs/ActivityCronJob.php index 2680f5cb..274c6635 100644 --- a/src/Cli/CronJobs/ActivityCronJob.php +++ b/src/Cli/CronJobs/ActivityCronJob.php @@ -1,12 +1,16 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/BackupsCronJob.php b/src/Cli/CronJobs/BackupsCronJob.php index 04bb8341..70cdf0fb 100644 --- a/src/Cli/CronJobs/BackupsCronJob.php +++ b/src/Cli/CronJobs/BackupsCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -85,7 +89,7 @@ class BackupsCronJob implements CommandInterface { } else { try { $rError = json_decode(explode(', in apiCall', $rResponse->error->getMessage())[0], true)['error_summary']; - } catch (exception $e) { + } catch (\exception $e) { $rError = 'Unknown error'; } file_put_contents($rFilename . '.error', $rError); @@ -115,7 +119,7 @@ class BackupsCronJob implements CommandInterface { foreach ($rDelete as $rItem) { try { BackupService::deleteRemote($rItem['path']); - } catch (exception $e) { + } catch (\exception $e) { } } } diff --git a/src/Cli/CronJobs/CacheCronJob.php b/src/Cli/CronJobs/CacheCronJob.php index 8b77d719..e646bc41 100644 --- a/src/Cli/CronJobs/CacheCronJob.php +++ b/src/Cli/CronJobs/CacheCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -275,7 +279,7 @@ class CacheCronJob implements CommandInterface { $db->query('SELECT `id`, `category_id` FROM `streams`;'); if ($db->dbh && $db->result) { if ($db->result->rowCount() > 0) { - foreach ($db->result->fetchAll(PDO::FETCH_ASSOC) as $rStreamInfo) { + foreach ($db->result->fetchAll(\PDO::FETCH_ASSOC) as $rStreamInfo) { $rCategoryChannels[$rStreamInfo['id']] = json_decode($rStreamInfo['category_id'] ?? '[]', true); } } diff --git a/src/Cli/CronJobs/CacheEngineCronJob.php b/src/Cli/CronJobs/CacheEngineCronJob.php index 23e80c1b..1b1904c9 100644 --- a/src/Cli/CronJobs/CacheEngineCronJob.php +++ b/src/Cli/CronJobs/CacheEngineCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -85,7 +89,7 @@ class CacheEngineCronJob implements CommandInterface { $db->query('SELECT `id`, GREATEST(IFNULL(UNIX_TIMESTAMP(`streams`.`updated`), 0), IFNULL(MAX(UNIX_TIMESTAMP(`streams_servers`.`updated`)), 0)) AS `updated` FROM `streams` LEFT JOIN `streams_servers` ON `streams`.`id` = `streams_servers`.`stream_id` GROUP BY `id`;'); if ($db->dbh && $db->result) { if ($db->result->rowCount() > 0) { - foreach ($db->result->fetchAll(PDO::FETCH_ASSOC) as $rRow) { + foreach ($db->result->fetchAll(\PDO::FETCH_ASSOC) as $rRow) { if (!file_exists(STREAMS_TMP_PATH . 'stream_' . $rRow['id']) || (filemtime(STREAMS_TMP_PATH . 'stream_' . $rRow['id']) ?: 0) < $rRow['updated']) { $rReturn['changes'][] = $rRow['id']; } @@ -114,7 +118,7 @@ class CacheEngineCronJob implements CommandInterface { $db->query('SELECT `id`, `username`, `password`, `access_token`, UNIX_TIMESTAMP(`updated`) AS `updated` FROM `lines`;'); if ($db->dbh && $db->result) { if ($db->result->rowCount() > 0) { - foreach ($db->result->fetchAll(PDO::FETCH_ASSOC) as $rRow) { + foreach ($db->result->fetchAll(\PDO::FETCH_ASSOC) as $rRow) { if (!file_exists(LINES_TMP_PATH . 'line_i_' . $rRow['id']) || (filemtime(LINES_TMP_PATH . 'line_i_' . $rRow['id']) ?: 0) < $rRow['updated']) { $rReturn['changes'][] = $rRow['id']; } @@ -189,7 +193,7 @@ class CacheEngineCronJob implements CommandInterface { $db->query('SELECT * FROM `streams_series`;'); if ($db->result) { if ($db->result->rowCount() > 0) { - foreach ($db->result->fetchAll(PDO::FETCH_ASSOC) as $rRow) { + foreach ($db->result->fetchAll(\PDO::FETCH_ASSOC) as $rRow) { if (isset($cacheInitTime[$rRow['id']])) { $rRow['last_modified'] = $cacheInitTime[$rRow['id']]; } @@ -392,7 +396,7 @@ class CacheEngineCronJob implements CommandInterface { } if ($db->result) { if ($db->result->rowCount() > 0) { - foreach ($db->result->fetchAll(PDO::FETCH_ASSOC) as $rUserInfo) { + foreach ($db->result->fetchAll(\PDO::FETCH_ASSOC) as $rUserInfo) { $rExists[] = $rUserInfo['id']; file_put_contents(LINES_TMP_PATH . 'line_i_' . $rUserInfo['id'], igbinary_serialize($rUserInfo)); $rKey = (SettingsManager::getAll()['case_sensitive_line'] ? $rUserInfo['username'] . '_' . $rUserInfo['password'] : strtolower($rUserInfo['username'] . '_' . $rUserInfo['password'])); @@ -451,7 +455,7 @@ class CacheEngineCronJob implements CommandInterface { } if ($db->result) { if ($db->result->rowCount() > 0) { - $rRows = $db->result->fetchAll(PDO::FETCH_ASSOC); + $rRows = $db->result->fetchAll(\PDO::FETCH_ASSOC); $rStreamMap = $rStreamIDs = []; foreach ($rRows as $rRow) { $rStreamIDs[] = $rRow['id']; @@ -460,7 +464,7 @@ class CacheEngineCronJob implements CommandInterface { $db->query('SELECT `stream_id`, `server_id`, `pid`, `to_analyze`, `stream_status`, `monitor_pid`, `on_demand`, `delay_available_at`, `bitrate`, `parent_id`, `on_demand`, `stream_info`, `video_codec`, `audio_codec`, `resolution`, `compatible` FROM `streams_servers` WHERE `stream_id` IN (' . implode(',', $rStreamIDs) . ')'); if ($db->result) { if ($db->result->rowCount() > 0) { - foreach ($db->result->fetchAll(PDO::FETCH_ASSOC) as $rRow) { + foreach ($db->result->fetchAll(\PDO::FETCH_ASSOC) as $rRow) { $rStreamMap[intval($rRow['stream_id'])][intval($rRow['server_id'])] = $rRow; } } diff --git a/src/Cli/CronJobs/CertbotCronJob.php b/src/Cli/CronJobs/CertbotCronJob.php index a056344b..2ddddfb9 100644 --- a/src/Cli/CronJobs/CertbotCronJob.php +++ b/src/Cli/CronJobs/CertbotCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/CleanupCronJob.php b/src/Cli/CronJobs/CleanupCronJob.php index 77363ecf..d5daa861 100644 --- a/src/Cli/CronJobs/CleanupCronJob.php +++ b/src/Cli/CronJobs/CleanupCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/EpgCronJob.php b/src/Cli/CronJobs/EpgCronJob.php index e45b5c56..752dcd54 100644 --- a/src/Cli/CronJobs/EpgCronJob.php +++ b/src/Cli/CronJobs/EpgCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -38,7 +42,7 @@ class EpgCronJob implements CommandInterface { $rEPGID = intval($rArgs[0]); } - $this->printLog("=== XC_VM[EPG] Process started ==="); + $this->printLog("=== \XC_VM[EPG] Process started ==="); $this->printLog("Mode: " . ($rEPGID ? "Single EPG ID: $rEPGID" : "Full update")); set_time_limit(0); diff --git a/src/Cli/CronJobs/ErrorsCronJob.php b/src/Cli/CronJobs/ErrorsCronJob.php index 31cad039..64cf5b02 100644 --- a/src/Cli/CronJobs/ErrorsCronJob.php +++ b/src/Cli/CronJobs/ErrorsCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/LinesLogsCronJob.php b/src/Cli/CronJobs/LinesLogsCronJob.php index 41e8249c..398f1f95 100644 --- a/src/Cli/CronJobs/LinesLogsCronJob.php +++ b/src/Cli/CronJobs/LinesLogsCronJob.php @@ -1,12 +1,16 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/MaxMindCronJob.php b/src/Cli/CronJobs/MaxMindCronJob.php index 049aecd3..2028ac18 100644 --- a/src/Cli/CronJobs/MaxMindCronJob.php +++ b/src/Cli/CronJobs/MaxMindCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/RootMysqlCronJob.php b/src/Cli/CronJobs/RootMysqlCronJob.php index 0e07cd4e..0831f1f0 100644 --- a/src/Cli/CronJobs/RootMysqlCronJob.php +++ b/src/Cli/CronJobs/RootMysqlCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/RootSignalsCronJob.php b/src/Cli/CronJobs/RootSignalsCronJob.php index 4b441d1a..859b0250 100644 --- a/src/Cli/CronJobs/RootSignalsCronJob.php +++ b/src/Cli/CronJobs/RootSignalsCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -256,7 +260,7 @@ class RootSignalsCronJob implements CommandInterface { $rXC_VMList = trim(implode("\n", array_unique($rXC_VMList))); $rCurrentList = (trim(file_get_contents(BIN_PATH . 'nginx/conf/realip_xc_vm.conf')) ?: ''); if ($rXC_VMList != $rCurrentList) { - echo 'Updating XC_VM IP List...' . "\n"; + echo 'Updating \XC_VM IP List...' . "\n"; file_put_contents(BIN_PATH . 'nginx/conf/realip_xc_vm.conf', $rXC_VMList); $rReload = true; } @@ -444,7 +448,7 @@ class RootSignalsCronJob implements CommandInterface { $rJobs = []; $db->query('SELECT * FROM `crontab` WHERE `enabled` = 1;'); foreach ($db->get_rows() as $rRow) { - $rJobs[] = $rRow['time'] . ' ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:' . $rRow['filename'] . ' # XC_VM'; + $rJobs[] = $rRow['time'] . ' ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php cron:' . $rRow['filename'] . ' # \XC_VM'; } $rActualCron = trim(implode("\n", $rJobs)); if ($rCurrentCron != $rActualCron) { @@ -455,10 +459,10 @@ class RootSignalsCronJob implements CommandInterface { } } if (file_exists(CONFIG_PATH . 'sysctl.on')) { - if (strtoupper(substr(explode("\n", file_get_contents('/etc/sysctl.conf'))[0], 0, 9)) != '# XC_VM') { + if (strtoupper(substr(explode("\n", file_get_contents('/etc/sysctl.conf'))[0], 0, 9)) != '# \XC_VM') { echo 'Sysctl missing! Writing it.' . "\n"; exec('sudo modprobe ip_conntrack'); - file_put_contents('/etc/sysctl.conf', implode(PHP_EOL, ['# XC_VM', '', 'net.core.somaxconn = 655350', 'net.ipv4.route.flush=1', 'net.ipv4.tcp_no_metrics_save=1', 'net.ipv4.tcp_moderate_rcvbuf = 1', 'fs.file-max = 6815744', 'fs.aio-max-nr = 6815744', 'fs.nr_open = 6815744', 'net.ipv4.ip_local_port_range = 1024 65000', 'net.ipv4.tcp_sack = 1', 'net.ipv4.tcp_rmem = 10000000 10000000 10000000', 'net.ipv4.tcp_wmem = 10000000 10000000 10000000', 'net.ipv4.tcp_mem = 10000000 10000000 10000000', 'net.core.rmem_max = 524287', 'net.core.wmem_max = 524287', 'net.core.rmem_default = 524287', 'net.core.wmem_default = 524287', 'net.core.optmem_max = 524287', 'net.core.netdev_max_backlog = 300000', 'net.ipv4.tcp_max_syn_backlog = 300000', 'net.netfilter.nf_conntrack_max=1215196608', 'net.ipv4.tcp_window_scaling = 1', 'vm.max_map_count = 655300', 'net.ipv4.tcp_max_tw_buckets = 50000', 'net.ipv6.conf.all.disable_ipv6 = 1', 'net.ipv6.conf.default.disable_ipv6 = 1', 'net.ipv6.conf.lo.disable_ipv6 = 1', 'kernel.shmmax=134217728', 'kernel.shmall=134217728', 'vm.overcommit_memory = 1', 'net.ipv4.tcp_tw_reuse=1'])); + file_put_contents('/etc/sysctl.conf', implode(PHP_EOL, ['# \XC_VM', '', 'net.core.somaxconn = 655350', 'net.ipv4.route.flush=1', 'net.ipv4.tcp_no_metrics_save=1', 'net.ipv4.tcp_moderate_rcvbuf = 1', 'fs.file-max = 6815744', 'fs.aio-max-nr = 6815744', 'fs.nr_open = 6815744', 'net.ipv4.ip_local_port_range = 1024 65000', 'net.ipv4.tcp_sack = 1', 'net.ipv4.tcp_rmem = 10000000 10000000 10000000', 'net.ipv4.tcp_wmem = 10000000 10000000 10000000', 'net.ipv4.tcp_mem = 10000000 10000000 10000000', 'net.core.rmem_max = 524287', 'net.core.wmem_max = 524287', 'net.core.rmem_default = 524287', 'net.core.wmem_default = 524287', 'net.core.optmem_max = 524287', 'net.core.netdev_max_backlog = 300000', 'net.ipv4.tcp_max_syn_backlog = 300000', 'net.netfilter.nf_conntrack_max=1215196608', 'net.ipv4.tcp_window_scaling = 1', 'vm.max_map_count = 655300', 'net.ipv4.tcp_max_tw_buckets = 50000', 'net.ipv6.conf.all.disable_ipv6 = 1', 'net.ipv6.conf.default.disable_ipv6 = 1', 'net.ipv6.conf.lo.disable_ipv6 = 1', 'kernel.shmmax=134217728', 'kernel.shmall=134217728', 'vm.overcommit_memory = 1', 'net.ipv4.tcp_tw_reuse=1'])); exec('sudo sysctl -p > /dev/null'); } } @@ -527,7 +531,7 @@ class RootSignalsCronJob implements CommandInterface { break; case 'update_binaries': echo 'Updating binaries...' . "\n"; - $db->query("INSERT INTO `mysql_syslog`(`server_id`, `type`, `error`, `username`, `ip`, `database`, `date`) VALUES(?, 'BINARIES', 'Updating XC_VM binaries from XC_VM server...', 'root', 'localhost', NULL, ?);", SERVER_ID, time()); + $db->query("INSERT INTO `mysql_syslog`(`server_id`, `type`, `error`, `username`, `ip`, `database`, `date`) VALUES(?, 'BINARIES', 'Updating \XC_VM binaries from \XC_VM server...', 'root', 'localhost', NULL, ?);", SERVER_ID, time()); shell_exec('sudo ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php binaries 2>&1 &'); break; case 'install_module': @@ -537,7 +541,7 @@ class RootSignalsCronJob implements CommandInterface { break; case 'update': echo 'Updating...' . "\n"; - $db->query("INSERT INTO `mysql_syslog`(`server_id`, `type`, `error`, `username`, `ip`, `database`, `date`) VALUES(?, 'UPDATE', 'Updating XC_VM...', 'root', 'localhost', NULL, ?);", SERVER_ID, time()); + $db->query("INSERT INTO `mysql_syslog`(`server_id`, `type`, `error`, `username`, `ip`, `database`, `date`) VALUES(?, 'UPDATE', 'Updating \XC_VM...', 'root', 'localhost', NULL, ?);", SERVER_ID, time()); shell_exec('sudo ' . PHP_BIN . ' ' . MAIN_HOME . 'console.php update update 2>&1 &'); break; case 'set_services': diff --git a/src/Cli/CronJobs/SeriesCronJob.php b/src/Cli/CronJobs/SeriesCronJob.php index 0d2a6273..14d421bf 100644 --- a/src/Cli/CronJobs/SeriesCronJob.php +++ b/src/Cli/CronJobs/SeriesCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/ServersCronJob.php b/src/Cli/CronJobs/ServersCronJob.php index d4119be2..6dd469be 100644 --- a/src/Cli/CronJobs/ServersCronJob.php +++ b/src/Cli/CronJobs/ServersCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -72,18 +76,18 @@ class ServersCronJob implements CommandInterface { } } - $rSignals = intval(trim(shell_exec('pgrep -U xc_vm | xargs ps -f -p | grep -E "signals|XC_VM\\[Signals\\]" | grep -v grep | grep -v pgrep | wc -l'))); + $rSignals = intval(trim(shell_exec('pgrep -U xc_vm | xargs ps -f -p | grep -E "signals|\XC_VM\\[Signals\\]" | grep -v grep | grep -v pgrep | wc -l'))); if ($rSignals == 0) { shell_exec(PHP_BIN . ' ' . MAIN_HOME . 'console.php signals > /dev/null 2>/dev/null &'); } if ($rServers[SERVER_ID]['is_main']) { - $rCache = intval(trim(shell_exec('pgrep -U xc_vm | xargs ps -f -p | grep -E "cache_handler|XC_VM\\[CacheHandler\\]" | grep -v grep | grep -v pgrep | wc -l'))); + $rCache = intval(trim(shell_exec('pgrep -U xc_vm | xargs ps -f -p | grep -E "cache_handler|\XC_VM\\[CacheHandler\\]" | grep -v grep | grep -v pgrep | wc -l'))); if (SettingsManager::getAll()['enable_cache'] && $rCache == 0) { shell_exec(PHP_BIN . ' ' . MAIN_HOME . 'console.php cache_handler > /dev/null 2>/dev/null &'); } elseif (!SettingsManager::getAll()['enable_cache'] && $rCache > 0) { echo 'Killing Cache Handler' . "\n"; - exec("pgrep -U xc_vm | xargs ps | grep -E 'cache_handler|XC_VM\\[CacheHandler\\]' | awk '{print \$1}'", $rPIDs); + exec("pgrep -U xc_vm | xargs ps | grep -E 'cache_handler|\XC_VM\\[CacheHandler\\]' | awk '{print \$1}'", $rPIDs); foreach ($rPIDs as $rPID) { if (intval($rPID) > 0) { shell_exec('kill -9 ' . intval($rPID)); @@ -97,12 +101,12 @@ class ServersCronJob implements CommandInterface { shell_exec(BIN_PATH . 'network > /dev/null 2>/dev/null &'); } - $rWatchdog = intval(trim(shell_exec('pgrep -U xc_vm | xargs ps -f -p | grep -E "watchdog|XC_VM\\[Watchdog\\]" | grep -v grep | grep -v pgrep | wc -l'))); + $rWatchdog = intval(trim(shell_exec('pgrep -U xc_vm | xargs ps -f -p | grep -E "watchdog|\XC_VM\\[Watchdog\\]" | grep -v grep | grep -v pgrep | wc -l'))); if ($rWatchdog == 0) { shell_exec(PHP_BIN . ' ' . MAIN_HOME . 'console.php watchdog > /dev/null 2>/dev/null &'); } - $rQueue = intval(trim(shell_exec('pgrep -U xc_vm | xargs ps -f -p | grep -E "queue|XC_VM\\[Queue\\]" | grep -v grep | grep -v pgrep | wc -l'))); + $rQueue = intval(trim(shell_exec('pgrep -U xc_vm | xargs ps -f -p | grep -E "queue|\XC_VM\\[Queue\\]" | grep -v grep | grep -v pgrep | wc -l'))); if ($rQueue == 0) { shell_exec(PHP_BIN . ' ' . MAIN_HOME . 'console.php queue > /dev/null 2>/dev/null &'); } diff --git a/src/Cli/CronJobs/StatsCronJob.php b/src/Cli/CronJobs/StatsCronJob.php index fbe2beb5..d0578514 100644 --- a/src/Cli/CronJobs/StatsCronJob.php +++ b/src/Cli/CronJobs/StatsCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/StreamsCronJob.php b/src/Cli/CronJobs/StreamsCronJob.php index c2169c64..ce6205ca 100644 --- a/src/Cli/CronJobs/StreamsCronJob.php +++ b/src/Cli/CronJobs/StreamsCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -226,14 +230,14 @@ class StreamsCronJob implements CommandInterface { $db->query('SELECT `stream_id` FROM `streams_servers` WHERE `on_demand` = 1 AND `server_id` = ?;', SERVER_ID); $rOnDemandIDs = array_keys($db->get_rows(true, 'stream_id')); - $rProcesses = shell_exec('ps aux | grep XC_VM'); - if (preg_match_all('/XC_VM\\[(.*)\\]/', $rProcesses, $rMatches)) { + $rProcesses = shell_exec('ps aux | grep \XC_VM'); + if (preg_match_all('/\XC_VM\\[(.*)\\]/', $rProcesses, $rMatches)) { $rRemove = array_diff($rMatches[1], $rStreamIDs); $rRemove = array_diff($rRemove, $rOnDemandIDs); foreach ($rRemove as $rStreamID) { if (is_numeric($rStreamID)) { echo 'Kill Stream ID: ' . $rStreamID . "\n"; - shell_exec("kill -9 `ps -ef | grep '/" . intval($rStreamID) . '_.m3u8\\|XC_VM\\[' . intval($rStreamID) . "\\]' | grep -v grep | awk '{print \$2}'`;"); + shell_exec("kill -9 `ps -ef | grep '/" . intval($rStreamID) . '_.m3u8\\|\XC_VM\\[' . intval($rStreamID) . "\\]' | grep -v grep | awk '{print \$2}'`;"); shell_exec('rm -f ' . STREAMS_PATH . intval($rStreamID) . '_*'); } } diff --git a/src/Cli/CronJobs/StreamsLogsCronJob.php b/src/Cli/CronJobs/StreamsLogsCronJob.php index 235a4e57..91fb23ba 100644 --- a/src/Cli/CronJobs/StreamsLogsCronJob.php +++ b/src/Cli/CronJobs/StreamsLogsCronJob.php @@ -1,12 +1,16 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/TmpCronJob.php b/src/Cli/CronJobs/TmpCronJob.php index 291ba04a..fe3d0190 100644 --- a/src/Cli/CronJobs/TmpCronJob.php +++ b/src/Cli/CronJobs/TmpCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/UpdateCronJob.php b/src/Cli/CronJobs/UpdateCronJob.php index f0964d7d..35f8f9f8 100644 --- a/src/Cli/CronJobs/UpdateCronJob.php +++ b/src/Cli/CronJobs/UpdateCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -24,7 +28,7 @@ class UpdateCronJob implements CommandInterface { } public function getDescription(): string { - return 'Cron: check for XC_VM updates'; + return 'Cron: check for \XC_VM updates'; } public function execute(array $rArgs): int { diff --git a/src/Cli/CronJobs/UsersCronJob.php b/src/Cli/CronJobs/UsersCronJob.php index e49c3ef7..813463cf 100644 --- a/src/Cli/CronJobs/UsersCronJob.php +++ b/src/Cli/CronJobs/UsersCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronJobs/VodCronJob.php b/src/Cli/CronJobs/VodCronJob.php index 60ef6e5b..7bb9430c 100644 --- a/src/Cli/CronJobs/VodCronJob.php +++ b/src/Cli/CronJobs/VodCronJob.php @@ -1,5 +1,9 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ diff --git a/src/Cli/CronTrait.php b/src/Cli/CronTrait.php index dfdadae7..1d4a1c3f 100644 --- a/src/Cli/CronTrait.php +++ b/src/Cli/CronTrait.php @@ -1,5 +1,7 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -26,7 +28,7 @@ trait CronTrait { */ protected function assertRunAsXcVm(): bool { if ((posix_getpwuid(posix_geteuid())['name'] ?? null) !== 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return false; } return true; diff --git a/src/Cli/DaemonTrait.php b/src/Cli/DaemonTrait.php index 89bfd45b..203f5341 100644 --- a/src/Cli/DaemonTrait.php +++ b/src/Cli/DaemonTrait.php @@ -1,5 +1,7 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -36,7 +38,7 @@ trait DaemonTrait { */ protected function assertRunAsXcVm(): bool { if (posix_getpwuid(posix_geteuid())['name'] !== 'xc_vm') { - echo "Please run as XC_VM!\n"; + echo "Please run as \XC_VM!\n"; return false; } return true; @@ -59,14 +61,14 @@ trait DaemonTrait { * Запомнить MD5 файла команды для обнаружения обновлений. */ protected function initDaemonMD5(): void { - $this->rDaemonMD5 = md5_file((new ReflectionClass($this))->getFileName()); + $this->rDaemonMD5 = md5_file((new \ReflectionClass($this))->getFileName()); } /** * Проверить, изменился ли файл команды с момента запуска. */ protected function hasFileChanged(): bool { - return md5_file((new ReflectionClass($this))->getFileName()) !== $this->rDaemonMD5; + return md5_file((new \ReflectionClass($this))->getFileName()) !== $this->rDaemonMD5; } /** diff --git a/src/Cli/migration_logic.php b/src/Cli/migration_logic.php index 8fab08e8..cab946c6 100644 --- a/src/Cli/migration_logic.php +++ b/src/Cli/migration_logic.php @@ -1,5 +1,6 @@ * @copyright 2025-2026 Vateron Media - * @link https://github.com/Vateron-Media/XC_VM + * @link https://github.com/Vateron-Media/\XC_VM * @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html */ @@ -51,7 +52,7 @@ if ($odb->num_rows() > 0) { echo "\n" . "Couldn't find anything to migrate in the `xc_vm_migrate` database. Please ensure you restore your backup to that database specifically." . "\n\n"; exit(); } - echo "\n" . 'Migrating database to XC_VM...' . "\n\n"; + echo "\n" . 'Migrating database to \XC_VM...' . "\n\n"; if (in_array('access_codes', $rMigrateOptions)) { $odb->query('SELECT * FROM `access_codes`;'); @@ -69,7 +70,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `access_codes`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); AuthRepository::updateCodes(); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -99,7 +100,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `users`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -117,7 +118,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `blocked_ips`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -135,7 +136,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `blocked_uas`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -153,7 +154,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `blocked_isps`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -171,7 +172,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `bouquets`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -201,7 +202,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `enigma2_devices`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -231,7 +232,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `mag_devices`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -249,7 +250,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `epg`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -267,7 +268,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `users_groups`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -285,7 +286,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `users_packages`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -303,7 +304,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `rtmp_ips`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -333,7 +334,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `streams_series`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -363,7 +364,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `streams_episodes`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -382,7 +383,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `servers`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -412,7 +413,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `streams`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -442,7 +443,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `streams_options`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -478,7 +479,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `streams_servers`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -496,7 +497,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `streams_categories`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -514,7 +515,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `tickets`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -532,7 +533,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `tickets_replies`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -550,7 +551,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `profiles`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -568,7 +569,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `providers`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -604,7 +605,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `lines`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -645,7 +646,7 @@ if ($odb->num_rows() > 0) { echo "\n" . "Couldn't find anything to migrate in the `xc_vm_migrate` database. Please ensure you restore your backup to that database specifically." . "\n\n"; exit(); } - echo "\n" . 'Migrating database to XC_VM...' . "\n\n"; + echo "\n" . 'Migrating database to \XC_VM...' . "\n\n"; echo 'Remapping bouquets.' . "\n"; $rSeriesMap = $rBouquetMap = array(); @@ -683,7 +684,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `users`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -714,7 +715,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `users`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -732,7 +733,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `blocked_ips`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -750,7 +751,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `blocked_uas`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -768,7 +769,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `blocked_isps`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -786,7 +787,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `blocked_isps`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -832,7 +833,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `bouquets`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -864,7 +865,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `enigma2_devices`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -900,7 +901,7 @@ if ($odb->num_rows() > 0) { $db->query($rQuery, ...$rPrepare['data']); } } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -918,7 +919,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `epg`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -936,7 +937,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `epg`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -960,7 +961,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `users_groups`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -984,7 +985,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `users_groups`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1008,7 +1009,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `users_groups`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1047,7 +1048,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `users_packages`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1067,7 +1068,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `rtmp_ips`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1104,7 +1105,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT IGNORE INTO `streams_series`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1136,7 +1137,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `streams_episodes`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1169,7 +1170,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `servers`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1202,7 +1203,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `servers`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1246,11 +1247,11 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `streams`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1281,7 +1282,7 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `streams_options`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1330,7 +1331,7 @@ if ($odb->num_rows() > 0) { $db->query($rQuery, ...$rPrepare['data']); } } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1375,7 +1376,7 @@ if ($odb->num_rows() > 0) { $db->query($rQuery, ...$rPrepare['data']); } } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1393,7 +1394,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `streams_categories`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1411,7 +1412,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `streams_categories`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1429,7 +1430,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `tickets`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1447,7 +1448,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `tickets_replies`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1465,7 +1466,7 @@ if ($odb->num_rows() > 0) { $rPrepare = QueryHelper::prepareArray($rResult); $rQuery = 'INSERT INTO `profiles`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1493,7 +1494,7 @@ if ($odb->num_rows() > 0) { foreach ($rResults as $rResult) { $rOutput[$rResult['user_id']][] = $rResult['access_output_id']; } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1537,12 +1538,12 @@ if ($odb->num_rows() > 0) { $rQuery = 'INSERT INTO `lines`(' . $rPrepare['columns'] . ') VALUES(' . $rPrepare['placeholder'] . ');'; $db->query($rQuery, ...$rPrepare['data']); } - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } try { - } catch (Exception $e) { + } catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } } @@ -1574,7 +1575,7 @@ try { $odb->query('SELECT * FROM `settings` LIMIT 1;'); $rSettings = $odb->get_row(); $db->query('UPDATE `settings` SET `server_name` = ?, `default_timezone` = ?;', $rSettings['server_name'], $rSettings['default_timezone']); -} catch (Exception $e) { +} catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } try { @@ -1590,13 +1591,13 @@ try { $db->query('UPDATE `settings` SET `recaptcha_v2_secret_key` = ?, `recaptcha_v2_site_key` = ?;', $rAdminSettings['recaptcha_v2_secret_key'], $rAdminSettings['recaptcha_v2_site_key']); } } -} catch (Exception $e) { +} catch (\Exception $e) { echo 'Error: ' . $e . "\n"; } if (in_array('access_codes', $rMigrateOptions)) { echo "\n" . 'Admin acces code: ' . $AdminAccesCode; } -echo "\n" . 'Migration has been completed!' . "\n\n" . 'Your settings have been reset to the XC_VM default, please take some time to review the settings page and make the desired changes.' . "\n"; +echo "\n" . 'Migration has been completed!' . "\n\n" . 'Your settings have been reset to the \XC_VM default, please take some time to review the settings page and make the desired changes.' . "\n"; file_put_contents(TMP_PATH . '.migration.status', 2); if (is_object($odb)) { diff --git a/src/Core/Module/BaseModule.php b/src/Core/Module/BaseModule.php index ae32d6d2..229312d1 100644 --- a/src/Core/Module/BaseModule.php +++ b/src/Core/Module/BaseModule.php @@ -1,6 +1,7 @@ modules as $module) { if ($module instanceof CommandProviderInterface) { $module->registerCommands($registry); diff --git a/src/Domain/Server/ServerService.php b/src/Domain/Server/ServerService.php index ecd7e263..4d7ffed4 100644 --- a/src/Domain/Server/ServerService.php +++ b/src/Domain/Server/ServerService.php @@ -1,6 +1,7 @@ 'XC_VM[Console]', @@ -49,23 +52,25 @@ $rRegistry = new CommandRegistry(); // ── Auto-discover: core Commands + CronJobs ────────────────────── +// Each directory maps to its PSR-4 namespace; classes are resolved by FQCN and +// loaded by the Composer autoloader (no manual require, no basename==classname). $rCommandDirs = [ - __DIR__ . '/Cli/Commands', - __DIR__ . '/Cli/CronJobs', + __DIR__ . '/Cli/Commands' => 'XcVm\\Cli\\Commands\\', + __DIR__ . '/Cli/CronJobs' => 'XcVm\\Cli\\CronJobs\\', ]; -foreach ($rCommandDirs as $rDir) { +foreach ($rCommandDirs as $rDir => $rNamespace) { if (!is_dir($rDir)) { continue; } foreach (glob($rDir . '/*.php') as $rFile) { - $rClassName = basename($rFile, '.php'); - require_once $rFile; - if (class_exists($rClassName, false)) { - $rReflection = new ReflectionClass($rClassName); - if (!$rReflection->isAbstract() && $rReflection->implementsInterface('CommandInterface')) { - $rRegistry->register(new $rClassName()); - } + $rClass = $rNamespace . basename($rFile, '.php'); + if (!class_exists($rClass)) { + continue; + } + $rReflection = new ReflectionClass($rClass); + if (!$rReflection->isAbstract() && $rReflection->implementsInterface(CommandInterface::class)) { + $rRegistry->register(new $rClass()); } } } diff --git a/tests/Unit/CronProviderTest.php b/tests/Unit/CronProviderTest.php index 03edd44b..1aa590da 100644 --- a/tests/Unit/CronProviderTest.php +++ b/tests/Unit/CronProviderTest.php @@ -202,7 +202,7 @@ final class CronProviderTest extends TestCase { . "use XcVm\Core\Module\ModuleInterface;\n" . "use XcVm\Core\Container\ServiceContainer;\n" . "use XcVm\\Core\\Http\\Router;\n" - . "use CommandRegistry;\n" + . "use XcVm\Cli\CommandRegistry;\n" . "use XcVm\Core\Module\NavbarRegistry;\n" . "class {$cls} implements ModuleInterface {\n" . "\tpublic function getName(): string { return '{$name}'; }\n" diff --git a/tests/Unit/InterfaceContractTest.php b/tests/Unit/InterfaceContractTest.php index 02dc8e57..2db6d515 100644 --- a/tests/Unit/InterfaceContractTest.php +++ b/tests/Unit/InterfaceContractTest.php @@ -1,5 +1,6 @@ assertInterfaceMethod($rc, 'registerCommands', ['CommandRegistry'], 'void'); + $this->assertInterfaceMethod($rc, 'registerCommands', ['XcVm\Cli\CommandRegistry'], 'void'); } // ── NavbarProviderInterface ─────────────────────────────────── diff --git a/tests/Unit/ModuleLoaderBootTest.php b/tests/Unit/ModuleLoaderBootTest.php index 8c6de78b..97dd9112 100644 --- a/tests/Unit/ModuleLoaderBootTest.php +++ b/tests/Unit/ModuleLoaderBootTest.php @@ -229,7 +229,7 @@ final class ModuleLoaderBootTest extends TestCase { . "use XcVm\Core\Module\ModuleInterface;\n" . "use XcVm\Core\Container\ServiceContainer;\n" . "use XcVm\\Core\\Http\\Router;\n" - . "use CommandRegistry;\n" + . "use XcVm\Cli\CommandRegistry;\n" . "use XcVm\Core\Module\NavbarRegistry;\n" . "class {$cls} implements ModuleInterface {\n" . "\tpublic function getName(): string { return '{$name}'; }\n" diff --git a/tests/Unit/ModuleLoaderPriorityTest.php b/tests/Unit/ModuleLoaderPriorityTest.php index 7c6c6d4e..826ed215 100644 --- a/tests/Unit/ModuleLoaderPriorityTest.php +++ b/tests/Unit/ModuleLoaderPriorityTest.php @@ -1,5 +1,6 @@