/**
  * Login to OpenX without using the login form in the user interface and
  * receive a session ID.
  *
  * @access private
  *
  * @param string $username
  * @param string $password
  *
  * @return boolean
  */
 function _internalLogin($username, $password)
 {
     // Require the default language file.
     include_once MAX_PATH . '/lib/max/language/Loader.php';
     // Load the required language file.
     Language_Loader::load('default');
     $oPlugin = OA_Auth::staticGetAuthPlugin();
     $doUser = $oPlugin->checkPassword($username, $password);
     if ($doUser) {
         phpAds_SessionDataRegister(OA_Auth::getSessionData($doUser));
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 /**
  * Logs in an user
  *
  * @static
  *
  * @param callback $redirectCallback
  * @return mixed Array on success
  */
 function login($redirectCallback = null)
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     if (!is_callable($redirectCallback)) {
         // Set the default callback
         $redirectCallback = array('OA_Auth', 'checkRedirect');
     }
     if (call_user_func($redirectCallback)) {
         header('location: http://' . $aConf['webpath']['admin']);
         exit;
     }
     if (defined('OA_SKIP_LOGIN')) {
         return OA_Auth::getFakeSessionData();
     }
     if (OA_Auth::suppliedCredentials()) {
         $doUser = OA_Auth::authenticateUser();
         if (!$doUser) {
             sleep(3);
             OA_Auth::restart($GLOBALS['strUsernameOrPasswordWrong']);
         }
         return OA_Auth::getSessionData($doUser);
     }
     OA_Auth::restart();
 }
Ejemplo n.º 3
0
 /**
  * Save the new password in the user properties
  *
  * @param string recovery ID
  * @param string new password
  * @return bool Ttrue the new password was correctly saved
  */
 function saveNewPasswordAndLogin($recoveryId, $password)
 {
     $doPwdRecovery = OA_Dal::factoryDO('password_recovery');
     $doPwdRecovery->recovery_id = $recoveryId;
     $doPwdRecoveryClone = clone $doPwdRecovery;
     $doPwdRecovery->find();
     if ($doPwdRecovery->fetch()) {
         $userId = $doPwdRecovery->user_id;
         $doPlugin =& OA_Auth::staticGetAuthPlugin();
         $doPlugin->setNewPassword($userId, $password);
         $doPwdRecoveryClone->delete();
         phpAds_SessionStart();
         $doUser = OA_Dal::staticGetDO('users', $userId);
         phpAds_SessionDataRegister(OA_Auth::getSessionData($doUser));
         phpAds_SessionDataStore();
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 function _checkLoginOld($tableName, $agencySupport)
 {
     if (!isset($_COOKIE['sessionID'])) {
         return new PEAR_Error($GLOBALS['strEnableCookies']);
     }
     $prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
     $oDbh = OA_DB::singleton();
     if (!PEAR::isError($oDbh)) {
         $tblPreferences = $oDbh->quoteIdentifier($prefix . $tableName, true);
         $query = "SELECT admin, admin_pw FROM {$tblPreferences}";
         if ($agencySupport) {
             $query .= " WHERE agencyid = 0";
         }
         $aPref = $oDbh->queryRow($query, null, MDB2_FETCHMODE_ASSOC);
         if (is_array($aPref)) {
             $oPlugin =& OA_Auth::staticGetAuthPlugin('internal');
             $aCredentials = $oPlugin->_getCredentials(false);
             if (!PEAR::isError($aCredentials)) {
                 if (strtolower($aPref['admin']) == strtolower($aCredentials['username']) && $aPref['admin_pw'] == md5($aCredentials['password'])) {
                     $doUser = OA_Dal::factoryDO('users');
                     $doUser->username = $aPref['admin'];
                     $aSession = OA_Auth::getSessionData($doUser, true);
                     $aSession['user']->aAccount['account_type'] = OA_ACCOUNT_ADMIN;
                     phpAds_SessionDataRegister($aSession);
                 }
             }
         }
         // Openads for PostgreSQL 2.0 session.last_used field is a
         // timestamp with timezone, which gives troubles reading back
         // session data if TZ offset is > 0
         if ($tableName == 'config' && $oDbh->dbsyntax == 'pgsql') {
             // Make sure that session time is loaded as UTC
             $oDbh->exec("SET TIMEZONE TO 'UTC'");
             phpAds_SessionDataStore();
             $oDbh->exec("SET TIMEZONE TO DEFAULT");
             return;
         }
         phpAds_SessionDataStore();
     }
 }