mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-18 04:02:59 +02:00
Hardening driven by a 2.3.3 panel error log (166 entries): - TmdbClient: _call() returns an empty/error payload on network or API failure — all 20 `$result['results']` accesses guarded with `?? []` (was: hourly "Undefined array key results" + foreach(null) warnings from the popular cron when the TMDb API was unreachable or the key was invalid). - get_rows()/get_row() return false while MySQL is briefly unavailable (restart windows) — guarded with `?: []` in ServerRepository, BouquetService, BlocklistService (all 7 sites) and SettingsRepository, plus `?? ''` for the allow_countries / allowed_stb_types / stalker_lock_images json_decode inputs (was: foreach(bool) + "Undefined array key" bursts during DB restarts). - ServersCronJob: @fsockopen — an unreachable node is an expected state already handled via the return value; the warning only polluted the panel log on every ping of an offline server. - DiagnosticsService: send error reports to the xcvm.tech endpoint over HTTPS instead of plain HTTP.
57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace XcVm\Core\Config;
|
|
|
|
/**
|
|
* SettingsRepository — settings repository
|
|
*
|
|
* @package XC_VM_Core_Config
|
|
* @author Divarion_D <https://github.com/Divarion-D>
|
|
* @copyright 2025-2026 Vateron Media
|
|
* @link https://github.com/Vateron-Media/XC_VM
|
|
* @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
|
|
*/
|
|
|
|
class SettingsRepository {
|
|
/**
|
|
* Load all panel settings, decoding JSON fields and caching the result.
|
|
*
|
|
* @param bool $rForce Bypass the file cache and re-read from the database.
|
|
* @return array Settings map (with normalized array fields).
|
|
*/
|
|
public static function getAll($rForce = false) {
|
|
global $db;
|
|
if (!$rForce) {
|
|
$rCache = \XcVm\Core\Cache\FileCache::getCache('settings', 20);
|
|
if (!empty($rCache)) {
|
|
return $rCache;
|
|
}
|
|
}
|
|
|
|
$rOutput = array();
|
|
$db->query('SELECT * FROM `settings`');
|
|
$rRows = $db->get_row();
|
|
foreach ($rRows ?: array() as $rKey => $rValue) {
|
|
$rOutput[$rKey] = $rValue;
|
|
}
|
|
|
|
$rOutput['allow_countries'] = json_decode($rOutput['allow_countries'] ?? '', true);
|
|
|
|
$decodedAllowedSTB = json_decode($rOutput['allowed_stb_types'] ?? '', true);
|
|
$rOutput['allowed_stb_types'] = array();
|
|
if (is_array($decodedAllowedSTB)) {
|
|
$rOutput['allowed_stb_types'] = array_map('strtolower', $decodedAllowedSTB);
|
|
}
|
|
|
|
$rOutput['stalker_lock_images'] = json_decode($rOutput['stalker_lock_images'] ?? '', true);
|
|
if (array_key_exists('bouquet_name', $rOutput)) {
|
|
$rOutput['bouquet_name'] = str_replace(' ', '_', $rOutput['bouquet_name']);
|
|
}
|
|
$rOutput['api_ips'] = !empty($rOutput['api_ips']) ? explode(',', $rOutput['api_ips']) : [];
|
|
|
|
\XcVm\Core\Cache\FileCache::setCache('settings', $rOutput);
|
|
|
|
return $rOutput;
|
|
}
|
|
}
|