-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewPlaylist.php
75 lines (62 loc) · 2.38 KB
/
viewPlaylist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
require "generalFunctions.php";
if (!isset($_GET["playlistName"]) or !isset($_GET["owner"])) {
header("Location: /index.php");
exit();
} else {
$playlistName = $_GET["playlistName"];
$owner = $_GET["owner"];
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include("head.html"); ?>
</head>
<body>
<?php include("header.php"); ?>
<?php include("noscript.html"); ?>
<div class="content-center">
<div>
<?php echo "<h2>" . $playlistName . "</h2>"; ?>
<?php echo "Uploaded by: " . $owner; ?>
<hr>
<?php
$query = "select * from PlaylistContainsSong where playlistName = ? and playlistOwner = ? order by track_no;";
try {
$db = new PDO("sqlite:database/noiseFactionDatabase.db");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$statement = $db->prepare($query);
$result = $statement->execute(array($playlistName, $owner));
$anything = false;
while ($row = $statement->fetch()) {
$anything = true;
echo generateSongPlayerFromPK($row["title"], $row["artist"], $row["songUploader"]);
}
if (!$anything) {
echo "There doesn't seem to be anything here!";
}
} catch(PDOException $e) {
echo 'Exception: '.$e->getMessage();
}
?>
</div>
<hr>
<?php
if ($_SESSION["username"] === $owner) {
echo "Add a song to $playlistName:";
echo "<form method='post' action='addToPlaylist.php'>";
echo "Song title: <input type='text' name='title'><br>";
echo "Song artist: <input type='text' name='artist'><br>";
echo "Song uploader: <input type='text' name='songUploader'><br>";
echo "<input type='text' name='playlistName' value='$playlistName' hidden='true'>";
echo "<input type='text' name='owner' value='$owner' hidden='true'>";
echo "<input type='submit' name='submit' value='Add Song'></form>";
}
?>
</div>
</body>
</html>