SHOW:
|
|
- or go back to the newest paste.
| 1 | function errore(text) | |
| 2 | term.setBackgroundColor(colors.red) | |
| 3 | term.clear() | |
| 4 | term.setTextColor(colors.white) | |
| 5 | term.setCursorPos(20, 1) | |
| 6 | print("ERRORE IRREVERSIBILE")
| |
| 7 | print("\n\n"..text)
| |
| 8 | print("\n\nClicca un tasto qualsiasi")
| |
| 9 | local lol, sus = os.pullEvent("key")
| |
| 10 | shell.run("reboot")
| |
| 11 | end | |
| 12 | ||
| 13 | function c(color, tec) | |
| 14 | term.setBackgroundColor(colors[color]) | |
| 15 | term.clear() | |
| 16 | term.setTextColor(colors[tec]) | |
| 17 | term.setCursorPos(18, 1) | |
| 18 | print("Gestione Domini Web")
| |
| 19 | end | |
| 20 | ||
| 21 | function split(inputstr, sep) | |
| 22 | local t = {}
| |
| 23 | for str in string.gmatch(inputstr, "([^"..sep.."^]+)") do | |
| 24 | table.insert(t, str) | |
| 25 | end | |
| 26 | return t | |
| 27 | end | |
| 28 | ||
| 29 | function lun(t) | |
| 30 | local count = 0 | |
| 31 | for _ in pairs(t) do cound = count + 1 end | |
| 32 | return cound | |
| 33 | end | |
| 34 | ||
| 35 | function button(color, text, x, y, ncol) | |
| 36 | term.setBackgroundColor(colors[color]) | |
| 37 | term.setTextColor(colors.white) | |
| 38 | term.setCursorPos(x, y) | |
| 39 | print(" "..text.." ")
| |
| 40 | term.setBackgroundColor(colors.white) | |
| 41 | term.setTextColor(colors[ncol]) | |
| 42 | end | |
| 43 | ||
| 44 | term.setBackgroundColor(colors.white) | |
| 45 | term.clear() | |
| 46 | term.setTextColor(colors.black) | |
| 47 | term.setCursorPos(18, 1) | |
| 48 | print("Gestione Domini Web")
| |
| 49 | print("\n\nQua potrai controllare se un dominio e' libero oppure di chi e'")
| |
| 50 | print("\n\nInserisci il dominio da cercare:")
| |
| 51 | dom = read() | |
| 52 | print("\nOra inserisci il tuo nome utente:")
| |
| 53 | user = read() | |
| 54 | ||
| 55 | if fs.exists("domini/"..dom) == false then
| |
| 56 | c("white", "blue")
| |
| 57 | print("\n\nIl dominio risulta libero!\n\nPrendilo ORA!\nDominio: "..dom)
| |
| 58 | button("green", "Prendi!", 6, 9, "blue")
| |
| 59 | button("red", "Indietro", 20, 9, "blue")
| |
| 60 | ||
| 61 | local event, bt, x, y = os.pullEvent("mouse_click")
| |
| 62 | if y == 9 and x >= 6 and x <= 13 then | |
| 63 | -- Verifico che effettivamente il dominio sia valido | |
| 64 | doma = split(dom, ".") | |
| 65 | if doma == nil then | |
| 66 | errore("Il dominio non e' valido!\nmanca un ltd (.)")
| |
| 67 | end | |
| 68 | ||
| 69 | if lun(doma) < 1 then | |
| 70 | errore("Il dominio non e' valido\nManca un LTD (.)")
| |
| 71 | end | |
| 72 | ||
| 73 | if doma[2] == "com" or doma[2] == "cf" or doma[2] == "it" then | |
| 74 | errore("Il dominio non e' valido!\nNon sono ammessi gli LT .com / .cf / .it")
| |
| 75 | end | |
| 76 | ||
| 77 | -- Ok, ora ho la certezza che sia validissimo | |
| 78 | -- lo salvo in un file | |
| 79 | local h = fs.open("domini/"..dom, "w")
| |
| 80 | h.write("prop = '"..user.."'")
| |
| 81 | h.flush() | |
| 82 | h.close() | |
| 83 | c("blue", "white")
| |
| 84 | print("\nHai registrato con successo il dominio: "..dom)
| |
| 85 | print("\n\nPremi un tasto qualsiasi...")
| |
| 86 | local event, lol = os.pullEvent("key")
| |
| 87 | shell.run("startup")
| |
| 88 | else | |
| 89 | shell.run("startup")
| |
| 90 | end | |
| 91 | elseif fs.exists("domini/"..dom) == true then
| |
| 92 | shell.run("domini/"..dom)
| |
| 93 | c("orange", "white")
| |
| 94 | print("\n\nIl dominio "..dom.." e' gia' stato registrato da: "..prop)
| |
| 95 | print("\n\nPremi un tasto per uscire...")
| |
| 96 | local event, lol = os.pullEvent("key")
| |
| 97 | shell.run("startup")
| |
| 98 | end |