http://www.php.net/{$module} for more info"); } } if (get_magic_quotes_gpc()) { die("Your environment has magic_quotes_gpc enabled which will interfere with Shindig. Please set 'magic_quotes_gpc' to 'Off' in php.ini"); } } // All configurable classes are autoloaded (see config.php for the configurable classes) // To load these, we scan our entire directory structure function __autoload($className) { $locations = array('src/common', 'src/common/sample', 'src/gadgets', 'src/gadgets/servlet', 'src/gadgets/oauth', 'src/gadgets/sample', 'src/social', 'src/social/servlet', 'src/social/service', 'src/social/opensocial', 'src/social/model', 'src/social/spi', 'src/social/converters', 'src/social/oauth', 'src/social/sample'); $extension_class_paths = Config::get('extension_class_paths'); if (! empty($extension_class_paths)) { $locations = array_merge(explode(',', $extension_class_paths), $locations); } // Check for the presense of this class in our all our directories. $fileName = $className . '.php'; foreach ($locations as $path) { if (file_exists("{$path}/$fileName")) { require $path . '/' . $fileName; return; } } if (($loader = Config::get('extension_autoloader')) && function_exists($loader)) { call_user_func($loader, $className); } } $servletMap = array(Config::get('web_prefix') . '/gadgets/files' => 'FilesServlet', Config::get('web_prefix') . '/gadgets/js' => 'JsServlet', Config::get('web_prefix') . '/gadgets/proxy' => 'ProxyServlet', Config::get('web_prefix') . '/gadgets/makeRequest' => 'MakeRequestServlet', Config::get('web_prefix') . '/gadgets/ifr' => 'GadgetRenderingServlet', Config::get('web_prefix') . '/gadgets/metadata' => 'MetadataServlet', Config::get('web_prefix') . '/gadgets/oauthcallback' => 'OAuthCallbackServlet', Config::get('web_prefix') . '/gadgets/api/rpc' => 'JsonRpcServlet', Config::get('web_prefix') . '/gadgets/api/rest' => 'DataServiceServlet', Config::get('web_prefix') . '/social/rest' => 'DataServiceServlet', Config::get('web_prefix') . '/social/rpc' => 'JsonRpcServlet', Config::get('web_prefix') . '/public.crt' => 'CertServlet', Config::get('web_prefix') . '/public.cer' => 'CertServlet'); // 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 == Config::get('web_prefix') . '/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 "

405 Method Not Allowed

"; } } else { // Unhandled event, display simple 404 error header("HTTP/1.0 404 Not Found"); echo "

404 Not Found

"; }