tytdarchive/www/channel.php

96 lines
2.5 KiB
PHP
Raw Permalink Normal View History

2024-06-22 04:03:20 +00:00
<?php
include("header-1.php");
?>
<title>TYTD Archive - Channel<?php
if(isset($_GET['id'])) {
echo " ".htmlspecialchars($_GET['id']);
}
?></title>
<?php
include("header-2.php");
?>
<?php
include_once 'db.php';
$offset = 0;
$page_first=0;
$search="";
$name = "";
if(isset($_GET["id"]))
{
$search = $_GET["id"];
if(isset($_GET["page"]))
{
$offset = ((int)$_GET["page"])-1;
$page_first = $offset - ($offset % 3);
}
$stmt = $pdo->prepare("select * from SavedVideo where AuthorId like '$search' LIMIT ".strval($offset*20).", 20");
$stmt->execute();
$videos = $stmt->fetchAll();
foreach($videos as $video)
{
if(strlen($name) == 0)
{
$name = $video["AuthorTitle"];
echo "<h1>".htmlspecialchars($name)."</h1>";
echo "<a class=\"btn btn-primary\" href=\"".$tytd_root."api/AddChannel/".rawurlencode($search)."\">Add To Downloader</a><br>";
}
$class = "class=\"bg-danger\"";
if(strlen(video_exists($video["Id"],"PreMuxed")) > 0)
$class = "";
echo "<a ".$class." href=\"./watch.php?v=".$video["Id"]."\">".htmlspecialchars($video["Title"])."</a>";
echo "<br>";
}
}
?>
<nav aria-label="...">
<ul class="pagination">
<li class="page-item <?php if($offset == 0) echo "disabled"; ?>">
<a class="page-link" href="./channel.php?id=<?php echo urlencode($search); ?>&page=<?php echo $offset; ?>">Previous</a>
</li>
<li class="page-item <?php
if(($page_first) == $offset) echo "active";
?>"><a class="page-link" href="./channel.php?id=<?php echo urlencode($search); ?>&page=<?php echo $page_first+1; ?>"><?php
echo $page_first+1;
?></a></li>
<li class="page-item <?php
if(($page_first+1) == $offset) echo "active";
?>">
<a class="page-link" href="./channel.php?id=<?php echo urlencode($search); ?>&page=<?php echo $page_first+2; ?>"> <span class="sr-only"><?php
echo $page_first+2;
?></span></a>
</li>
<li class="page-item <?php
if(($page_first+2) == $offset) echo "active";
?>"><a class="page-link" href="./channel.php?id=<?php echo urlencode($search); ?>&page=<?php echo $page_first+3; ?>"><?php
echo $page_first+3;
?></a></li>
<li class="page-item">
<a class="page-link" href="./channel.php?id=<?php echo urlencode($search); ?>&page=<?php echo $offset+2; ?>">Next</a>
</li>
</ul>
</nav>
<?php
include("footer.php");
?>