Advertisement
Guest User

Untitled

a guest
Apr 14th, 2019
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. function changeAccountPassword(thePlayer, commandName, accountUsername, newPass, newPassConfirm)
  2. if exports.integration:isPlayerSeniorAdmin(thePlayer) then
  3. if not accountUsername or not newPass or not newPassConfirm then
  4. outputChatBox("SYNTAX: /" .. commandName .. " [Account Username] [New Password] [Confirm Pass]", thePlayer, 125, 125, 125)
  5. else
  6. if (newPass ~= newPassConfirm) then
  7. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "The passwords do not match.")
  8. elseif (string.len(newPass)<6) then
  9. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password is too short. \n You must enter 6 or more characters.")
  10. elseif (string.len(newPass)>=30) then
  11. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password is too long. \n You must enter less than 30 characters.")
  12. elseif (string.find(newPass, ";", 0)) or (string.find(newPass, "'", 0)) or (string.find(newPass, "@", 0)) or (string.find(newPass, ",", 0)) then
  13. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password cannot contain ;,@'.")
  14. else
  15. local accountData
  16. local account = exports.mysql:query("SELECT id, salt FROM accounts WHERE username ='"..exports.mysql:escape_string(accountUsername).."' LIMIT 1")
  17. if (mysql:num_rows(account) > 0) then
  18. accountData = mysql:fetch_assoc(account)
  19. mysql:free_result(account)
  20. else
  21. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "No account with that username was found.")
  22. return
  23. end
  24. local encryptionRule = accountData["salt"]
  25. local password = string.lower(md5(string.lower(md5(newPass))..encryptionRule))
  26. local escapedPass = exports.mysql:escape_string(password)
  27. local query = exports.mysql:query_free("UPDATE accounts SET password = '" .. escapedPass .. "' WHERE id = '" .. accountData["id"] .. "'")
  28. if query then
  29. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, accountUsername.." a fost schimbată cu succes.")
  30. else
  31. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "MySQL error please try again later.")
  32. end
  33. end
  34. end
  35. end
  36. end
  37. addCommandHandler("setaccountpassword", changeAccountPassword, false, false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement