Advertisement
Guest User

startup

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