diff --git a/customerror.module b/customerror.module index 5e9ccdd96f2d79542d45292f44d047b7a1f1448e..e479632eee4300a50ad38221be7baa5916a90013 100644 --- a/customerror.module +++ b/customerror.module @@ -147,9 +147,6 @@ function customerror_simpletest() { drupal_get_path('module', 'customerror') . '/tests', '\.test$')); } -/** - * Implementation of hook_page(). - */ function customerror_page() { $code = arg(1); $_SESSION['destination'] = $_REQUEST['destination']; @@ -157,7 +154,12 @@ function customerror_page() { switch($code) { case 403: case 404: + // Check if we should redirect customerror_check_redirect(); + + // Make sure that we sent an appropriate header + customerror_header($code); + drupal_set_title(variable_get('customerror_'. $code .'_title', _customerror_fetch_error($code))); $output = theme('customerror', $code, variable_get('customerror_' . $code, _customerror_fetch_error($code))); $output = (variable_get('customerror_' . $code . '_php', FALSE)) ? drupal_eval($output) : $output; @@ -170,6 +172,17 @@ function customerror_page() { return $output; } +function customerror_header($code) { + switch($code) { + case 403: + drupal_set_header('HTTP/1.1 403 Forbidden'); + break; + case 404: + drupal_set_header('HTTP/1.1 404 Not Found'); + break; + } +} + /** * Themeable function */