Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function errore(text)
- term.setBackgroundColor(colors.red)
- term.clear()
- term.setTextColor(colors.white)
- term.setCursorPos(20, 1)
- print("ERRORE IRREVERSIBILE")
- print("\n\n"..text)
- print("\n\nClicca un tasto qualsiasi")
- local lol, sus = os.pullEvent("key")
- shell.run("reboot")
- end
- function c(color, tec)
- term.setBackgroundColor(colors[color])
- term.clear()
- term.setTextColor(colors[tec])
- term.setCursorPos(18, 1)
- print("Gestione Domini Web")
- end
- function split(inputstr, sep)
- local t = {}
- for str in string.gmatch(inputstr, "([^"..sep.."^]+)") do
- table.insert(t, str)
- end
- return t
- end
- function lun(t)
- local count = 0
- for _ in pairs(t) do cound = count + 1 end
- return cound
- end
- function button(color, text, x, y, ncol)
- term.setBackgroundColor(colors[color])
- term.setTextColor(colors.white)
- term.setCursorPos(x, y)
- print(" "..text.." ")
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors[ncol])
- end
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setTextColor(colors.black)
- term.setCursorPos(18, 1)
- print("Gestione Domini Web")
- print("\n\nQua potrai controllare se un dominio e' libero oppure di chi e'")
- print("\n\nInserisci il dominio da cercare:")
- dom = read()
- print("\nOra inserisci il tuo nome utente:")
- user = read()
- if fs.exists("domini/"..dom) == false then
- c("white", "blue")
- print("\n\nIl dominio risulta libero!\n\nPrendilo ORA!\nDominio: "..dom)
- button("green", "Prendi!", 6, 9, "blue")
- button("red", "Indietro", 20, 9, "blue")
- local event, bt, x, y = os.pullEvent("mouse_click")
- if y == 9 and x >= 6 and x <= 13 then
- -- Verifico che effettivamente il dominio sia valido
- doma = split(dom, ".")
- if doma == nil then
- errore("Il dominio non e' valido!\nmanca un ltd (.)")
- end
- if lun(doma) < 1 then
- errore("Il dominio non e' valido\nManca un LTD (.)")
- end
- if doma[2] == "com" or doma[2] == "cf" or doma[2] == "it" then
- errore("Il dominio non e' valido!\nNon sono ammessi gli LT .com / .cf / .it")
- end
- -- Ok, ora ho la certezza che sia validissimo
- -- lo salvo in un file
- local h = fs.open("domini/"..dom, "w")
- h.write("prop = '"..user.."'")
- h.flush()
- h.close()
- c("blue", "white")
- print("\nHai registrato con successo il dominio: "..dom)
- print("\n\nPremi un tasto qualsiasi...")
- local event, lol = os.pullEvent("key")
- shell.run("startup")
- else
- shell.run("startup")
- end
- elseif fs.exists("domini/"..dom) == true then
- shell.run("domini/"..dom)
- c("orange", "white")
- print("\n\nIl dominio "..dom.." e' gia' stato registrato da: "..prop)
- print("\n\nPremi un tasto per uscire...")
- local event, lol = os.pullEvent("key")
- shell.run("startup")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement