Exemple #1
0
 public function LOGINAUTH($AUTHDATA)
 {
     $this->AR['LOG']->LSET("USERClass: LOGINAUTH(" . $AUTHDATA['LOGIN'] . ", " . $AUTHDATA['PASS'] . ")");
     if (strcmp($AUTHDATA['LOGIN'], "") != 0 and strcmp($AUTHDATA['PASS'], "") != 0) {
         // Если параметры и не пустые
         $LOGIN = clean($this->AR, $AUTHDATA['LOGIN'], "S");
         $PASS = clean($this->AR, $AUTHDATA['PASS'], "S");
         $USERINF = $this->USERINFO("n", $LOGIN);
         if ($USERINF) {
             if (strcmp($USERINF['PASS'], $PASS) == 0) {
                 session_start();
                 // Старт сесий
                 $_SESSION['LCMS_USERSES_CODE'] = GenHashe($LOGIN);
                 // Генерируем сесионный хеш
                 //$_SESSION['LCMS_USERSES_NAME'] = $LOGIN; // Генерируем сесионный хеш
                 $RESHASH = API_USER_SETSESION($this->AR, $USERINF['NAME'], $_SESSION['LCMS_USERSES_CODE']);
                 // Устанавливаем хеш пользователю
                 if ($RESHASH) {
                     header("location: " . INDEX_FILE . "");
                     exit;
                 } else {
                     unset($_SESSION['LCMS_USERSES_CODE']);
                     // Убираем переменную
                     session_destroy();
                     // Уничтожаем сесию
                     $this->AR['MSG']->SHOW($this->AR['LNG']->LP['e_usenoin'], "W");
                     // Ошибка установки сесии
                 }
             } else {
                 // Неверный пароль
                 $this->AR['MSG']->SHOW($this->AR['LNG']->LP['w_nopass'], "W");
             }
         } else {
             // Нет такого пользователя
             $this->AR['MSG']->SHOW($this->AR['LNG']->LP['w_nouser'], "W");
         }
     } else {
         // Пустые строки
         $this->AR['MSG']->SHOW($this->AR['LNG']->LP['w_dataisbad'], "W");
     }
 }
 public function AUTH()
 {
     if (isset($_POST['login']) and isset($_POST['password'])) {
         $LOGIN = clean($this->AR, $_POST['login'], "S");
         // Clean login
         $PASS = clean($this->AR, $_POST['password'], "S");
         // Clean passwords
         $USERINF = $this::USERINFO($LOGIN, "N");
         // Get user info
         if ($USERINF) {
             // If have user
             $this->AR['LOG']->WR("USERSClass: User " . $LOGIN . " found");
             //$this->AR['LOG']->WR("USERSClass: GenPass test is ".GenPass($PASS, $PASS."ota")." <-");
             if (strcmp($USERINF['PASS'], GenPass($PASS, $PASS . "ota")) == 0) {
                 session_start();
                 $_SESSION['USERSES_CODE'] = GenHashe($LOGIN, "ota");
                 $this->AR['LOG']->WR("USERSClass: SESION is " . $_SESSION['USERSES_CODE'] . " for " . $LOGIN . "");
                 $DATAS['SESSION'] = $_SESSION['USERSES_CODE'];
                 // Sesion
                 $DATAS['NAME'] = $LOGIN;
                 // Login name
                 $RESHASH = USER_SET_API($DATAS, "S", $this->AR);
                 // Sets session to db
                 if ($RESHASH == 1) {
                     $this->AR['LOG']->WR("USERSClass: SESION is " . $_SESSION['USERSES_CODE'] . " for " . $LOGIN . " updated");
                     header("location: " . INDEX_FILE . "");
                     exit;
                 } else {
                     unset($_SESSION['USERSES_CODE']);
                     // Del session
                     session_destroy();
                     // Destroy
                     $this->AR['LOG']->WR("USERSClass: SESION is " . $_SESSION['USERSES_CODE'] . " for " . $LOGIN . " ERROR");
                     $this->AR['MENU']->SET($this->AR['LNG']->STR['m_nazad'], "javascript:history.go(-1);", "R");
                     // Create menu
                     $this->AR['MSG']->SHOW($this->AR['LNG']->STR['msg_no_sesionset'], "I");
                 }
             } else {
                 $this->AR['MENU']->SET($this->AR['LNG']->STR['m_nazad'], "javascript:history.go(-1);", "R");
                 // Create menu
                 $this->AR['MSG']->SHOW($this->AR['LNG']->STR['msg_bed_bass'], "I");
             }
         } else {
             // If no user
             $this->AR['LOG']->WR("USERSClass: User " . $LOGIN . "  not found");
             $this->AR['MENU']->SET($this->AR['LNG']->STR['m_nazad'], "javascript:history.go(-1);", "R");
             // Create menu
             $this->AR['MSG']->SHOW($this->AR['LNG']->STR['msg_no_user'], "I");
         }
     } else {
         $this->AR['MENU']->SET($this->AR['LNG']->STR['m_nazad'], "javascript:history.go(-1);", "R");
         // Create menu
         $this->AR['MSG']->SHOW($this->AR['LNG']->STR['msg_no_data'], "I");
     }
 }