diff --git a/includes/common.inc b/includes/common.inc index 73839d2d365700b4b46d3717e095f7cca7ad5ce7..0eb565d2e175be23cb10642d5d3d37a070fcb2f5 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -318,16 +318,22 @@ function drupal_site_offline() { */ function drupal_not_found() { drupal_set_header('HTTP/1.0 404 Not Found'); - watchdog('page not found', check_plain($_GET['q']), WATCHDOG_WARNING); + $return = ''; + + if (variable_get('site_404_message_display', TRUE)) { + $message = variable_get('site_404_message', t('We are sorry, the requested page was not found on this webserver. Either the URL does not exist or the page you were looking has been deleted.')); + drupal_set_message(filter_xss_admin($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(); } @@ -336,8 +342,9 @@ function drupal_not_found() { 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); @@ -350,13 +357,20 @@ function drupal_access_denied() { drupal_set_header('HTTP/1.0 403 Forbidden'); watchdog('access denied', check_plain($_GET['q']), WATCHDOG_WARNING); -// Keep old path for reference + $return = ''; + + if (variable_get('site_403_message_display', TRUE)) { + $message = variable_get('site_403_message', t('We are sorry, you do not have access to this page. 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.')); + drupal_set_message(filter_xss_admin($message)); + } + + // Keep old path for reference if (!isset($_REQUEST['destination'])) { $_REQUEST['destination'] = $_GET['q']; } $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(); } @@ -365,9 +379,9 @@ function drupal_access_denied() { 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); } diff --git a/modules/system/system.module b/modules/system/system.module index 6b7a630f4f1d7e0a7ac941ddee926779dd9784f6..c828cf7794b31c884dc3d1a137ebae1a0c787a9e 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -550,35 +550,67 @@ function system_clean_url_settings() { } 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 <em>403 error</em>.'), + ); + $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 "<code>?q=</code>". 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 "<code>?q=</code>". If unsure, leave blank.'), ); - - $form['site_404'] = array( + $form['403']['site_403_message_display'] = array( + '#type' => 'checkbox', + '#title' => t('Display error message'), + '#description' => t('Enabling this feature will display the message below when a 403 error occurs, even if <em>"Page to display"</em> is set.'), + '#default_value' => variable_get('site_403_message_display', TRUE), + ); + $form['403']['site_403_message'] = array( + '#type' => 'textarea', + '#title' => t('Message'), + '#default_value' => variable_get('site_403_message', t('We are sorry, you do not have access to this page. 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['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 <em>404 error</em>.'), + ); + $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 "<code>?q=</code>". 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 "<code>?q=</code>". If unsure, leave blank.'), ); - - $form['error_level'] = array( + $form['404']['site_404_message_display'] = array( + '#type' => 'checkbox', + '#title' => t('Display error message'), + '#description' => t('Enabling this feature will display the message below when a 404 error occurs, even if <em>"Page to display"</em> is set.'), + '#default_value' => variable_get('site_404_message_display', TRUE), + ); + $form['404']['site_404_message'] = array( + '#type' => 'textarea', + '#title' => t('Message'), + '#default_value' => variable_get('site_404_message', t('We are sorry, the requested page was not found on this webserver. Either the URL does not exist or the page you were looking has been deleted.')), + ); + $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); diff --git a/modules/user/user.module b/modules/user/user.module index 2dc1213a52ffcb241a4f6e284040dab1f076333c..a184e322755f48a532e52de89441613505156778 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -2272,7 +2272,7 @@ function user_help($section) { case 'admin/user/user/create': case 'admin/user/user/account/create': return t('<p>This web page allows the administrators to register a new users by hand. Note that you cannot have a user where either the e-mail address or the username match another user in the system.</p>'); - case strstr($section, 'admin/user/rules'): + case 'admin/user/rules': return t('<p>Set up username and e-mail address access rules for new <em>and</em> existing accounts (currently logged in accounts will not be logged out). If a username or e-mail address for an account matches any deny rule, but not an allow rule, then the account will not be allowed to be created or to log in. A host rule is effective for every page view, not just registrations.</p>'); case 'admin/user/access': return t('<p>Permissions let you control what users can do on your site. Each user role (defined on the <a href="@role">user roles page</a>) has its own set of permissions. For example, you could give users classified as "Administrators" permission to "administer nodes" but deny this power to ordinary, "authenticated" users. You can use permissions to reveal new features to privileged users (those with subscriptions, for example). Permissions also allow trusted users to share the administrative burden of running a busy site.</p>', array('@role' => url('admin/user/roles')));