summaryrefslogtreecommitdiff
path: root/ajax.php
diff options
context:
space:
mode:
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;