Beispiel #1
0
	public function add(Request $request)
	{
		$hash = $request->get_hash();
		$new_requests = $request->extract_children();

		if ($this->get_hash() == $hash) {
			foreach ($request->get_binded() as $object) {
				$this->bind($object);
			}
			unset($request);
		} else {
			if (isset($this->requests[$hash])) {
				foreach ($request->get_binded() as $callback) {
					$this->requests[$hash]->bind($callback);
				}
				unset($request);
			} else {
				$this->requests[$hash] = $request;
			}
		}

		foreach ($new_requests as $new_request) {
			$this->add($new_request);
		}
	}
Beispiel #2
0
	public function gather_request() {
		$request = new Request();

		foreach ($this->modules as $module) {
			$request->add($module->gather_request());
		}

		$add = $this->make_request();
		$add = is_object($add) ? [$add] : $add;
		foreach ($add as $item) {
			$request->add($item);
		}

		return $request;
	}
Beispiel #3
0
 protected function make_request()
 {
     $url = Config::getInstance()->get('api', 'url');
     $link = false;
     foreach ($_FILES as $file) {
         foreach ((array) $file['type'] as $key => $type) {
             if (strpos($type, 'link') !== false) {
                 $link = file_get_contents($file['tmp_name'][$key]);
                 break 2;
             }
         }
     }
     if ($link) {
         if (!Config::getInstance()->get('api', 'inner')) {
             $request = new Request('upload_art', $this, ['file' => $link]);
             $request->perform();
         } else {
             $api = new ApiUploadArt(new ApiRequestInner(['file' => $link]));
             $response = $api->set_base_path(API_IMAGES)->process_request()->get_response();
             $this->recieve_data($response);
         }
         return array();
     }
     // Hacked because of file send
     if (!Config::getInstance()->get('api', 'inner')) {
         $url .= '/upload/art';
         $post = [];
         foreach ($_FILES['file']['tmp_name'] as $key => $file) {
             $post['file' . $key] = '@' . $file . ';filename=' . $_FILES['file']['name'][$key] . ';type=' . $_FILES['file']['type'][$key];
         }
         $header = ['Content-type: multipart/form-data'];
         $ch = curl_init($url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_ENCODING, '');
         curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
         $response = curl_exec($ch);
         curl_close($ch);
     } else {
         $api = new ApiUploadArt(new ApiRequest('dummy'));
         $response = $api->set_base_path(API_IMAGES)->process_request()->get_response();
     }
     $this->recieve_data(json_decode($response, true));
     return array();
 }