diff options
| author | root | 2014-09-13 22:26:58 +0200 |
|---|---|---|
| committer | root | 2014-09-13 22:26:58 +0200 |
| commit | c5639ee890215e4e8e0f544821ea8d285ca58eb8 (patch) | |
| tree | 29f685943c61c4d7ec0e376e485686e985b97065 /video.php | |
| parent | f8c60cae423fc78ed21d17a9217716ccc1e6dab1 (diff) | |
| download | video-dl-c5639ee890215e4e8e0f544821ea8d285ca58eb8.tar.gz | |
init
Diffstat (limited to 'video.php')
| -rw-r--r-- | video.php | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/video.php b/video.php new file mode 100644 index 0000000..2a4b47c --- /dev/null +++ b/video.php @@ -0,0 +1,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 ...    )</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"); ?> |
