Поддержка redirect, вывод pls, мелкофиксы

master
AnthonyAxenov 2020-08-29 00:38:20 +08:00
parent fe65178bf3
commit 65901013cb
1 changed files with 41 additions and 21 deletions

View File

@ -1,10 +1,8 @@
<?php <?php
if ($_GET['dbg']) { ini_set('display_errors', 1);
ini_set('display_errors', 1); ini_set('display_startup_errors', 1);
ini_set('display_startup_errors', 1); error_reporting(E_ALL);
error_reporting(E_ALL);
}
/** /**
* Возвращает количество каналов в плейлисте * Возвращает количество каналов в плейлисте
@ -21,18 +19,38 @@ function getChannelCount($pls_url) {
// Шаблон короткой ссылки на плейлист // Шаблон короткой ссылки на плейлист
// $my_url = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'?s='; // $my_url = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'?s=';
$my_url = $_SERVER['SERVER_NAME'].'/'.basename(__DIR__).'?s='; $my_url = $_SERVER['SERVER_NAME'].'/iptv?s=';
// Чтение списка плейлистов из ini-файла // Чтение списка плейлистов из ini-файла
$data = parse_ini_file('playlists.ini', true); $data = parse_ini_file('playlists.ini', true);
if (empty($_GET['s'])) { ?> if (!empty($_GET['s'])) {
if (!empty($data[$_GET['s']]['redirect'])) {
header('Location: '.$data[$data[$_GET['s']]['redirect']]['pls']);
} elseif (!empty($data[$_GET['s']]['pls'])) {
header('Location: '.$data[$_GET['s']]['pls']);
}
} else {
?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="ru"> <html lang="ru">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IPTV Playlists</title> <title>IPTV Playlists</title>
<style>
.myurl {
font-weight: bold;
line-height: 2em;
display: block;
}
.center {
text-align: center;
}
.pointer {
cursor:pointer;
}
</style>
</head> </head>
<body> <body>
<h1>Список самообновляемых плейлистов для IPTV</h1> <h1>Список самообновляемых плейлистов для IPTV</h1>
@ -51,9 +69,9 @@ if (empty($_GET['s'])) { ?>
<table width="100%" border="1" cellpadding="1"> <table width="100%" border="1" cellpadding="1">
<thead> <thead>
<tr> <tr>
<td style="text-align: center">ID</td> <td class="center">ID</td>
<td>Информация о плейлисте</td> <td>Информация о плейлисте</td>
<td style="text-align: center">Каналов</td> <td class="center">Каналов</td>
<td title="Нажмите на ссылку, чтобы скопировать адрес">Ссылка на плейлист</td> <td title="Нажмите на ссылку, чтобы скопировать адрес">Ссылка на плейлист</td>
</tr> </tr>
</thead> </thead>
@ -63,25 +81,28 @@ if (empty($_GET['s'])) { ?>
continue; continue;
} ?> } ?>
<tr> <tr>
<td style="text-align: center"> <td class="center">
<strong><?=$id?></strong> <strong><?=$id?></strong>
</td> </td>
<td> <td>
<strong><?=$element['name']?></strong> <strong><?=$element['name'] ?: "Плейлист #".$id?></strong>
<?php if (!empty($element['src'])) { ?> <?php if (!empty($element['src'])) { ?>
<br><a href="<?=$element['src']?>" target="_blank" rel="noopener nofollow">(источник)</a> <br><a href="<?=$element['src']?>" target="_blank" rel="noopener nofollow">Источник</a>
<?php } ?> <?php } ?>
<?php if (!empty($element['desc'])) { ?> <?php if (!empty($element['desc'])) { ?>
<br><?=$element['desc']?> <br><?=$element['desc']?>
<?php } ?> <?php } ?>
</td> </td>
<td style="text-align: center"><?=getChannelCount($element['pls'])?></td> <td class="center"><?=getChannelCount($element['pls'])?></td>
<td onclick="prompt('Скопируйте адрес плейлиста', '<?=$my_url?><?=$id?>')" <td width="250">
title="Нажмите, чтобы скопировать адрес" <span onclick="prompt('Скопируйте адрес плейлиста', '<?=$my_url?><?=$id?>')"
style="cursor:pointer"> title="Нажмите, чтобы скопировать адрес"
<strong> class="pointer myurl">
<pre><?=$my_url?><?=$id?></pre> <?=$my_url?><?=$id?>
</strong> </span>
<span>
Прямая ссылка: <a href="<?=$element['pls']?>">M3U</a>
</span>
</td> </td>
</tr> </tr>
<?php } ?> <?php } ?>
@ -89,6 +110,5 @@ if (empty($_GET['s'])) { ?>
</table> </table>
</body> </body>
</html> </html>
<?php } else { <?php
header('Location: '.$data[$_GET['s']]['pls']);
} }