summaryrefslogtreecommitdiff
path: root/video.php
blob: 2a4b47c7641df4d015b9d1ecdfe340fcc5e0ba4d (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
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
<?php
require("func.php");

$varnotset = false;
if($_SERVER["REQUEST_METHOD"] == "POST"){
	if(empty($_POST["vid"])){
		$varnotset = true;
	} else {
		$video = $_POST["vid"];
	}
} else if ($_SERVER["REQUEST_METHOD"] == "GET") {
	if(empty($_GET["vid"])){
		$varnotset = true;
	} else {
		$video = $_GET["vid"];
	}
} else if ($_SERVER["REQUEST_METHOD"] == "HEAD") {
	if(empty($_GET["vid"])){
		$varnotset = true;
	} else {
		$video = $_GET["vid"];
	}
} else {
	failure("Not supported", true);
}
?>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>Get videos from Youtube or Vimeo</title>
	<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
	<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
	<link rel="stylesheet" href="/css/style.css">
	<?php require_once("static/noscript.html"); ?>
<?php
	if(!$varnotset){
		if($_SERVER["REQUEST_METHOD"] == "GET"){
			echo "
	<script type='text/javascript'>
		function prep_video(task){
			r = new XMLHttpRequest();
			r.onreadystatechange=function(){
				if(r.readyState == 4){
					if(r.status == 200){
						if(task == 'info'){
							document.getElementById('information').innerHTML=r.responseText;
							prep_video('size');
						}
						else if (task == 'size'){
							document.getElementById('size').innerHTML=r.responseText;
							var result = r.responseText.match(/streaming|not/);
							if(result == 'streaming'){
								document.getElementById('audio').className=document.getElementById('audio').className + ' disabled';
								document.getElementById('download').className=document.getElementById('download').className + ' disabled';
							} else if(result == 'not'){
								document.getElementById('audio').className=document.getElementById('audio').className + ' disabled';
								document.getElementById('download').className=document.getElementById('download').className + ' disabled';
								document.getElementById('streaming').className=document.getElementById('streaming').className + ' disabled';
								document.getElementById('options-heading').className=document.getElementById('options-heading').className + ' disabled';
							}
						}
							
					} else if (r.status == 404){
						document.getElementById('information').innerHTML=r.responseText;
					} else if (r.status == 403){
							document.getElementById('size').innerHTML=r.responseText;
							document.getElementById('options').innerHTML=\"<p><h4 style='color:red;';>Oh, we got a 403 error (forbidden). This means, this will not work.<br><br>Read <a href='/faq#video_is_blocked'' title='FAQ: I am blocked' style='color:red;text-decoration:underline;'>here</a> more.</h4>\";
					}
				}
			}
			if(task == 'info'){
				r.open('POST', '/info.php', true);
				r.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
				r.send('vid=".urlencode($video)."', 'ajax=1');
			} else {
				r.open('POST', '/ajax.php', true);
				r.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
				r.send('vid=".urlencode($video)."', 'task=size', 'ajax=1');
			}
		}
	</script>
	";
		} else {
			echo "
	<script type='text/javascript'>
		function prep_video(task){
			r = new XMLHttpRequest();
			r.onreadystatechange=function(){
				if(r.readyState == 4){
					if(r.status == 200){
						var oldUrl = window.location;
						window.location = oldUrl + '/' + r.responseText;
					} else if (r.status == 404){
						document.getElementById('information').innerHTML=r.responseText;
					}
				}
			}
			r.open('POST', '/id.php', true);
			r.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			r.send('vid=".urlencode($video)."','ajax=1');
		}
	</script>
	";
		}
	}
?>
</head>

<body <?php if(!$varnotset) echo "onload=\"prep_video('info')\""; ?>>
<?php require_once("static/header.php"); ?>
<div class="container">
	<div class="text-center">
		<div class="row" >
			<div id='information'>		
<?php
	if(!$varnotset){
		echo "
		<h3>Just one moment please</h3>
		<p>( preparing the aweseome ... &#160; 	&#160;)</p>
		<br>
		<img src='/static/ajax-loader.gif' alt='ajax-loader'>
		<br>";
	} else {
		echo "
		<h3>No video information supplied.<br>Try again please.</h3>
		";
	}
?>
			</div>
		</div>
	</div>
</div>
<?php require_once("static/foot.php"); ?>