| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
//$Id: customerror.module,v 1.17.2.4 2008/10/06 01:03:09 kbahey Exp $ |
//$Id: customerror.module,v 1.17.2.5 2009/03/16 18:39:05 kbahey Exp $ |
| 4 |
|
|
| 5 |
// Copyright 2005 Khalid Baheyeldin http://2bits.com |
// Copyright 2005 Khalid Baheyeldin http://2bits.com |
| 6 |
|
|
| 147 |
drupal_get_path('module', 'customerror') . '/tests', '\.test$')); |
drupal_get_path('module', 'customerror') . '/tests', '\.test$')); |
| 148 |
} |
} |
| 149 |
|
|
|
/** |
|
|
* Implementation of hook_page(). |
|
|
*/ |
|
| 150 |
function customerror_page() { |
function customerror_page() { |
| 151 |
$code = arg(1); |
$code = arg(1); |
| 152 |
$_SESSION['destination'] = $_REQUEST['destination']; |
$_SESSION['destination'] = $_REQUEST['destination']; |
| 154 |
switch($code) { |
switch($code) { |
| 155 |
case 403: |
case 403: |
| 156 |
case 404: |
case 404: |
| 157 |
|
// Check if we should redirect |
| 158 |
customerror_check_redirect(); |
customerror_check_redirect(); |
| 159 |
|
|
| 160 |
|
// Make sure that we sent an appropriate header |
| 161 |
|
customerror_header($code); |
| 162 |
|
|
| 163 |
drupal_set_title(variable_get('customerror_'. $code .'_title', _customerror_fetch_error($code))); |
drupal_set_title(variable_get('customerror_'. $code .'_title', _customerror_fetch_error($code))); |
| 164 |
$output = theme('customerror', $code, variable_get('customerror_' . $code, _customerror_fetch_error($code))); |
$output = theme('customerror', $code, variable_get('customerror_' . $code, _customerror_fetch_error($code))); |
| 165 |
$output = (variable_get('customerror_' . $code . '_php', FALSE)) ? drupal_eval($output) : $output; |
$output = (variable_get('customerror_' . $code . '_php', FALSE)) ? drupal_eval($output) : $output; |
| 172 |
return $output; |
return $output; |
| 173 |
} |
} |
| 174 |
|
|
| 175 |
|
function customerror_header($code) { |
| 176 |
|
switch($code) { |
| 177 |
|
case 403: |
| 178 |
|
drupal_set_header('HTTP/1.1 403 Forbidden'); |
| 179 |
|
break; |
| 180 |
|
case 404: |
| 181 |
|
drupal_set_header('HTTP/1.1 404 Not Found'); |
| 182 |
|
break; |
| 183 |
|
} |
| 184 |
|
} |
| 185 |
|
|
| 186 |
/** |
/** |
| 187 |
* Implementation of hook_theme(). |
* Implementation of hook_theme(). |
| 188 |
*/ |
*/ |