You are here

function drupal_access_denied in Drupal 4

Same name and namespace in other branches
  1. 5 includes/common.inc \drupal_access_denied()
  2. 6 includes/common.inc \drupal_access_denied()
  3. 7 includes/common.inc \drupal_access_denied()

Generates a 403 error if the request is not allowed.

12 calls to drupal_access_denied()
book_export_html in modules/book.module
This function is called by book_export() to generate HTML for export.
comment_edit in modules/comment.module
contact_mail_user in modules/contact.module
Personal contact page.
file_download in includes/file.inc
Call modules that implement hook_file_download() to find out if a file is accessible and what headers it should be transferred with. If a module returns -1 drupal_access_denied() will be returned. If one or more modules returned headers the download…
index.php in ./index.php

... See full list

File

includes/common.inc, line 313
Common functions that many Drupal modules will need to reference.

Code

function drupal_access_denied() {
  drupal_set_header('HTTP/1.0 403 Forbidden');
  watchdog('access denied', t('%page denied access.', array(
    '%page' => theme('placeholder', $_GET['q']),
  )), WATCHDOG_WARNING, l(t('view'), $_GET['q']));

  // 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']) {
    menu_set_active_item($path);
    $return = menu_execute_active_handler();
  }
  else {

    // Redirect to a non-existent menu item to make possible tabs disappear.
    menu_set_active_item('');
  }
  if (empty($return)) {
    drupal_set_title(t('Access denied'));
    $return = t('You are not authorized to access this page.');
  }
  print theme('page', $return);
}