summaryrefslogtreecommitdiff
path: root/protected/Async.php
diff options
context:
space:
mode:
authoryo mama <pepper@scannerjammer.com>2015-04-04 01:11:47 -0700
committeryo mama <pepper@scannerjammer.com>2015-04-04 01:11:47 -0700
commita736da57f084017ac17e06cd9db19b1fd166e1a6 (patch)
tree55a9e83b31f6bdc176731125de0cc42668daf988 /protected/Async.php
first
Diffstat (limited to 'protected/Async.php')
-rwxr-xr-xprotected/Async.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/protected/Async.php b/protected/Async.php
new file mode 100755
index 0000000..0f677e8
--- /dev/null
+++ b/protected/Async.php
@@ -0,0 +1,71 @@
+<?php
+
+
+class Async {
+
+ private $_method = 'error';
+
+ public function __construct($method,$password){
+
+ $realPassword = Settings::$DeveloperPassword;
+
+ if($password == $realPassword){
+ $this->_method = $method;
+ }
+ }
+
+ public function Run(){
+ $method = $this->_method;
+
+ $this->$method();
+ }
+
+ private function error(){
+
+ }
+
+ private function cacheVideo(){
+
+ $url = (isset($_POST['url'])) ? $_POST['url'] : null;
+
+ $cache = new Cache();
+
+ $cache->CacheHttpVideo($url);
+
+ }
+
+
+ public static function createAsyncRequest($uri, $params){
+
+ $type='POST';
+
+ foreach ($params as $key => &$val) {
+ if (is_array($val)) $val = implode(',', $val);
+ $post_params[] = $key.'='.urlencode($val);
+ }
+
+ $post_string = implode('&', $post_params);
+
+ $domain = Settings::$Domain;
+ $parts=parse_url($domain . $uri);
+
+ $fp = fsockopen($parts['host'],
+ isset($parts['port'])?$parts['port']:80,
+ $errno, $errstr, 2);
+
+ // Data goes in the path for a GET request
+ if('GET' == $type) $parts['path'] .= '?'.$post_string;
+
+ $out = "$type ".$parts['path']." HTTP/1.1\r\n";
+ $out.= "Host: ".$parts['host']."\r\n";
+ $out.= "Content-Type: application/x-www-form-urlencoded\r\n";
+ $out.= "Content-Length: ".strlen($post_string)."\r\n";
+ $out.= "Connection: Close\r\n\r\n";
+ // Data goes in the request body for a POST request
+ if ('POST' == $type && isset($post_string)) $out.= $post_string;
+
+ fwrite($fp, $out);
+ fclose($fp);
+
+ }
+}