Advertisement
Guest User

Untitled

a guest
May 12th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.96 KB | None | 0 0
  1. <?php
  2. class Auth {
  3.    
  4.     function Auth(){
  5.        
  6.     }
  7.    
  8.     function login ( username, password ){
  9.         $query = sprintf("SELECT adminId FROM ".$glob['dbprefix']."CubeCart_admin_users WHERE username = %s AND password = %s", $db->mySQLSafe($_POST['username']), $db->mySQLSafe(md5($_POST['password'])));
  10.      
  11.         $result = $db->select($query);
  12.         $query = "UPDATE ".$glob['dbprefix']."CubeCart_admin_users SET lang = ".$db->mySQLSafe($lang_now);
  13.         $lang_update = $db->misc($query);
  14.        
  15.         // insert admin session log
  16.         $data["username"] = $db->mySQLSafe($_POST['username']);
  17.         $data["time"] = time();
  18.         $data["ipAddress"] = $db->mySQLSafe($_SERVER['REMOTE_ADDR']);      
  19.             if($result == TRUE) {
  20.                 $data["success"] = 1;
  21.             } else {
  22.                 $data["success"] = 0;
  23.             }  
  24.         $insert = $db->insert($glob['dbprefix']."CubeCart_admin_sessions", $data);
  25.        
  26.         // if there is over max amount of login records delete last one
  27.         // this prevents database attacks of bloating
  28.         if($db->numrows("SELECT loginId FROM ".$glob['dbprefix']."CubeCart_admin_sessions")>250){
  29.             $loginId = $db->select("SELECT max(loginId) as id FROM ".$glob['dbprefix']."CubeCart_admin_sessions");
  30.             $db->delete($glob['dbprefix']."CubeCart_admin_sessions","loginId='".$loginId[0]['id']."'");
  31.         }
  32.        
  33.         if($result == TRUE) {
  34.            
  35.             $_SESSION['ccAdmin'] = $result[0]['adminId'];
  36.            
  37.             // update no logins
  38.             $increment['noLogins'] = "noLogins+1";
  39.             $result = $db->update($glob['dbprefix']."CubeCart_admin_users", $increment, "adminId=".$result[0]['adminId'],$stripQuotes="");
  40.            
  41.             if(isset($_GET['goto']) && !empty($_GET['goto'])){
  42.                 header("Location: ".urldecode($_GET['goto']));
  43.             } else {
  44.                 header("Location: ".$GLOBALS['rootRel']."admin/index.php?s_lang=".$lang_now);
  45.             }
  46.            
  47.         } else {
  48.            
  49.             $msg = "<p class='warnText'>".$lang['admin']['other']['login_failed']."</p>";
  50.        
  51.         }
  52.     }
  53.    
  54.    
  55.     function logout (){
  56.    
  57.     }
  58.  
  59.     function change password ( old password, newpassword1, newpassword2) {
  60.    
  61.     }
  62.    
  63.  
  64.  
  65.  
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement