From b44a26eb73010260922d242875a3b4773936a084 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 15 Sep 2014 15:04:39 +0200 Subject: f5 protection and improved UI --- 404.php | 1 - 504.php | 1 - dl.php | 12 ++++++------ error.php | 1 - faq.php | 1 - func.php | 10 +++++----- func_youtube.php | 3 ++- help.php | 1 - index.php | 2 +- random.php | 1 - stream.php | 30 ++++++++++++++++++++++-------- video.php | 1 - 12 files changed, 36 insertions(+), 28 deletions(-) diff --git a/404.php b/404.php index b72a40a..eea3fc5 100644 --- a/404.php +++ b/404.php @@ -8,7 +8,6 @@ - diff --git a/504.php b/504.php index bc7dd29..a2d414b 100644 --- a/504.php +++ b/504.php @@ -8,7 +8,6 @@ - diff --git a/dl.php b/dl.php index 3fd0753..0cf9f59 100644 --- a/dl.php +++ b/dl.php @@ -120,7 +120,7 @@ switch($_GET["task"]){ case("stream"): ignore_user_abort(true); if(file_exists($CACHEDIR."/".$info[2].".txt")) - failure('
This is very cpu intensive operation, so thanks for your understanding.
', false);
+ failure('This page will refresh when the task is done.
', false);
# send 'cached' response in case we already have the video on disk
if(file_exists($CACHEDIR."/".$info[2]) && !file_exists($CACHEDIR."/".$info[2].".txt")){
echo "cached";
@@ -151,20 +151,20 @@ switch($_GET["task"]){
}
*/
if(file_exists($CACHEDIR."/".$info[2].".webm.txt"))
- failure('( This is very cpu intensive operation, so thanks for your understanding. )
', false);
+ failure('This page will refresh when the task is done.
( This is a very cpu intensive operation, so it may take a while. )
', false);
if(file_exists($CACHEDIR."/".$info[2]."webm")){
echo "cached";
exit;
} else {
- if(!convert_video($CACHEDIR, $info[2]))
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ $mime = $finfo->file($CACHEDIR . "/" . $info[2]);
+
+ if(!convert_video($CACHEDIR, $info[2], $mime))
failure("Converting video failed.", false);
else
unlink($CACHEDIR."/".$info[2].".webm.txt");
}
- $finfo = new finfo(FILEINFO_MIME_TYPE);
- $mime = $finfo->file($CACHEDIR . "/" . $info[2]);
-
pr_player(htmlentities($CACHEDIR . "/" . $info[2]), htmlentities($info[4]), htmlentities($mime), htmlentities($info[1]), htmlentities($info[2]), true);
break;
diff --git a/error.php b/error.php
index 3265184..9fecf27 100644
--- a/error.php
+++ b/error.php
@@ -9,7 +9,6 @@
-
diff --git a/faq.php b/faq.php
index 16832e1..9a435ab 100644
--- a/faq.php
+++ b/faq.php
@@ -8,7 +8,6 @@
-
diff --git a/func.php b/func.php
index 0a626c0..0efa43a 100644
--- a/func.php
+++ b/func.php
@@ -68,9 +68,9 @@ function video_xt_audio($VIDEO, $CACHEDIR, $FILENAME){
return true;
}
-function convert_video($CACHEDIR, $FILENAME){
+function convert_video($CACHEDIR, $FILENAME, $MIME){
$fp=fopen($CACHEDIR."/".$FILENAME.".webm.txt", "w");
- $content="extracting audio: ".$FILENAME."\n";
+ $content="converting video ".$FILENAME." to .webm\n";
fputs($fp, $content);
fclose($fp);
/*
@@ -81,9 +81,9 @@ function convert_video($CACHEDIR, $FILENAME){
*/
if(file_exists($CACHEDIR . "/" . $FILENAME.".webm"))
return true;
- rename($CACHEDIR . "/" . $FILENAME, $CACHEDIR . "/" . $FILENAME. ".mp4");
- exec("ffmpeg -i " . $CACHEDIR . "/" . $FILENAME. ".mp4 " . $CACHEDIR . "/" . $FILENAME. ".webm", $pid, $ret);
- rename($CACHEDIR . "/" . $FILENAME . ".mp4", $CACHEDIR . "/" . $FILENAME);
+// rename($CACHEDIR . "/" . $FILENAME, $CACHEDIR . "/" . $FILENAME. ".mp4");
+ exec("ffmpeg -f ".escapeshellarg(preg_replace("/^video\//i", "", $MIME))." -i " . escapeshellarg($CACHEDIR . "/" . $FILENAME). " " . escapeshellarg($CACHEDIR . "/" . $FILENAME. ".webm"), $output, $ret);
+// rename($CACHEDIR . "/" . $FILENAME . ".mp4", $CACHEDIR . "/" . $FILENAME);
if($ret != 0){
return false;
}
diff --git a/func_youtube.php b/func_youtube.php
index 9affc33..692cc90 100644
--- a/func_youtube.php
+++ b/func_youtube.php
@@ -11,7 +11,8 @@ $yt->setMajorProtocolVersion(2);
function error(){
- header("Refresh: 0; /youtube");
+ header($_SERVER['SERVER_PROTOCOL'] . " 503 Temporary unavailable");
+ header("Refresh: 0; /random");
exit;
}
diff --git a/help.php b/help.php
index eef5dc6..a2cda89 100644
--- a/help.php
+++ b/help.php
@@ -8,7 +8,6 @@
-
diff --git a/index.php b/index.php
index 9cad5db..da964d0 100644
--- a/index.php
+++ b/index.php
@@ -8,8 +8,8 @@
-
*/ ?>
diff --git a/random.php b/random.php
index 02194dd..3c99705 100644
--- a/random.php
+++ b/random.php
@@ -7,7 +7,6 @@
-
@@ -47,26 +46,41 @@ unset($db);
if(r.readyState == 4){
if(r.status == 404){
document.getElementById('middle').innerHTML=r.responseText;
+ var checkIfReload = r.responseText.match(/Convert|Stream/);
+ //alert(checkIfReload);
+ var checkIfFailed = r.responseText.match(/failed/);
+ if(checkIfFailed != 'failed' && (checkIfReload == 'Convert' || checkIfReload == 'Stream')){
+ var todo = checkIfReload.toString().toLowerCase();
+ setTimeout(function(){
+ doVideo(todo);
+ }, 5000);
+ }
} else if(r.status == 200){
if(r.responseText == "cached"){
doVideo("player");
}
else if(task == "player"){
document.getElementById('middle').innerHTML=r.responseText;
+ var askToConvert = localStorage.getItem('askToConvert') || '';
var canPlay = false;
var v = document.createElement('video');
if(v.canPlayType && v.canPlayType('video/mp4').replace(/no/, '')) {
canPlay = true;
}
if(canPlay != true){
- var canWebm = false;
- if(v.canPlayType && v.canPlayType('video/webm').replace(/no/, '')){
- if(window.confirm('It seems your browser doesn\'t support mp4 videos. Do you want to convert it to WebM?')){
- document.getElementById('middle').innerHTML='
This page will refresh when the task is done.
( This is a very cpu intensive operation, so it may take a while. )
