Advertisement
Guest User

Untitled

a guest
Nov 9th, 2017
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 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 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 password = md5("wedorp" .. newPass)
  25. local escapedPass = exports.mysql:escape_string(password)
  26. local query = exports.mysql:query_free("UPDATE accounts SET password = '" .. escapedPass .. "' WHERE id = '" .. accountData["id"] .. "'")
  27. if query then
  28. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, accountUsername.."'s password was sussesfully changed.")
  29. else
  30. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "MySQL error please try again later.")
  31. end
  32. end
  33. end
  34. end
  35. end
  36. addCommandHandler("setaccountpassword", changeAccountPassword, false, false)
  37.  
  38. function changePlayerPassword(thePlayer, commandName, newPass, newPassConfirm)
  39. if getElementData(thePlayer, "loggedin") then
  40. if not newPass or not newPassConfirm then
  41. outputChatBox("SYNTAX: /" .. commandName .. " [New Password] [Confirm Pass]", thePlayer, 125, 125, 125)
  42. else
  43. if (newPass ~= newPassConfirm) then
  44. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "The passwords do not match.")
  45. elseif (string.len(newPass)<6) then
  46. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password is too short. \n You must enter 6 or more characters.")
  47. elseif (string.len(newPass)>=30) then
  48. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password is too long. \n You must enter less than 30 characters.")
  49. elseif (string.find(newPass, ";", 0)) or (string.find(newPass, "'", 0)) or (string.find(newPass, "@", 0)) or (string.find(newPass, ",", 0)) then
  50. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password cannot contain ;,@'.")
  51. else
  52. local dbid = getElementData(thePlayer, "account:id")
  53. local escapedID = exports.mysql:escape_string(dbid) -- Pointless, I know -Tam
  54. local password = md5("wedorp" .. newPass)
  55. local escapedPass = exports.mysql:escape_string(password)
  56. local query = exports.mysql:query_free("UPDATE accounts SET password = '" .. escapedPass .. "' WHERE id = '" .. escapedID .. "'")
  57. if query then
  58. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "Your password was sussesfully changed.")
  59. else
  60. triggerClientEvent(thePlayer, "accounts:error:window", thePlayer, "MySQL error please try again later.")
  61. end
  62. end
  63. end
  64. end
  65. end
  66. addCommandHandler("changeaccountpassword", changePlayerPassword, false, false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement