-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfull-recordings.php
81 lines (69 loc) · 2.63 KB
/
full-recordings.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
76
77
78
79
80
81
<?php
// Global database/session initialization.
require_once "./config.php";
$sort = trim($_GET["sort"]);
if(empty($sort)){
$sort = desc;
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="./styles.css">
</head>
<body>
<h1 class="main-title"><?php echo $sitename ?></h1>
<p class="top-nav">
<a class="button-orange" href="./index.php">Home</a>
<a class="button-blue" <?php if($sort == "asc"){echo "style=\"text-decoration: underline; text-underline-position: under;\"";} ?>href="./full-recordings.php?sort=asc">Oldest First</a>
<a class="button-blue" <?php if($sort == "desc"){echo "style=\"text-decoration: underline; text-underline-position: under;\"";} ?>href="./full-recordings.php?sort=desc">Newest First</a>
</p>
<table class="full-recordings-list">
<tr>
<th>Preview</th>
<th>Title</th>
<th>Date</th>
<th>Primary Game</th>
<th style="text-align: center;">Secondary Game</th>
<th>Length</th>
</tr>
<?php
// SQL query for getting all full recordings, ascending.
if($sort == "asc"){
$stmt = $pdo->prepare("SELECT title, date, primary_game, secondary_game, length, id, thumb FROM full ORDER BY date ASC");
}elseif($sort == "desc"){
$stmt = $pdo->prepare("SELECT title, date, primary_game, secondary_game, length, id, thumb FROM full ORDER BY date DESC");
}
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach(new RecursiveArrayIterator($stmt->fetchAll()) as $result) {
$x++;
$resultColor = ($x%2 == 0)? 'darkResult': 'lightResult';
echo "<tr class=\"" . $resultColor . "\" >";
echo "<td><a href=\"./experience.php?id=" . $result['id'] . "\"><img class=\"full-preview\" src=\"" . $result['thumb'] . "\" /></a></td>";
echo "<td><a class=\"episode-link\" href=\"./experience.php?id=" . $result['id'] . "\"> " . $result['title'] . "</a></td>";
echo "<td>" . $result['date'] . "</td>";
echo "<td>" . $result['primary_game'] . "</td>";
echo "<td style=\"text-align: center;\">" . $result['secondary_game'] . "</td>";
echo "<td>" . $result['length'] . "</td>";
echo "</tr></a>";
}
unset($pdo);
?>
</table>
<p class="bottom-nav">
<?php
if($_SESSION["loggedin"] == false){
echo '<a class="button-orange" href="./login.php">Log In</a>';
}
if($_SESSION["loggedin"] == true){
if($_SESSION["admin"] == true){
echo '<a class="button-blue" href="./experience-add.php">Add Recording</a>';
}
echo '<a class="button-orange" href="./logout.php">Log Out</a>';
}
?>
</p>
<?php require_once "./footer.php"; ?>
</body>
</html>