2026-02-20 21:53:34 +03:00
|
|
|
<?php
|
|
|
|
|
|
2026-06-24 20:52:00 +03:00
|
|
|
namespace XcVm\Core\Config;
|
|
|
|
|
|
2026-04-05 22:38:36 +03:00
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
|
2026-02-20 21:53:34 +03:00
|
|
|
class SettingsRepository {
|
2026-06-22 11:19:31 +03:00
|
|
|
/**
|
|
|
|
|
* 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).
|
|
|
|
|
*/
|
2026-03-07 21:53:45 +03:00
|
|
|
public static function getAll($rForce = false) {
|
2026-03-03 20:00:34 +03:00
|
|
|
global $db;
|
2026-03-07 21:53:45 +03:00
|
|
|
if (!$rForce) {
|
2026-06-24 22:35:33 +03:00
|
|
|
$rCache = \XcVm\Core\Cache\FileCache::getCache('settings', 20);
|
2026-02-20 21:53:34 +03:00
|
|
|
if (!empty($rCache)) {
|
|
|
|
|
return $rCache;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rOutput = array();
|
|
|
|
|
$db->query('SELECT * FROM `settings`');
|
|
|
|
|
$rRows = $db->get_row();
|
2026-07-05 20:29:44 +03:00
|
|
|
foreach ($rRows ?: array() as $rKey => $rValue) {
|
2026-02-20 21:53:34 +03:00
|
|
|
$rOutput[$rKey] = $rValue;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-05 20:29:44 +03:00
|
|
|
$rOutput['allow_countries'] = json_decode($rOutput['allow_countries'] ?? '', true);
|
2026-02-20 21:53:34 +03:00
|
|
|
|
2026-07-05 20:29:44 +03:00
|
|
|
$decodedAllowedSTB = json_decode($rOutput['allowed_stb_types'] ?? '', true);
|
2026-02-20 21:53:34 +03:00
|
|
|
$rOutput['allowed_stb_types'] = array();
|
|
|
|
|
if (is_array($decodedAllowedSTB)) {
|
|
|
|
|
$rOutput['allowed_stb_types'] = array_map('strtolower', $decodedAllowedSTB);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-05 20:29:44 +03:00
|
|
|
$rOutput['stalker_lock_images'] = json_decode($rOutput['stalker_lock_images'] ?? '', true);
|
2026-02-20 21:53:34 +03:00
|
|
|
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']) : [];
|
|
|
|
|
|
2026-06-24 22:35:33 +03:00
|
|
|
\XcVm\Core\Cache\FileCache::setCache('settings', $rOutput);
|
2026-02-20 21:53:34 +03:00
|
|
|
|
|
|
|
|
return $rOutput;
|
|
|
|
|
}
|
|
|
|
|
}
|