users
[ class tree: users ] [ index: users ] [ all elements ]

Source for file validate.php

Documentation is available at validate.php

  1. <?php
  2. /**
  3.  * validate user login
  4.  *
  5.  * @copyright (c) 2004-15 bitweaver.org
  6.  *
  7.  * @package users
  8.  * @subpackage functions
  9.  */
  10. $bypass_siteclose_check = 'y';
  11.  
  12. /**
  13.  * this is a dirty hack to allow admins to log in when we require a visit to the installer
  14.  * used in kernel/setup_inc.php - xing - Friday Oct 03, 2008   16:44:48 CEST
  15.  */
  16. define( 'LOGIN_VALIDATE', TRUE );
  17.  
  18. /**
  19.  * required setup
  20.  */
  21. require_once( '../kernel/setup_inc.php' );
  22.  
  23. global $gBitSystem;
  24.  
  25. //Remember where user is logging in from and send them back later; using session variable for those of us who use WebISO services
  26. //do not use session loginfrom with login.php or register.php - only "inline" login forms display in perm denied fatals, etc.
  27. if( !empty( $_SESSION['returnto'] ) ) {
  28.     // we have been explicitly told where we want to return
  29.     $_SESSION['loginfrom'] = $_SESSION['returnto'];
  30. } elseif( isset( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'], 'login.php' ) === FALSE && strpos( $_SERVER['HTTP_REFERER'], 'register.php' ) === FALSE ) {
  31.     $from = parse_url( $_SERVER['HTTP_REFERER'] );
  32.     $_SESSION['loginfrom'] = (!empty($from['path']) ? $from['path'] : '').( !empty( $from['query'] ) ? '?'.$from['query'] : '' );
  33. } elseif( !empty( $_SESSION['loginfrom'] ) ) {
  34.     unset( $_SESSION['loginfrom'] );
  35. }
  36.  
  37. // Added check for IIS $_SERVER['HTTPS'] uses 'off' value - wolff_borg
  38. $https_mode = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off';
  39. if( $gBitSystem->isLive() && $gBitSystem->isFeatureActive( 'site_https_login_required' ) && !$https_mode) {
  40.     $url = $gBitSystem->getConfig( 'site_https_domain', $_SERVER['HTTP_HOST'] );
  41.     $site_https_port = $gBitSystem->getConfig('site_https_port', $site_https_port);
  42.     if ($site_https_port != 443) {
  43.         $url .= ':' . $site_https_port;
  44.     }
  45.     $url .= $gBitSystem->getConfig( 'site_https_prefix' ) . $gBitSystem->getDefaultPage();
  46.     if ( defined( 'SID' ) ) {
  47.         $url .= '?' . SID;
  48.     }
  49.     $url = preg_replace('/\/+/', '/', $url);
  50.     header("Location: https://$url");
  51.     exit;
  52. }
  53.  
  54. $user = isset($_REQUEST['user']) ? $_REQUEST['user'] : false;
  55. $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : false;
  56. $challenge = isset($_REQUEST['challenge']) ? $_REQUEST['challenge'] : false;
  57. $response = isset($_REQUEST['response']) ? $_REQUEST['response'] : false;
  58.  
  59. // if $referer is set, login() will return the user to whence he came
  60. $url = $gBitUser->login( $user, $pass, $challenge, $response );
  61. if (!preg_match('/^\w+:\/{2}/', $url)) {
  62.     $url = httpPrefix() . $url;
  63. }
  64.  
  65. // but if we came from a login page, let's go home (except if we got an error when login in)
  66. if(( strpos( $url, 'login.php?' ) || strpos( $url, 'remind_password.php' )) && strpos( $url, 'login.php?error=' ) == -1 ) {
  67.     $url = $gBitSystem->getDefaultPage();
  68. }
  69.  
  70. bit_redirect( $url );
  71. exit;

Documentation generated on Wed, 29 Jul 2015 13:57:32 +0000 by phpDocumentor 1.5.0-lsces