if (!(count($streamArrUrl) > 0)) {
goto Addf182f86a94b305381bd0e81174f08;
}
if (!empty($streamUrl)) {
$streamArrUrl = array($streamUrl);
goto ac8a864b3489c444d14e1904ec5dfd7e;
}
if (ipTV_lib::$settings["priority_backup"] != 1) {
if (empty($stream["server_info"]["current_source"])) {
goto e7eedc2b99021a3a11f4a0933af2c2b1;
}
$Baee0c34e5755f1cfaa4159ea7e8702e = array_search($stream["server_info"]["current_source"], $streamArrUrl);
if (!($Baee0c34e5755f1cfaa4159ea7e8702e !== false)) {
goto D63aacc4ea564f12e24abd6538c7b052;
}
$C48e0083a9caa391609a3c645a2ec889 = 0;
B1fcf06a1d6da24af4b5d7d516d25b90:
if (!($C48e0083a9caa391609a3c645a2ec889 <= $Baee0c34e5755f1cfaa4159ea7e8702e)) {
$streamArrUrl = array_values($streamArrUrl);
D63aacc4ea564f12e24abd6538c7b052:
e7eedc2b99021a3a11f4a0933af2c2b1:
goto Fd0c9fa73a22d3ad21baec039c9f9b6c;
}
$Ad110d626a9e62f0778a8f19383a0613 = $streamArrUrl[$C48e0083a9caa391609a3c645a2ec889];
unset($streamArrUrl[$C48e0083a9caa391609a3c645a2ec889]);
array_push($streamArrUrl, $Ad110d626a9e62f0778a8f19383a0613);
$C48e0083a9caa391609a3c645a2ec889++;
goto B1fcf06a1d6da24af4b5d7d516d25b90;
}
Fd0c9fa73a22d3ad21baec039c9f9b6c:
ac8a864b3489c444d14e1904ec5dfd7e:
Addf182f86a94b305381bd0e81174f08:
if (count($streamUrlArr) > 0) {
if (ipTV_lib::$settings["priority_backup"] != 1) {
if (!empty($stream['server_info']['current_source'])) {
$currentSourceIndex = array_search($stream['server_info']['current_source'], $streamUrlArr);
if ($currentSourceIndex !== false) {
$streamUrlKey = 0;
while ($streamUrlKey <= $currentSourceIndex) {
$Ad110d626a9e62f0778a8f19383a0613 = $streamUrlArr[$streamUrlKey];
unset($streamUrlArr[$streamUrlKey]);
array_push($streamUrlArr, $Ad110d626a9e62f0778a8f19383a0613);
$streamUrlKey++;
}
$streamUrlArr = array_values($streamUrlArr);
}
}
}
} elseif (!empty($streamUrl)) {
$streamUrlArr = array($streamUrl);
}
function rotateToLast(&$streamArrUrl, $streamUrl, $stream) {
if (count($streamArrUrl) === 0) {
return;
}
if (empty($streamUrl)) {
$streamArrUrl = [$streamUrl];
return;
}
if (ipTV_lib::$settings["priority_backup"] === 1) {
return;
}
if (empty($stream["server_info"]["current_source"])) {
return;
}
$sourceIdx = array_search($stream["server_info"]["current_source"], $streamArrUrl);
if ($sourceIdx === false) {
return;
}
$tmp = array_slice($streamArrUrl, $sourceIdx + 1);
array_splice($streamArrUrl, $sourceIdx + 1);
$streamArrUrl = array_merge($tmp, $streamArrUrl);
}
rotateToLast($streamArrUrl, $streamUrl, $stream);