Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cmp = require("component")
- local gpu = cmp.gpu
- local event = require("event")
- local serialization = require("serialization")
- local unicode=require("unicode")
- local filesystem = require("filesystem")
- local shell = require("shell")
- local term = require("term")
- local uc=require('unicode')
- local computer = require("computer")
- local keyboard = require("keyboard")
- local len = uc.len
- local sub = uc.sub
- auth = {}
- local function saveTbl(tbl, fl) file = io.open(fl, 'w') file:write(serialization.serialize(tbl)) file:close() end
- local function loadTbl(fl)
- file = io.open(fl, 'r')
- if file == nil then
- file = io.open(fl, 'w')
- file:write('{}')
- file:close()
- return {}
- else
- file = io.open(fl, 'r')
- return serialization.unserialize(file:read('*a'))
- end
- end
- function auth.delInArr(arr,id)
- nar ={}
- for i=1,#arr do
- if i ~= id then
- nar[#nar+1] = arr[i]
- end
- end
- return nar
- end
- function auth.check(arr,str)
- find={false,0}
- for i=1,#arr do
- if arr[i]==str then
- find={true,i}
- break
- end
- end
- return find
- end
- function auth.delUser(db,user)
- arr = loadTbl(db)
- find = auth.check(arr,user)
- if find[1] == true then
- arr = auth.delInArr(arr,find[2])
- saveTbl(arr,db)
- end
- return find[1]
- end
- function auth.addUser(db,user)
- arr=loadTbl(db)
- status = nil
- find = auth.check(arr,user)
- if find[1] ~= true then
- arr[#arr+1]=user
- saveTbl(arr,db)
- return true
- else
- return false
- end
- end
- return auth
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement