SHOW:
|
|
- or go back to the newest paste.
| 1 | local maxw, maxh = term.getSize() | |
| 2 | ||
| 3 | --IMPLEMENTAZIONE DEL DRAWFILLEDBOX | |
| 4 | local function drawPixelInternal(xPos, yPos) | |
| 5 | term.setCursorPos(xPos, yPos) | |
| 6 | term.write(" ")
| |
| 7 | end | |
| 8 | ||
| 9 | local tColourLookup = {}
| |
| 10 | for n = 1,16 do | |
| 11 | tColourLookup[string.byte("0123456789abcdef", n, n)] = 2^(n-1)
| |
| 12 | end | |
| 13 | ||
| 14 | function drawFilledBox(startX, startY, endX, endY, nColour) | |
| 15 | if type(startX) ~= "number" or type(startX) ~= "number" or | |
| 16 | type(endX) ~= "number" or type(endY) ~= "number" or | |
| 17 | (nColour ~= nil and type(nColour) ~= "number") then | |
| 18 | error("Expected startX, startY, endX, endY, colour", 2)
| |
| 19 | end | |
| 20 | ||
| 21 | startX = math.floor(startX) | |
| 22 | startY = math.floor(startY) | |
| 23 | endX = math.floor(endX) | |
| 24 | endY = math.floor(endY) | |
| 25 | ||
| 26 | if nColour then | |
| 27 | term.setBackgroundColor(nColour) | |
| 28 | end | |
| 29 | if startX == endX and startY == endY then | |
| 30 | drawPixelInternal(startX, startY) | |
| 31 | return | |
| 32 | end | |
| 33 | ||
| 34 | local minX = math.min(startX, endX) | |
| 35 | if minX == startX then | |
| 36 | minY = startY | |
| 37 | maxX = endX | |
| 38 | maxY = endY | |
| 39 | else | |
| 40 | minY = endY | |
| 41 | maxX = startX | |
| 42 | maxY = startY | |
| 43 | end | |
| 44 | ||
| 45 | for x = minX, maxX do | |
| 46 | for y = minY, maxY do | |
| 47 | drawPixelInternal(x, y) | |
| 48 | end | |
| 49 | end | |
| 50 | end | |
| 51 | ||
| 52 | function clear() | |
| 53 | sfondo(colors.lightBlue) | |
| 54 | term.clear() | |
| 55 | term.setCursorPos(1, 1) | |
| 56 | end | |
| 57 | ||
| 58 | function colore(sfumatura) | |
| 59 | term.setTextColour(sfumatura) | |
| 60 | end | |
| 61 | ||
| 62 | function sfondo(sfumaturaSfondo) | |
| 63 | term.setBackgroundColour(sfumaturaSfondo) | |
| 64 | end | |
| 65 | ||
| 66 | function titolo(testo) | |
| 67 | drawFilledBox(1, 1, maxw, 1, colors.yellow) | |
| 68 | term.setCursorPos((maxw - #testo) / 2, 1) | |
| 69 | colore(colors.black) | |
| 70 | term.write(testo) | |
| 71 | sfondo(colors.lightBlue) | |
| 72 | end | |
| 73 | ||
| 74 | function update() | |
| 75 | term.setCursorPos(1, 21) | |
| 76 | shell.run("rm startup")
| |
| 77 | shell.run("pastebin get y1AP0iNY startup") -- Inserire paste di nPay
| |
| 78 | os.reboot() | |
| 79 | end | |
| 80 | ||
| 81 | function disconnetti() | |
| 82 | clear() | |
| 83 | text = "ARRIVEDERCI!" | |
| 84 | colore(colors.white) | |
| 85 | term.setCursorPos((maxw - #text) / 2, math.floor(maxh / 2)) | |
| 86 | term.write(text) | |
| 87 | colore(colors.black) | |
| 88 | text2 = "Tra poco saråA5A0 possibile eseguire" | |
| 89 | text3 = "una nuova operazione..." | |
| 90 | term.setCursorPos((maxw - #text2) / 2, math.floor(maxh / 2) + 2) | |
| 91 | print(text2) | |
| 92 | term.setCursorPos((maxw - #text3) / 2, math.floor(maxh / 2) + 3) | |
| 93 | print(text3) | |
| 94 | os.sleep(0.5) | |
| 95 | update() | |
| 96 | end | |
| 97 | ||
| 98 | function drawCard() | |
| 99 | drawFilledBox(6, 7, 24, 7, colors.blue) | |
| 100 | drawFilledBox(6, 15, 24, 15, colors.blue) | |
| 101 | drawFilledBox(5, 8, 25, 14, colors.blue) | |
| 102 | ||
| 103 | drawFilledBox(7, 9, 23, 9, colors.lightGray) | |
| 104 | drawFilledBox(7, 12, 23, 13, colors.black) | |
| 105 | end | |
| 106 | ||
| 107 | mag = peripheral.wrap("bottom")
| |
| 108 | bl = "BN Credit" | |
| 109 | ||
| 110 | sfondo(colors.lightBlue) | |
| 111 | clear() | |
| 112 | ||
| 113 | colore(colors.white) | |
| 114 | print(" ")
| |
| 115 | print(" ___ ")
| |
| 116 | print(" _ __ / _ \\__ _ _ _ ")
| |
| 117 | print(" | '_ \\ / /_)/ _ | | | |")
| |
| 118 | print(" | | | / ___/ (_| | |_| |")
| |
| 119 | print(" |_| |_\\/ \\__,_|\\__, |")
| |
| 120 | print(" |___/ ")
| |
| 121 | ||
| 122 | -- Bottoni login/registrati | |
| 123 | ||
| 124 | drawFilledBox(14, 10, 38, 12, colors.white) | |
| 125 | term.setCursorPos(23, 11) | |
| 126 | colore(colors.black) | |
| 127 | term.write("Accedi")
| |
| 128 | ||
| 129 | drawFilledBox(14, 15, 38, 17, colors.white) | |
| 130 | term.setCursorPos(21, 16) | |
| 131 | colore(colors.black) | |
| 132 | term.write("Sei nuovo?")
| |
| 133 | ||
| 134 | while true do | |
| 135 | event, key, x, y = os.pullEvent("mouse_click")
| |
| 136 | if event == "mouse_click" and x >= 14 and x <= 38 and y >= 15 and y <= 17 then | |
| 137 | -- Registrazione nuovo utente | |
| 138 | clear() | |
| 139 | titolo("Registrati a nPay")
| |
| 140 | term.setCursorPos(1, 3) | |
| 141 | print("Inserisci un nome utente e una password sicura.")
| |
| 142 | term.setCursorPos(1, 5) | |
| 143 | colore(colors.gray) | |
| 144 | print("Premi ENTER per confermare i dati inseriti.\nSe i dati sono corretti, il campo diventeråA5A0 verde.\nSe sono errati, il programma chiederåA5A0 di reinserirli nuovamente.")
| |
| 145 | ||
| 146 | -- Nome Utente | |
| 147 | term.setCursorPos(1, 10) | |
| 148 | colore(colors.black) | |
| 149 | term.write("Nome utente:")
| |
| 150 | term.setCursorPos(14, 10) | |
| 151 | colore(colors.white) | |
| 152 | utenteAccettato = false | |
| 153 | conteggioErrori = 0 | |
| 154 | while utenteAccettato == false do | |
| 155 | utente = read() | |
| 156 | checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. utente).readAll()
| |
| 157 | tabcheckuser = textutils.unserialize(checkuser) | |
| 158 | if tabcheckuser.stato == "NO" then | |
| 159 | term.setCursorPos(14, 10) | |
| 160 | colore(colors.lime) | |
| 161 | term.write(utente) | |
| 162 | colore(colors.white) | |
| 163 | utenteAccettato = true | |
| 164 | else | |
| 165 | term.setCursorPos(14, 10) | |
| 166 | colore(colors.red) | |
| 167 | term.write("Utente giåA5A0 esistente!")
| |
| 168 | sleep(2) | |
| 169 | term.setCursorPos(14, 10) | |
| 170 | colore(colors.white) | |
| 171 | term.write(" ")
| |
| 172 | term.setCursorPos(14, 10) | |
| 173 | conteggioErrori = conteggioErrori + 1 | |
| 174 | if conteggioErrori > 2 then | |
| 175 | term.setCursorPos(14, 10) | |
| 176 | colore(colors.red) | |
| 177 | term.write("Tre tentativi di immissione errati.")
| |
| 178 | sleep(2) | |
| 179 | term.setCursorPos(14, 10) | |
| 180 | colore(colors.white) | |
| 181 | term.write(" ")
| |
| 182 | term.setCursorPos(14, 10) | |
| 183 | clear() | |
| 184 | os.reboot() | |
| 185 | end | |
| 186 | end | |
| 187 | end | |
| 188 | ||
| 189 | --password | |
| 190 | colore(colors.black) | |
| 191 | term.setCursorPos(1, 12) | |
| 192 | term.write("Password:")
| |
| 193 | term.setCursorPos(11, 12) | |
| 194 | colore(colors.white) | |
| 195 | ||
| 196 | passAccettata = false | |
| 197 | conteggioErrori = 0 | |
| 198 | while passAccettata == false do | |
| 199 | password1 = read("#")
| |
| 200 | colore(colors.black) | |
| 201 | term.setCursorPos(1, 13) | |
| 202 | term.write("Verifica:")
| |
| 203 | term.setCursorPos(11, 13) | |
| 204 | colore(colors.white) | |
| 205 | local password2 = read("#")
| |
| 206 | if password1 == password2 then | |
| 207 | term.setCursorPos(11, 12) | |
| 208 | colore(colors.lime) | |
| 209 | term.write("###############")
| |
| 210 | term.setCursorPos(11, 13) | |
| 211 | term.write("###############")
| |
| 212 | colore(colors.white) | |
| 213 | passAccettata = true | |
| 214 | else | |
| 215 | colore(colors.red) | |
| 216 | term.setCursorPos(11, 12) | |
| 217 | term.write("Le password non corrispondono! ")
| |
| 218 | term.setCursorPos(1, 13) | |
| 219 | colore(colors.white) | |
| 220 | term.write(" ")
| |
| 221 | sleep(1.5) | |
| 222 | term.setCursorPos(11, 12) | |
| 223 | term.write(" ")
| |
| 224 | term.setCursorPos(11, 12) | |
| 225 | conteggioErrori = conteggioErrori + 1 | |
| 226 | if conteggioErrori > 2 then | |
| 227 | term.setCursorPos(14, 12) | |
| 228 | colore(colors.red) | |
| 229 | term.write("Tre tentativi di immissione errati.")
| |
| 230 | sleep(1.5) | |
| 231 | term.setCursorPos(14, 12) | |
| 232 | colore(colors.white) | |
| 233 | term.write(" ")
| |
| 234 | term.setCursorPos(14, 12) | |
| 235 | clear() | |
| 236 | os.reboot() | |
| 237 | end | |
| 238 | end | |
| 239 | end | |
| 240 | ||
| 241 | --crea l'account | |
| 242 | ||
| 243 | term.setCursorPos(1, 17) | |
| 244 | creaAccount = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password1 .. "&utente=" .. utente .. "&richiesta=crea&valore=0").readAll()
| |
| 245 | tabCreaAccount = textutils.unserialize(creaAccount) | |
| 246 | if tabCreaAccount.stato == "OA" then | |
| 247 | colore(colors.lime) | |
| 248 | print("Conto creato con successo.")
| |
| 249 | sleep(1.5) | |
| 250 | clear() | |
| 251 | os.reboot() | |
| 252 | else | |
| 253 | colore(colors.red) | |
| 254 | print("Errore durante la creazione del conto.")
| |
| 255 | sleep(1.5) | |
| 256 | clear() | |
| 257 | os.reboot() | |
| 258 | end | |
| 259 | ||
| 260 | elseif event == "mouse_click" and x >= 14 and x <= 38 and y >= 10 and y <= 12 then | |
| 261 | clear() | |
| 262 | titolo("Accedi a nPay")
| |
| 263 | term.setCursorPos(1, 3) | |
| 264 | colore(colors.black) | |
| 265 | print("Inserire i propri dati.")
| |
| 266 | colore(colors.gray) | |
| 267 | print("\nPremere Enter per confermare i dati inseriti.\nSe i dati sono corretti, il campo diventeråA5A0 verde.\nSe sono errati, il programma chiederåA5A0 di reinserirli nuovamente.")
| |
| 268 | ||
| 269 | --nomeutente | |
| 270 | term.setCursorPos(1, 10) | |
| 271 | colore(colors.black) | |
| 272 | term.write("Nome utente:")
| |
| 273 | term.setCursorPos(15, 10) | |
| 274 | colore(colors.white) | |
| 275 | utenteAccettato = false | |
| 276 | conteggioErrori = 0 | |
| 277 | while utenteAccettato == false do | |
| 278 | utente = read() | |
| 279 | checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. utente).readAll()
| |
| 280 | tabcheckuser = textutils.unserialize(checkuser) | |
| 281 | if tabcheckuser.stato == "OK" then | |
| 282 | term.setCursorPos(15, 10) | |
| 283 | colore(colors.lime) | |
| 284 | term.write(utente) | |
| 285 | colore(colors.white) | |
| 286 | utenteAccettato = true | |
| 287 | else | |
| 288 | term.setCursorPos(15, 10) | |
| 289 | colore(colors.red) | |
| 290 | term.write("Utente errato! ")
| |
| 291 | sleep(2) | |
| 292 | term.setCursorPos(15, 10) | |
| 293 | colore(colors.white) | |
| 294 | term.write(" ")
| |
| 295 | term.setCursorPos(15, 10) | |
| 296 | conteggioErrori = conteggioErrori + 1 | |
| 297 | if conteggioErrori > 2 then | |
| 298 | term.setCursorPos(15, 10) | |
| 299 | colore(colors.red) | |
| 300 | term.write("Tre tentativi di immissione errati.")
| |
| 301 | sleep(2) | |
| 302 | term.setCursorPos(15, 10) | |
| 303 | colore(colors.white) | |
| 304 | term.write(" ")
| |
| 305 | term.setCursorPos(15, 10) | |
| 306 | clear() | |
| 307 | os.reboot() | |
| 308 | end | |
| 309 | end | |
| 310 | end | |
| 311 | ||
| 312 | --password | |
| 313 | colore(colors.black) | |
| 314 | term.setCursorPos(1,12) | |
| 315 | term.write("Password:")
| |
| 316 | term.setCursorPos(15, 12) | |
| 317 | ||
| 318 | conteggioErrori = 0 | |
| 319 | passAccettata = false | |
| 320 | while passAccettata == false do | |
| 321 | colore(colors.white) | |
| 322 | password = read("#")
| |
| 323 | colore(colors.black) | |
| 324 | checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&richiesta=addebito&valore=0&utente=".. utente).readAll()
| |
| 325 | risposta = textutils.unserialize(checkuser) | |
| 326 | if risposta.stato == "OK" then | |
| 327 | term.setCursorPos(15, 12) | |
| 328 | colore(colors.lime) | |
| 329 | term.write("############## ")
| |
| 330 | colore(colors.white) | |
| 331 | passAccettata = true | |
| 332 | else | |
| 333 | term.setCursorPos(15, 12) | |
| 334 | colore(colors.red) | |
| 335 | term.write("Password errata! ")
| |
| 336 | conteggioErrori = conteggioErrori + 1 | |
| 337 | sleep(2) | |
| 338 | term.setCursorPos(15, 12) | |
| 339 | term.write(" ")
| |
| 340 | term.setCursorPos(15, 12) | |
| 341 | if conteggioErrori > 2 then | |
| 342 | term.setCursorPos(15, 12) | |
| 343 | colore(colors.red) | |
| 344 | term.write("Tre tentativi di immissione errati.")
| |
| 345 | sleep(2) | |
| 346 | term.setCursorPos(15, 12) | |
| 347 | term.write(" ")
| |
| 348 | term.setCursorPos(15, 12) | |
| 349 | clear() | |
| 350 | os.reboot() | |
| 351 | end | |
| 352 | end | |
| 353 | end | |
| 354 | ||
| 355 | conteggioErrori = 0 | |
| 356 | -- Pagina in cui scegli le operazioni da fare | |
| 357 | ||
| 358 | while true do | |
| 359 | --Ricontrolla il saldo per gestire l'aggiornamento di piåA5B9 operazioni | |
| 360 | checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth="..password.."&richiesta=addebito&valore=0&utente="..utente).readAll()
| |
| 361 | risposta = textutils.unserialize(checkuser) | |
| 362 | saldo = tonumber(risposta.saldo) | |
| 363 | --Disegna la finestra del pannello utente | |
| 364 | clear() | |
| 365 | titolo("Pannello utente nPay")
| |
| 366 | term.setCursorPos(1, 3) | |
| 367 | term.write("Benvenuto, ")
| |
| 368 | colore(colors.white) | |
| 369 | term.write(utente) | |
| 370 | colore(colors.black) | |
| 371 | term.write("! Saldo: ")
| |
| 372 | colore(colors.white) | |
| 373 | term.write(saldo) | |
| 374 | colore(colors.black) | |
| 375 | term.write(" IC")
| |
| 376 | print("\n\nOperazioni disponibili:\n")
| |
| 377 | sfondo(colors.white) | |
| 378 | print(" Carica denaro su nPay \n")
| |
| 379 | print(" Preleva denaro da nPay \n")
| |
| 380 | print(" Trasferisci denaro \n")
| |
| 381 | print(" Estratto conto \n")
| |
| 382 | colore(colors.red) | |
| 383 | print(" Disconnettiti da nPay \n")
| |
| 384 | colore(colors.black) | |
| 385 | ||
| 386 | antitonto = os.startTimer(60) | |
| 387 | ||
| 388 | event, key, x, y = os.pullEventRaw() | |
| 389 | if event == "mouse_click" and y == 7 and x <= 24 then --Pulsante carica denaro su nPay | |
| 390 | clear() | |
| 391 | titolo("Caricamento denaro su nPay")
| |
| 392 | ||
| 393 | drawCard() | |
| 394 | ||
| 395 | sfondo(colors.lightBlue) | |
| 396 | colore(colors.black) | |
| 397 | term.setCursorPos(30, 8) | |
| 398 | print("INSERIRE LA CARTA")
| |
| 399 | term.setCursorPos(29, 10) | |
| 400 | print("NEL LETTORE IN BASSO")
| |
| 401 | drawFilledBox(34, 14, 42, 14, colors.white) | |
| 402 | term.setCursorPos(35, 14) | |
| 403 | term.write("Annulla")
| |
| 404 | ||
| 405 | mag.setInsertCardLight(true) | |
| 406 | finalBreakC = false | |
| 407 | while true do | |
| 408 | event, arg1, arg2, arg3 = os.pullEventRaw() | |
| 409 | if event == "mouse_click" and arg3 == 14 and arg2 >= 34 and arg2 <= 42 then -- arg2 = x | arg3 = y | |
| 410 | mag.setInsertCardLight(false) | |
| 411 | clear() | |
| 412 | term.setCursorPos(1,1) | |
| 413 | break | |
| 414 | elseif event == "mag_swipe" then | |
| 415 | mag.setInsertCardLight(false) | |
| 416 | tabel = textutils.unserialize(arg1) | |
| 417 | if tabel == "" or tabel == nil then | |
| 418 | clear() | |
| 419 | titolo("Caricamento denaro da nPay")
| |
| 420 | ||
| 421 | drawCard() | |
| 422 | ||
| 423 | sfondo(colors.lightBlue) | |
| 424 | term.setCursorPos(36, 10) | |
| 425 | colore(colors.red) | |
| 426 | term.write("ERRORE!")
| |
| 427 | term.setCursorPos(30, 12) | |
| 428 | colore(colors.black) | |
| 429 | term.write("Carta smagnetizzata!")
| |
| 430 | os.sleep(3) | |
| 431 | break | |
| 432 | elseif tabel.t ~= "cc" or tabel.e ~= "BN" then | |
| 433 | clear() | |
| 434 | titolo("Caricamento denaro da nPay")
| |
| 435 | ||
| 436 | drawCard() | |
| 437 | ||
| 438 | sfondo(colors.lightBlue) | |
| 439 | term.setCursorPos(36, 10) | |
| 440 | colore(colors.red) | |
| 441 | term.write("ERRORE!")
| |
| 442 | term.setCursorPos(31, 12) | |
| 443 | colore(colors.black) | |
| 444 | term.write("Carta non valida!")
| |
| 445 | os.sleep(3) | |
| 446 | break | |
| 447 | else | |
| 448 | while true do | |
| 449 | clear() | |
| 450 | titolo("Caricamento denaro su nPay")
| |
| 451 | colore(colors.gray) | |
| 452 | print("\n\nDisponibilitåA5A0 su carta: " .. tabel.v .. " IC")
| |
| 453 | colore(colors.red) | |
| 454 | term.setCursorPos(1, 14) | |
| 455 | term.write("ATTENZIONE:")
| |
| 456 | colore(colors.black) | |
| 457 | term.setCursorPos(1, 15) | |
| 458 | term.write("Eccezionalmente, grazie ai 600 voti di marzo,")
| |
| 459 | --term.write("Per le operazioni inferiori a 50 000 IC,")
| |
| 460 | term.setCursorPos(1, 16) | |
| 461 | print("le operazioni saranno GRATUITE fino al 4 aprile!")
| |
| 462 | --print("si applica una commissione del 0.15%.")
| |
| 463 | --print("Oltre 50 000 IC la commissione åA5A8 del 0.05%.")
| |
| 464 | term.setCursorPos(1, 5) | |
| 465 | term.write("Importo da caricare: ")
| |
| 466 | colore(colors.white) | |
| 467 | credito = tonumber(tabel.v) | |
| 468 | credit = read() | |
| 469 | if tonumber(credit) == "" or tonumber(credit) == nil or tonumber(credit) <= 0 then | |
| 470 | colore(colors.red) | |
| 471 | term.setCursorPos(22, 5) | |
| 472 | term.write("Importo errato! ")
| |
| 473 | colore(colors.black) | |
| 474 | sleep(1.5) | |
| 475 | clear() | |
| 476 | else | |
| 477 | if tonumber(credit) >= 50000 then | |
| 478 | --commissioni = tonumber(credit) * 0.005 | |
| 479 | commissioni = tonumber(credit) * 0 | |
| 480 | else | |
| 481 | --commissioni = tonumber(credit) * 0.015 | |
| 482 | commissioni = tonumber(credit) * 0 | |
| 483 | end | |
| 484 | crediton = credit + commissioni | |
| 485 | if tonumber(tabel.v) >= crediton then | |
| 486 | tab = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?utente=" .. utente .. "&auth=" .. password .. "&richiesta=accredito&valore=" .. credit).readAll()
| |
| 487 | tabella = textutils.unserialize(tab) | |
| 488 | tabr = {}
| |
| 489 | tabr.t = tabel.t | |
| 490 | tabr.e = tabel.e | |
| 491 | tabr.p = tabel.p | |
| 492 | tabr.v = tonumber(tabel.v) - crediton | |
| 493 | ncr = textutils.serialize(tabr) | |
| 494 | clear() | |
| 495 | titolo("Caricamento denaro su nPay")
| |
| 496 | ||
| 497 | drawCard() | |
| 498 | ||
| 499 | colore(colors.black) | |
| 500 | sfondo(colors.lightBlue) | |
| 501 | term.setCursorPos(29, 10) | |
| 502 | print("RE-INSERIRE LA CARTA")
| |
| 503 | term.setCursorPos(29, 12) | |
| 504 | print("NEL LETTORE IN BASSO")
| |
| 505 | ||
| 506 | mag.setInsertCardLight(true) | |
| 507 | mag.beginWrite(ncr, bl) | |
| 508 | za2, carta = os.pullEvent("mag_write_done")
| |
| 509 | mag.setInsertCardLight(false) | |
| 510 | clear() | |
| 511 | titolo("Caricamento denaro su nPay")
| |
| 512 | ||
| 513 | colore(colors.lime) | |
| 514 | term.setCursorPos(1, 3) | |
| 515 | print("Operazione completata!")
| |
| 516 | colore(colors.black) | |
| 517 | term.setCursorPos(1, 5) | |
| 518 | print("Denaro accreditato: " .. credit .. " IC")
| |
| 519 | print("Commissioni: " .. commissioni .. " IC")
| |
| 520 | term.setCursorPos(1, 8) | |
| 521 | print("Saldo sul conto: " .. tabella.credito .. " IC")
| |
| 522 | print("Saldo sulla carta: " .. tabr.v .. " IC")
| |
| 523 | sfondo(colors.white) | |
| 524 | term.setCursorPos(1, 12) | |
| 525 | term.write(" Torna alla pagina principale ")
| |
| 526 | sfondo(colors.lightBlue) | |
| 527 | ||
| 528 | antiTonto2 = os.startTimer(15) | |
| 529 | while true do | |
| 530 | local event, arg1, arg2, arg3 = os.pullEventRaw() | |
| 531 | if event == "mouse_click" and arg3 == 12 and arg2 <= 30 or event == "timer" and arg1 == antiTonto2 then -- arg2 = x | arg3 = y | |
| 532 | finalBreakC = true | |
| 533 | break | |
| 534 | end | |
| 535 | end | |
| 536 | break | |
| 537 | else | |
| 538 | colore(colors.red) | |
| 539 | term.setCursorPos(22, 5) | |
| 540 | term.write("Credito su carta insufficente.")
| |
| 541 | colore(colors.black) | |
| 542 | sleep(1.5) | |
| 543 | clear() | |
| 544 | end | |
| 545 | end | |
| 546 | end | |
| 547 | if finalBreakC then | |
| 548 | break | |
| 549 | end | |
| 550 | end | |
| 551 | end | |
| 552 | end | |
| 553 | ||
| 554 | elseif event == "mouse_click" and y == 9 and x <= 24 then --Pulsante preleva denaro da nPay | |
| 555 | clear() | |
| 556 | titolo("Prelievo denaro da nPay")
| |
| 557 | ||
| 558 | drawCard() | |
| 559 | ||
| 560 | sfondo(colors.lightBlue) | |
| 561 | colore(colors.black) | |
| 562 | term.setCursorPos(30, 8) | |
| 563 | print("INSERIRE LA CARTA")
| |
| 564 | term.setCursorPos(29, 10) | |
| 565 | print("NEL LETTORE IN BASSO")
| |
| 566 | drawFilledBox(34, 14, 42, 14, colors.white) | |
| 567 | term.setCursorPos(35, 14) | |
| 568 | term.write("Annulla")
| |
| 569 | ||
| 570 | mag.setInsertCardLight(true) | |
| 571 | finalBreakP = false | |
| 572 | while true do | |
| 573 | event, arg1, arg2, arg3 = os.pullEventRaw() | |
| 574 | if event == "mouse_click" and arg3 == 14 and arg2 >= 34 and arg2 <= 42 then -- arg2 = x | arg3 = y | |
| 575 | mag.setInsertCardLight(false) | |
| 576 | clear() | |
| 577 | term.setCursorPos(1,1) | |
| 578 | break | |
| 579 | elseif event == "mag_swipe" then | |
| 580 | mag.setInsertCardLight(false) | |
| 581 | sfondo(colors.lightBlue) | |
| 582 | clear() | |
| 583 | tabel = textutils.unserialize(arg1) | |
| 584 | if tabel == "" or tabel == nil then | |
| 585 | clear() | |
| 586 | titolo("Prelievo denaro da nPay")
| |
| 587 | ||
| 588 | drawCard() | |
| 589 | ||
| 590 | sfondo(colors.lightBlue) | |
| 591 | term.setCursorPos(36, 10) | |
| 592 | colore(colors.red) | |
| 593 | term.write("ERRORE!")
| |
| 594 | term.setCursorPos(30, 12) | |
| 595 | colore(colors.black) | |
| 596 | term.write("Carta smagnetizzata!")
| |
| 597 | os.sleep(3) | |
| 598 | break | |
| 599 | elseif tabel.t ~= "cc" or tabel.e ~= "BN" then | |
| 600 | clear() | |
| 601 | titolo("Prelievo denaro da nPay")
| |
| 602 | ||
| 603 | drawCard() | |
| 604 | ||
| 605 | sfondo(colors.lightBlue) | |
| 606 | term.setCursorPos(36, 10) | |
| 607 | colore(colors.red) | |
| 608 | term.write("ERRORE!")
| |
| 609 | term.setCursorPos(31, 12) | |
| 610 | colore(colors.black) | |
| 611 | term.write("Carta non valida!")
| |
| 612 | os.sleep(3) | |
| 613 | break | |
| 614 | else | |
| 615 | while true do | |
| 616 | tabr = {}
| |
| 617 | tabr.e = tabel.e | |
| 618 | tabr.p = tabel.p | |
| 619 | tabr.t = tabel.t | |
| 620 | tab1 = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?utente=" .. utente .. "&auth=" .. password .. "&richiesta=accredito&valore=0").readAll()
| |
| 621 | tab3 = textutils.unserialize(tab1) | |
| 622 | clear() | |
| 623 | titolo("Prelievo denaro da nPay")
| |
| 624 | colore(colors.gray) | |
| 625 | print("\n\nDisponibilitåA5A0 su conto: " .. saldo .. " IC")
| |
| 626 | colore(colors.black) | |
| 627 | term.setCursorPos(1, 5) | |
| 628 | term.write("Importo da ritirare: ")
| |
| 629 | colore(colors.white) | |
| 630 | credito = tonumber(tabel.v) | |
| 631 | credit = read() | |
| 632 | if tonumber(credit) == "" or tonumber(credit) == nil or tonumber(credit) <= 0 then | |
| 633 | colore(colors.red) | |
| 634 | term.setCursorPos(22, 5) | |
| 635 | term.write("Importo errato! ")
| |
| 636 | colore(colors.black) | |
| 637 | sleep(1.5) | |
| 638 | clear() | |
| 639 | else | |
| 640 | tab = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?utente=" .. utente .. "&auth=" .. password .. "&richiesta=addebito&valore=" .. credit).readAll()
| |
| 641 | tabella = textutils.unserialize(tab) | |
| 642 | if tabella.stato == "DI" then | |
| 643 | colore(colors.red) | |
| 644 | term.setCursorPos(22, 5) | |
| 645 | term.write("Credito su carta insufficente.")
| |
| 646 | colore(colors.black) | |
| 647 | sleep(1.5) | |
| 648 | clear() | |
| 649 | else | |
| 650 | tabr.v = tonumber(tabel.v) + tonumber(credit) | |
| 651 | ncr = textutils.serialize(tabr) | |
| 652 | mag.setInsertCardLight(true) | |
| 653 | mag.beginWrite(ncr, bl) | |
| 654 | clear() | |
| 655 | titolo("Prelievo denaro da nPay")
| |
| 656 | ||
| 657 | drawCard() | |
| 658 | ||
| 659 | colore(colors.black) | |
| 660 | sfondo(colors.lightBlue) | |
| 661 | term.setCursorPos(29, 10) | |
| 662 | print("RE-INSERIRE LA CARTA")
| |
| 663 | term.setCursorPos(29, 12) | |
| 664 | print("NEL LETTORE IN BASSO")
| |
| 665 | ||
| 666 | mag.setInsertCardLight(true) | |
| 667 | event = os.pullEvent("mag_write_done")
| |
| 668 | mag.setInsertCardLight(false) | |
| 669 | clear() | |
| 670 | titolo("Prelievo denaro da nPay")
| |
| 671 | ||
| 672 | colore(colors.lime) | |
| 673 | term.setCursorPos(1, 3) | |
| 674 | print("Operazione completata!")
| |
| 675 | colore(colors.black) | |
| 676 | term.setCursorPos(1, 5) | |
| 677 | print("Denaro prelevato: " .. credit .. " IC")
| |
| 678 | term.setCursorPos(1, 7) | |
| 679 | print("Saldo sul conto: " .. tabella.credito .. " IC")
| |
| 680 | print("Saldo sulla carta: " .. tabr.v .. " IC")
| |
| 681 | sfondo(colors.white) | |
| 682 | term.setCursorPos(1, 11) | |
| 683 | term.write(" Torna alla pagina principale ")
| |
| 684 | sfondo(colors.lightBlue) | |
| 685 | ||
| 686 | antiTonto2 = os.startTimer(15) | |
| 687 | while true do | |
| 688 | local event, arg1, arg2, arg3 = os.pullEventRaw() | |
| 689 | if event == "mouse_click" and arg3 == 11 and arg2 <= 30 or event == "timer" and arg1 == antiTonto2 then -- arg2 = x | arg3 = y | |
| 690 | finalBreakP = true | |
| 691 | break | |
| 692 | end | |
| 693 | end | |
| 694 | break | |
| 695 | end | |
| 696 | end | |
| 697 | end | |
| 698 | if finalBreakP then | |
| 699 | break | |
| 700 | end | |
| 701 | end | |
| 702 | end | |
| 703 | end | |
| 704 | ||
| 705 | elseif event == "mouse_click" and y == 11 and x <= 24 then --Pulsante trasferisci denaro | |
| 706 | --Trasferisci denaro | |
| 707 | --inizio pagina | |
| 708 | clear() | |
| 709 | titolo("Trasferimento di denaro")
| |
| 710 | term.setCursorPos(1, 3) | |
| 711 | term.write("Inserire il nome utente del beneficiario.")
| |
| 712 | colore(colors.gray) | |
| 713 | print("\n\nPremere Enter per confermare i dati inseriti.\nSe i dati sono corretti, il campo diventeråA5A0 verde.\nSe sono errati, il programma chiederåA5A0 di reinserirli nuovamente.")
| |
| 714 | ||
| 715 | --Mostra saldo | |
| 716 | term.setCursorPos(1, 10) | |
| 717 | colore(colors.gray) | |
| 718 | print("Saldo disponibile: " .. saldo .. " IC")
| |
| 719 | colore(colors.black) | |
| 720 | ||
| 721 | --Verifica Beneficiario | |
| 722 | term.setCursorPos(1, 12) | |
| 723 | term.write("Beneficiario:")
| |
| 724 | term.setCursorPos(15, 12) | |
| 725 | colore(colors.white) | |
| 726 | destAccettato = false | |
| 727 | conteggioErrori = 0 | |
| 728 | while destAccettato == false do | |
| 729 | beneficiario = read() | |
| 730 | checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" .. beneficiario).readAll()
| |
| 731 | tabcheckuser = textutils.unserialize(checkuser) | |
| 732 | if tabcheckuser.stato == "OK" and beneficiario ~= utente then | |
| 733 | term.setCursorPos(15, 12) | |
| 734 | colore(colors.lime) | |
| 735 | term.write(beneficiario) | |
| 736 | colore(colors.white) | |
| 737 | destAccettato = true | |
| 738 | else | |
| 739 | conteggioErrori = conteggioErrori + 1 | |
| 740 | term.setCursorPos(15, 12) | |
| 741 | colore(colors.red) | |
| 742 | if beneficiario == utente then | |
| 743 | term.write("Non puoi inserire te stesso.")
| |
| 744 | else | |
| 745 | term.write("Utente inesistente! ")
| |
| 746 | end | |
| 747 | sleep(2) | |
| 748 | term.setCursorPos(15, 12) | |
| 749 | colore(colors.white) | |
| 750 | term.write(" ")
| |
| 751 | term.setCursorPos(15, 12) | |
| 752 | if conteggioErrori > 2 then | |
| 753 | term.setCursorPos(15, 12) | |
| 754 | colore(colors.red) | |
| 755 | term.write("Tre tentativi di immissione errati.")
| |
| 756 | sleep(2) | |
| 757 | term.setCursorPos(15, 12) | |
| 758 | colore(colors.white) | |
| 759 | term.write(" ")
| |
| 760 | term.setCursorPos(15, 12) | |
| 761 | clear() | |
| 762 | os.reboot() | |
| 763 | end | |
| 764 | end | |
| 765 | end | |
| 766 | ||
| 767 | colore(colors.black) | |
| 768 | --Verifica valore dell'invio | |
| 769 | term.setCursorPos(1, 14) | |
| 770 | term.write("Importo:")
| |
| 771 | term.setCursorPos(15, 14) | |
| 772 | colore(colors.white) | |
| 773 | importoAccettato = false | |
| 774 | conteggioErrori = 0 | |
| 775 | while importoAccettato == false do | |
| 776 | importo = tonumber(read()) | |
| 777 | if importo == "" or importo == nil or importo <= 0 then | |
| 778 | conteggioErrori = conteggioErrori + 1 | |
| 779 | term.setCursorPos(15, 14) | |
| 780 | colore(colors.red) | |
| 781 | term.write("Importo errato! ")
| |
| 782 | sleep(2) | |
| 783 | term.setCursorPos(15, 14) | |
| 784 | colore(colors.white) | |
| 785 | term.write(" ")
| |
| 786 | term.setCursorPos(15, 14) | |
| 787 | elseif importo <= saldo and importo > 0 then | |
| 788 | term.setCursorPos(15, 14) | |
| 789 | colore(colors.lime) | |
| 790 | term.write(importo .. " IC") | |
| 791 | colore(colors.white) | |
| 792 | importoAccettato = true | |
| 793 | else | |
| 794 | conteggioErrori = conteggioErrori + 1 | |
| 795 | term.setCursorPos(15, 14) | |
| 796 | colore(colors.red) | |
| 797 | term.write("Credito insufficiente! ")
| |
| 798 | sleep(2) | |
| 799 | term.setCursorPos(15, 14) | |
| 800 | colore(colors.white) | |
| 801 | term.write(" ")
| |
| 802 | term.setCursorPos(15, 14) | |
| 803 | if conteggioErrori > 2 then | |
| 804 | term.setCursorPos(15, 14) | |
| 805 | colore(colors.red) | |
| 806 | term.write("Tre tentativi di immissione errati.")
| |
| 807 | sleep(2) | |
| 808 | term.setCursorPos(15, 14) | |
| 809 | colore(colors.white) | |
| 810 | term.write(" ")
| |
| 811 | term.setCursorPos(15, 14) | |
| 812 | clear() | |
| 813 | os.reboot() | |
| 814 | end | |
| 815 | end | |
| 816 | end | |
| 817 | ||
| 818 | sleep(0.5) | |
| 819 | clear() | |
| 820 | titolo("Riepilogo del trasferimento")
| |
| 821 | ||
| 822 | text = "Vuoi inviare " .. importo .. " IC a " .. beneficiario .. "?" | |
| 823 | term.setCursorPos((maxw - #text) / 2, 6) | |
| 824 | term.write("Vuoi inviare ")
| |
| 825 | colore(colors.white) | |
| 826 | term.write(tostring(importo) .. " IC ") | |
| 827 | colore(colors.black) | |
| 828 | term.write("a ")
| |
| 829 | colore(colors.white) | |
| 830 | term.write(beneficiario) | |
| 831 | colore(colors.black) | |
| 832 | term.write("?")
| |
| 833 | ||
| 834 | drawFilledBox(7, 11, 23, 13, colors.white) | |
| 835 | drawFilledBox(29, 11, 45, 13, colors.white) | |
| 836 | ||
| 837 | term.setCursorPos(8, 12) | |
| 838 | colore(colors.lime) | |
| 839 | term.write("Invia il denaro")
| |
| 840 | ||
| 841 | term.setCursorPos(34, 12) | |
| 842 | colore(colors.red) | |
| 843 | term.write("Annulla")
| |
| 844 | ||
| 845 | inviare = false | |
| 846 | while true do | |
| 847 | event, key, x, y = os.pullEvent() | |
| 848 | if event == "mouse_click" and x >= 7 and x <= 23 and y >= 11 and y <= 13 then | |
| 849 | inviaDenaro = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=trasferimento&valore=" .. importo .. "&beneficiario=" .. beneficiario).readAll()
| |
| 850 | risultatoInvio = textutils.unserialize(inviaDenaro) | |
| 851 | if risultatoInvio.stato == "OK" then | |
| 852 | text = "Invio del denaro riuscito." | |
| 853 | text2 = "Nuovo saldo: " .. risultatoInvio.credito .. " IC" | |
| 854 | sfondo(colors.lightBlue) | |
| 855 | colore(colors.lime) | |
| 856 | term.setCursorPos((maxw - #text) / 2, 16) | |
| 857 | term.write(text) | |
| 858 | colore(colors.black) | |
| 859 | term.setCursorPos((maxw - #text2) / 2, 18) | |
| 860 | term.write(text2) | |
| 861 | sleep(2) | |
| 862 | clear() | |
| 863 | break | |
| 864 | else | |
| 865 | text = "Errore durante l'invio del denaro." | |
| 866 | text2 = risultatoInvio.errore | |
| 867 | sfondo(colors.lightBlue) | |
| 868 | colore(colors.red) | |
| 869 | term.setCursorPos((maxw - #text) / 2, 16) | |
| 870 | term.write(text) | |
| 871 | colore(colors.black) | |
| 872 | term.setCursorPos((maxw - #text2) / 2, 18) | |
| 873 | term.write(text2) | |
| 874 | sleep(2) | |
| 875 | clear() | |
| 876 | break | |
| 877 | end | |
| 878 | elseif event == "mouse_click" and x >= 29 and x <= 45 and y >= 11 and y <= 13 then | |
| 879 | sfondo(colors.lightBlue) | |
| 880 | colore(colors.red) | |
| 881 | text = "Operazione annullata." | |
| 882 | term.setCursorPos((maxw - #text) / 2, 16) | |
| 883 | term.write(text) | |
| 884 | sleep(1.5) | |
| 885 | clear() | |
| 886 | break | |
| 887 | end | |
| 888 | end | |
| 889 | ||
| 890 | elseif event == "mouse_click" and y == 13 and x <= 24 then --Pulsante estratto conto | |
| 891 | --Estratto Conto (inizio pagina) | |
| 892 | clear() | |
| 893 | titolo("Estratto conto")
| |
| 894 | ||
| 895 | estratto = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=" .. password .. "&utente=" .. utente .. "&richiesta=estratto").readAll()
| |
| 896 | ec = textutils.unserialize(estratto) | |
| 897 | term.setCursorPos(1, 3) | |
| 898 | print("Entrate:")
| |
| 899 | colore(colors.lime) | |
| 900 | print(ec.entrata1) | |
| 901 | print(ec.entrata2) | |
| 902 | print(ec.entrata3) | |
| 903 | print(ec.entrata4) | |
| 904 | colore(colors.black) | |
| 905 | print("\nUscite:")
| |
| 906 | colore(colors.red) | |
| 907 | print(ec.uscita1) | |
| 908 | print(ec.uscita2) | |
| 909 | print(ec.uscita3) | |
| 910 | print(ec.uscita4) | |
| 911 | term.setCursorPos(1, 18) | |
| 912 | sfondo(colors.white) | |
| 913 | colore(colors.black) | |
| 914 | term.write(" Torna al menåA5B9 principale ")
| |
| 915 | while true do | |
| 916 | event, key, x, y = os.pullEventRaw() | |
| 917 | if event == "mouse_click" and x <= 26 and y == 18 then | |
| 918 | break | |
| 919 | end | |
| 920 | end | |
| 921 | ||
| 922 | elseif event == "mouse_click" and y == 15 and x <= 24 then --Pulsante disconnetti da nPay | |
| 923 | disconnetti() | |
| 924 | ||
| 925 | elseif event == "timer" and key == antitonto then --Butta fuori l'utente se non fa niente | |
| 926 | disconnetti() | |
| 927 | ||
| 928 | elseif event == "mouse_click" and x == maxw and y == maxh then -- Auto aggiornamento su magic corner (pannello utente) | |
| 929 | update() | |
| 930 | end | |
| 931 | end | |
| 932 | ||
| 933 | elseif event == "mouse_click" and x == maxw and y == maxh then -- Auto aggiornamento su magic corner (schermata principale) | |
| 934 | update() | |
| 935 | end | |
| 936 | end |