Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.565
diff -u -r1.565 common.inc
--- includes/common.inc 23 Aug 2006 18:32:39 -0000 1.565
+++ includes/common.inc 23 Aug 2006 19:53:44 -0000
@@ -317,16 +317,28 @@
* Generates a 404 error if the request can not be handled.
*/
function drupal_not_found() {
- drupal_set_header('HTTP/1.0 404 Not Found');
+ if (variable_get('site_404_header', TRUE)) {
+ drupal_set_header('HTTP/1.0 404 Not Found');
+ }
+
watchdog('page not found', t('%page not found.', array('%page' => $_GET['q'])), WATCHDOG_WARNING);
+ $return = '';
+
+ if (variable_get('site_404_message_show', TRUE)) {
+ $message = variable_get('site_404_message', t('We are sorry, %path could not be found. Please check the spelling and punctuation. This website is case sensitive, so also make sure that the address has the correct case.'));
+ $message = str_replace('%path', theme('placeholder', url($_GET['q'], NULL, NULL, TRUE)), $message);
+ $message = filter_xss_admin($message);
+ drupal_set_message($message);
+ }
+
// Keep old path for reference
if (!isset($_REQUEST['destination'])) {
$_REQUEST['destination'] = $_GET['q'];
}
$path = drupal_get_normal_path(variable_get('site_404', ''));
- if ($path && $path != $_GET['q']) {
+ if (!empty($path) && $path != $_GET['q']) {
menu_set_active_item($path);
$return = menu_execute_active_handler();
}
@@ -335,8 +347,9 @@
menu_set_active_item('');
}
- if (empty($return)) {
- drupal_set_title(t('Page not found'));
+ if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
+ drupal_set_title(t('404 - File not found'));
+ $return = ' ';
}
// To conserve CPU and bandwidth, omit the blocks
print theme('page', $return, FALSE);
@@ -346,8 +359,20 @@
* Generates a 403 error if the request is not allowed.
*/
function drupal_access_denied() {
- drupal_set_header('HTTP/1.0 403 Forbidden');
- watchdog('access denied', t('%page denied access.', array('%page' => $_GET['q'])), WATCHDOG_WARNING, l(t('view'), $_GET['q']));
+ if (variable_get('site_403_header', TRUE)) {
+ drupal_set_header('HTTP/1.0 403 Forbidden');
+ }
+
+ watchdog('access denied', t('%page denied access.', array('%page' => 'placeholder', $_GET['q'])), WATCHDOG_WARNING, l(t('view'), $_GET['q']));
+
+ $return = '';
+
+ if (variable_get('site_403_message_show', TRUE)) {
+ $message = variable_get('site_403_message', t(' We are sorry, you do not have access to %path. If you are not already logged in, please try to login and then visit this page again. If you think should be able to access this page, please contact site admins.'));
+ $message = str_replace('%path', theme('placeholder', url($_GET['q'], NULL, NULL, TRUE)), $message);
+ $message = filter_xss_admin($message);
+ drupal_set_message($message);
+ }
// Keep old path for reference
if (!isset($_REQUEST['destination'])) {
@@ -355,7 +380,7 @@
}
$path = drupal_get_normal_path(variable_get('site_403', ''));
- if ($path && $path != $_GET['q']) {
+ if (!empty($path) && $path != $_GET['q']) {
menu_set_active_item($path);
$return = menu_execute_active_handler();
}
@@ -364,9 +389,9 @@
menu_set_active_item('');
}
- if (empty($return)) {
- drupal_set_title(t('Access denied'));
- $return = t('You are not authorized to access this page.');
+ if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
+ drupal_set_title(t('403 - Access denied'));
+ $return = ' ';
}
print theme('page', $return);
}
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.349
diff -u -r1.349 system.module
--- modules/system/system.module 23 Aug 2006 04:40:57 -0000 1.349
+++ modules/system/system.module 23 Aug 2006 19:53:45 -0000
@@ -550,35 +550,81 @@
}
function system_error_reporting_settings() {
-
- $form['site_403'] = array(
+ $form['403'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Access denied page (403)'),
+ '#description' => t('These settings apply when the requested document is denied to the current user, i.e. a 403 error.'),
+ );
+ $form['403']['site_403'] = array(
'#type' => 'textfield',
- '#title' => t('Default 403 (access denied) page'),
+ '#title' => t('Page to display'),
'#default_value' => variable_get('site_403', ''),
- '#description' => t('This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.')
+ '#description' => t('This page is displayed when a 403 error occurs. If you are not using clean URLs, specify the part after "?q=". If unsure, leave blank.'),
);
-
- $form['site_404'] = array(
+ $form['403']['site_403_message_show'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable error message'),
+ '#description' => t('Displays the message below.'),
+ '#default_value' => variable_get('site_403_message_show', TRUE),
+ );
+ $form['403']['site_403_message'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Message'),
+ '#description' => t('This message is shown when a 403 error occurs, if enabled. "%path" will be replaced with the path of the requested document.'),
+ '#default_value' => variable_get('site_403_message', t('We are sorry, you do not have access to %path. If you are not already logged in, please try to login and then visit this page again. If you think should be able to access this page, please contact site admins.')),
+ );
+ $form['403']['site_403_header'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Send 403 header'),
+ '#description' => t('Sends a 403 header to browser, recommended.'),
+ '#default_value' => variable_get('site_403_header', TRUE),
+ );
+ $form['404'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('File not found page (404)'),
+ '#description' => t('These settings apply when the requested document could not be found, i.e. a 404 error.'),
+ );
+ $form['404']['site_404'] = array(
'#type' => 'textfield',
- '#title' => t('Default 404 (not found) page'),
+ '#title' => t('Page to display'),
'#default_value' => variable_get('site_404', ''),
- '#description' => t('This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.')
+ '#description' => t('This page is displayed when a 404 error occurs. If you are not using clean URLs, specify the part after "?q=". If unsure, leave blank.'),
);
-
- $form['error_level'] = array(
+ $form['404']['site_404_message_show'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable error message'),
+ '#description' => t('Displays the message below.'),
+ '#default_value' => variable_get('site_404_message_show', TRUE),
+ );
+ $form['404']['site_404_message'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Message'),
+ '#description' => t('This message is shown when a 404 error occurs, if enabled. "%path" will be replaced with the path of the requested document.'),
+ '#default_value' => variable_get('site_404_message', t('We are sorry, %path could not be found. Please check the spelling and punctuation. This website is case sensitive, so also make sure that the address has the correct case.')),
+ );
+ $form['404']['site_404_header'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Send 404 header'),
+ '#description' => t('Sends a 404 header to browser, recommended.'),
+ '#default_value' => variable_get('site_404_header',TRUE),
+ );
+ $form['error'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Other error handling'),
+ );
+ $form['error']['error_level'] = array(
'#type' => 'select', '#title' => t('Error reporting'), '#default_value' => variable_get('error_level', 1),
'#options' => array(t('Write errors to the log'), t('Write errors to the log and to the screen')),
- '#description' => t('Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen.')
+ '#description' => t('Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen.'),
);
-
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
$period['1000000000'] = t('Never');
- $form['watchdog_clear'] = array(
+ $form['error']['watchdog_clear'] = array(
'#type' => 'select',
'#title' => t('Discard log entries older than'),
'#default_value' => variable_get('watchdog_clear', 604800),
'#options' => $period,
- '#description' => t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.')
+ '#description' => t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.'),
);
return system_settings_form($form);