home *** CD-ROM | disk | FTP | other *** search
/ PCNet 2006 April / PCnet 2006-06.4.iso / shareware / nmsetup.exe / WebServer / web / _handle_login.php < prev    next >
Encoding:
PHP Script  |  2006-05-01  |  3.0 KB  |  92 lines

  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // <!--Copyright (c) 2005 Pure Networks Inc.  All rights reserved.-->
  4. ////////////////////////////////////////////////////////////////////////////////
  5. //
  6. // Build: 3.0.6121.0 (Stable)
  7. // $Revision: #1 $
  8. //
  9.     // Common functions
  10.     //
  11.     // Include _util.php before default.inc, as default.inc requries a value in _util.php
  12.     require "_util.php";
  13.     require "_config.php";
  14.     require "_error_codes.php";
  15.     
  16.     // must increment login attempt counter before doing anything else
  17.     try
  18.     {
  19.         $nmRaHelper = new COM("PureNetworks.NetMagic.NmRaMgrHelper");
  20.         $nmRaManager = $nmRaHelper->GetNmRaManager();
  21.         $iCounter = $nmRaManager->LoginAttempts;
  22.         $nmRaManager->LoginAttempts = ($iCounter + 1);
  23.     }
  24.     catch (exception $ex)
  25.     {
  26.         log_activity("login attmept counter", "exception", $ex->getMessage());
  27.     }
  28.  
  29.     // are we locked out of login? - also imports functions needed to update and set lockout states
  30.     require "_loginutils.php";
  31.     $bIsLockedOut = false;
  32.     if (isLockedOut())
  33.     {
  34.         log_activity("login handler called inside lockout window", "failure", return_error_text(116, "", $arErrors));
  35.         gotoAbs("/authorize/116");
  36.         exit();
  37.     }
  38.  
  39.     function authenticate_hash($hashcode, $arErrors, $nmRaManager)
  40.     {
  41.         // Concatenate the password with the session id
  42.         try
  43.         {
  44.             $newhash = strtolower($nmRaManager->GetPasswordHash(session_id()));
  45.     
  46.             if (strcmp($newhash, $hashcode) == 0)
  47.             {
  48.                 log_activity("hash authentication", "success", "");
  49.                 return TRUE;
  50.             }
  51.             else
  52.             {
  53.                 updateLockoutCount();
  54.                 log_activity("hash authentication", "failure", return_error_text(101, "", $arErrors));
  55.                 return FALSE;
  56.             }
  57.         }
  58.         catch (exception $ex)
  59.         {
  60.             updateLockoutCount();
  61.             log_activity("hash authentication", "exception", return_error_text(103, "", $arErrors));
  62.             gotoAbs("/authorize/103");
  63.             exit();
  64.         }
  65.     }
  66.         
  67.     // Ensure that we have started the session
  68.     session_start();
  69.         
  70.         // Perform the logon checks
  71.         if (!isset($_POST['hash']) or ($_POST['hash'] == ''))
  72.         {
  73.             updateLockoutCount();
  74.             log_activity("hash existence check", "failure", "hash is missing or is empty");
  75.             gotoAbs('/authorize');
  76.             exit();
  77.         }
  78.         
  79.         $hashcode = $_POST['hash'];
  80.         
  81.         if (!authenticate_hash($hashcode, $arErrors, $nmRaManager))
  82.         {
  83.             // Bad hash, send back to the login page, should add
  84.             // some text saying there was a problem
  85.             gotoAbs('/authorize/101');
  86.             exit();
  87.         }
  88.  
  89.         // Perform the session magic to log the user onto the system
  90.         logon($nmRaManager);
  91.         goto_logged_in_url();
  92. ?>