summaryrefslogtreecommitdiff
path: root/ajax.php
diff options
context:
space:
mode:
authorroot2014-09-13 22:26:58 +0200
committerroot2014-09-13 22:26:58 +0200
commitc5639ee890215e4e8e0f544821ea8d285ca58eb8 (patch)
tree29f685943c61c4d7ec0e376e485686e985b97065 /ajax.php
parentf8c60cae423fc78ed21d17a9217716ccc1e6dab1 (diff)
downloadvideo-dl-c5639ee890215e4e8e0f544821ea8d285ca58eb8.tar.gz
init
Diffstat (limited to 'ajax.php')
-rw-r--r--ajax.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/ajax.php b/ajax.php
new file mode 100644
index 0000000..ed3f596
--- /dev/null
+++ b/ajax.php
@@ -0,0 +1,32 @@
+<?php
+
+require_once("func.php");
+if($_SERVER["REQUEST_METHOD"] != "POST")
+ failure("Request method not supported.", false);
+
+if(empty($_POST["vid"]))
+ failure("Not found.", false);
+
+require_once("config.php");
+require_once("class/redis.php");
+
+$id = getId($_POST["vid"]);
+$db = new database($REDIS_DBNAME, $REDIS_CONNECT);
+$db->open();
+$vidurl = $db->getItem($id, 3);
+$curl = curlInfo($vidurl);
+$filesize = $curl[2];
+
+$size = BytesHumanSize($filesize);
+if($filesize < $MAXSIZE && $filesize != 0){ /* 50M */
+ $filesize = "<p style='color:green;'>Size: ".$size."</p>";
+} else if($filesize < $STREAM_MAXSIZE && $filesize != 0){
+ $filesize = "<p style='color:red;'>Size: ".$size." (only streaming supported!)</p>";
+} else if($filesize != 0) {
+ $filesize = "<p style='color:red;'>Size: ".$size." (not supported!)</p>";
+} else {
+ $filesize = "<p style=\"color:red;\">Size: ".$size." (Access forbidden!)</p>";
+ header($_SERVER['SERVER_PROTOCOL'] . " $curl[0] forbidden");
+}
+
+echo $filesize;