add video counter and list

This commit is contained in:
Mike Nolan 2024-08-28 02:51:48 +00:00
parent 7f2451b523
commit 6392799410
2 changed files with 78 additions and 3 deletions

View File

@ -4,7 +4,9 @@
{ {
$path=$_GET["q"]; $path=$_GET["q"];
} }
$files = glob("./content/PreMuxed/*.*");
$count = count($files);
?> ?>
</head> </head>
<body class="bg-dark text-light"> <body class="bg-dark text-light">
@ -19,7 +21,9 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/">Home</a> <a class="nav-link" href="/">Home</a>
</li> </li>
<li class="nav-item">
<a class="nav-link" href="/videos.php">Videos <span class="badge text-bg-secondary"><?php echo $count; ?></span></a>
</li>
</ul> </ul>
<form class="d-flex" action="/search.php" method="GET" role="search"> <form class="d-flex" action="/search.php" method="GET" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" name="q" value=<?php echo "\"".htmlspecialchars($path)."\""; ?>> <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" name="q" value=<?php echo "\"".htmlspecialchars($path)."\""; ?>>
@ -29,4 +33,4 @@
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<br> <br>

71
www/videos.php Normal file
View File

@ -0,0 +1,71 @@
<?php
include("header-1.php");
?>
<title>TYTD Archive - All Videos</title>
<?php
include("header-2.php");
?>
<div class="alert alert-info" role="alert">
The videos page may be empty, click next till videos start showing up.
</div>
<?php
$offset = 0;
$page_first=0;
include_once 'db.php';
if(isset($_GET["page"]))
{
$offset = ((int)$_GET["page"])-1;
$page_first = $offset - ($offset % 3);
}
$stmt = $pdo->prepare("select * from SavedVideo LIMIT ".strval($offset*20).", 20");
$stmt->execute();
$videos = $stmt->fetchAll();
foreach($videos as $video)
{
$class = "class=\"bg-danger\"";
if(strlen(video_exists($video["Id"],"PreMuxed")) > 0)
{
echo "<a 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="./videos.php?page=<?php echo $offset; ?>">Previous</a>
</li>
<li class="page-item <?php
if(($page_first) == $offset) echo "active";
?>"><a class="page-link" href="./videos.php?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="./videos.php?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="./videos.php?page=<?php echo $page_first+3; ?>"><?php
echo $page_first+3;
?></a></li>
<li class="page-item">
<a class="page-link" href="./videos.php?page=<?php echo $offset+2; ?>">Next</a>
</li>
</ul>
</nav>
<?php
include("footer.php");
?>