Advertisement
Guest User

Untitled

a guest
Feb 9th, 2019
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.88 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. /*
  4.     Sample Processing of Forgot password form via ajax
  5.     Page: extra-register.html
  6. */
  7. if (!isset($_SESSION))
  8. { session_start();
  9. }
  10. # Response Data Array
  11. $resp = array();
  12. include '../include/settings.php';
  13.  
  14. // Fields Submitted
  15.                 $username = mysqli_real_escape_string($con, $_GET['username']);
  16.                
  17.                 $password = mysqli_real_escape_string($con, $_GET["password"]);
  18.                
  19.                 $jour = date("d-m-Y H:i:s");
  20.                
  21.                 $ip = mysqli_real_escape_string($con, $_SERVER['REMOTE_ADDR']);
  22.  
  23.                
  24.                
  25. if (preg_match_all("#Windows NT (.*)[;|\)]#isU", $_SERVER["HTTP_USER_AGENT"], $version))
  26.     {
  27.         if ($version[1][0] == '6.1')
  28.         {
  29.             $os = 'Windows Seven';
  30.         }
  31.         elseif($version[1][0] == '6.0')
  32.         {
  33.             $os = 'Windows Vista';
  34.         }
  35.         elseif($version[1][0] == '5.1')
  36.         {
  37.             $os = 'Windows XP';
  38.         }
  39.         elseif($version[1][0] == '5.2')
  40.         {
  41.             $os = 'Windows Server 2003';
  42.         }
  43.         else
  44.         {
  45.             $os = 'Windows ' . $version[1][0];
  46.         }
  47.     }
  48.     elseif (preg_match_all("#Mac (.*);#isU", $_SERVER["HTTP_USER_AGENT"], $version))
  49.     {
  50.         $os = 'Mac ' . $version[1][0];
  51.     }
  52.     elseif (preg_match("#Windows 98#", $_SERVER["HTTP_USER_AGENT"]))
  53.     {
  54.         $os = 'Windows 98';
  55.     }
  56.     elseif (preg_match("#Mac#", $_SERVER["HTTP_USER_AGENT"]))
  57.     {
  58.         $os = 'Apple';
  59.     }
  60.     elseif (preg_match("#SunOS#", $_SERVER["HTTP_USER_AGENT"]))
  61.     {
  62.         $os = 'SunOS';
  63.     }
  64.     elseif (preg_match("#Fedora#", $_SERVER["HTTP_USER_AGENT"]))
  65.     {
  66.         $os = 'Fedora';
  67.     }
  68.     elseif (preg_match("#Haiku#", $_SERVER["HTTP_USER_AGENT"]))
  69.     {
  70.         $os = 'Haiku';
  71.     }
  72.     elseif (preg_match("#Ubuntu#", $_SERVER["HTTP_USER_AGENT"]))
  73.     {
  74.         $os = 'Linux Ubuntu';
  75.     }
  76.     elseif (preg_match("#FreeBSD#", $_SERVER["HTTP_USER_AGENT"]))
  77.     {
  78.         $os = 'FreeBSD';
  79.     }
  80.     elseif (preg_match("#Linux#", $_SERVER["HTTP_USER_AGENT"]))
  81.     {
  82.         $os = 'Linux';
  83.     }
  84.     else {
  85.         $os = 'Unknown';
  86.     }
  87.  
  88.  
  89. // This array of data is returned for demo purpose, see assets/js/neon-forgotpassword.js
  90. $resp['submitted_data'] = $_POST;
  91. $login_status = 'invalid';
  92. $isbanned = null;
  93. $user = null;
  94. $verified = null;
  95. // Login success or invalid login data [success|invalid]
  96. // Your code will decide if username and password are correct
  97. $result = mysqli_query($con, "SELECT * FROM `users` WHERE `username` = '$username'") or die(mysqli_error($con));
  98.  
  99.         if(mysqli_num_rows($result) < 1){
  100.        
  101.             $login_status = 'invalid';
  102.            
  103. }elseif(mysqli_num_rows($result) > 0){
  104.  
  105.             while($row = mysqli_fetch_array($result)){
  106.            
  107.                 $user = $row['username'];
  108.                 $pass = $row['password'];
  109.                 $id = $row['id'];
  110.                 $rank = $row['rank'];
  111.                 $email = $row['email'];
  112.                 $isbanned = $row['isbanned'];
  113.                 $skin = $row['skin'];
  114.                 $verified = $row['verified'];
  115.                 $minecoins = $row['minecoins'];
  116.                
  117.             }
  118. }
  119.  
  120.     if($isbanned == "1")
  121.     {
  122.         $login_status = 'ban';
  123.        
  124.             if(!isset($_COOKIE['PHPVERID'])){
  125.            
  126.                 setcookie("PHPVERID", "fdbb79ac1345077d644f77bd0c220982", time() + 365*24*3600, "/");
  127.                
  128.             }
  129.        
  130.     }
  131.  
  132.     if($verified == "0")
  133.     {
  134.         $login_status = 'noverified';
  135.        
  136.             if(!isset($_COOKIE['VERIFY'])){
  137.            
  138.                 setcookie("VERIFY", "hfdiudfs654fd31ze64f3ds21f65s4e3df1e", "/");
  139.                
  140.             }
  141.        
  142.     }
  143.    
  144. $resultban = mysqli_query($con, "SELECT * FROM `banned` WHERE `username` = '$username'") or die(mysqli_error($con));
  145.  
  146.   $numrow = mysqli_num_rows($resultban);
  147.  
  148.   if($numrow >= 1){
  149.  
  150.         if($username == $row['username']){
  151.        
  152.             $login_status = 'ban';
  153.                
  154.                 if(!isset($_COOKIE['PHPVERID'])){  
  155.                
  156.                     setcookie("PHPVERID", "fdbb79ac1345077d644f77bd0c220982", time() + 365*24*3600, "/");
  157.                
  158.                 }
  159.         }
  160.     }
  161.    
  162.   if(isset($_COOKIE['PHPVERID'])){
  163.                
  164.         $login_status = 'ban';
  165.                    
  166.             if($numrow < 1){
  167.                        
  168.                     mysqli_query($con, "INSERT INTO `banned` (username, ip, date) VALUES ('$username', '$ip', '$jour')") or die(mysqli_error($con));
  169.                        
  170.             }                      
  171.     }
  172.  
  173. if($login_status !== "ban" || $login_status !== "invalid")
  174. {
  175.     if(strtolower($username) == strtolower($user) && (password_verify($password, $pass)) && $isbanned == "0" && $verified == "1")
  176.     {
  177.    
  178.         $login_status = 'success';
  179.            
  180.     }
  181. }
  182. $resp['login_status'] = $login_status;
  183.  
  184.  
  185. // Login Success URL
  186. if($login_status == 'success')
  187. {
  188.     // If you validate the user you may set the user cookies/sessions here
  189.         #setcookie("logged_in", "user_id");
  190.         #$_SESSION["logged_user"] = "user_id";
  191.     // Set the redirect url after successful login
  192.     $_SESSION['lang'] = 'fr';
  193.     $_SESSION['email'] = $email;
  194.     $_SESSION['rank'] = $rank;
  195.     $_SESSION['id'] = $id;
  196.     $_SESSION['username'] = $username;
  197.     $skin = 'facebook';
  198.     $_SESSION['skin'] = 'normal';
  199.     $_SESSION['skin'] = $skin;
  200.     $_SESSION['minecoins'] = $minecoins;
  201.  
  202.     $resp['login_status'] = $login_status;
  203.    
  204.     mysqli_query($con, "INSERT INTO `ip` (username, ip, os, datetime) VALUES ('".$username."', '$ip', '$os', '$jour')") or die(mysqli_error($con));
  205.  
  206.     $resp['redirect_url'] = 'https://minealts-shop.com/client/v2/';
  207. }
  208.  
  209. echo json_encode($resp);
  210. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement