-
Notifications
You must be signed in to change notification settings - Fork 36
/
index.php
executable file
·271 lines (241 loc) · 10.4 KB
/
index.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<?php
require 'backend/includes/helpers.php';
$params = $_GET;
if (!isset($_GET['strict'])) {
$params['strict'] = true;
}
if (isset($_GET['video'])) {
$params['uid'] = $_GET['video'];
}
// this should be fine for most cases
$video_data = getVideoData($params);
// but if it isn't we can try this too
if (!isset($video_data['data'])) {
// get raw query so it doesn't try to parse the reserved characters (;/?:@&=+,$)
// the `substr` call removes the "video=" from the start
$params['uid'] = rawurldecode(substr($_SERVER['QUERY_STRING'],6));
$video_data = getVideoData($params);
}
if (!isset($video_data['data'])) {
header('HTTP/1.0 404 Not Found');
include_once 'backend/pages/notfound.php';
die();
}
$video = $video_data['data'];
$identifier = $video['uid'];
$filepath = (strlen($video['path']) > 0 ? (rawurlencode($video['path']) . '/') : '') . rawurlencode($video['file']);
$title = $video['title'];
$source = $video['source'];
$songKnown = array_key_exists('song', $video);
if ($songKnown) {
$songTitle = $video['song']['title'];
$songArtist = $video['song']['artist'];
if ($description == '')
$description = 'Song: "' . $songTitle . '" by ' . $songArtist;
}
$subtitlesAvailable = array_key_exists('subtitles', $video);
$subtitleAttribution = $subtitlesAvailable ? ('[' . $video['subtitles'] . ']') : '';
$hidden = isset($video['hidden']) && $video['hidden'];
if (isset($_GET['video'])) {
$pagetitle = ($hidden ? 'Secret~' : ($title . ' from ' . $source));
$description = '';
} else {
$pagetitle = 'Anime Openings';
$description = 'Anime openings from hundreds of series in high-quality';
}
$baseURL = 'https://' . $CACHE['WEBSITE_URL'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1);
$oembedURL = $baseURL . 'api/oembed/?url=' . rawurlencode($baseURL . '?' . $_SERVER['QUERY_STRING']);
?>
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#">
<head>
<!-- Basic Page Stuff -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title><?php echo $pagetitle; ?></title>
<meta name="description" content="<?php echo $description; ?>">
<!-- oEmbed Discovery -->
<link rel="alternate" type="application/json+oembed" href="<?php echo $oembedURL; ?>&format=json" title="<?php echo $pagetitle; ?>">
<link rel="alternate" type="text/xml+oembed" href="<?php echo $oembedURL; ?>&format=xml" title="<?php echo $pagetitle; ?>">
<!-- Open Graph Tags -->
<meta property="og:type" content="video.other">
<meta property="og:url" content="<?php echo $baseURL . '?video=' . $identifier; ?>">
<meta property="og:site_name" content="<?php echo $CACHE['WEBSITE_URL']; ?>">
<meta property="og:title" content="<?php echo $pagetitle; ?>">
<meta property="og:description" content="<?php echo $description; ?>">
<meta property="og:image" content="<?php echo $baseURL; ?>assets/logo/512px.png"><?php
foreach ($video['mime'] as $mime) {
$ext = mimeToExt($mime);
$content = ' content="' . $baseURL . $filepath . $ext . '"';
echo "\n\t\t" . '<meta property="og:video"' . $content . '>';
echo "\n\t\t" . '<meta property="og:video:url"' . $content . '>';
echo "\n\t\t" . '<meta property="og:video:secure_url"' . $content . '>';
echo "\n\t\t" . '<meta property="og:video:type" content="' . htmlspecialchars($mime) . '">';
if (isset($video['width'])) {
echo "\n\t\t" . '<meta property="og:video:width" content="' . $video['width'] . '">';
}
if (isset($video['height'])) {
echo "\n\t\t" . '<meta property="og:video:height" content="' . $video['height'] . '">';
}
}
echo "\n";
?>
<!-- Facebook App Link -->
<meta property="al:web:url" content="<?php echo $baseURL . '?video=' . $identifier; ?>">
<!-- CSS and JS Resources -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="CSS/main.css">
<link rel="stylesheet" type="text/css" href="CSS/fonts.css">
<link rel="stylesheet" type="text/css" href="CSS/subtitles.css">
<script type="text/javascript">
// Set values from PHP into JavaScript.
const BACKEND_VALUES = {
'prefix_skip': '<?php echo PREFIX_SKIP; ?>',
'video_data': <?php echo json_encode($video_data); ?>
};
</script>
<script src="JS/main.js"></script>
<script defer src="JS/subtitles.js"></script>
<!-- Web App Tags -->
<meta name="theme-color" content="#E58B00">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<!-- Logo Links -->
<link href="/assets/logo/152px.png" rel="apple-touch-icon">
<link href="/assets/logo/16px.png" rel="icon" sizes="16x16">
<link href="/assets/logo/32px.png" rel="icon" sizes="32x32">
<link href="/assets/logo/64px.png" rel="icon" sizes="64x64">
<link href="/assets/logo/152px.png" rel="icon" sizes="152x152">
<link href="/assets/logo/512px.png" rel="icon" sizes="512x512">
</head>
<body>
<div id="wrapper">
<video id="bgvid" loop preload="none"><?php
foreach ($video['mime'] as $mime) {
$ext = mimeToExt($mime);
echo "\n\t\t\t\t" . '<source src="' . $filepath . $ext . '" type="' . htmlspecialchars($mime) . '">';
}
echo "\n";
?>
</video>
</div>
<i id="giant-play-button" class="overlay fa fa-play quadbutton quadNotMobile"></i>
<div id="progressbar" class="progressbar">
<div class="progress">
<div id="bufferprogress" class="progress"></div>
<div id="timeprogress" class="progress"></div>
</div>
</div>
<div class="displayTopRight"></div>
<a id="menubutton" href="/hub/faq.php" class="quadbutton fa fa-bars"></a>
<a id="searchbutton" href="/list/" class="quadbutton fa fa-search"></a>
<div class="controlsleft">
<span id="getnewvideo" class="quadbutton fa fa-refresh"></span>
<span id="autonext" class="quadbutton fa fa-toggle-off"></span>
</div>
<div class="controlsright">
<span id="subtitles-button" class="quadbutton fa fa-commenting-o"<?php if (!$subtitlesAvailable) echo ' style="display:none"'; ?>></span>
<span id="skip-left" class="quadbutton fa fa-arrow-left"></span>
<span id="skip-right" class="quadbutton fa fa-arrow-right"></span>
<span id="pause-button" class="quadbutton fa fa-play"></span>
<span id="fullscreen-button" class="quadbutton fa fa-expand"></span>
</div>
<div id="site-menu" hidden>
<span id="closemenubutton" class="quadbutton fa fa-times"></span>
<p id="title"><?php echo $title; ?> </p>
<p id="source"><?php echo 'From ' . $source; ?></p>
<span id="song"><?php // If we have the data, echo it
if ($songKnown)
echo 'Song: "' . $songTitle . '" by ' . $songArtist;
else { // Otherwise, let's just pretend it never existed... or troll the user.
if ($hidden || mt_rand(0,100) == 1)
echo 'Song: "Sandstorm" by Darude';
} ?></span>
<p id="subs"<?php if (!$subtitlesAvailable) echo ' style="display:none"'; ?>>Subtitles by <span id="subtitle-attribution"><?php echo $subtitleAttribution; ?></span></p>
<ul id="linkarea">
<li class="link"<?php if ($hidden) echo ' hidden'; ?>><a href="?video=<?php if (!$hidden) echo $identifier; ?>" id="videolink">Link to this video</a></li><?php
foreach ($video['mime'] as $mime) {
$ext = mimeToExt($mime);
echo "\n\t\t\t\t" . '<li class="link videodownload"' . ($hidden ? ' hidden' : '') . '><a href="' . (!$hidden ? $filepath . $ext : '') . '" download>Download this video as ' . substr($ext,1) . '</a></li>';
}
echo "\n";
?>
<li class="link"><a id="listlink" href="list/">Video list</a></li>
<li class="link"><a href="hub/">Hub</a></li>
</ul>
<div class="accordion">
<input type="checkbox" id="settings-checkbox">
<label for="settings-checkbox">
<i class="fa fa-chevron-right"></i>
<i class="fa fa-chevron-down"></i>
Saved settings
</label>
<table id="settings-table">
<tr>
<td>Show Video Title</td>
<td>
<input id="show-title-checkbox" type="checkbox" checked><label for="show-title-checkbox">Yes</label>
<label id="show-title-delay">after <input type="number" min="0" value="0" step="1"> seconds</label>
</td>
</tr>
<tr id="video-types">
<td>Show Video Types</td>
<td><?php
foreach ($CACHE['TYPES'] as $key => $value) {
if ($key !== $value['name']) continue;
echo "\n\t\t\t\t\t\t\t" . '<label' . ($value['hidden'] ? ' hidden' : '') . '><input type="checkbox" value="' . $value['abbreviation'] . '" checked>' . $key . '</label>';
}
echo "\n";
?>
</td>
</tr>
<tr>
<td>On End</td>
<td>
<label><input checked name="autonext" type="radio" value="false">Repeat Video</label>
<label><input name="autonext" type="radio" value="true">Get a New Video</label>
</td>
</tr>
<tr>
<td>Enable Subtitles</td>
<td>
<label><input checked id="subtitle-checkbox" type="checkbox">Yes</label>
</td>
</tr>
<tr>
<td>Volume</td>
<td>
<input id="volume-slider" type="range" min="0" max="100" value="100" step="1">
<label for="volume-slider" id="volume-amount">100%</label>
</td>
</tr>
</table>
</div>
<div class="accordion">
<input type="checkbox" id="keybindings-checkbox">
<label for="keybindings-checkbox">
<i class="fa fa-chevron-right"></i>
<i class="fa fa-chevron-down"></i>
Keyboard bindings
</label>
<table id="keybindings-table">
<tr><th>Key</th><th>Action</th></tr>
<tr><td>M</td><td>Open/Close Menu</td></tr>
<tr><td>/</td><td>Open Search Pane</td></tr>
<tr><td>N</td><td>Get a new video</td></tr>
<tr><td>S</td><td>Toggle subtitles (if available)</td></tr>
<tr><td><span class="fa fa-arrow-left"></span>/<span class="fa fa-arrow-right"></span></td><td>Back/Forward 10 seconds</td></tr>
<tr><td>Space</td><td>Pause/Play</td></tr>
<tr><td>F</td><td>Toggle fullscreen</td></tr>
<tr><td>Page Up/Down</td><td>Volume</td></tr>
<tr><td>Scroll Wheel</td><td>Volume</td></tr>
</table>
</div>
</div>
<div id="tooltip" class="is-hidden"></div>
<span id="title-popup"></span>
<div id="modal" class="overlay"><iframe></iframe></div>
<?php include_once 'backend/includes/botnet.html'; ?>
</body>
</html>