Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists("/Fsociety/data/side") then
- print("ERROR NO SIDE FILE")
- os.reboot()
- end
- sideFile = fs.open("/Fsociety/data/side","r")
- modemSide = sideFile.readLine()
- sideFile.close()
- --------------------------------------------
- -- --
- -- Data System from --
- -- Security System V0.1 --
- -- By Fsociety --
- -- --
- --------------------------------------------
- local m = peripheral.wrap(modemSide)
- m.open(102)
- if fs.exists("/Fsociety/data/whitelist") then
- whitelistFile = fs.open("/Fsociety/data/whitelist","r")
- else
- print("EDIT WHITELIST IN /Fsociety/data/whitelist")
- fs.makeDir("/Fsociety")
- fs.makeDir("/Fsociety/data")
- create = fs.open("/Fsociety/data/whitelist","w")
- create.write("Put withelisted user ( only one per line )")
- create.close()
- whitelistFile = fs.open("/Fsociety/data/whitelisted","r")
- end
- local nbLine = 0
- local whitelist = {}
- whitelistFile.readLine()
- while whitelistFile.readLine() ~= nil do
- nbLine = nbLine + 1
- end
- whitelistFile.close()
- whitelistFile = fs.open("/Fsociety/data/whitelist","r")
- whitelistFile.readLine()
- for i=1,nbLine do
- whitelist[i] = whitelistFile.readLine()
- end
- for x=1,nbLine do print(whitelist[x]) end
- whitelistFile.close()
- while true do
- local event , param1 , param2 , param3 , param4 = os.pullEvent()
- if event == "modem_message" then
- print(param2)
- print(param3)
- print(param4)
- if param4 ~= "pim" then
- test = true
- for i=1,nbLine do
- test = test and whitelist[i] ~= param4
- end
- if test == false then
- m.transmit(101,55,"User allowed")
- elseif test == true then
- m.transmit(101,55,"User not allowed")
- end
- else
- m.transmit(101,55,"Nobody")
- end
- end
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement