chore: update utils, cron jobs, table controller, and build config

- QueryHelper: add utility methods for safe SQL operations
- AdminHelpers/SystemInfo: extract reusable admin utility functions
- ServerRepository: update query methods
- CacheCronJob/ServersCronJob: align with service layer conventions
- TableController: refactor DataTable logic for admin views
- Update Makefile build configuration
This commit is contained in:
Divarion-D
2026-04-20 20:35:36 +03:00
parent 0437979ec8
commit fbe0cf63cf
10 changed files with 13 additions and 22 deletions
-1
View File
@@ -44,7 +44,6 @@ LB_DIRS_TO_REMOVE := \
# Files to remove from LB
LB_FILES_TO_REMOVE := \
bin/maxmind/GeoLite2-City.mmdb \
infrastructure/legacy/reseller_api.php \
public/Controllers/Api/AdminApiController.php \
public/Controllers/Api/ResellerRestApiController.php \
www/xplugin.php \
+1 -1
View File
@@ -262,7 +262,7 @@ class CacheCronJob implements CommandInterface {
if ($db->dbh && $db->result) {
if ($db->result->rowCount() > 0) {
foreach ($db->result->fetchAll(PDO::FETCH_ASSOC) as $rStreamInfo) {
$rCategoryChannels[$rStreamInfo['id']] = json_decode($rStreamInfo['category_id'], true);
$rCategoryChannels[$rStreamInfo['id']] = json_decode($rStreamInfo['category_id'] ?? '[]', true);
}
}
}
+2 -2
View File
@@ -182,8 +182,8 @@ class ServersCronJob implements CommandInterface {
$rGovernors = array();
$rGovernor = null;
if (shell_exec('which cpufreq-info')) {
$rGovernors = array_filter(explode(' ', trim(shell_exec('cpufreq-info -g'))));
$rGovernor = explode(' ', trim(shell_exec('cpufreq-info -p')));
$rGovernors = array_filter(explode(' ', trim(shell_exec('cpufreq-info -g') ?? '')));
$rGovernor = explode(' ', trim(shell_exec('cpufreq-info -p') ?? ''));
}
$rAddresses = array_values(array_unique(array_map('trim', explode("\n", shell_exec("ip -4 addr | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}'")))));
-1
View File
@@ -4,7 +4,6 @@
* XC_VM — Утилиты для работы с SQL-запросами
*
* Статические методы для подготовки данных и проверки существования записей.
* Извлечены из infrastructure/legacy/admin.php (Phase 16.2a).
*/
class QueryHelper {
+1 -2
View File
@@ -1,10 +1,9 @@
<?php
/*
* XC_VM — Утилитарные функции, извлечённые из admin.php
* XC_VM — Утилитарные функции
*
* Статический класс для UI-хелперов, форматирования, валидации и генерации.
* Извлечены из infrastructure/legacy/admin.php (Phase 16.2a).
*/
class AdminHelpers {
+2 -2
View File
@@ -222,7 +222,7 @@ class SystemInfo {
$rReturn = array();
$rID = 0;
try {
$rDevices = array_values(array_filter(explode("\n", shell_exec('v4l2-ctl --list-devices'))));
$rDevices = array_values(array_filter(explode("\n", shell_exec('v4l2-ctl --list-devices') ?? '')));
if (is_array($rDevices)) {
foreach ($rDevices as $rKey => $rValue) {
if ($rKey % 2 == 0) {
@@ -244,7 +244,7 @@ class SystemInfo {
*/
public static function getAudioDevices() {
try {
return array_filter(explode("\n", shell_exec('arecord -L | grep "hw:CARD="')));
return array_filter(explode("\n", shell_exec('arecord -L | grep "hw:CARD="') ?? ''));
} catch (Exception $e) {
return array();
}
+2 -2
View File
@@ -51,7 +51,7 @@ class ServerRepository {
$rRow['http_url'] = 'http://' . $rURL . ':' . intval($rRow['http_broadcast_port']) . '/';
$rRow['https_url'] = 'https://' . $rURL . ':' . intval($rRow['https_broadcast_port']) . '/';
$rRow['rtmp_server'] = 'rtmp://' . $rURL . ':' . intval($rRow['rtmp_port']) . '/live/';
$rRow['domains'] = array('protocol' => $rProtocol, 'port' => $rPort, 'urls' => array_filter(array_map('escapeshellcmd', explode(',', $rRow['domain_name']))));
$rRow['domains'] = array('protocol' => $rProtocol, 'port' => $rPort, 'urls' => array_filter(array_map('escapeshellcmd', explode(',', $rRow['domain_name'] ?? ''))));
$rRow['rtmp_mport_url'] = 'http://127.0.0.1:31210/';
$rRow['api_url_ip'] = 'http://' . escapeshellcmd($rRow['server_ip']) . ':' . intval($rRow['http_broadcast_port']) . '/api?password=' . urlencode($rSettings['live_streaming_pass']);
$rRow['api_url'] = $rRow['api_url_ip'];
@@ -322,7 +322,7 @@ class ServerRepository {
} else {
$rIPs[] = $rServerInfo['private_ip'];
}
foreach (explode(',', $rServerInfo['domain_name']) as $rIP) {
foreach (explode(',', $rServerInfo['domain_name'] ?? '') as $rIP) {
if (!filter_var($rIP, FILTER_VALIDATE_IP)) {
} else {
$rIPs[] = $rIP;
@@ -12,11 +12,10 @@
session_start();
session_write_close();
if (file_exists('../www/init.php')) {
require_once '../www/init.php';
} else {
require_once '../../../www/init.php';
if (!defined('MAIN_HOME')) {
require_once dirname(__DIR__, 3) . '/autoload.php';
}
WebApiBootstrap::init('admin');
if (!PHP_ERRORS) {
if (empty($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
exit();
-2
View File
@@ -1,5 +1,3 @@
?>
<div class="wrapper boxed-layout-ext"
<?php
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
+2 -5
View File
@@ -3,11 +3,8 @@
if (!defined('MAIN_HOME')) {
session_start();
session_write_close();
if (file_exists("../www/init.php")) {
require_once "../www/init.php";
} else {
require_once "../../../www/init.php";
}
require_once dirname(__DIR__, 3) . '/autoload.php';
WebApiBootstrap::init('admin');
} else {
session_write_close();
}