public static function call(OkapiRequest $request) { $result = array(); $result['site_url'] = Settings::get('SITE_URL'); $result['okapi_base_url'] = Okapi::get_recommended_base_url(); $result['okapi_base_urls'] = Okapi::get_allowed_base_urls(); $result['site_name'] = Okapi::get_normalized_site_name(); $result['okapi_version_number'] = Okapi::$version_number; $result['okapi_revision'] = Okapi::$version_number; /* Important for backward-compatibility! */ $result['okapi_git_revision'] = Okapi::$git_revision; $result['registration_url'] = Settings::get('REGISTRATION_URL'); $result['mobile_registration_url'] = Settings::get('MOBILE_REGISTRATION_URL'); $result['image_max_upload_size'] = Settings::get('IMAGE_MAX_UPLOAD_SIZE'); $result['image_rcmd_max_pixels'] = Settings::get('IMAGE_MAX_PIXEL_COUNT'); return Okapi::formatted_response($request, $result); }
private function init_request() { $this->request = OAuthRequest::from_request(); /* Verify if the request was issued with proper HTTP method. */ if (!in_array($this->request->get_normalized_http_method(), array('GET', 'POST'))) { throw new BadRequest("Use GET and POST methods only."); } /* Verify if the request was issued with proper okapi_base_url. */ $url = $this->request->get_normalized_http_url(); $allowed = false; foreach (Okapi::get_allowed_base_urls() as $allowed_prefix) { if (strpos($url, $allowed_prefix) === 0) { $allowed = true; break; } } if (!$allowed) { throw new BadRequest("Unrecognized base URL prefix! See `okapi_base_urls` field " . "in the `services/apisrv/installation` method. (Recommended " . "base URL to use is '" . Okapi::get_recommended_base_url() . "'.)"); } }