Update sPhone.lua

This commit is contained in:
Ale32bit 2015-11-13 23:22:02 +01:00
parent fcfd446832
commit 2265ec075a

View file

@ -122,6 +122,13 @@ local function kernel()
f.close() f.close()
end end
if not fs.exists("/.sPhone/config/newPassword") and fs.exists("/.sPhone/.password") then
fs.move("/.sPhone/.password","/.sPhone/config/.password")
f = fs.open("/.sPhone/config/newPassword","w")
f.write("Ignore Me. I just check if the password is moved to the config folder")
f.close()
end
if not fs.exists("/.sPhone/autorun") then if not fs.exists("/.sPhone/autorun") then
fs.makeDir("/.sPhone/autorun") fs.makeDir("/.sPhone/autorun")
end end
@ -636,7 +643,7 @@ end
end end
else else
if (y > 2 and x > 1) and (y < 6 and x < 9) then if (y > 2 and x > 1) and (y < 6 and x < 9) then
os.pullEvent = os.oldPullEvent os.pullEvent = os.oldPullEvent
term.setBackgroundColor(colors.black) term.setBackgroundColor(colors.black)
term.clear() term.clear()
term.setCursorPos(1,1) term.setCursorPos(1,1)
@ -691,16 +698,16 @@ end
term.clear() term.clear()
term.setCursorPos(1,1) term.setCursorPos(1,1)
term.setTextColor(colors.black) term.setTextColor(colors.black)
local passwordLogin = read("*") local passwordLogin = read("*")
term.redirect(sPhone.mainTerm) term.redirect(sPhone.mainTerm)
local fpw = fs.open("/.sPhone/.password","r") local fpw = fs.open("/.sPhone/config/.password","r")
if sha256.sha256(passwordLogin) == fpw.readLine() then if sha256.sha256(passwordLogin) == fpw.readLine() then
sPhone.wrongPassword = false sPhone.wrongPassword = false
home() home()
else else
sPhone.wrongPassword = true sPhone.wrongPassword = true
end end
end end
else else
local name local name
local pw local pw
@ -742,7 +749,7 @@ end
local password2 = read("*") local password2 = read("*")
term.redirect(sPhone.mainTerm) term.redirect(sPhone.mainTerm)
if password1 == password2 then if password1 == password2 then
local f = fs.open("/.sPhone/.password", "w") local f = fs.open("/.sPhone/config/.password", "w")
f.write(sha256.sha256(password1)) f.write(sha256.sha256(password1))
f.close() f.close()
term.setTextColor(colors.lime) term.setTextColor(colors.lime)