Refactor permission management and authentication processes

- Moved advanced permissions loading to a separate file for better organization and maintainability.
- Updated permission checks to utilize a centralized Authorization class for improved code clarity.
- Refactored login processes in both admin and reseller APIs to use a dedicated Authenticator class, streamlining the authentication logic.
- Introduced RedisManager for handling Redis connections and signal management.
- Adjusted error reporting settings in Logger to reduce verbosity in production.
- Enhanced playlist generation logic to correctly handle proxy IPs.
- Improved handling of optional parameters in streaming URL generation to prevent potential errors.
This commit is contained in:
Divarion-D
2026-02-20 21:53:34 +03:00
parent c54d322a89
commit 5ee46d1d3d
33 changed files with 1701 additions and 1458 deletions
+63
View File
@@ -0,0 +1,63 @@
<?php
class DomainResolver {
public static function resolve($rServers, $rSettings, $rServerID, $rForceSSL = false, $rGetProxies = null, $rGetCache = null) {
$rOriginatorID = null;
if ($rForceSSL) {
$rProtocol = 'https';
} else {
if (isset($_SERVER['SERVER_PORT']) && $rSettings['keep_protocol']) {
$rProtocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http');
} else {
$rProtocol = $rServers[$rServerID]['server_protocol'];
}
}
$rProxied = $rServers[$rServerID]['enable_proxy'];
if ($rProxied) {
$rProxyIDs = is_callable($rGetProxies) ? array_keys(call_user_func($rGetProxies, $rServerID, true)) : array();
if (count($rProxyIDs) == 0) {
$rProxyIDs = is_callable($rGetProxies) ? array_keys(call_user_func($rGetProxies, $rServerID, false)) : array();
}
if (count($rProxyIDs) != 0) {
$rOriginatorID = $rServerID;
$rServerID = $rProxyIDs[array_rand($rProxyIDs)];
} else {
return '';
}
}
$rHost = ($_SERVER['HTTP_HOST'] ?? '');
if (strpos($rHost, ':') !== false) {
list($rDomain, $rAccessPort) = explode(':', $rHost, 2);
} else {
$rDomain = $rHost;
}
if ($rProxied || $rSettings['use_mdomain_in_lists'] == 1) {
$rResellerDomains = is_callable($rGetCache) ? (call_user_func($rGetCache, 'reseller_domains') ?: array()) : array();
if (!(strlen($rDomain) > 0 && in_array(strtolower($rDomain), $rResellerDomains))) {
if (empty($rServers[$rServerID]['domain_name'])) {
$rDomain = escapeshellcmd($rServers[$rServerID]['server_ip']);
} else {
$rDomain = str_replace(array('http://', '/', 'https://'), '', escapeshellcmd(explode(',', $rServers[$rServerID]['domain_name'])[0]));
}
}
} else {
if (strlen($rDomain) == 0) {
if (empty($rServers[$rServerID]['domain_name'])) {
$rDomain = escapeshellcmd($rServers[$rServerID]['server_ip']);
} else {
$rDomain = str_replace(array('http://', '/', 'https://'), '', escapeshellcmd(explode(',', $rServers[$rServerID]['domain_name'])[0]));
}
}
}
$rServerURL = $rProtocol . '://' . $rDomain . ':' . $rServers[$rServerID][$rProtocol . '_broadcast_port'] . '/';
if ($rServers[$rServerID]['server_type'] == 1 && $rOriginatorID && $rServers[$rOriginatorID]['is_main'] == 0) {
$rServerURL .= md5($rServerID . '_' . $rOriginatorID . '_' . OPENSSL_EXTRA) . '/';
}
return $rServerURL;
}
}