diff --git a/src/Cli/CronJobs/ProvidersCronJob.php b/src/Cli/CronJobs/ProvidersCronJob.php index b0c30f56..8b6636a9 100644 --- a/src/Cli/CronJobs/ProvidersCronJob.php +++ b/src/Cli/CronJobs/ProvidersCronJob.php @@ -52,7 +52,7 @@ class ProvidersCronJob implements CommandInterface { private function readURL(string $rURL): ?array { $rContext = stream_context_create(array('http' => array('timeout' => 30))); - return json_decode(file_get_contents($rURL, false, $rContext), true); + return json_decode(@file_get_contents($rURL, false, $rContext) ?: 'null', true); } private function loadCron(?int $rProviderID): void { @@ -105,13 +105,13 @@ class ProvidersCronJob implements CommandInterface { $rLiveCategories = $this->readURL($rCategoriesURL); if (!is_array($rLiveCategories)) $rLiveCategories = []; foreach ($rLiveCategories as $rCategory) { - $rCategories[$rCategory['category_id']] = $rCategory['category_name']; + if (isset($rCategory['category_id'])) { $rCategories[$rCategory['category_id']] = $rCategory['category_name'] ?? ''; } } $rCategoriesURL = $rURL . '&action=get_vod_categories'; $rVodCategories = $this->readURL($rCategoriesURL); if (!is_array($rVodCategories)) $rVodCategories = []; foreach ($rVodCategories as $rCategory) { - $rCategories[$rCategory['category_id']] = $rCategory['category_name']; + if (isset($rCategory['category_id'])) { $rCategories[$rCategory['category_id']] = $rCategory['category_name'] ?? ''; } } $rStreamsURL = $rURL . '&action=get_live_streams'; @@ -141,6 +141,11 @@ class ProvidersCronJob implements CommandInterface { $rTime = time(); foreach (array('live' => $rStreams, 'movie' => $rVOD) as $rType => $rSelection) { foreach ($rSelection as $rStream) { + // External provider payloads may omit any of these keys. + $rStream += array('stream_id' => null, 'category_id' => '', 'name' => '', 'stream_icon' => '', 'epg_channel_id' => '', 'container_extension' => ''); + if ($rStream['stream_id'] === null) { + continue; + } $rNewIDs[] = $rStream['stream_id']; $rCategoryIDs = (isset($rStream['category_ids']) ? (is_array($rStream['category_ids']) ? $rStream['category_ids'] : array()) : array($rStream['category_id'])); $rCategoryArray = array(); diff --git a/src/Domain/User/UserRepository.php b/src/Domain/User/UserRepository.php index 54928c0a..e242f007 100644 --- a/src/Domain/User/UserRepository.php +++ b/src/Domain/User/UserRepository.php @@ -239,6 +239,7 @@ class UserRepository { */ private static function applyIspInfo(array $rUserInfo, $rSettings, $rCached, $rIP, $db): array { $rUserInfo['con_isp_name'] = null; + $rUserInfo['isp_asn'] = null; $rUserInfo['isp_violate'] = 0; $rUserInfo['isp_is_server'] = 0; diff --git a/src/Public/Controllers/Api/PlayerApiController.php b/src/Public/Controllers/Api/PlayerApiController.php index d7979ecd..bfecf73f 100644 --- a/src/Public/Controllers/Api/PlayerApiController.php +++ b/src/Public/Controllers/Api/PlayerApiController.php @@ -68,7 +68,7 @@ class PlayerApiController { generateError('PLAYER_API_DISABLED'); } - if (strtolower(explode('.', ltrim(parse_url($_SERVER['REQUEST_URI'])['path'], '/'))[0]) == 'panel_api') { + if (strtolower(explode('.', ltrim(parse_url($_SERVER['REQUEST_URI'])['path'] ?? '', '/'))[0]) == 'panel_api') { if (!$rSettings['legacy_panel_api']) { $this->deny = false; generateError('LEGACY_PANEL_API_DISABLED'); @@ -78,11 +78,11 @@ class PlayerApiController { } $rIP = $_SERVER['REMOTE_ADDR']; - $rUserAgent = trim($_SERVER['HTTP_USER_AGENT']); + $rUserAgent = trim($_SERVER['HTTP_USER_AGENT'] ?? ''); $this->offset = (empty($rRequest['params']['offset']) ? 0 : abs(intval($rRequest['params']['offset']))); $this->limit = (empty($rRequest['params']['items_per_page']) ? 0 : abs(intval($rRequest['params']['items_per_page']))); $this->domainName = DomainResolver::resolve(SERVER_ID); - $this->domain = parse_url($this->domainName)['host']; + $this->domain = parse_url($this->domainName)['host'] ?? ''; $rValidActions = array('get_epg', 200 => 'get_vod_categories', 201 => 'get_live_categories', 202 => 'get_live_streams', 203 => 'get_vod_streams', 204 => 'get_series_info', 205 => 'get_short_epg', 206 => 'get_series_categories', 207 => 'get_simple_data_table', 208 => 'get_series', 209 => 'get_vod_info'); $rAction = (!empty($rRequest['action']) && (in_array($rRequest['action'], $rValidActions) || array_key_exists($rRequest['action'], $rValidActions)) ? $rRequest['action'] : ''); diff --git a/src/Public/Views/admin/providers.php b/src/Public/Views/admin/providers.php index a1601917..eb9267f0 100644 --- a/src/Public/Views/admin/providers.php +++ b/src/Public/Views/admin/providers.php @@ -56,11 +56,11 @@ if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQ 0) { - $rColour = $rData['max_connections'] * 0.75 < $rData['active_connections'] ? 'danger' : ($rData['max_connections'] * 0.5 < $rData['active_connections'] ? 'warning' : 'success'); - echo ''; + if (($rData['max_connections'] ?? 0) > 0) { + $rColour = ($rData['max_connections'] ?? 0) * 0.75 < ($rData['active_connections'] ?? 0) ? 'danger' : (($rData['max_connections'] ?? 0) * 0.5 < ($rData['active_connections'] ?? 0) ? 'warning' : 'success'); + echo ''; } else { - echo ''; + echo ''; } ?> diff --git a/src/Public/admin/live.php b/src/Public/admin/live.php index 951e1ce7..996bb4c1 100644 --- a/src/Public/admin/live.php +++ b/src/Public/admin/live.php @@ -299,7 +299,7 @@ if (0 < $db->num_rows()) { if (file_exists(STREAMS_PATH . $rNextSegment)) { // next segment already exists → current one is complete; drain the remainder and advance clearstatcache(true, STREAMS_PATH . $rSegmentFile); - $rRestSize = filesize(STREAMS_PATH . $rSegmentFile) - ftell($rFP); + $rRestSize = (($rSegSize = @filesize(STREAMS_PATH . $rSegmentFile)) !== false ? $rSegSize - ftell($rFP) : 0); if (0 < $rRestSize) { echo stream_get_line($rFP, $rRestSize); diff --git a/src/Public/stream/probe.php b/src/Public/stream/probe.php index 7813d9f9..4fafb82c 100644 --- a/src/Public/stream/probe.php +++ b/src/Public/stream/probe.php @@ -152,7 +152,7 @@ if (isset($rRequest['data'])) { $rServerID = SERVER_ID; } - if (0 < $rChannelInfo['monitor_pid'] && 0 < $rChannelInfo['pid'] && $rServers[$rServerID]['last_status'] == 1) { + if (is_array($rChannelInfo) && 0 < ($rChannelInfo['monitor_pid'] ?? 0) && 0 < ($rChannelInfo['pid'] ?? 0) && ($rServers[$rServerID]['last_status'] ?? 0) == 1) { if (file_exists(STREAMS_PATH . $rStreamID . '_.stream_info')) { $rInfo = file_get_contents(STREAMS_PATH . $rStreamID . '_.stream_info'); } else { @@ -160,7 +160,7 @@ if (isset($rRequest['data'])) { } $rInfo = json_decode($rInfo, true); - echo json_encode(array('codecs' => $rInfo['codecs'], 'container' => $rInfo['container'], 'bitrate' => $rInfo['bitrate'])); + echo json_encode(array('codecs' => $rInfo['codecs'] ?? null, 'container' => $rInfo['container'] ?? null, 'bitrate' => $rInfo['bitrate'] ?? null)); exit(); } diff --git a/src/Streaming/Delivery/StreamRedirector.php b/src/Streaming/Delivery/StreamRedirector.php index 983a4826..0e31b032 100644 --- a/src/Streaming/Delivery/StreamRedirector.php +++ b/src/Streaming/Delivery/StreamRedirector.php @@ -18,8 +18,11 @@ use XcVm\Domain\Stream\ConnectionTracker; class StreamRedirector { public static function redirectStream($rCached, $rSettings, $rServers, $rStreamID, $rExtension, $rUserInfo, $rCountryCode, $rUserISP = '', $rType = '') { if ($rCached) { - $rStream = (igbinary_unserialize(file_get_contents(STREAMS_TMP_PATH . 'stream_' . $rStreamID)) ?: null); - $rStream['bouquets'] = BouquetService::getMapEntry($rStreamID); + $rRaw = @file_get_contents(STREAMS_TMP_PATH . 'stream_' . $rStreamID); + $rStream = ($rRaw !== false ? (igbinary_unserialize($rRaw) ?: null) : null); + if (is_array($rStream)) { + $rStream['bouquets'] = BouquetService::getMapEntry($rStreamID); + } } else { $rStream = self::getStreamData($rStreamID); } @@ -35,7 +38,7 @@ class StreamRedirector { $rAvailableServers = array($rStream['info']['tv_archive_server_id']); } } else { - if (!($rStream['info']['direct_source'] == 1 && $rStream['info']['direct_proxy'] == 0)) { + if (!(($rStream['info']['direct_source'] ?? 0) == 1 && ($rStream['info']['direct_proxy'] ?? 0) == 0)) { foreach ($rServers as $rServerID => $rServerInfo) { if (!array_key_exists($rServerID, $rStreamServers) || !$rServerInfo['server_online'] || $rServerInfo['server_type'] != 0) { continue;