Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.89 KB | None | 0 0
  1. --IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  2. local function drawPixelInternal( xPos, yPos )
  3. term.setCursorPos( xPos, yPos )
  4. term.write(" ")
  5. end
  6. local tColourLookup = {}
  7. for n=1,16 do
  8. tColourLookup[ string.byte( "0123456789abcdef",n,n ) ] = 2^(n-1)
  9. end
  10. function drawFilledBox( startX, startY, endX, endY, nColour )
  11. if type( startX ) ~= "number" or type( startX ) ~= "number" or
  12. type( endX ) ~= "number" or type( endY ) ~= "number" or
  13. (nColour ~= nil and type( nColour ) ~= "number") then
  14. error( "Expected startX, startY, endX, endY, colour", 2 )
  15. end
  16.  
  17. startX = math.floor(startX)
  18. startY = math.floor(startY)
  19. endX = math.floor(endX)
  20. endY = math.floor(endY)
  21.  
  22. if nColour then
  23. term.setBackgroundColor( nColour )
  24. end
  25. if startX == endX and startY == endY then
  26. drawPixelInternal( startX, startY )
  27. return
  28. end
  29.  
  30. local minX = math.min( startX, endX )
  31. if minX == startX then
  32. minY = startY
  33. maxX = endX
  34. maxY = endY
  35. else
  36. minY = endY
  37. maxX = startX
  38. maxY = startY
  39. end
  40.  
  41. for x=minX,maxX do
  42. for y=minY,maxY do
  43. drawPixelInternal( x, y )
  44. end
  45. end
  46. end
  47.  
  48.  
  49. function clear()
  50. term.clear()
  51. term.setCursorPos(1, 1)
  52. end
  53.  
  54. function colore(sfumatura)
  55. term.setTextColour(sfumatura)
  56. end
  57. function fineColore()
  58. term.setTextColour(colours.white)
  59. end
  60. function sfondo(sfumaturaSfondo)
  61. term.setBackgroundColour(sfumaturaSfondo)
  62. end
  63. function fineSfondo()
  64. term.setBackgroundColour(colours.black)
  65. end
  66.  
  67. function disconnetti()
  68. sfondo(colors.lightBlue)
  69. clear()
  70. print("Arrivederci")
  71. print("Tra poco sarà possibile eseguire una nuova operazione")
  72. colore(colors.lightBlue)
  73. shell.run("rm startup")
  74. shell.run("pastebin get y1AP0iNY startup")
  75. os.reboot()
  76. end
  77.  
  78.  
  79. mag = peripheral.wrap("bottom")
  80. bl = "BN Credit"
  81.  
  82. sfondo(colors.lightBlue)
  83. clear()
  84.  
  85. colore(colours.white)
  86. print(" ___ ")
  87. print(" _ __ / _ \\__ _ _ _ ")
  88. print(" | '_ \\ / /_)/ _ | | | |")
  89. print(" | | | / ___/ (_| | |_| |")
  90. print(" |_| |_\\/ \\__,_|\\__, |")
  91. print(" |___/ ")
  92. fineColore()
  93.  
  94. drawFilledBox(14, 10, 37, 12, colors.white)
  95. term.setCursorPos(20, 11)
  96. colore(colours.black)
  97. term.write("Nuovo utente")
  98.  
  99. drawFilledBox(14, 15, 37, 17, colors.white)
  100. term.setCursorPos(16, 16)
  101. colore(colours.black)
  102. term.write("Utente già registrato")
  103.  
  104. while true do
  105. event, key, x, y = os.pullEvent("mouse_click")
  106. if event == "mouse_click" and x > 14 and x < 37 and y > 10 and y < 13 then
  107. --Registrazione nuovo utente
  108. clear()
  109. sfondo(colours.lightBlue)
  110. term.clear()
  111. colore(colours.black)
  112. sfondo(colours.yellow)
  113. print(" Registrazione a nPay ")
  114. sfondo(colours.lightBlue)
  115. print("\nInserire un nome utente e una password sicura. Premere Enter per confermare i dati inseriti. \nSe i dati sono corretti, il campo diventerà verde. Se sono errati, il programma chiederà di reinserirli nuovamente.")
  116.  
  117. --nomeutente
  118. term.setCursorPos(1,9)
  119. term.write("Nome utente:")
  120. term.setCursorPos(14, 9)
  121. fineColore()
  122. utenteAccettato = false
  123. conteggioErrori = 0
  124. while utenteAccettato == false do
  125. utente = read()
  126. checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente="..utente).readAll()
  127. tabcheckuser = textutils.unserialize(checkuser)
  128. if tabcheckuser.stato == "NO" then
  129. term.setCursorPos(14, 9)
  130. colore(colours.green)
  131. term.write(utente)
  132. fineColore()
  133. utenteAccettato=true
  134. else
  135. term.setCursorPos(14, 9)
  136. colore(colours.red)
  137. term.write("Utente già esistente!")
  138. sleep(2)
  139. term.setCursorPos(14, 9)
  140. fineColore()
  141. term.write(" ")
  142. term.setCursorPos(14, 9)
  143. conteggioErrori = conteggioErrori + 1
  144. if conteggioErrori > 2 then
  145. term.setCursorPos(14, 9)
  146. colore(colours.red)
  147. term.write("Troppi tentativi di immissione errati ")
  148. sleep(2)
  149. term.setCursorPos(14, 9)
  150. fineColore()
  151. term.write(" ")
  152. term.setCursorPos(14, 9)
  153. clear()
  154. os.reboot()
  155. end
  156. end
  157. end
  158.  
  159. --password
  160. colore(colours.black)
  161. term.setCursorPos(1,11)
  162. term.write("Password:")
  163. term.setCursorPos(14, 11)
  164. fineColore()
  165.  
  166. passAccettata = false
  167. conteggioErrori = 0
  168. while passAccettata == false do
  169. password1 = read("#")
  170. colore(colours.black)
  171. term.setCursorPos(1,13)
  172. term.write("Verifica:")
  173. term.setCursorPos(14, 13)
  174. fineColore()
  175. local password2 = read("#")
  176. if password1 == password2 then
  177. term.setCursorPos(14, 11)
  178. colore(colours.green)
  179. term.write("###############")
  180. term.setCursorPos(14, 13)
  181. term.write("###############")
  182. fineColore()
  183. passAccettata=true
  184. else
  185. term.setCursorPos(14, 11)
  186. colore(colours.red)
  187. term.write("La password non coincide! ")
  188. term.setCursorPos(14, 13)
  189. fineColore()
  190. term.write(" ")
  191. sleep(2)
  192. term.setCursorPos(14, 11)
  193. term.write(" ")
  194. term.setCursorPos(14, 11)
  195. conteggioErrori = conteggioErrori + 1
  196. if conteggioErrori > 2 then
  197. term.setCursorPos(14, 11)
  198. colore(colours.red)
  199. term.write("Troppi tentativi di immissione errati ")
  200. sleep(2)
  201. term.setCursorPos(14, 11)
  202. fineColore()
  203. term.write(" ")
  204. term.setCursorPos(14, 11)
  205. clear()
  206. os.reboot()
  207. end
  208. end
  209. end
  210.  
  211. --crea l'account
  212.  
  213. term.setCursorPos(1, 17)
  214. creaAccount = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth="..password1.."&utente="..utente.."&richiesta=crea&valore=0").readAll()
  215. tabCreaAccount = textutils.unserialize(creaAccount)
  216. if tabCreaAccount.stato == "OA" then
  217. colore(colors.black)
  218. print("Conto creato con successo.")
  219. sleep(3)
  220. clear()
  221. os.reboot()
  222. else
  223. colore(colors.red)
  224. print("Errore durante la creazione del conto.")
  225. sleep(3)
  226. clear()
  227. os.reboot()
  228. end
  229.  
  230.  
  231.  
  232.  
  233. elseif event == "mouse_click" and x > 14 and x < 37 and y > 15 and y < 17 then
  234.  
  235. clear()
  236. --Autentica l'utente e mostra il menu principale
  237. sfondo(colours.lightBlue)
  238. term.clear()
  239. colore(colours.black)
  240. sfondo(colours.yellow)
  241. print(" Autenticazione su nPay ")
  242. sfondo(colours.lightBlue)
  243. print("\nInserire i propri dati. Premere Enter per confermare i dati inseriti. \nSe i dati sono corretti, il campo diventerà verde. Se sono errati, il programma chiederà di reinserirli nuovamente.")
  244.  
  245. --nomeutente
  246. term.setCursorPos(1,9)
  247. term.write("Nome utente:")
  248. term.setCursorPos(15, 9)
  249. fineColore()
  250. utenteAccettato = false
  251. conteggioErrori = 0
  252. while utenteAccettato == false do
  253. utente = read()
  254. checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente="..utente).readAll()
  255. tabcheckuser = textutils.unserialize(checkuser)
  256. if tabcheckuser.stato == "OK" then
  257. term.setCursorPos(15, 9)
  258. colore(colours.green)
  259. term.write(utente)
  260. fineColore()
  261. utenteAccettato=true
  262. else
  263. term.setCursorPos(15, 9)
  264. colore(colours.red)
  265. term.write("Utente errato! ")
  266. sleep(2)
  267. term.setCursorPos(15, 9)
  268. fineColore()
  269. term.write(" ")
  270. term.setCursorPos(15, 9)
  271. conteggioErrori = conteggioErrori + 1
  272. if conteggioErrori > 2 then
  273. term.setCursorPos(15, 9)
  274. colore(colours.red)
  275. term.write("Troppi tentativi di immissione errati ")
  276. sleep(2)
  277. term.setCursorPos(15, 9)
  278. fineColore()
  279. term.write(" ")
  280. term.setCursorPos(15, 9)
  281. clear()
  282. os.reboot()
  283. end
  284. end
  285. end
  286.  
  287. --password
  288. colore(colours.black)
  289. term.setCursorPos(1,11)
  290. term.write("Password:")
  291. term.setCursorPos(15, 11)
  292.  
  293. conteggioErrori = 0
  294. passAccettata = false
  295. while passAccettata == false do
  296. fineColore()
  297. password = read("#")
  298. colore(colours.black)
  299. checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth="..password.."&richiesta=addebito&valore=0&utente="..utente).readAll()
  300. risposta = textutils.unserialize(checkuser)
  301. if risposta.stato == "OK" then
  302. term.setCursorPos(15, 11)
  303. colore(colours.green)
  304. term.write("############## ")
  305. fineColore()
  306. passAccettata=true
  307. else
  308. term.setCursorPos(15, 11)
  309. colore(colours.red)
  310. term.write("Password errata! ")
  311. conteggioErrori = conteggioErrori + 1
  312. sleep(2)
  313. term.setCursorPos(15, 11)
  314. term.write(" ")
  315. term.setCursorPos(15, 11)
  316. if conteggioErrori > 2 then
  317. term.setCursorPos(15, 11)
  318. colore(colours.red)
  319. term.write("Troppi tentativi di immissione errati")
  320. sleep(2)
  321. term.setCursorPos(15, 11)
  322. term.write(" ")
  323. term.setCursorPos(15, 11)
  324. clear()
  325. os.reboot()
  326. end
  327. end
  328. end
  329.  
  330. conteggioErrori = 0
  331. -- Pagina in cui scegli le operazioni da fare
  332.  
  333.  
  334. while true do
  335. --Ricontrolla il saldo per gestire l'aggiornamento di più operazioni
  336. checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth="..password.."&richiesta=addebito&valore=0&utente="..utente).readAll()
  337. risposta = textutils.unserialize(checkuser)
  338. saldo = tonumber(risposta.saldo)
  339. --Disegna la finestra del pannello utente
  340. clear()
  341. sfondo(colours.lightBlue)
  342. term.clear()
  343. colore(colours.black)
  344. sfondo(colours.yellow)
  345. print(" Pannello utente nPay ")
  346. sfondo(colours.lightBlue)
  347. print("\nBenvenuto "..utente.."! Saldo: "..saldo.." IC")
  348. print("\n\nOperazioni disponibili:\n")
  349. sfondo(colours.white)
  350. print("Carica denaro su nPay \n")
  351. print("Preleva denaro da nPay \n")
  352. print("Trasferisci denaro \n")
  353. print("Estratto conto \n")
  354. print("Disconnettiti da nPay \n")
  355.  
  356. antitonto = os.startTimer(120)
  357.  
  358. event, key, x, y = os.pullEvent()
  359. if event == "mouse_click" and y == 8 then --Pulsante carica denaro su nPay
  360. sfondo(colours.lightBlue)
  361. clear()
  362. colore(colours.black)
  363. sfondo(colours.yellow)
  364. print(" Caricamento denaro su nPay ")
  365. sfondo(colours.lightBlue)
  366. drawFilledBox(6,6,25,14,colors.blue)
  367. drawFilledBox(6,7,25,8,colors.black)
  368. colore(colors.black)
  369. sfondo(colours.lightBlue)
  370. term.setCursorPos(30, 9)
  371. print("Inserire la carta")
  372. term.setCursorPos(30, 10)
  373. print("nel lettore in basso")
  374. mag.setInsertCardLight(true)
  375. za, rawcarta = os.pullEvent("mag_swipe")
  376. mag.setInsertCardLight(false)
  377. tabel = textutils.unserialize(rawcarta)
  378. clear()
  379. if tabel == "" or tabel == nil then
  380. print("Carta smagnetizzata!")
  381. os.sleep(5)
  382. elseif tabel.t ~= "cc" then
  383. print("Carta non valida!")
  384. os.sleep(5)
  385. elseif tabel.e ~= "BN" then
  386. print("Carta non valida!")
  387. os.sleep(5)
  388. os.reboot()
  389. else
  390.  
  391.  
  392. sfondo(colours.yellow)
  393. print(" Caricamento denaro su nPay ")
  394. sfondo(colours.lightBlue)
  395. colore(colors.red)
  396. print("\nATTENZIONE:\n")
  397. colore(colors.black)
  398. print("Per le operazioni inferiori a 50 000 IC, si applica una commissione del 3%\nOltre 50 000 IC la commissione è dell'1%")
  399. colore(colors.gray)
  400. print("\nDisponibilità su carta: "..tabel.v.." IC\n")
  401. colore(colors.black)
  402. term.write("Importo da caricare: ")
  403. credito = tonumber(tabel.v)
  404. credit = read()
  405. if tonumber(credit) == "" or tonumber(credit) == nil or tonumber(credit) <= 0 then
  406. print("\n\nImporto errato! ")
  407. sleep(5)
  408. else
  409. if tonumber(credit) >= 50000 then
  410. clolz = tonumber(credit) * 0.01
  411. else
  412. clolz = tonumber(credit) * 0.03
  413. end
  414. crediton = tonumber(credit) + clolz
  415. if tonumber(tabel.v) >= crediton then
  416. tab4 = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?utente=Lolz&auth=lorenzo06&richiesta=accredito&valore="..clolz).readAll()
  417. tab6 = textutils.unserialize(tab4)
  418. tab = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?utente="..utente.."&auth="..password.."&richiesta=accredito&valore="..credit).readAll()
  419. tabella = textutils.unserialize(tab)
  420. tabr = {}
  421. tabr.t = tabel.t
  422. tabr.e = tabel.e
  423. tabr.p = tabel.p
  424. tabr.v = tonumber(tabel.v) - crediton
  425. ncr = textutils.serialize(tabr)
  426. sfondo(colours.lightBlue)
  427. clear()
  428. colore(colours.black)
  429. sfondo(colours.yellow)
  430. print(" Caricamento denaro su nPay ")
  431. sfondo(colours.lightBlue)
  432. drawFilledBox(6,6,25,14,colors.blue)
  433. drawFilledBox(6,7,25,8,colors.black)
  434. colore(colors.black)
  435. sfondo(colours.lightBlue)
  436. term.setCursorPos(30, 9)
  437. print("Inserire la carta")
  438. term.setCursorPos(30, 10)
  439. print("per confermare")
  440. mag.setInsertCardLight(true)
  441. mag.beginWrite(ncr, bl)
  442. za2, carta = os.pullEvent("mag_write_done")
  443. mag.setInsertCardLight(false)
  444. sfondo(colours.lightBlue)
  445. clear()
  446. colore(colours.black)
  447. sfondo(colours.yellow)
  448. print(" Caricamento denaro su nPay ")
  449. sfondo(colours.lightBlue)
  450. print("\nOperazione completata!\n\n")
  451.  
  452. print("Denaro accreditato : "..credit.." IC")
  453. print("Commissioni: "..clolz.." IC\n")
  454. print("Nuovo saldo su conto: "..tabella.credito.." IC")
  455. print("Saldo su carta: "..tabr.v.." IC\n\n\n")
  456. sfondo(colors.white)
  457. print("Torna alla pagina principale")
  458. sfondo(colors.lightBlue)
  459. antiTonto2 = os.startTimer(15)
  460. event = os.pullEvent()
  461. clear()
  462. else
  463. colore(colors.red)
  464. print("\nDisponibilità carta insufficente")
  465. colore(colors.black)
  466. sleep(2)
  467. clear()
  468. end
  469. end
  470. end
  471.  
  472.  
  473. elseif event == "mouse_click" and y == 10 then --Pulsante preleva denaro da nPay
  474.  
  475. sfondo(colours.lightBlue)
  476. clear()
  477. colore(colours.black)
  478. sfondo(colours.yellow)
  479. print(" Prelievo denaro da nPay ")
  480. sfondo(colours.lightBlue)
  481. drawFilledBox(6,6,25,14,colors.blue)
  482. drawFilledBox(6,7,25,8,colors.black)
  483. colore(colors.black)
  484. sfondo(colours.lightBlue)
  485. term.setCursorPos(30, 9)
  486. print("Inserire la carta")
  487. term.setCursorPos(30, 10)
  488. print("nel lettore in basso")
  489. mag.setInsertCardLight(true)
  490. za, rawcarta = os.pullEvent("mag_swipe")
  491. mag.setInsertCardLight(false)
  492. tabel = textutils.unserialize(rawcarta)
  493. clear()
  494. if tabel == "" or tabel == nil then
  495. print("Carta smagnetizzata!")
  496. os.sleep(5)
  497. elseif tabel.t ~= "cc" then
  498. print("Carta non valida!")
  499. os.sleep(5)
  500. elseif tabel.e ~= "BN" then
  501. print("Carta non valida!")
  502. os.sleep(5)
  503. else
  504. tabr = {}
  505. tabr.e = tabel.e
  506. tabr.p = tabel.p
  507. tabr.t = tabel.t
  508. tab1 = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?utente="..utente.."&auth="..password.."&richiesta=accredito&valore=0").readAll()
  509. tab3 = textutils.unserialize(Iarrtab1)
  510. sfondo(colours.yellow)
  511. print(" Prelievo denaro da nPay ")
  512. sfondo(colours.lightBlue)
  513. colore(colors.gray)
  514. print("\n\nDisponibilità su conto: "..saldo.." IC\n")
  515. colore(colors.black)
  516. term.write("Importo da ritirare: ")
  517. credito = tonumber(tabel.v)
  518. credit = read()
  519. if tonumber(credit) == "" or tonumber(credit) == nil or tonumber(credit) <= 0 then
  520. print("\n\nImporto errato! ")
  521. sleep(5)
  522. else
  523. tab = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?utente="..utente.."&auth="..password.."&richiesta=addebito&valore="..credit).readAll()
  524. tabella = textutils.unserialize(tab)
  525. if tabella.stato == "DI" then
  526. colore(colors.red)
  527. print("\nDisponibilità conto insufficente")
  528. colore(colors.black)
  529. os.sleep(5)
  530. clear()
  531. else
  532. tabr.v = tonumber(tabel.v) + tonumber(credit)
  533. ncr = textutils.serialize(tabr)
  534. mag.setInsertCardLight(true)
  535. mag.beginWrite(ncr, bl)
  536. sfondo(colours.lightBlue)
  537. clear()
  538. colore(colours.black)
  539. sfondo(colours.yellow)
  540. print(" Prelievo denaro da nPay ")
  541. sfondo(colours.lightBlue)
  542. drawFilledBox(6,6,25,14,colors.blue)
  543. drawFilledBox(6,7,25,8,colors.black)
  544. colore(colors.black)
  545. sfondo(colours.lightBlue)
  546. term.setCursorPos(30, 9)
  547. print("Inserire la carta")
  548. term.setCursorPos(30, 10)
  549. print("per confermare")
  550. mag.setInsertCardLight(true)
  551. za2, carta = os.pullEvent("mag_write_done")
  552. mag.setInsertCardLight(false)
  553. sfondo(colours.lightBlue)
  554. clear()
  555. colore(colours.black)
  556. sfondo(colours.yellow)
  557. print(" Prelievo denaro da nPay ")
  558. sfondo(colours.lightBlue)
  559. print("\nOperazione completata!\n\n")
  560.  
  561. print("Denaro prelevato : "..credit.." IC")
  562. print("Saldo su conto: "..tabella.credito.." IC")
  563. print("Saldo su carta: "..tabr.v.." IC\n\n\n")
  564. sfondo(colors.white)
  565. print("Torna alla pagina principale")
  566. sfondo(colors.lightBlue)
  567. antiTonto3 = os.startTimer(15)
  568. event = os.pullEvent()
  569. clear()
  570. os.sleep(3.5)
  571. term.clear()
  572. term.setCursorPos(1,1)
  573. end
  574. end
  575. end
  576.  
  577.  
  578.  
  579. elseif event == "mouse_click" and y == 12 then --Pulsante trasferisci denaro
  580. --Trasferisci denaro
  581. --inizio pagina
  582. clear()
  583. sfondo(colours.lightBlue)
  584. term.clear()
  585. colore(colours.black)
  586. sfondo(colours.yellow)
  587. print(" Trasferimento di denaro ")
  588. sfondo(colours.lightBlue)
  589. print("\nInserire i propri dati. Premere Enter per confermare i dati inseriti. \nSe i dati sono corretti, il campo diventerà verde. Se sono errati, il programma chiederà di reinserirli nuovamente.")
  590.  
  591. --Mostra saldo
  592. term.setCursorPos(1, 9)
  593. colore(colors.gray)
  594. print("Saldo disponibile: "..saldo.." IC")
  595. colore(colors.black)
  596.  
  597. --Verifica Beneficiario
  598. term.setCursorPos(1,13)
  599. term.write("Beneficiario:")
  600. term.setCursorPos(15, 13)
  601. fineColore()
  602. destAccettato = false
  603. conteggioErrori = 0
  604. while destAccettato == false do
  605. beneficiario = read()
  606. checkuser = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente="..beneficiario).readAll()
  607. tabcheckuser = textutils.unserialize(checkuser)
  608. if tabcheckuser.stato == "OK" and beneficiario ~= utente then
  609. term.setCursorPos(15, 13)
  610. colore(colours.green)
  611. term.write(beneficiario)
  612. fineColore()
  613. destAccettato=true
  614. else
  615. conteggioErrori = conteggioErrori + 1
  616. term.setCursorPos(15, 13)
  617. colore(colours.red)
  618. term.write("Beneficiario inesistente! ")
  619. sleep(2)
  620. term.setCursorPos(15, 13)
  621. fineColore()
  622. term.write(" ")
  623. term.setCursorPos(15, 13)
  624. if conteggioErrori > 2 then
  625. term.setCursorPos(15, 13)
  626. colore(colours.red)
  627. term.write("Troppi tentativi di immissione errati")
  628. sleep(2)
  629. term.setCursorPos(15, 13)
  630. fineColore()
  631. term.write(" ")
  632. term.setCursorPos(15, 13)
  633. clear()
  634. os.reboot()
  635. end
  636. end
  637. end
  638. colore(colors.black)
  639. --Verifica valore dell'invio
  640. term.setCursorPos(1,15)
  641. term.write("Importo:")
  642. term.setCursorPos(15, 15)
  643. fineColore()
  644. importoAccettato = false
  645. conteggioErrori = 0
  646. while importoAccettato == false do
  647. importo = tonumber(read())
  648. if importo == "" or importo == nil or importo <= 0 then
  649. conteggioErrori = conteggioErrori + 1
  650. term.setCursorPos(15, 15)
  651. colore(colours.red)
  652. term.write("Importo errato! ")
  653. sleep(2)
  654. term.setCursorPos(15, 15)
  655. fineColore()
  656. term.write(" ")
  657. term.setCursorPos(15, 15)
  658. elseif importo <= saldo and importo > 0 then
  659. term.setCursorPos(15, 15)
  660. colore(colours.green)
  661. term.write(importo.." IC")
  662. fineColore()
  663. importoAccettato=true
  664. else
  665. conteggioErrori = conteggioErrori + 1
  666. term.setCursorPos(15, 15)
  667. colore(colours.red)
  668. term.write("Disponibilità insufficiente! ")
  669. sleep(2)
  670. term.setCursorPos(15, 15)
  671. fineColore()
  672. term.write(" ")
  673. term.setCursorPos(15, 15)
  674. if conteggioErrori > 2 then
  675. term.setCursorPos(15, 15)
  676. colore(colours.red)
  677. term.write("Troppi tentativi di immissione errati")
  678. sleep(2)
  679. term.setCursorPos(15, 15)
  680. fineColore()
  681. term.write(" ")
  682. term.setCursorPos(15, 15)
  683. clear()
  684. os.reboot()
  685. end
  686. end
  687. end
  688.  
  689. sleep(0.5)
  690. sfondo(colours.lightBlue)
  691. term.setCursorPos(1, 1)
  692. term.clear()
  693. colore(colours.black)
  694. sfondo(colours.yellow)
  695. print(" Riepilogo dell'operazione di trasferimento ")
  696. sfondo(colours.lightBlue)
  697. colore(colors.black)
  698. term.setCursorPos(1, 3)
  699. term.write("Invio di ")
  700. colore(colors.gray)
  701. term.write(importo)
  702. colore(colors.black)
  703. term.write(" IC a favore di ")
  704. colore(colors.gray)
  705. term.write(beneficiario)
  706. colore(colors.black)
  707. print("\n\nConfermare l'operazione?")
  708. colore(colours.yellow)
  709. print("\n\n\nInvia il denaro Annulla e torna a nPay")
  710.  
  711. inviare = false
  712. while true do
  713. event, key, x, y = os.pullEvent()
  714. if event == "mouse_click" and x < 16 and y == 9 then
  715. inviaDenaro = http.get("http://172.16.20.220/luanet/servlets/nebraskapay.php?auth="..password.."&utente="..utente.."&richiesta=trasferimento&valore="..importo.."&beneficiario="..beneficiario).readAll()
  716. risultatoInvio = textutils.unserialize(inviaDenaro)
  717. if risultatoInvio.stato == "OK" then
  718. colore(colors.black)
  719. print("\n\n\n\nInvio del denaro riuscito.\nNuovo saldo: "..risultatoInvio.credito.." IC")
  720. sleep(3)
  721. clear()
  722. break
  723. else
  724. colore(colors.red)
  725. print("\n\n\n\nErrore durante l'invio del denaro.\n"..risultatoInvio.errore)
  726. sleep(3)
  727. clear()
  728. break
  729.  
  730. end
  731. elseif event == "mouse_click" and x > 18 and y == 9 then
  732. colore(colors.red)
  733. print("\n\n\n\nInvio annullato.")
  734. sleep(3)
  735. clear()
  736. break
  737. end
  738. end
  739. elseif event == "mouse_click" and y == 14 then --Pulsante estratto conto
  740.  
  741. --Estratto Conto (inizio pagina)
  742. clear()
  743. sfondo(colours.lightBlue)
  744. term.clear()
  745. colore(colours.black)
  746. sfondo(colours.yellow)
  747. print(" Estratto conto ")
  748. sfondo(colours.lightBlue)
  749. print("Entrate:")
  750. colore(colours.green)
  751. print("+ 50 IC")
  752. print("+ 50 IC")
  753. print("+ 50 IC")
  754. print("+ 50 IC")
  755. colore(colours.black)
  756. print("Uscite:")
  757. colore(colours.red)
  758. print("- 50 IC")
  759. print("- 50 IC")
  760. print("- 50 IC")
  761. print("- 50 IC")
  762. print()
  763.  
  764. elseif event == "mouse_click" and y == 16 then --Pulsante disconnetti da nPay
  765. disconnetti()
  766. elseif event == "timer" and x == antitonto then --Butta fuori l'utente se non fa niente
  767. disconnetti()
  768.  
  769. end
  770.  
  771. end
  772.  
  773. elseif event == "mouse_click" and x == 51 and y == 19 then -- Auto aggiornamento su magic corner
  774. shell.run("rm startup")
  775. shell.run("pastebin get y1AP0iNY startup")
  776. os.reboot()
  777. end
  778. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement