This repository has been archived by the owner on Dec 16, 2023. It is now read-only.
forked from AniDevTwitter/animeopenings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·251 lines (222 loc) · 10.1 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
<?php
include_once 'backend/includes/helpers.php';
include_once 'names.php';
// check if a specific video has been requested
if (isset($_GET['video'])) {
// this should be fine for most cases
$video = identifierToFileData($_GET['video']);
// but if it isn't we can try this too
if ($video === false) {
// get raw query so it doesn't try to parse the reserved characters (;/?:@&=+,$)
// the `substr` call removes the "video=" from the start
$identifier = substr($_SERVER['QUERY_STRING'],6);
$video = identifierToFileData(rawurldecode($identifier));
}
if ($video === false) {
header('HTTP/1.0 404 Not Found');
include_once 'backend/pages/notfound.php';
die();
}
$series = $video['series'];
$title = $video['title'];
$filename = $video['file'];
$pagetitle = (isset($video['egg']) ? 'Secret~' : ($title . ' from ' . $series));
$description = '';
} else { // otherwise pick a random video
$series = array_rand($names);
$title = array_rand($names[$series]);
$video = $names[$series][$title];
$filename = $video['file'];
$pagetitle = 'Anime Openings';
$description = 'Anime openings from hundreds of series in high-quality';
}
$identifier = filenameToIdentifier($filename);
$filename = rawurlencode($filename);
$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'] . ']') : '';
$isEgg = isset($video['egg']);
$baseURL = 'https://' . $WEBSITE_URL . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1);
$oembedURL = $baseURL . 'api/oembed/?url=' . $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 $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 . 'video/' . $filename . $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) . '">';
}
echo PHP_EOL;
?>
<!-- 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 config values from PHP into JavaScript.
window.config = {
VIDEO_INDEX_PADDING: <?php echo $VIDEO_INDEX_PADDING; ?>,
USE_FILENAME_AS_IDENTIFIER: <?php echo ($USE_FILENAME_AS_IDENTIFIER ? 'true' : 'false') . PHP_EOL; ?>
};
</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="video/' . $filename . $ext . '" type="' . htmlspecialchars($mime) . '">';
}
echo PHP_EOL;
?>
</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="videoTypeToggle" class="quadbutton fa fa-circle"></span>
<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 ' . $series; ?></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 ($isEgg || 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 ($isEgg) echo ' hidden'; ?>><a href="?video=<?php if (!$isEgg) 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"' . ($isEgg ? ' hidden' : '') . '><a href="video/' . (!$isEgg ? $filename . $ext : '') . '" download>Download this video as ' . substr($ext,1) . '</a></li>';
}
echo PHP_EOL;
?>
<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>
<form id="settings-form">
<fieldset>
<legend>Show Video Title</legend>
<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>
</fieldset>
<fieldset>
<legend>Play</legend>
<label><input checked name="videoType" type="radio" value="all">All</label>
<label><input name="videoType" type="radio" value="op">Openings Only</label>
<label><input name="videoType" type="radio" value="ed">Endings Only</label>
</fieldset>
<fieldset>
<legend>On End</legend>
<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>
</fieldset>
<fieldset>
<legend>Enable Subtitles</legend>
<label><input checked id="subtitle-checkbox" type="checkbox">Yes</label>
</fieldset>
<fieldset>
<legend>Volume</legend>
<input id="volume-slider" type="range" min="0" max="100" value="100" step="1">
<label for="volume-slider" id="volume-amount">100%</label>
</fieldset>
</form>
</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>