You are here

function shib_auth_debug in Shibboleth Authentication 7.4

Same name and namespace in other branches
  1. 6.4 shib_auth.module \shib_auth_debug()

Determines if the called page is in the debug path.

Function to determine whether the called page is in the debug path print_r-s $_SERVER if yes.

1 call to shib_auth_debug()
shib_auth_init in ./shib_auth.module
Creates a new user, if necessary, based on information from the handler.

File

./shib_auth.module, line 213
Drupal Shibboleth authentication module.

Code

function shib_auth_debug() {
  global $user;
  $tags = array(
    'pre',
    'b',
    'br',
  );
  if (shib_auth_config('debug_state')) {
    if (drupal_substr($_GET['q'], 0, drupal_strlen(shib_auth_config('debug_url'))) == shib_auth_config('debug_url')) {
      if (user_is_logged_in()) {
        $userinfo = array(
          'uid' => $user->uid,
          'name' => $user->name,
          'mail' => $user->mail,
          'roles' => $user->roles,
        );
        $debug_message = filter_xss('<b>$user:</b><br /><pre>' . print_r($userinfo, TRUE) . '</pre>', $tags);
        drupal_set_message(t('!msg', array(
          '!msg' => $debug_message,
        )));
      }

      // Work around that drupal_set_message() keeps previous messages
      // in $_SESSION.
      if (!empty($_SESSION)) {
        $session_copy = $_SESSION;
      }
      else {
        $session_copy = array();
      }
      if (isset($session_copy['messages'])) {
        unset($session_copy['messages']);
      }
      $debug_message = filter_xss('<b>$_SESSION:</b><br /><pre>' . print_r($session_copy, TRUE) . '</pre>', $tags);
      unset($session_copy);

      // End of workaround.
      drupal_set_message(t('!msg', array(
        '!msg' => $debug_message,
      )));
      $debug_message = filter_xss('<b>$_SERVER:</b><br /><pre>' . print_r($_SERVER, TRUE) . '</pre>', $tags);
      drupal_set_message(t('!msg', array(
        '!msg' => $debug_message,
      )));
      $config_keys = shib_auth_config('', TRUE);
      sort($config_keys);
      $config_copy = array();
      foreach ($config_keys as $key) {
        $config_copy[$key] = shib_auth_config($key);
      }
      $debug_message = filter_xss('<b>MODULE CONFIGURATION:</b><br /><pre>' . print_r($config_copy, TRUE) . '</pre>', $tags);
      drupal_set_message(t('!msg', array(
        '!msg' => $debug_message,
      )));
    }
  }
}