[ Index ]
 

Code source de IMP H3 (4.1.5)

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> redirect.php (source)

   1  <?php
   2  /**
   3   * $Horde: imp/redirect.php,v 1.116.2.16 2007/01/02 13:54:54 jan Exp $
   4   *
   5   * Copyright 1999-2007 Charles J. Hagenbuch <chuck@horde.org>
   6   * Copyright 1999-2007 Jon Parise <jon@horde.org>
   7   *
   8   * See the enclosed file COPYING for license information (GPL).  If you
   9   * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  10   */
  11  
  12  function _framesetUrl($url)
  13  {
  14      if (Util::getFormData('load_frameset')) {
  15          $full_url = Horde::applicationUrl($GLOBALS['registry']->get('webroot', 'horde') . '/index.php', true);
  16          $url = Util::addParameter($full_url, 'url', $url, false);
  17      }
  18      return $url;
  19  }
  20  
  21  function _newSessionUrl($actionID, $isLogin)
  22  {
  23      $url = '';
  24      $addActionID = true;
  25  
  26      if (Util::getFormData('url')) {
  27          $url = Horde::url(Util::removeParameter(Util::getFormData('url'), session_name()), true);
  28      } elseif (Auth::getProvider() == 'imp') {
  29          $url = Horde::applicationUrl($GLOBALS['registry']->get('webroot', 'horde') . '/', true);
  30          /* Force the initial page to IMP if we're logging in to compose a
  31           * message. */
  32          if ($actionID == 'login_compose') {
  33              $url = Util::addParameter($url, 'url', IMP_Session::getInitialUrl('login_compose', false));
  34              $addActionID = false;
  35          }
  36      } else {
  37          $url = IMP_Session::getInitialUrl($actionID, false);
  38          if ($isLogin) {
  39              /* Don't show popup window in initial page. */
  40              $url = Util::addParameter($url, 'no_newmail_popup', 1, false);
  41          }
  42      }
  43  
  44      if ($addActionID && $actionID) {
  45          /* Preserve the actionID. */
  46          $url = Util::addParameter($url, 'actionID', $actionID, false);
  47      }
  48  
  49      return $url;
  50  }
  51  
  52  function _redirect($url)
  53  {
  54      if ($GLOBALS['browser']->isBrowser('msie') &&
  55          $GLOBALS['conf']['use_ssl'] == 3 &&
  56          strlen($url) < 160) {
  57          header('Refresh: 0; URL=' . $url);
  58      } else {
  59          header('Location: ' . $url);
  60      }
  61      exit;
  62  }
  63  
  64  @define('AUTH_HANDLER', true);
  65  @define('IMP_BASE', dirname(__FILE__));
  66  $authentication = 'none';
  67  require_once  IMP_BASE . '/lib/base.php';
  68  require_once  IMP_BASE . '/lib/Session.php';
  69  require_once 'Horde/Maintenance.php';
  70  
  71  $actionID = (Util::getFormData('action') == 'compose') ? 'login_compose' : Util::getFormData('actionID');
  72  $autologin = Util::getFormData('autologin');
  73  $imapuser = empty($autologin) ? Util::getPost('imapuser') : Auth::getBareAuth();
  74  $pass = empty($autologin) ? Util::getPost('pass') : Auth::getCredential('password');
  75  $isLogin = IMP::loginTasksFlag();
  76  
  77  /* If we are returning from Maintenance processing. */
  78  if (Util::getFormData(MAINTENANCE_DONE_PARAM)) {
  79      /* Finish up any login tasks we haven't completed yet. */
  80      IMP_Session::loginTasks();
  81  
  82      _redirect(_framesetUrl(_newSessionUrl($actionID, $isLogin)));
  83  }
  84  
  85  /* If we already have a session: */
  86  if (isset($_SESSION['imp']) && is_array($_SESSION['imp'])) {
  87      /* Make sure that if a username was specified, it is the current
  88       * username. */
  89      if (($imapuser !== null && ($imapuser != $_SESSION['imp']['user'])) ||
  90          ($pass !== null && ($pass != Secret::read(Secret::getKey('imp'), $_SESSION['imp']['pass'])))) {
  91  
  92          /* Disable the old session. */
  93          unset($_SESSION['imp']);
  94          _redirect(Auth::addLogoutParameters(IMP::logoutUrl(), AUTH_REASON_FAILED));
  95      }
  96  
  97      /* Finish up any login tasks we haven't completed yet. */
  98      IMP_Session::loginTasks();
  99  
 100      $url = Util::getFormData('url');
 101      if (empty($url)) {
 102          $url = IMP_Session::getInitialUrl($actionID, false);
 103      } elseif (!empty($actionID)) {
 104          $url = Util::addParameter($url, 'actionID', $actionID, false);
 105      }
 106  
 107      /* Don't show popup window in initial page. */
 108      if ($isLogin) {
 109          $url = Util::addParameter($url, 'no_newmail_popup', 1, false);
 110      }
 111  
 112      _redirect(_framesetUrl($url));
 113  }
 114  
 115  /* Create a new session if we're given the proper parameters. */
 116  if ((!is_null($imapuser) && !is_null($pass))) {
 117      if (Auth::getProvider() == 'imp') {
 118          /* Destroy any existing session on login and make sure to use
 119           * a new session ID, to avoid session fixation issues. */
 120          Horde::getCleanSession();
 121      }
 122  
 123      /* Read the required server parameters from the servers.php
 124       * file. */
 125      require_once IMP_BASE . '/config/servers.php';
 126      $server_key = Util::getFormData('server_key', IMP::getAutoLoginServer(true));
 127      if (!empty($servers[$server_key])) {
 128          $sessArray = $servers[$server_key];
 129      }
 130  
 131      /* If we're not using hordeauth get parameters altered from the defaults
 132       * from the form data. */
 133      if (empty($autologin)) {
 134          foreach (array('server', 'port', 'protocol', 'smtphost', 'smtpport') as $val) {
 135              $data = Util::getFormData($val);
 136              if (!empty($data)) {
 137                  $sessArray[$val] = $data;
 138              }
 139          }
 140      } else {
 141          if (!empty($sessArray['hordeauth'])) {
 142              if (strcasecmp($sessArray['hordeauth'], 'full') == 0) {
 143                  $imapuser = Auth::getAuth();
 144              }
 145          } else {
 146              $entry = sprintf('Invalid server key "%s" from client [%s]', $server_key, $_SERVER['REMOTE_ADDR']);
 147              Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO);
 148          }
 149      }
 150  
 151      if (!empty($sessArray) &&
 152          IMP_Session::createSession($imapuser, $pass, $sessArray['server'], $sessArray)) {
 153          $entry = sprintf('Login success for %s [%s] to {%s:%s}', $imp['uniquser'], $_SERVER['REMOTE_ADDR'], $imp['server'], $imp['port']);
 154          Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE);
 155  
 156          $ie_version = Util::getFormData('ie_version');
 157          if ($ie_version) {
 158              $browser->setIEVersion($ie_version);
 159          }
 160  
 161          if (($horde_language = Util::getFormData('new_lang'))) {
 162              $_SESSION['horde_language'] = $horde_language;
 163          }
 164  
 165          IMP_Session::loginTasks();
 166  
 167          $url = _newSessionUrl($actionID, $isLogin);
 168      } else {
 169          $url = Auth::addLogoutParameters(IMP::logoutUrl());
 170      }
 171  
 172      _redirect(_framesetUrl($url));
 173  }
 174  
 175  /* No session, and no login attempt. Just go to the login page. */
 176  require  IMP_BASE . '/login.php';


Généré le : Thu Nov 29 12:30:07 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics