home *** CD-ROM | disk | FTP | other *** search
- <?php
- ////////////////////////////////////////////////////////////////////////////////
- // <!--Copyright (c) 2005 Pure Networks Inc. All rights reserved.-->
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Build: 3.0.6121.0 (Stable)
- // $Revision: #1 $
- //
- // Common functions
- //
- // Include _util.php before default.inc, as default.inc requries a value in _util.php
- require "_util.php";
- require "_config.php";
- require "_error_codes.php";
-
- // must increment login attempt counter before doing anything else
- try
- {
- $nmRaHelper = new COM("PureNetworks.NetMagic.NmRaMgrHelper");
- $nmRaManager = $nmRaHelper->GetNmRaManager();
- $iCounter = $nmRaManager->LoginAttempts;
- $nmRaManager->LoginAttempts = ($iCounter + 1);
- }
- catch (exception $ex)
- {
- log_activity("login attmept counter", "exception", $ex->getMessage());
- }
-
- // are we locked out of login? - also imports functions needed to update and set lockout states
- require "_loginutils.php";
- $bIsLockedOut = false;
- if (isLockedOut())
- {
- log_activity("login handler called inside lockout window", "failure", return_error_text(116, "", $arErrors));
- gotoAbs("/authorize/116");
- exit();
- }
-
- function authenticate_hash($hashcode, $arErrors, $nmRaManager)
- {
- // Concatenate the password with the session id
- try
- {
- $newhash = strtolower($nmRaManager->GetPasswordHash(session_id()));
-
- if (strcmp($newhash, $hashcode) == 0)
- {
- log_activity("hash authentication", "success", "");
- return TRUE;
- }
- else
- {
- updateLockoutCount();
- log_activity("hash authentication", "failure", return_error_text(101, "", $arErrors));
- return FALSE;
- }
- }
- catch (exception $ex)
- {
- updateLockoutCount();
- log_activity("hash authentication", "exception", return_error_text(103, "", $arErrors));
- gotoAbs("/authorize/103");
- exit();
- }
- }
-
- // Ensure that we have started the session
- session_start();
-
- // Perform the logon checks
- if (!isset($_POST['hash']) or ($_POST['hash'] == ''))
- {
- updateLockoutCount();
- log_activity("hash existence check", "failure", "hash is missing or is empty");
- gotoAbs('/authorize');
- exit();
- }
-
- $hashcode = $_POST['hash'];
-
- if (!authenticate_hash($hashcode, $arErrors, $nmRaManager))
- {
- // Bad hash, send back to the login page, should add
- // some text saying there was a problem
- gotoAbs('/authorize/101');
- exit();
- }
-
- // Perform the session magic to log the user onto the system
- logon($nmRaManager);
- goto_logged_in_url();
- ?>