current coding:
--Drachma 0.1
os.pullEvent=os.pullEventRaw
--[[to-do list:
logout feature
create "user already exists" portion of newUser
develop os functions
create password changing function
admin password cannot be changed
experiment w/ h.write & h.writeLine commands
create file identification
create program licenses
admins grant licenses to .iso files to authorize their use
licenses must be verified before every attempt to run program
dangerScan level 1 failures ignored
develop dangerScan license compatibility
big: develop Drachma as OS
big: develop Wenceslas
]]
--[[file system extensions
.prg = program
.dba = database
.txt = text
.iso = isolated program
.lic = licensed program
.img = image
]]
--Variable lineup
userTrust = false
adminTrust = false
aiCheck = false
--Functions
function login()
term.clear()
term.setCursorPos(1,1)
print("Username: ")
term.setCursorPos(1,3)
usr = read()
term.setCursorPos(1,3)
print("Password: ")
term.setCursorPos(1,4)
pwd = read("*")
usr.dba = fs.open("drachma/usr.dba", "r")
pwd.dba = fs.open("drachma/pwd.dba", "r")
_usr=textutils.unserialize(usr.dba readAll())
_pwd=textutils.unserialize(pwd.dba.readAll())
for i = 1,0,1 do
if usr = _usr[i] and pwd = _pwd[i] then
if usr="admin" then
adminTrust = true
os.pullEvent = os.pullEvent
usertrust = true
i = 0
home()
else
userTrust = true
i = 0
home()
end
else
print("Credential Mismatch. Access Denied.")
end
end
end
function gui()
end
function aiStatus()
term.clear()
if aiCheck == true then
shell.run("drachma/Wenceslas.lai")
else
x, y = term.getSize()
_x = x-14
term.setCursorPos(_x,y)
io.write("AI unavailable.")
term.setCursorPos(1,1)
end
end
function os()
input = read()
if string.sub(input,1,4)=="open"
--extensions(input,5,#input)
else
print("Unrecognized Command.")
sleep(3)
end
end
function home()
while true do
--gui()
aiStatus()
--os()
end
end
function newUser()
if adminTrust==true then
term.setCursorPos(1,1)
print("New Username:")
term.setCursorPos(1,2)
usr = read()
term.setCursorPos(1,3)
print("New Password:")
term.setCursorPos(1,4)
pwd = read("*")
usr.dba = fs.open("drachma/usr.dba", "a")
usr.dba.writeLine(usr)
usr.dba.flush()
usr.dba.close()
pwd.dba = fs.open("drachma/pwd.dba", "a")
pwd.dba.writeLine(pwd)
pwd.dba.flush()
pwd.dba.close()
print("Success! User".. usr .." created.")
sleep(5)
term.clear()
else
print("Access Denied. Administrator priveleges required.")
sleep(5)
term.clear()
end
home()
end
function dangerScan(fileName)
file = fs.open(fileName,"r")
contents = file.readAll()
lv2.dba = fs.open("drachma/lv2.dba", "r")
lv2 = textutils.unserialize(lv2.dba.readAll())
lv1.dba = fs.open("drachma/lv1.dba", "r")
lv1 = textutils.unserialize(lv1.dba.readAll())
for i = 1, #lv2 do
status = string.search(contents, lv2[i])
if status ~= nil then
fs.delete(fileName)
print("Dangerous script detected, deleting file.")
return(2)
else
status = string.search(contents, lv1[i])
if status ~= nil then
fs.move(fileName, string.sub(fileName, 1, #fileName-3).."iso")
print("Suspicious script detected, isolating file.")
return(1)
else
return(0)
end
end
end
end
login()
also… apparently ^that^ doesn't get along very consistently with the tab button…