Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CheckSecurity()
- return true
- end
- function CheckAccess(file)
- local file = fs.open("os/Files/ProgramKeys.txt","r")
- local Table = textutils.unserialize(file.readAll())
- file.close()
- local Key
- for i = 1, #Table do
- if Table[i][1] == file then Key = Table[i][2] end
- end
- settings.load("os/settings.txt")
- local Doc = fs.open(fs.combine("os/System/Users",settings.get("active_user"),"UserKeys.txt"),"r")
- local UserKeys = textutils.unserialize(Doc.readAll())
- Doc.close()
- local Pass = false
- for i = 1, #UserKeys do
- if Key == UserKeys[i] then Pass = true end
- end
- if Pass == false and Key == nil then Pass = true end
- return Pass
- end
- function getKey(file)
- local file = fs.open("os/Files/ProgramKeys.txt","r")
- local Table = textutils.unserialize(file.readAll())
- file.close()
- local Key
- for i = 1, #Table do
- if Table[i][1] == file then Key = Table[i][2] end
- end
- return Key
- end
- function AddKey(file,key)
- local file = fs.open("os/Files/ProgramKeys.txt","r")
- local Table = textutils.unserialize(file.readAll())
- Table[#Table + 1] = {file,key}
- file.close()
- local Doc = fs.open("os/Files/ProgramKeys.txt","w")
- Doc.write(textutils.serialize(Table))
- Doc.close()
- end
- function AddUserKey(user,key)
- local file = fs.open(fs.combine("os/System/Users",user,"UserKeys.txt"),"r")
- local Table = textutils.unserialize(file.readAll())
- Table[#Table + 1] = {file,key}
- file.close()
- local Doc = fs.open(fs.combine("os/System/Users",user,"UserKeys.txt"),"w")
- Doc.write(textutils.serialize(Table))
- Doc.close()
- end
Add Comment
Please, Sign In to add comment