SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 138 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BEGIN
  2. DECLARE _id INT;
  3. DECLARE _active INT DEFAULT 3;
  4. DECLARE _ipaddr INT DEFAULT 0;
  5. DECLARE _lockout BOOLEAN DEFAULT 0;
  6. DECLARE _locktime TIMESTAMP;
  7.  
  8. SELECT id INTO _id
  9. FROM Users
  10. WHERE username = name;
  11.  
  12. SELECT active,TIMESTAMP INTO _lockout,_locktime
  13. FROM User_lockout
  14. WHERE (user_id = id OR origin = ip) ORDER BY TIMESTAMP DESC LIMIT 1;
  15.  
  16. SELECT active INTO _active
  17. FROM Users
  18. WHERE username = name AND pass = TRUE;
  19.  
  20. SELECT id INTO _ipaddr
  21. FROM User_ip_list
  22. WHERE ipaddr = ip;
  23.  
  24. IF _lockout > 0 THEN
  25.     SELECT 'Login ignored, you have made to many attempts try again in about 15 minutes.' AS 'id';
  26. ELSE
  27.     IF _active = 0 THEN
  28.         INSERT INTO User_loginHist (id, user_id, email_used, TIMESTAMP, success, origin, cookie)
  29.         VALUES (NULL, _id, name, CURRENT_TIMESTAMP, '0', ip, cookid);
  30.         SELECT 'This account is disabled' AS 'id';
  31.     ELSE
  32.         IF _id > 0 AND _active = 1 THEN
  33.             IF _ipaddr > 0 OR TRUE THEN
  34.                 INSERT INTO User_loginHist (id, user_id, email_used, TIMESTAMP, success, origin, cookie)
  35.                 VALUES (NULL, _id, name, CURRENT_TIMESTAMP, '1', ip, cookid);
  36.                 SELECT id,User_info.GROUP,User_info.DOMAIN,CONCAT(User_info.first_name, " ", User_info.last_name) AS first_name FROM Users NATURAL JOIN User_info WHERE username = name;
  37.             ELSE
  38.                 INSERT INTO User_loginHist (id, user_id, email_used, TIMESTAMP, success, origin, cookie)
  39.                 VALUES (NULL, _id, name, CURRENT_TIMESTAMP, '0', ip, cookid);
  40.                 SELECT 'Login is not permitted from this location' AS 'id';
  41.             END IF;
  42.         ELSE
  43.             INSERT INTO User_loginHist (id, user_id, email_used, TIMESTAMP, success, origin, cookie)
  44.             VALUES (NULL, _id, name, CURRENT_TIMESTAMP, '0', ip, cookid);
  45.             SELECT 'Bad Username or Password. Check your login and try again' AS 'id';
  46.         END IF;
  47.     END IF;
  48. END IF;
  49. END
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top