[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ -> login.php (source)

   1  <?php
   2  /**
   3   * $Horde: horde/login.php,v 2.175.2.11 2006/01/16 15:57:53 jan Exp $
   4   *
   5   * Copyright 1999-2006 Charles J. Hagenbuch <chuck@horde.org>
   6   * Copyright 1999-2006 Jon Parise <jon@horde.org>
   7   *
   8   * See the enclosed file COPYING for license information (LGPL). If you
   9   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  10   */
  11  
  12  @define('AUTH_HANDLER', true);
  13  @define('HORDE_BASE', dirname(__FILE__));
  14  require_once  HORDE_BASE . '/lib/base.php';
  15  require_once  'Horde/Menu.php';
  16  require_once 'Horde/Secret.php';
  17  
  18  /* Initialize the Auth credentials key. */
  19  Secret::setKey('auth');
  20  
  21  /* Get an Auth object. */
  22  $auth = &Auth::singleton($conf['auth']['driver']);
  23  if (is_a($auth, 'PEAR_Error')) {
  24      Horde::fatal($auth, __FILE__, __LINE__);
  25  }
  26  
  27  /* Get parameters. */
  28  $logout_reason = $auth->getLogoutReason();
  29  $url_param = Util::getFormData('url');
  30  $ie_version = Util::getFormData('ie_version');
  31  
  32  if ($logout_reason) {
  33      $login_screen = $auth->getLoginScreen();
  34      if (Util::getFormData('nosidebar') &&
  35          isset($GLOBALS['notification'])) {
  36          $url = Auth::addLogoutParameters($login_screen);
  37          if ($url_param) {
  38              $url = Util::addParameter($url, 'url', $url_param);
  39          }
  40          $notification->push('window.parent.location.href = \'' . $url . '\';', 'javascript');
  41          echo '<html><body>' . $GLOBALS['notification']->notify(array('listeners' => array('javascript'))) . '</body></html>';
  42          exit;
  43      }
  44  
  45      if (Util::removeParameter($login_screen, array('url', 'nocache')) !=
  46          Util::removeParameter(Horde::selfUrl(false, false, true), array('url', 'nocache'))) {
  47          $url = Auth::addLogoutParameters($login_screen);
  48          if ($url_param) {
  49              $url = Util::addParameter($url, 'url', $url_param);
  50          }
  51          header('Location: ' . $url);
  52          exit;
  53      }
  54  
  55      $language = isset($prefs) ? $prefs->getValue('language') : NLS::select();
  56  
  57      $entry = sprintf('User %s [%s] logged out of Horde',
  58                       Auth::getAuth(), $_SERVER['REMOTE_ADDR']);
  59      Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE);
  60      Auth::clearAuth();
  61      @session_destroy();
  62  
  63      /* Redirect the user on logout if redirection is enabled. */
  64      if (!empty($conf['auth']['redirect_on_logout'])) {
  65          $logout_url = $conf['auth']['redirect_on_logout'];
  66          if (!isset($_COOKIE[session_name()])) {
  67              $logout_url = Util::addParameter($logout_url, session_name(), session_id());
  68          }
  69          header('Location: ' . $logout_url);
  70          exit;
  71      }
  72  
  73      Horde::setupSessionHandler();
  74      @session_start();
  75  
  76      NLS::setLang($language);
  77  
  78      /* Hook to preselect the correct language in the widget. */
  79      $_GET['new_lang'] = $language;
  80  }
  81  
  82  if (isset($_POST['horde_user']) && isset($_POST['horde_pass'])) {
  83      /* Destroy any existing session on login and make sure to use a
  84       * new session ID, to avoid session fixation issues. */
  85      Horde::getCleanSession();
  86      if ($auth->authenticate(Util::getPost('horde_user'),
  87                              array('password' => Util::getPost('horde_pass')))) {
  88          $entry = sprintf('Login success for %s [%s] to Horde',
  89                           Auth::getAuth(), $_SERVER['REMOTE_ADDR']);
  90          Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE);
  91  
  92          if ($ie_version) {
  93              $browser->setIEVersion($ie_version);
  94          }
  95  
  96          if ($url_param) {
  97              $url = Horde::url(Util::removeParameter($url_param, session_name()), true);
  98              $horde_url = $registry->get('webroot', 'horde') . '/index.php';
  99              $horde_url = Util::addParameter($horde_url, 'url', $url);
 100          } else {
 101              $horde_url = Horde::url($registry->get('webroot', 'horde') . '/index.php');
 102          }
 103  
 104          $url = Horde::applicationUrl($horde_url, true);
 105          if ($browser->isBrowser('msie') &&
 106              $conf['use_ssl'] == 3 &&
 107              strlen($url) < 160) {
 108              header('Refresh: 0; URL=' . $url);
 109          } else {
 110              header('Location: ' . $url);
 111          }
 112          exit;
 113      } else {
 114          $entry = sprintf('FAILED LOGIN for %s [%s] to Horde',
 115                           Util::getFormData('horde_user'), $_SERVER['REMOTE_ADDR']);
 116          Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_ERR);
 117          if ($conf['menu']['always']) {
 118              $main_page = Util::addParameter(Horde::selfUrl(), 'reason', $auth->getLogoutReasonString());
 119              if ($browser->hasQuirk('scrollbar_in_way')) {
 120                  $scrollbar = 'yes';
 121              } else {
 122                  $scrollbar = 'auto';
 123              }
 124              require  HORDE_TEMPLATES . '/index/frames_index.inc';
 125              exit;
 126          }
 127      }
 128  }
 129  
 130  if (Auth::getAuth()) {
 131      if ($browser->isMobile()) {
 132          $url = 'services/portal/mobile.php';
 133      } else {
 134          $url = 'services/portal/index.php';
 135      }
 136      require HORDE_BASE . '/' . $url;
 137      exit;
 138  }
 139  
 140  /* Try transparent authentication. */
 141  if (Auth::isAuthenticated()) {
 142      require  HORDE_BASE . '/index.php';
 143      exit;
 144  }
 145  
 146  /* Redirect the user if an alternate login page has been specified. */
 147  if (!empty($conf['auth']['alternate_login'])) {
 148      $url = Auth::addLogoutParameters($conf['auth']['alternate_login']);
 149      if (!isset($_COOKIE[session_name()])) {
 150          $url = Util::addParameter($url, session_name(), session_id(), false);
 151      }
 152      if ($url_param) {
 153          $url = Util::addParameter($url, 'url', $url_param, false);
 154      }
 155      header('Location: ' . $url);
 156      exit;
 157  }
 158  
 159  $login_screen = $auth->_getLoginScreen();
 160  if (Util::removeParameter($login_screen, array('url', 'nocache')) !=
 161      Horde::selfUrl(false, false, true)) {
 162      if ($url_param) {
 163          $login_screen = Util::addParameter($login_screen, 'url', $url_param, false);
 164      }
 165      if ($ie_version) {
 166          $login_screen = Util::addParameter($login_screen, 'ie_version', $ie_version, false);
 167      }
 168      header('Location: ' . $login_screen);
 169      exit;
 170  }
 171  
 172  if ($browser->isMobile()) {
 173      require_once 'Horde/Mobile.php';
 174      require  HORDE_TEMPLATES . '/login/mobile.inc';
 175      exit;
 176  }
 177  
 178  /* Build the <select> widget containing the available languages. */
 179  if (!$prefs->isLocked('language')) {
 180      $_SESSION['horde_language'] = NLS::select();
 181      $langs = '<select name="new_lang" onchange="selectLang()">';
 182      foreach ($nls['languages'] as $key => $val) {
 183          $sel = ($key == $_SESSION['horde_language']) ? ' selected="selected"' : '';
 184          $langs .= "<option value=\"$key\"$sel>$val</option>";
 185      }
 186      $langs .= '</select>';
 187  }
 188  
 189  $title = _("Log in");
 190  $notification->push('setFocus()', 'javascript');
 191  if ($logout_reason && $conf['menu']['always']) {
 192      $notification->push('if (window.parent.frames.horde_menu) window.parent.frames.horde_menu.location.href = \'' . Horde::applicationUrl('services/portal/sidebar.php') . '\';', 'javascript');
 193  }
 194  
 195  $reason = $auth->getLogoutReasonString();
 196  
 197  /* Add some javascript. */
 198  Horde::addScriptFile('enter_key_trap.js', 'horde', true);
 199  
 200  /* Do we need to do IE version detection? */
 201  if (($browser->getBrowser() == 'msie') && ($browser->getMajor() >= 5)) {
 202      $ie_clientcaps = true;
 203  }
 204  
 205  require  HORDE_TEMPLATES . '/common-header.inc';
 206  require  HORDE_TEMPLATES . '/login/login.inc';
 207  require  HORDE_TEMPLATES . '/common-footer.inc';


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7