Move web related stuff to root

This commit is contained in:
2024-09-14 03:01:32 -07:00
parent 29902eee50
commit 97618f25c1
18 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,50 @@
<?php
/* Copyright (C) 2021 Alexander Rosenberg
* This file is AGPL v3. See LICENSE file for more information
*/
require 'library.php';
require 'Album.php';
header("Content-Type: text/html");
$method = $_SERVER['REQUEST_METHOD'];
function get_albums() {
global $LIBRARY_INFO;
$albums = [];
$start = $_GET['start'];
$end = $_GET['end'];
if (!ctype_digit($start) || !ctype_digit($end) || $start > $end) {
echo 'Invalid range!';
http_response_code(400);
exit(0);
}
$len = count($LIBRARY_INFO['albums']);
if ($start >= $len) {
return array();
}
if ($end >= $len) {
$end = $len - 1;
}
$albums = [];
for ($i = $start; $i <= $end; ++$i) {
$albums[] = new Album($LIBRARY_INFO['albums'][$i]);
}
return $albums;
}
switch ($method) {
case 'HEAD':
case 'GET':
$albums = get_albums();
foreach ($albums as $album) {
echo $album->get_html();
}
break;
default:
echo 'Method not permitted';
http_response_code(405);
exit(0);
}
?>