Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONFIGURAZIONE
- sideIsPaymentGood = "right"
- sideToStopPaymentGood = "back"
- beneficiario = "eternal"
- importo = 100 -- In IC
- local maxw, maxh = term.getSize()
- --IMPLEMENTAZIONE DEL DRAWFILLEDBOX
- local function drawPixelInternal(xPos, yPos)
- term.setCursorPos(xPos, yPos)
- term.write(" ")
- end
- local tColourLookup = {}
- for n = 1,16 do
- tColourLookup[string.byte("0123456789abcdef", n, n)] = 2^(n-1)
- end
- function drawFilledBox(startX, startY, endX, endY, nColour)
- if type(startX) ~= "number" or type(startX) ~= "number" or
- type(endX) ~= "number" or type(endY) ~= "number" or
- (nColour ~= nil and type(nColour) ~= "number") then
- error("Expected startX, startY, endX, endY, colour", 2)
- end
- startX = math.floor(startX)
- startY = math.floor(startY)
- endX = math.floor(endX)
- endY = math.floor(endY)
- if nColour then
- term.setBackgroundColor(nColour)
- end
- if startX == endX and startY == endY then
- drawPixelInternal(startX, startY)
- return
- end
- local minX = math.min(startX, endX)
- if minX == startX then
- minY = startY
- maxX = endX
- maxY = endY
- else
- minY = endY
- maxX = startX
- maxY = startY
- end
- for x = minX, maxX do
- for y = minY, maxY do
- drawPixelInternal(x, y)
- end
- end
- end
- function button(x, y, color, text)
- term.setBackgroundColor(colors[color])
- term.setTextColor(colors.white)
- term.setCursorPos(x, y)
- print(text)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- end
- function clear()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function titolo(testo)
- drawFilledBox(1, 1, maxw, 1, colors.blue)
- term.setCursorPos((maxw - #testo) / 2, 1)
- term.setTextColor(colors.white)
- term.write(testo)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- end
- isGood = false
- isLogged = false
- page = 0
- while true do
- -- Facciamo prima il check
- if rs.getInput(sideToStopPaymentGood) == false and isGood == true then
- rs.setOutput(sideIsPaymentGood, true)
- elseif rs.getInput(sideToStopPaymentGood) == true then
- isGood = false
- rs.setOutput(sideIsPaymentGood, false)
- end
- if page == 0 and isLogged == false then
- clear()
- titolo("Pagamento con nPay - Accedi!")
- print("\n\n\nNome Utente:")
- utente = read()
- checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. utente).readAll()
- print("\nPassword:")
- password = read("#")
- checkpass = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&richiesta=addebito&valore=0&utente=".. utente).readAll()
- risposta = textutils.unserialize(checkpass)
- tabcheckuser = textutils.unserialize(checkuser)
- if tabcheckuser.stato == "OK" and risposta.stato == "OK" then
- isLogged = true
- page = "logged"
- else
- isLogged = false
- term.setTextColor(colors.red)
- print("\n\nNome Utente o Password errati!\n\nPotrai riprovare tra 2 secondi....")
- sleep(1.5)
- os.reboot()
- end
- elseif page == "logged" and isLogged == true then
- clear()
- titolo("Pagamento con nPay - Benvenuto, " ..utente.."!")
- print("\n\nStai per pagare "..importo.."IC a favore di " ..beneficiario.."!")
- button(15, 10, "green", " PAGA ORA ")
- button(30, 10, "red", " ANNULLA ")
- local event, bt, x, y = os.pullEvent("mouse_click")
- if x > 15 and x < 25 then
- inviaDenaro = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=trasferimento&valore=" .. importo .. "&beneficiario=" .. beneficiario).readAll()
- risultatoInvio = textutils.unserialize(inviaDenaro)
- if risultatoInvio.stato == "OK" then
- clear()
- titolo("Pagamento con nPay - Pagamento Effettuato")
- term.setTextColor(colors.lime)
- print("\n\nPAGAMENTO EFFETTUATO CON SUCCESSO!\n\nVerrai sloggato automaticamente tra qualche secondo...")
- isGood = true
- sleep(5)
- -- Slogghiamo
- page = 0
- utente = nil
- password = nil
- else
- clear()
- term.setTextColor(colors.red)
- print("\n\nUn errore selvatico e' appena apparso ed il pagamento non e' avvenuto con successo...\nn\Potrai riprovare tra qualche secondo...")
- sleep(3)
- -- Slogghiamo ma in modo bello
- os.reboot()
- end
- elseif x > 30 then
- print("Ok, arrivederci!")
- sleep(1)
- os.reboot()
- end
- end
- sleep(0.11)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement