getMessage(), DEFAULT_LOG_LIMIT, LOG_ERR); emit_http_error(404); } catch (ResourceUriException $e) { log_error($e->getMessage(), DEFAULT_LOG_LIMIT, LOG_ERR); emit_http_error(404); } catch (ResourcePathException $e) { log_error($e->getMessage(), DEFAULT_LOG_LIMIT, LOG_ERR); emit_http_error(404); } catch (ResourceOpenException $e) { log_error($e->getMessage(), DEFAULT_LOG_LIMIT, LOG_ERR); emit_http_error(403); } catch (ResourceLoadException $e) { log_error($e->getMessage(), DEFAULT_LOG_LIMIT, LOG_ERR); emit_http_error(500); } catch (DocumentParseException $e) { log_error($e->getMessage(), DEFAULT_LOG_LIMIT, LOG_ERR); emit_http_error(500); } catch (Exception $e) { log_error($e->getMessage(), DEFAULT_LOG_LIMIT, LOG_ERR); emit_http_error(500); } } function configure_php_interpreter() { if (DEFAULT_LOG_LIMIT !== LOG_DEBUG) { error_reporting(0); } mb_internal_encoding('UTF-8'); libxml_use_internal_errors(TRUE); } class RequestException extends Exception {} function check_w2ml_query_param($value) { if (!is_string($value)) { throw new RequestException ('Missing '.W2ML_QUERY_PARAM.' HTTP request parameter'); } if ($value === '') { throw new RequestException ('Missing '.W2ML_QUERY_PARAM.' HTTP request parameter value'); } } function emit_http_error($error_number) { static $errors_text = array( 400 => 'Bad Request', 403 => 'Forbidden', 404 => 'Not Found', 500 => 'Internal Server Error' ); header('Status: '.$error_number.' '.$errors_text[$error_number]); header('HTTP/1.0 '.$error_number.' '.$errors_text[$error_number]); echo http_error_in_xhtml('Error '.$error_number.': '.$errors_text[$error_number]); } ?>