Advertisement
Selim_042

Northbridge Network CC API

Sep 25th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. --[[
  2.     Used for ease of use with Northbridge Network
  3.     http://northbridge.dx.am
  4. ]]--
  5.  
  6. version = 0.1
  7.  
  8. local apiUrl = "http://api.northbridge.dx.am/"
  9.  
  10. local function checkForJson()
  11.   if (json == null) then
  12.     error('json api is not running')
  13.   end
  14. end
  15.  
  16. os.version = function()
  17.   return "Northbridge OS Terminal v"..version
  18. end
  19.  
  20. client = {
  21.   setThemeColor = function(color, themePart)
  22.     theme[themePart] = color
  23.     local file = fs.open("northbridge/theme", "w")
  24.     file.write(json.encodePretty(theme))
  25.     file.close()
  26.   end
  27.   ,
  28.   splitString = function(string, splitChar)
  29.     return {string:match('/(.-) (.+)')}
  30.   end
  31. }
  32.  
  33. user = {
  34.   login = function(username, password)
  35.     checkForJson()
  36.     return json.decode(http.get(textutils.urlEncode(apiUrl.."user.php?cmd=login&username="..username.."&password="..password)).readAll())
  37.   end
  38.   ,
  39.   register = function(username, password, email)
  40.     checkForJson()
  41.     return json.decode(http.get(textutils.urlEncode(apiUrl.."user.php?cmd=register&username="..username.."&password="..password.."&email="..email)).readAll())
  42.   end
  43.   ,
  44.   validate = function(username, key)
  45.     checkForJson()
  46.     return json.decode(http.get(textutils.urlEncode(apiUrl.."user.php?cmd=validate&username="..username.."&key="..key)).readAll())
  47.   end
  48.   ,
  49.   logout = function(username, key)
  50.     checkForJson()
  51.     return json.decode(http.get(textutils.urlEncode(apiUrl.."user.php?cmd=logout&username="..username.."&key="..key)).readAll())
  52.   end
  53.   ,
  54.   changePassword = function(username, password, newPassword)
  55.     checkForJson()
  56.     return json.decode(http.get(textutils.urlEncode(apiUrl.."user.php?cmd=passChange&username="..username.."&password="..password.."&newPassword="..newPassword)).readAll())
  57.   end
  58.   ,
  59.   changeEmail = function(username, password, newEmail)
  60.     checkForJson()
  61.     return json.decode(http.get(textutils.urlEncode(apiUrl.."user.php?cmd=emailChange&username="..username.."&password="..password.."&newEmail="..newEmail)).readAll())
  62.   end
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement