Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetName()
- local rootNode = xmlLoadFile("details.xml")
- if rootNode then -- If the file is found
- local UserName = xmlFindChild(rootNode, "Username", 0) -- Find the childnode
- if UserName then -- If the childnode is found
- local succes = xmlNodeGetValue (UserName) -- Get the value of the childnode
- end
- xmlUnloadFile(rootNode)
- if succes then
- return tostring(succes)
- else
- return ""
- end
- end
- return ""
- end
- function GetPassword()
- local rootNode = xmlLoadFile("details.xml")
- if rootNode then -- If the file is found
- local Password = xmlFindChild(rootNode, "Password", 0) -- Find the childnode
- if Password then -- If the childnode is found
- local succes = xmlNodeGetValue (Password) -- Get the value of the childnode
- end
- xmlUnloadFile(rootNode)
- if succes then
- return tostring(succes)
- else
- return ""
- end
- end
- return ""
- end
- function saveDetails(username, password)
- local RootNode = xmlLoadFile("details.xml")
- local Username, Password, success1, success2
- -- Check if there is a file called "details.xml" on the client's computer
- if not rootNode then
- RootNode = xmlCreateFile("details.xml","Details") -- If "details.xml" is not on the clients computer then create new file
- end
- -- Find the nodes
- Username = xmlFindChild (RootNode, "Username", 0)
- Password = xmlFindChild (RootNode, "Password", 0)
- if Username and not Password then -- If username is found but password not
- Password = xmlCreateChild(RootNode, "Password") -- Create new password child
- elseif not Username and Password then -- If username is not found but password is
- Username = xmlCreateChild(RootNode, "Username") -- Create new username child
- elseif not Username and not Password then -- If none is found
- Username = xmlCreateChild(RootNode, "Username") -- Create new username child
- Password = xmlCreateChild(RootNode, "Password") -- Create new password child
- end
- -- Set the values of the childnodes
- success1 = xmlNodeSetValue(Username, username)
- success2 = xmlNodeSetValue(Password, password)
- if success1 and success2 then
- xmlSaveFile(RootNode)
- xmlUnloadFile(RootNode)
- else
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement