summaryrefslogtreecommitdiff
path: root/stream.php
blob: bbcc9a75efbc521003a96641dba53f3856a1aad4 (plain)
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
<?php ob_start(function($b){return preg_replace(['/\>[^\S ]+/s','/[^\S ]+\</s','/(\s)+/s'],['>','<','\\1'],$b);}); ?>
<?php
require_once("config.php");
require_once("func.php");
if(empty($_GET["vid"])){
	failure("No video found.", true);
}

require_once("class/redis.php");
$db = new database($REDIS_DBNAME, $REDIS_CONNECT);
$db->open();
if(!$db->listExists($_GET["vid"]))
	failure("No video found.", true);
$title = $db->getItem($_GET["vid"], 1);
$db->close();
unset($db);
?>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title><?php echo $title; ?> :: streaming</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
	<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
	<style><?php echo file_get_contents('./css/style.min.css'); ?></style>
	<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
	<link href="//vjs.zencdn.net/4.8/video-js.css" rel="stylesheet">
	<?php /*
	<link rel="stylesheet" href="/static/style.css">
	<link rel="stylesheet" href="/static/player.css">
	<link rel="stylesheet" href="/static/content.css">
	<script type='text/javascript' src='/boring.js'></script>
	*/ ?>
<?php ob_end_flush(); ?>
	<script type='text/javascript'>

		window.onload = function () {
			doVideo("stream");
		//	new countdown(9, 'counter');
		};
		document.createElement('video');document.createElement('audio');document.createElement('track');

		function doVideo(task){
			r = new XMLHttpRequest();
			r.onreadystatechange=function(){
				if(r.readyState == 4){
					if(r.status == 404){
						document.getElementById('middle').innerHTML=r.responseText;
					} else if(r.status == 200){
						if(r.responseText == "cached"){
							doVideo("player");
						}
						else if(task == "player"){
							document.getElementById('middle').innerHTML=r.responseText;
						} else {
							doVideo("player");
						}
					} else if(r.status == 504){
						document.getElementById('middle').innerHTML="<h1>The connection timed out</h1><br>Please refresh the page.";
						window.reload;
					}
				}
			}
			r.open('GET', '/dl.php?vid=<?php echo htmlentities($_GET["vid"]); ?>&ajax=1&task='+task, true);
			r.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			r.send();
		}
	</script>
	<?php require_once("static/noscript.html"); ?>
</head>
<?php ob_start(function($b){return preg_replace(['/\>[^\S ]+/s','/[^\S ]+\</s','/(\s)+/s'],['>','<','\\1'],$b);}); ?>

<body  >
	<?php require_once("static/header.php"); ?>
	<div class="container">
		<div class="text-center">
			<div id='middle'>
				<div class="row">
					<h1>This may take <span id='counter'>some</span> time.</h1>
				</div>
				<div class="row">
					<p>( meanwhile we are proving P = NP ...&#160; &#160;)</p>
					<br>
					<br>
					<img src='/static/ajax-loader.gif' alt='ajax-loader'>
				</div>
			</div>	
		</div>
	</div>
	<?php require_once("static/foot.php"); ?>
<?php ob_end_flush(); ?>