Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BEGIN
- DECLARE _id INT;
- DECLARE _active INT DEFAULT 3;
- DECLARE _ipaddr INT DEFAULT 0;
- DECLARE _lockout BOOLEAN DEFAULT 0;
- DECLARE _locktime TIMESTAMP;
- SELECT id INTO _id
- FROM Users
- WHERE username = name;
- SELECT active,TIMESTAMP INTO _lockout,_locktime
- FROM User_lockout
- WHERE (user_id = id OR origin = ip) ORDER BY TIMESTAMP DESC LIMIT 1;
- SELECT active INTO _active
- FROM Users
- WHERE username = name AND pass = TRUE;
- SELECT id INTO _ipaddr
- FROM User_ip_list
- WHERE ipaddr = ip;
- IF _lockout > 0 THEN
- SELECT 'Login ignored, you have made to many attempts try again in about 15 minutes.' AS 'id';
- ELSE
- IF _active = 0 THEN
- INSERT INTO User_loginHist (id, user_id, email_used, TIMESTAMP, success, origin, cookie)
- VALUES (NULL, _id, name, CURRENT_TIMESTAMP, '0', ip, cookid);
- SELECT 'This account is disabled' AS 'id';
- ELSE
- IF _id > 0 AND _active = 1 THEN
- IF _ipaddr > 0 OR TRUE THEN
- INSERT INTO User_loginHist (id, user_id, email_used, TIMESTAMP, success, origin, cookie)
- VALUES (NULL, _id, name, CURRENT_TIMESTAMP, '1', ip, cookid);
- 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;
- ELSE
- INSERT INTO User_loginHist (id, user_id, email_used, TIMESTAMP, success, origin, cookie)
- VALUES (NULL, _id, name, CURRENT_TIMESTAMP, '0', ip, cookid);
- SELECT 'Login is not permitted from this location' AS 'id';
- END IF;
- ELSE
- INSERT INTO User_loginHist (id, user_id, email_used, TIMESTAMP, success, origin, cookie)
- VALUES (NULL, _id, name, CURRENT_TIMESTAMP, '0', ip, cookid);
- SELECT 'Bad Username or Password. Check your login and try again' AS 'id';
- END IF;
- END IF;
- END IF;
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement