You are here

function shib_auth_debug in Shibboleth Authentication 6.4

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

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
Create a new user based on informations from the Shibboleth handler if it's necessary or log in.

File

./shib_auth.module, line 193
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->uid) {
        $userinfo = array(
          'uid' => $user->uid,
          'name' => $user->name,
          'mail' => $user->mail,
          'roles' => $user->roles,
        );
        $debug_message = '<b>$user:</b><br /><pre>' . print_r($userinfo, TRUE) . '</pre>';
        drupal_set_message(filter_xss($debug_message, $tags));
      }

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

      // end of workaround
      drupal_set_message(filter_xss($debug_message, $tags));
      $debug_message = '<b>$_SERVER:</b><br /><pre>' . print_r($_SERVER, TRUE) . '</pre>';
      drupal_set_message(filter_xss($debug_message, $tags));
      $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(filter_xss($debug_message, $tags));
    }
  }
}