localConfig = $localConfig; } public function run() { Config::loadConfig($this->localConfig); $this->checkServerConfig(); //get servlet map and prefix the servlet paths $configServletMap = Config::get('servlet_map'); $webPrefix = Config::get('web_prefix'); $servletMap = array(); foreach ($configServletMap as $path => $servlet) { $servletMap[$webPrefix . $path] = $servlet; } // Try to match the request url to our servlet mapping $servlet = false; $uri = $_SERVER["REQUEST_URI"]; foreach ($servletMap as $url => $class) { if (substr($uri, 0, strlen($url)) == $url) { //FIXME temporary hack to support both /proxy and /makeRequest with the same event handler // /makeRequest == /proxy?output=js if ($url == $webPrefix . '/gadgets/makeRequest') { $_GET['output'] = 'js'; } $servlet = $class; break; } } // If we found a correlating servlet, instance and call it. Otherwise give a 404 error if ($servlet) { $class = new $class(); $method = $_SERVER['REQUEST_METHOD']; // Not all clients support the PUT, HEAD & DELETE http methods, they depend on the X-HTTP-Method-Override instead if ($method == 'POST' && isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { $method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']; } $method = 'do' . ucfirst(strtolower($method)); if (is_callable(array($class, $method))) { $class->$method(); } else { header("HTTP/1.0 405 Method Not Allowed"); echo "