Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.54 KB | None | 0 0
  1. proc:BEGIN
  2.  
  3. /** --------
  4.  * Author: Yamachi
  5.  * Date: 09/02/2011
  6.  ** --------
  7.  * Handles login attempts.
  8.  ** --------
  9.  **/
  10.  
  11. /** ----------------------------- **/
  12.  
  13.  
  14. /* Auth results */
  15. DECLARE Success,                            # Login succeeded
  16.                 Fail,                                   # Login failed (wrong username or pass)
  17.                 Logged_In,                      # Account is already logged in
  18.                 Maintenance,                    # Server is undergoing maintenance
  19.                 Expired,                            # Account playtime has expired (was used during CABAL's very brief p2p moment)
  20.                 IP_Blocked,                     # IP is blocked
  21.                 Blocked,                            # Account is blocked
  22.                 Trial,                              # Free trial period (?)  No idea what this is for
  23.                 Cafe,                                   # Internet cafe account (must log in from a cafe)
  24.                 Unauthorised,                   # Account not authorised (need to verify email address)
  25.                 Password_Block  int;    # Account termporarily blocked for security measures (too many incorrect password attempts)
  26.  
  27. /* Account data */
  28. DECLARE _usernum,
  29.                 _authtype,
  30.                 _login      int;
  31. DECLARE _identityno char(13);
  32.  
  33. /* blah */
  34. DECLARE _authkey varchar(32);
  35.  
  36.  
  37. /** ----------------------------- **/
  38.  
  39.  
  40. /* Set the auth results constants */
  41. SET Success                 = 32,
  42.         Fail                        = 33,
  43.         Logged_In               = 34,
  44.         Maintenance         = 35,
  45.         Expired                 = 36,
  46.         IP_Blocked          = 37,
  47.         Blocked                 = 38,
  48.         Trial                       = 39,
  49.         Cafe                        = 40,
  50.         Unauthorised        = 41,
  51.         Password_Block  = 42;
  52.  
  53.  
  54. /** ----------------------------- **/
  55.  
  56.  
  57. /* Grab user info */
  58. SELECT SQL_CALC_FOUND_ROWS UserNum, AuthType, IdentityNo, Login
  59. FROM cabal_auth_table
  60. WHERE ID = id and Password = PASSWORD(pass)
  61. INTO _usernum, _authtype, _identityno, _login;
  62.  
  63. /* Check to see if account info was incorrect */
  64. IF FOUND_ROWS() = 0 THEN
  65.     COMMIT;
  66.     SELECT Fail;
  67.     LEAVE proc;
  68. END IF;
  69.  
  70. /* Check to see if account is blocked */
  71. IF _authtype = 2 THEN
  72.     COMMIT;
  73.     SELECT Blocked, _usernum, 0;
  74.     LEAVE proc;
  75. END IF;
  76.  
  77. /* Not sure what this is for */
  78. IF _authtype = 3 THEN
  79.     SET _identityno = SUBSTRING(_indentityno, 1, 6) + '0000001';
  80. END IF;
  81.  
  82. /* TODO: Check if IP is banned */
  83.  
  84. /* Check to see if account is already logged in */
  85. IF _login != 0 THEN
  86.     COMMIT;
  87.     SELECT Logged_In, _usernum, _login;
  88.     LEAVE proc;
  89. END IF;
  90.  
  91. /* TODO: Check premium status */
  92.  
  93. /* Generate and update AuthKey */
  94. SET _authkey = REPLACE(UUID(), '-', '');
  95. UPDATE cabal_auth_table
  96. SET Login = _login, LoginTime = CURDATE(), LastIp = ip, AuthKey = _authkey
  97. WHERE UserNum = _usernum;
  98.  
  99. /* Login succeeded */
  100. SELECT Success,
  101.              _usernum,
  102.              _login,
  103.              _identityno,
  104.              0,     # Type
  105.              0,     # Premium time left in seconds
  106.              0,     # PayMinutes (?)
  107.              0,     #   IsFreeIp (wtf is this?)
  108.              0,     # ServiceKind
  109.              _authkey;
  110.  
  111. COMMIT;
  112.  
  113. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement