aliroUserAuthenticator Class Reference

Inheritance diagram for aliroUserAuthenticator:

aliroAuthenticator

List of all members.

Public Member Functions

 userLogin ()
 systemLogin ($username=null, $passwd=null, $remember=null)
 logout ()
 authenticate (&$message, &$my, $username, $passwd, $remember=null)

Static Public Member Functions

static getInstance ()

Protected Attributes

 $prefix = 'user'

Static Private Attributes

static $instance = __CLASS__


Detailed Description

Definition at line 145 of file aliroAuthenticator.php.


Member Function Documentation

static aliroUserAuthenticator::getInstance (  )  [static]

Definition at line 149 of file aliroAuthenticator.php.

Referenced by aliroUserRequest::doControl(), and aliroSession::rememberMe().

00149                                           {
00150         return is_object(self::$instance) ? self::$instance : (self::$instance = new self::$instance());
00151     }

aliroUserAuthenticator::userLogin (  ) 

Definition at line 153 of file aliroAuthenticator.php.

References $_REQUEST, aliroRequest::getInstance(), systemLogin(), and T_().

00153                                  {
00154         $request = aliroRequest::getInstance();
00155         $username = $request->getParam($_POST, 'username');
00156         $passwd = $request->getParam($_POST, 'passwd');
00157         $remember = $request->getParam($_REQUEST, 'remember');
00158         if (!$username OR !$passwd) {
00159             $message = T_('Please complete the username and password fields.');
00160             $request->redirectSame($message, _ALIRO_ERROR_WARN);
00161             exit;
00162         }
00163         $message = $this->systemLogin ($username, $passwd, $remember);
00164         if ($message) $request->redirectSame ($message, _ALIRO_ERROR_WARN);
00165         if ($return = $request->getParam($_REQUEST, 'return')) $request->redirect($return);
00166         elseif (isset($_SESSION['aliro_redirect_here'])) $request->redirect ($_SESSION['aliro_redirect_here']);
00167         else $request->redirect();
00168     }

aliroUserAuthenticator::systemLogin ( username = null,
passwd = null,
remember = null 
)

Definition at line 170 of file aliroAuthenticator.php.

References aliroDatabase::getInstance(), aliroMambotHandler::getInstance(), aliroSessionFactory::getSession(), and T_().

Referenced by userLogin().

00170                                                                         {
00171         $session = aliroSessionFactory::getSession();
00172         if (!$session->cookiesAccepted()) return T_('Your browser is not accepting cookies - login is not possible.');
00173         $my = null;
00174         $mambothandler = aliroMambotHandler::getInstance();
00175         $database = aliroDatabase::getInstance();
00176         $username = $database->getEscaped($username);
00177         $escpasswd = $database->getEscaped($passwd);
00178         $remember = $remember ? true : false;
00179         $loginfo = new aliroLoginDetails($username, $escpasswd, $remember);
00180         $checkuser = true;
00181         $logresults = $mambothandler->trigger('requiredLogin',array($loginfo));
00182         $message = '';
00183         if (count($logresults) == 0) $logresults[] = T_('Logins are not permitted.  There is no authentication check active.');
00184         foreach ($logresults as $result) {
00185             if (($result instanceof mosUser) AND $result->id) {
00186                 if (!isset($my)) $my = $result;
00187             }
00188             elseif ($result) {
00189                 $message = $result;
00190                 $checkuser = false;
00191                 break;
00192             }
00193         }
00194         if ($checkuser AND isset($my)) {
00195             $session->setNewUserData($my);
00196             $mambothandler->trigger('goodLogin', array($loginfo));
00197             $currentDate = date("Y-m-d/TH:i:s");
00198             $query = "UPDATE #__users SET lastvisitDate='$currentDate', block=0 where id='$my->id'";
00199             if ($remember) {
00200                 $lifetime = time() + 365*24*60*60;
00201                 setcookie("usercookie[username]", $username, $lifetime, "/");
00202                 setcookie("usercookie[password]", $passwd, $lifetime, "/");
00203             }
00204         }
00205         else {
00206             $my = null;
00207             $query = "UPDATE #__users SET block=block+1 where username='$username'";
00208             if ($remember) {
00209                 $lifetime = time() - 365*24*60*60;
00210                 setcookie("usercookie[username]", $username, $lifetime, "/");
00211                 setcookie("usercookie[password]", $passwd, $lifetime, "/");
00212             }
00213         }
00214         $database->doSQL($query);
00215         if (is_null($my)) {
00216             $mambothandler->trigger('badLogin', array($loginfo));
00217             sleep(2);
00218         }
00219         return $message;
00220     }

aliroUserAuthenticator::logout (  ) 

Reimplemented from aliroAuthenticator.

Definition at line 222 of file aliroAuthenticator.php.

References aliroMambotHandler::getInstance().

00222                               {
00223         $mambothandler = aliroMambotHandler::getInstance();
00224         $loginfo = new aliroLoginDetails($_SESSION['aliro_username']);
00225         $mambothandler->trigger('beforeLogout', array($loginfo));
00226         parent::logout();
00227     }

aliroUserAuthenticator::authenticate ( &$  message,
&$  my,
username,
passwd,
remember = null 
)

Definition at line 229 of file aliroAuthenticator.php.

References block, aliroCoreDatabase::getInstance(), aliroDatabase::getInstance(), and T_().

00229                                                                                 {
00230         $message = '';
00231         $database = aliroDatabase::getInstance();
00232         $my = new mosUser();
00233         $database->setQuery( "SELECT id, gid, block, name, username, email, sendEmail, usertype FROM #__users WHERE username='$username'");
00234         if ($database->loadObject($my)) {
00235             if ($my->block > 10) {
00236                 $message = T_('Your login has been blocked. Please contact the administrator.');
00237                 return false;
00238             }
00239             $database = aliroCoreDatabase::getInstance();
00240             $database->setQuery("SELECT COUNT(*) FROM #__core_users WHERE id=$my->id  AND password=MD5(CONCAT(salt,'$passwd'))");
00241             if ($database->loadResult()) {
00242                 unset($my->block);
00243                 return true;
00244             }
00245         }
00246         $message = T_('Incorrect username or password. Please try again.');
00247         return false;
00248     }


Member Data Documentation

aliroUserAuthenticator::$instance = __CLASS__ [static, private]

Definition at line 146 of file aliroAuthenticator.php.

aliroUserAuthenticator::$prefix = 'user' [protected]

Definition at line 147 of file aliroAuthenticator.php.


The documentation for this class was generated from the following file:

Generated on Thu Apr 17 13:03:31 2008 for ALIRO by  doxygen 1.5.5