forked from TheDerpySage/engineertf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
videos.php
204 lines (189 loc) · 8.31 KB
/
videos.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!DOCTYPE html>
<html lang="en">
<?php
function iAmError($n) {
return "<center><h3>An Error Occured: $n</h3><video width='500' autoplay loop><source src='assets/jazz.webm' type='video/webm' autoplay='true'>Your shitty browser does not support Webms. Get a real browser you fucking nerd.</video></center>";
}
/* GET */
$id = isset($_GET['id']) ? $_GET['id'] : '';
$search = isset($_GET['search']) ? $_GET['search'] : '';
?>
<head>
<title>Engineer.tf - Videos</title>
<meta charset="utf-8">
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<style>
table {
width: 100%;
}
td {
padding: 5px;
background-color: #343a40;
text-align:center;
}
td:hover {
background-color: #f5f5f5;
}
body {
background-image: url("assets/engineer.jpg");
background-repeat: no-repeat;
background-color: #000000;
}
h2 {
text-align: center;
}
a {
color: #FFFFFF;
text-align: center;
}
a:hover {
color: #999999;
}
img {
max-width: 100%;
height: auto;
}
.seethru {
opacity: .75;
}
.bg-light-seethru {
background-color: rgba(248, 249, 250, 0.8)
}
.footer {
bottom: 0;
width: 100%;
}
</style>
</head>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark sticky-top">
<a class="navbar-brand" href="#"><img src="assets/nav-logo.png" style="width:40px;"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="./index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./blog.php">Blog</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./videos.php">Videos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./demos.php">Demos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.youtube.com/channel/UCpLek2j00mwJawRD7g6SBJQ">Youtube</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.twitch.tv/engineertf">Twitch</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://discord.gg/S5ekEUT">Discord</a>
</li>
</ul>
</div>
</nav>
<body>
<div class="container" style="margin-top:30px; margin-bottom:30px">
<div class="row bg-primary text-light">
<div class="col text-center">
<br />
<h1>Videos</h1>
<br />
</div>
</div>
<div class="row bg-light-seethru">
<div class="col-sm-12">
<br />
<form action='./videos.php' method='get' name='searchform'>
<?php
# This is here so we can see the search term used still
echo "<input type='text' name='search' value='$search' placeholder='Search'>";
?>
<input class='text' type='submit' value='Search'>
</form>
<br />
<?php
$FILE = './videos.txt';
if(file_exists($FILE)){
$HANDLER = fopen($FILE, "r");
if(empty($id)){
#If no id passed, load the normal page
$i = 0;
echo "<table><tr>";
while (!feof($HANDLER)) {
$LINE = explode(",", fgets($HANDLER));
#Watch out for newline characters
if(trim($LINE[0]) !== ""){
# If no filter has been given, process as normal
if(empty($search)){
echo "<td><a href='./videos.php?id=$LINE[0]'><image src='https://img.youtube.com/vi/$LINE[0]/hqdefault.jpg'><br/>$LINE[1]</a></td>";
$i++;
# Items per row break
if (($i % 2) == 0)
echo "</tr><tr>";
# Else process, but filter based on our search term
} else {
# No case sensitive search
if (strpos(strtolower($LINE[1]), strtolower($search)) !== false){
echo "<td><a href='./videos.php?id=$LINE[0]'><image src='https://img.youtube.com/vi/$LINE[0]/hqdefault.jpg'><br/>$LINE[1]</a></td>";
$i++;
# Items per row break
if (($i % 2) == 0)
echo "</tr><tr>";
}
}
}
}
# If no results, say as much...
if ($i == 0){
echo "<p>No results</p>";
}
echo "</tr></table>";
fclose($HANDLER);
} else {
#If an id is passed, start embed process
$title = "";
$HANDLER = fopen($FILE, "r");
#Validate the given id against whats in our file, and get our video title if we find it.
while (!feof($HANDLER)) {
$LINE = explode(",", fgets($HANDLER));
if ($id == $LINE[0]){
$title = $LINE[1];
break;
}
}
fclose($HANDLER);
#If it's in our file, finish processing
if ($title !== ""){
echo "<h2>$title</h2>";
echo "<br /><div class='embed-responsive embed-responsive-16by9'>";
echo "<iframe class='embed-responsive-item' src='https://www.youtube.com/embed/$id?autoplay=1&rel=0' frameborder='0' allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture' allowfullscreen></iframe>";
echo "</div><br />";
echo "<a href='./videos.php' role='button' class='btn btn-primary btn-sm'><--Back--</a><br />";
#If it's not in our file, error out
} else { echo iAmError("Not a valid video"); }
}
#If there is no file, error out
} else { echo iAmError("Videos File Not Found"); }
#Why do this?
#I dunno, I like input validation even tho it wouldn't be THAT hard for someone to client side deface the site if they REALLY wanted to.
?>
<br />
</div>
</div>
</div>
</body>
<footer class="footer card-footer text-center bg-dark">
<a href="./exaflamer/"><img src="assets/exa_colorcorrected.png" style="height:60px"></a>
<br />
<small class="text-muted">Last updated February 2020</small>
</footer>
</html>