public static function IsUploadRequest() { if ("post" != UrlUtils::RequestMethod()) { return false; } return sizeof($_FILES) > 0; }
public function Execute($method = null) { if ($method == null) { $method = UrlUtils::RequestMethod(); if (UrlUtils::ExistRequestParam("method")) { $method = strtolower(UrlUtils::GetRequestParam("method")); } } $availableMethods = get_class_methods(get_class($this)); $function = "do" . $method; try { if (in_array($function, $availableMethods)) { $this->{$function}(); } else { ApiBase::ReturnError("Invalid method", 405); } } catch (Exception $ex) { ApiBase::ReturnError($ex->getMessage(), 500); } }
public static function InitializeJsonInput() { if (UrlUtils::$_data != null) { return; } if (UrlUtils::RequestMethod() == "post" || UrlUtils::RequestMethod() == "put") { $postdata = UrlUtils::FileGetContents(); UrlUtils::$_data = json_decode($postdata, true); } }
public function RawRequest() { global $v2BatchDebug; if (!array_key_exists('CONTENT_TYPE', $_SERVER) && UrlUtils::RequestMethod() != "post") { HttpUtils::ApiError(405, "The HTTP verb used is not allowed."); } $a_data = array(); // read incoming data $input = file_get_contents('php://input'); if ($v2BatchDebug) { file_put_contents("batch.log", "REQUEST:" . $input . "\r\n", FILE_APPEND); file_put_contents("batch.log", "\r\n", FILE_APPEND); } // grab multipart boundary from content type header preg_match('/boundary=(.*)$/', $_SERVER['CONTENT_TYPE'], $matches); // content type is probably regular form-encoded if (!count($matches)) { return null; } $boundary = $matches[1]; $parsed = $this->ParseData($boundary, $input); $result = array(); if ($v2BatchDebug) { file_put_contents("batch.log", "PARSING:" . sizeof($parsed) . "\r\n", FILE_APPEND); file_put_contents("batch.log", "\r\n", FILE_APPEND); } for ($i = 0; $i < sizeof($parsed); $i++) { $item = $parsed[$i]; $item->ResultStatus = 200; if ($item->Method == "get") { $item->ResultData = HttpUtils::HttpGet($item->Action); } else { if ($item->Method == "get") { $item->ResultData = HttpUtils::HttpPost($item->Action, $item->Data, "application/atom+xml"); } } array_push($result, $item); } $response = Batcher::Elaborate($result); if ($v2BatchDebug) { file_put_contents("batch.log", "RESULT:" . $response . "\r\n", FILE_APPEND); file_put_contents("batch.log", "\r\n", FILE_APPEND); } }