Advertisement
Shiranuit

BanqueServeur_Startup

Apr 17th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 38.56 KB | None | 0 0
  1. os.loadAPI("NetSphere")
  2.  
  3. local h = http.get("http://pastebin.com/raw/9mQiK4PX")
  4. local DerniereVersion = textutils.unserialise(h.readAll())
  5. h.close()
  6.  
  7. local MaVersion = {["Serveur"]=0}
  8. if fs.exists("Version") then
  9.     local h = fs.open("Version","r")
  10.     MaVersion = textutils.unserialise(h.readAll())
  11.     h.close()
  12. end
  13.  
  14. if MaVersion["Serveur"] ~= DerniereVersion["Serveur"] then
  15.     fs.delete("install")
  16.     shell.run("pastebin get NfQk01Ex install")
  17.     shell.run("install")
  18. end
  19.  
  20. local ATM = {}
  21.  
  22. print("Veuillez placer un modem quelque part !")
  23.  
  24. while true do
  25. local modem = peripheral.find("modem",function(name,object) return object.isWireless() end)
  26.     if modem then
  27.         modem.open(os.getComputerID())
  28.         modem.open(65535)
  29.         break
  30.     else
  31.         shell.run("clear")
  32.         print("Veuillez placer un modem quelque part !")
  33.         os.pullEvent("peripheral")
  34.     end
  35. end
  36.  
  37. function AddATM(id)
  38.     ATM[id+0]=true
  39.     if fs.exists("Banque/IDATM/"..id.."/") == false then
  40.         fs.makeDir("Banque/IDATM/"..id.."/")
  41.     end
  42. end
  43.  
  44.  
  45.  
  46. function DelATM(id)
  47.     ATM[id+0]=nil
  48.     if fs.exists("Banque/IDATM/"..id.."/") then
  49.         fs.delete("Banque/IDATM/"..id.."/")
  50.     end
  51. end
  52.  
  53. function ListeATM()
  54.     return fs.list("Banque/IDATM/")
  55. end
  56.  
  57. shell.run("clear")
  58. rednet.host("Serveur_Banque","Serveur_Banque")
  59.  
  60. local IDConnecter = {}
  61.  
  62. function send(id, texte)
  63.     NetSphere.send(id, texte)
  64. end
  65.  
  66. function EffHistorique(Pseudo)
  67.     if fs.exists("Banque/Compte/"..Pseudo.."/Historique") then
  68.         h = fs.open("Banque/Compte/"..Pseudo.."/Historique","w")
  69.         h.write("")
  70.         h.close()
  71.     end
  72. end
  73.  
  74. function HaveAModem()
  75.     while true do
  76.         local event, side = os.pullEvent("peripheral_detach")
  77.         local f = peripheral.find("modem",function(name, object) return object.isWireless() end)
  78.         if not f or #f == 0 then
  79.             os.reboot()
  80.         end
  81.     end
  82. end
  83.  
  84.  
  85. function CompteExist(Pseudo)
  86.     if Pseudo == nil then
  87.         return false
  88.     else
  89.         if fs.exists("Banque/Compte/"..Pseudo) then
  90.             return true
  91.         else
  92.             return false
  93.         end
  94.     end
  95. end
  96.  
  97. function DecomposeJson(Fichier)
  98.     if fs.exists(Fichier) then
  99.         local tableau={}
  100.         h = fs.open(Fichier,"r")
  101.         while true do
  102.             result = h.readLine()
  103.             if result == nil then
  104.                 break
  105.             else
  106.  
  107.                 a1 = replace(result," ","")
  108.                 a2 = replace(a1,'"',"")
  109.                 a3 = replace(a2,',',"")
  110.                 if string.find(a2,"name:") then
  111.  
  112.  
  113.                     a4 = replace(a3,"name:","")
  114.                     tableau[#tableau+1] = a4
  115.  
  116.                 end
  117.             end
  118.         end
  119.         h.close()
  120.         return tableau
  121.     end
  122. end
  123.  
  124. function replace(texte,mot,apres)
  125.     if string.find(texte,mot) then
  126.         return string.gsub(texte, mot, apres)
  127.     else
  128.         return texte
  129.     end
  130. end
  131.  
  132. function error(erreur, menu,id)
  133.     info = {Act="Erreur",Menu=menu,Message=erreur}
  134.     infos = textutils.serialise(info)
  135.     send(id, infos)
  136. end
  137.  
  138. function Succes(Succes,menu, id)
  139.     info = {Act="Succes",Menu=menu,Message=Succes}
  140.     infos = textutils.serialise(info)
  141.     send(id, infos)
  142. end
  143.  
  144. function CreateCompte(Pseudo)
  145.     if fs.exists("Banque/Compte/"..Pseudo) == false then
  146.         h = fs.open("Banque/Compte/"..Pseudo.."/Solde","w")
  147.         h.write(1000)
  148.         h.close()
  149.         h = fs.open("Banque/Compte/"..Pseudo.."/Historique","w")
  150.         h.write("")
  151.         h.close()
  152.         h = fs.open("Banque/Compte/"..Pseudo.."/HistoriqueSave","w")
  153.         h.write("")
  154.         h.close()
  155.         h = fs.open("Banque/Compte/"..Pseudo.."/Mdp","w")
  156.         h.write(Pseudo)
  157.         h.close()
  158.         h = fs.open("Banque/Compte/"..Pseudo.."/Statut","w")
  159.         h.write("PLAYER")
  160.         h.close()
  161.         h = fs.open("Banque/Compte/"..Pseudo.."/Entreprises","w")
  162.         h.write("")
  163.         h.close()
  164.         Liste = ListeCompte()
  165.         fs.delete("ListeCompte")
  166.         h = fs.open("ListeCompte","w")
  167.         for i =1, #Liste do
  168.             h.write(Liste[i].."\n")
  169.         end
  170.         h.close()
  171.     end
  172. end
  173.  
  174. function DeleteCompte(Pseudo)
  175.     if fs.exists("Banque/Compte/"..Pseudo) == true then
  176.         fs.delete("Banque/Compte/"..Pseudo)
  177.         Liste = ListeCompte()
  178.         h = fs.open("ListeCompte","w")
  179.         for i =1, #Liste do
  180.             if Liste[i] == Pseudo then
  181.             else
  182.                 h.write(Liste[i].."\n")
  183.             end
  184.         end
  185.         h.close()
  186.     end
  187. end
  188.  
  189. function ListeCompte()
  190.     if fs.exists("ListeCompte") then
  191.         local Comptes=fs.list("Banque/Compte/")
  192.         return Comptes
  193.     end
  194. end
  195.  
  196. function ListeEntreprise()
  197.     if fs.exists("Banque/Entreprise/") then
  198.         local Comptes=fs.list("Banque/Entreprise/")
  199.         return Comptes
  200.     end
  201. end
  202.  
  203. function ActualiserC(Pseudo, Id)
  204.     if fs.exists("Banque/Compte/"..Pseudo.."/Solde") then
  205.         h = fs.open("Banque/Compte/"..Pseudo.."/Solde","r")
  206.         soldeP = h.readAll()
  207.         h.close()
  208.         h = fs.open("Banque/Compte/"..Pseudo.."/Statut","r")
  209.         statut = h.readAll()
  210.         h.close()
  211.         hst = textutils.serialise(HistoriqueCR(Pseudo))
  212.         entp = textutils.serialise(EntrepriseCR(Pseudo))
  213.         Ninfo = {Act="Actualiser",Solde=soldeP+0,Historique=hst,Entreprises=entp,Statut=statut}
  214.         Ninfos = textutils.serialise(Ninfo)
  215.         send(Id, Ninfos)
  216.         Liste = ListeCompte()
  217.         Ninfo = {Act="ListeComptesTab",Liste=Liste,ListeEnt=ListeEntreprise()}
  218.         Ninfos = textutils.serialise(Ninfo)
  219.         send(id, Ninfos)
  220.     end
  221. end
  222.  
  223. function ActualiserE(Entreprise, Id)
  224.     if fs.exists("Banque/Entreprise/"..Entreprise.."/Solde") then
  225.         h = fs.open("Banque/Entreprise/"..Entreprise.."/Solde","r")
  226.         soldeP = h.readAll()
  227.         h.close()
  228.         hst = textutils.serialise(EHistoriqueCR(Entreprise))
  229.         Ninfo = {Act="ActualiserE",Solde=soldeP+0,Historique=hst}
  230.         Ninfos = textutils.serialise(Ninfo)
  231.         send(Id, Ninfos)
  232.         Liste = ListeCompte()
  233.         Ninfo = {Act="ListeComptesTab",Liste=Liste,ListeEnt=ListeEntreprise()}
  234.         Ninfos = textutils.serialise(Ninfo)
  235.         send(Id, Ninfos)
  236.     end
  237. end
  238.  
  239. function HistoriqueCW(Pseudo,txt)
  240.     if fs.exists("Banque/Compte/"..Pseudo.."/Historique") then
  241.         h = fs.open("Banque/Compte/"..Pseudo.."/Historique","r")
  242.         hst = h.readAll()
  243.         h.close()
  244.         h = fs.open("Banque/Compte/"..Pseudo.."/Historique","w")
  245.         h.write(txt.."\n"..hst)
  246.         h.close()
  247.     end
  248.     if fs.exists("Banque/Compte/"..Pseudo.."/HistoriqueSave") then
  249.         h = fs.open("Banque/Compte/"..Pseudo.."/HistoriqueSave","r")
  250.         hst = h.readAll()
  251.         h.close()
  252.         h = fs.open("Banque/Compte/"..Pseudo.."/HistoriqueSave","w")
  253.         h.write(txt.."\n"..hst)
  254.         h.close()
  255.     end
  256. end
  257.  
  258. function HistoriqueCR(Pseudo)
  259.     if fs.exists("Banque/Compte/"..Pseudo.."/Historique") then
  260.         local historique={}
  261.         h = fs.open("Banque/Compte/"..Pseudo.."/Historique","r")
  262.         while true do
  263.             result = h.readLine()
  264.             if result == nil then
  265.                 break
  266.             else
  267.                 if result ~= "" then
  268.                     historique[#historique+1] = result
  269.                 end
  270.             end
  271.         end
  272.         h.close()
  273.         return historique
  274.     end
  275. end
  276.  
  277. function EHistoriqueCW(Entreprise,txt)
  278.     if fs.exists("Banque/Entreprise/"..Entreprise.."/Historique") then
  279.         h = fs.open("Banque/Entreprise/"..Entreprise.."/Historique","r")
  280.         hst = h.readAll()
  281.         h.close()
  282.         h = fs.open("Banque/Entreprise/"..Entreprise.."/Historique","w")
  283.         h.write(txt.."\n"..hst)
  284.         h.close()
  285.     end
  286. end
  287.  
  288. function EHistoriqueCR(Entreprise)
  289.     if fs.exists("Banque/Entreprise/"..Entreprise.."/Historique") then
  290.         local historique={}
  291.         h = fs.open("Banque/Entreprise/"..Entreprise.."/Historique","r")
  292.         while true do
  293.             result = h.readLine()
  294.             if result == nil then
  295.                 break
  296.             else
  297.                 if result ~= "" then
  298.                     historique[#historique+1] = result
  299.                 end
  300.             end
  301.         end
  302.         h.close()
  303.         return historique
  304.     end
  305. end
  306.  
  307. function EntrepriseCR(Pseudo)
  308.     if fs.exists("Banque/Compte/"..Pseudo.."/Entreprises") then
  309.         local entreprises = {}
  310.         h = fs.open("Banque/Compte/"..Pseudo.."/Entreprises","r")
  311.         while true do
  312.             result = h.readLine()
  313.             if result == nil then
  314.                 break
  315.             else
  316.                 if result ~= "" then
  317.                     entreprises[#entreprises+1] = result
  318.                 end
  319.             end
  320.         end
  321.         h.close()
  322.         return entreprises
  323.     end
  324. end
  325.  
  326. function EntrepriseAddMembre(Entreprise,Pseudo)
  327.     if Pseudo ~= "" and Entreprise ~= nil then
  328.         if fs.exists("Banque/Compte/"..Pseudo.."/Entreprises") then
  329.             h = fs.open("Banque/Entreprise/"..Entreprise.."/Permissions/"..Pseudo,"w")
  330.             nTable = {ModifPerm=false,Depos=true,Retrait=false,AddMembre=false,DeleteEntrep=false,DeleteMembre=false}
  331.             h.write(textutils.serialise(nTable))
  332.             h.close()
  333.             h = fs.open("Banque/Entreprise/"..Entreprise.."/Membres","a")
  334.             h.write("\n"..Pseudo)
  335.             h.close()
  336.             h = fs.open("Banque/Compte/"..Pseudo.."/Entreprises","a")
  337.             h.write("\n"..Entreprise)
  338.             h.close()
  339.         end
  340.     end
  341. end
  342.  
  343. function EntreReadMember(Entreprise)
  344.     if fs.exists("Banque/Entreprise/"..infos.Entreprise) then
  345.         local membres = {}
  346.         h = fs.open("Banque/Entreprise/"..Entreprise.."/Membres","r")
  347.         while true do
  348.             result = h.readLine()
  349.             if result == nil then
  350.                 break
  351.             else
  352.                 if result ~= "" then
  353.                     membres[#membres+1] = result
  354.                 end
  355.             end
  356.         end
  357.         h.close()
  358.         return membres
  359.     end
  360. end
  361.  
  362. function DeleteEntrepPlayer(Entreprise,Pseudo)
  363.     if fs.exists("Banque/Compte/"..Pseudo.."/Entreprises") then
  364.         local entreprises = {}
  365.         h = fs.open("Banque/Compte/"..Pseudo.."/Entreprises","r")
  366.         while true do
  367.             result = h.readLine()
  368.             if result == nil then
  369.                 break
  370.             else
  371.                 if result == Entreprise then
  372.                 else
  373.                     if result ~= "" then
  374.                         entreprises[#entreprises+1] = result
  375.                     end
  376.                 end
  377.             end
  378.         end
  379.         h.close()
  380.         h = fs.open("Banque/Compte/"..Pseudo.."/Entreprises","w")
  381.         for i = 1, #entreprises do
  382.             h.write("\n"..entreprises[i])
  383.         end
  384.         h.close()
  385.         membres = EntreReadMember(Entreprise)
  386.         h = fs.open("Banque/Entreprise/"..Entreprise.."/Membres","w")
  387.         for i = 1, #membres do
  388.             if membres[i] == Pseudo then
  389.             else
  390.                 h.write("\n"..membres[i])
  391.             end
  392.         end
  393.         h.close()
  394.  
  395.     end
  396. end
  397.  
  398. function EntreReadPermMember(Entreprise, Pseudo)
  399.     if fs.exists("Banque/Entreprise/"..infos.Entreprise) then
  400.         local Perm = {}
  401.         h = fs.open("Banque/Entreprise/"..Entreprise.."/Permissions/"..Pseudo,"r")
  402.         Perm = h.readAll()
  403.         h.close()
  404.         return textutils.unserialise(Perm)
  405.     end
  406. end
  407.  
  408. function isOp(pseudo)
  409.     if fs.exists("Banque/Compte/"..pseudo.."/Statut") then
  410.         local h = fs.open("Banque/Compte/"..pseudo.."/Statut","r")
  411.         local statut = h.readAll()
  412.         h.close()
  413.         if statut == "OP" then
  414.             return true
  415.         else
  416.             return false
  417.         end
  418.     end
  419. end
  420.  
  421. function compareMDP(pseudo, mdp)
  422.     if CompteExist(pseudo) then
  423.         local h =fs.open("Banque/Compte/"..pseudo.."/Solde","r")
  424.         nMdp = h.readAll()
  425.         h.close()
  426.         if mdp == nMdp then
  427.             return true
  428.         else
  429.             return false
  430.         end
  431.     end
  432. end
  433.  
  434. function GenKey(id,pseudo,somme,mdp)
  435.     if type(id) == "number" and type(pseudo) == "string" and type(somme) == "number" and type(mdp) == "string" and fs.exists("Banque/Compte/"..pseudo) and somme > 0 then
  436.         local h = fs.open("Banque/Compte/"..pseudo.."/Mdp","r")
  437.         local nMdp = h.readAll()
  438.         h.close()
  439.         if mdp == nMdp then
  440.             local lst = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  441.             local cle = ""
  442.             if not fs.exists("Banque/Compte/"..pseudo.."/Keys/") then
  443.                 fs.makeDir("Banque/Compte/"..pseudo.."/Keys/")
  444.             end
  445.             while true do
  446.                 cle = ""
  447.                 for i=1,10 do
  448.                     rnd = math.random(1,#lst)
  449.                     rnd = (rnd + os.day() + os.time() + os.clock())%#lst
  450.                     cle = cle..lst:sub(rnd,rnd)
  451.                 end
  452.                 if #fs.find("Banque/Compte/*/Keys/"..cle) == 0 then
  453.                     break
  454.                 end
  455.             end
  456.             local h = fs.open("Banque/Compte/"..pseudo.."/Keys/"..cle,"w")
  457.             h.write(somme)
  458.             h.close()
  459.             send(id, textutils.serialise({Act="KeyGen",Cle=cle}))
  460.         end
  461.     end
  462. end
  463.  
  464. function UseKey(id,pseudo,somme,cle)
  465.     if type(id) == "number" and type(pseudo) == "string" and type(somme) == "number" and type(cle) == "string" and fs.exists("Banque/Compte/"..pseudo) and somme > 0 then
  466.         local lien = fs.find("Banque/Compte/*/Keys/"..cle)
  467.         if #lien > 0 then
  468.             local compte = fs.getDir(fs.getDir(lien[1]))
  469.             if fs.getName(compte) ~= pseudo then
  470.                 local h = fs.open(compte.."/Solde","r")
  471.                 local soldeC = tonumber(h.readAll())
  472.                 h.close()
  473.                 h = fs.open("Banque/Compte/"..pseudo.."/Solde","r")
  474.                 local soldeD = tonumber(h.readAll())
  475.                 h.close()
  476.                 h = fs.open(lien[1],"r")
  477.                 local soldeK = tonumber(h.readAll())
  478.                 h.close()
  479.                 if soldeC >= somme and somme == soldeK then
  480.                     soldeD = soldeD + somme
  481.                     soldeC = soldeC - somme
  482.                     h = fs.open("Banque/Compte/"..pseudo.."/Solde","w")
  483.                     h.write(soldeD)
  484.                     h.close()
  485.                     h = fs.open(compte.."/Solde","w")
  486.                     h.write(soldeC)
  487.                     h.close()
  488.                     HistoriqueCW(pseudo,fs.getName(compte).."->"..pseudo..":"..infos.Somme..":UseKey")
  489.                     HistoriqueCW(fs.getName(compte),fs.getName(compte).."->"..pseudo..":"..infos.Somme..":UseKey")
  490.                     Succes("Somme transferé sur votre compte","MenuCle",id)
  491.                 else
  492.                     error("Somme incorrecte, supression de la cle","MenuCle",id)
  493.                 end
  494.                 fs.delete(lien[1])
  495.             else
  496.                 HistoriqueCW(pseudo,fs.getName(compte).."->"..pseudo..":"..infos.Somme..":UseKey")
  497.                 Succes("Somme transferé sur votre compte","MenuCle",id)
  498.             end
  499.         else
  500.             error("Cle inexistante","MenuCle",id)
  501.         end
  502.     elseif type(id) == "number" and type(pseudo) == "string" and type(somme) == "number" and type(cle) == "string" and fs.exists("Banque/Entreprise/"..pseudo) and somme > 0 then
  503.         local lien = fs.find("Banque/Compte/*/Keys/"..cle)
  504.         if #lien > 0 then
  505.             local compte = fs.getDir(fs.getDir(lien[1]))
  506.             local h = fs.open(compte.."/Solde","r")
  507.             local soldeC = tonumber(h.readAll())
  508.             h.close()
  509.             h = fs.open("Banque/Entreprise/"..pseudo.."/Solde","r")
  510.             local soldeD = tonumber(h.readAll())
  511.             h.close()
  512.             h = fs.open(lien[1],"r")
  513.             local soldeK = tonumber(h.readAll())
  514.             h.close()
  515.             if soldeC >= somme and somme == soldeK then
  516.                 soldeD = soldeD + somme
  517.                 soldeC = soldeC - somme
  518.                 h = fs.open("Banque/Entreprise/"..pseudo.."/Solde","w")
  519.                 h.write(soldeD)
  520.                 h.close()
  521.                 h = fs.open(compte.."/Solde","w")
  522.                 h.write(soldeC)
  523.                 h.close()
  524.                 EHistoriqueCW(pseudo,fs.getName(compte).."->"..pseudo..":"..infos.Somme..":UseKey")
  525.                 HistoriqueCW(fs.getName(compte),fs.getName(compte).."->"..pseudo..":"..infos.Somme..":UseKey")
  526.                 Succes("Somme transferé sur votre compte","MenuCle",id)
  527.             else
  528.                 error("Somme incorrecte, supression de la cle","MenuCle",id)
  529.             end
  530.             fs.delete(lien[1])
  531.         else
  532.             error("Cle inexistante","MenuCle",id)
  533.         end
  534.     else
  535.         error("Donnée invalides","MenuCle",id)
  536.     end
  537. end
  538.  
  539. function startup()
  540.     local ATMliste = ListeATM()
  541.     if ATMliste == nil then
  542.     else
  543.         for k, v in pairs(ATMliste) do
  544.             ATM[v+0]=true
  545.         end
  546.     end
  547.     if fs.exists("whitelist.json") then
  548.         whitelist = DecomposeJson("whitelist.json")
  549.         for i = 1, #whitelist do
  550.             CreateCompte(whitelist[i])
  551.         end
  552.     end
  553.     if fs.exists("ops.json") then
  554.         ops = DecomposeJson("ops.json")
  555.         for i = 1, #ops do
  556.             if fs.exists("Banque/Compte/"..ops[i]) then
  557.                 h = fs.open("Banque/Compte/"..ops[i].."/Statut","w")
  558.                 h.write("OP")
  559.                 h.close()
  560.             end
  561.         end
  562.     end
  563.     while true do
  564.         local CompteValide=false
  565.         id, message = NetSphere.receive()
  566.         print(id, message)
  567.             infos = textutils.unserialise(message)
  568.             if type(infos) == "nil" then
  569.             else
  570.                 if infos.Act == "Connection" then
  571.                     if fs.exists("Banque/Compte/"..infos.Pseudo.."/") then
  572.                         if fs.exists("Banque/Compte/"..infos.Pseudo.."/Mdp") then
  573.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/Mdp","r")
  574.                             local motdepasse = h.readAll()
  575.                             h.close()
  576.                             if infos.Mdp == motdepasse then
  577.                                 CompteValide=true
  578.                             else
  579.                                 CompteValide=false
  580.                             end
  581.                         else
  582.                             CompteValide=false
  583.                         end
  584.                     else
  585.                         CompteValide=false
  586.                     end
  587.                     if CompteValide == true then
  588.                         if fs.exists("Banque/Compte/"..infos.Pseudo.."/Solde") then
  589.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/Solde","r")
  590.                             sld = h.readAll()
  591.                             h.close()
  592.                         else
  593.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/Solde","w")
  594.                             h.write(1000)
  595.                             h.close()
  596.                             sld = 1000
  597.                         end
  598.                         if fs.exists("Banque/Compte/"..infos.Pseudo.."/Statut") then
  599.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/Statut","r")
  600.                             statut = h.readAll()
  601.                             h.close()
  602.                         else
  603.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/Statut","w")
  604.                             h.write("PLAYER")
  605.                             h.close()
  606.                             statut = "PLAYER"
  607.                         end
  608.                         histo = textutils.serialise(HistoriqueCR(infos.Pseudo))
  609.                         entp = textutils.serialise(EntrepriseCR(infos.Pseudo))
  610.                         Ninfo = {Act="CompteValide",Solde=sld,Historique=histo,Entreprises=entp,Statut=statut}
  611.                         Ninfos = textutils.serialise(Ninfo)
  612.                         send(id, Ninfos)
  613.                         IDConnecter[infos.Pseudo] = id
  614.                     else
  615.                         Ninfo = {Act="CompteNValide"}
  616.                         Ninfos = textutils.serialise(Ninfo)
  617.                         send(id, Ninfos)
  618.                     end
  619.                 elseif infos.Act == "GenKey" then
  620.                     GenKey(id,infos.psd,infos.Somme,infos.mdp)
  621.                 elseif infos.Act == "UseKey" then
  622.                     UseKey(id,infos.psd,infos.Somme,infos.Cle)
  623.                 elseif infos.Act == "ModifMdpPlayer" then
  624.                     if fs.exists("Banque/Compte/"..infos.Pseudo) then
  625.                         h = fs.open("Banque/Compte/"..infos.Pseudo.."/Mdp","r")
  626.                         AncienMdp = h.readAll()
  627.                         h.close()
  628.                         if AncienMdp == infos.AncienMdp then
  629.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/Mdp","w")
  630.                             h.write(infos.NouveauMdp)
  631.                             h.close()
  632.                             Ninfo = {Act="NvmdpOk"}
  633.                             Ninfos = textutils.serialise(Ninfo)
  634.                             send(id, Ninfos)
  635.                         else
  636.                             Ninfo = {Act="AncMdpInco"}
  637.                             Ninfos = textutils.serialise(Ninfo)
  638.                             send(id, Ninfos)
  639.                         end
  640.                     end
  641.                 elseif infos.Act == "RecupHistorique" then
  642.                     if CompteExist(infos.Pseudo) then
  643.                         if fs.exists("Banque/Compte/"..infos.Pseudo.."/HistoriqueSave") then
  644.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/HistoriqueSave","r")
  645.                             hst = h.readAll()
  646.                             h.close()
  647.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/Historique","w")
  648.                             h.write(hst)
  649.                             h.close()
  650.                             ActualiserC(infos.Pseudo,id)
  651.                         end
  652.                     end
  653.                 elseif infos.Act == "AddMemberConnection" then
  654.                     if fs.exists("Banque/Entreprise/"..infos.Entreprise) then
  655.                         Membres = EntreReadMember(infos.Entreprise)
  656.                         admit = false
  657.                         for i = 1, #Membres do
  658.                             if infos.Demandeur == Membres[i] then
  659.                                 admit = true
  660.                             end
  661.                         end
  662.  
  663.                         if admit == true then
  664.                             nMembres = textutils.serialise(EntreReadMember(infos.Entreprise))
  665.                              Ninfo = {Act="AddMemberConnecAut",membres=nMembres}
  666.                              Ninfos = textutils.serialise(Ninfo)
  667.                              send(id, Ninfos)
  668.                          else
  669.                              error("Vous ne faite pas parti de l'entreprise !","MenuEntreprise",id)
  670.                          end
  671.                     else
  672.                         Ninfo = {Act="EntrepriseNExist"}
  673.                          Ninfos = textutils.serialise(Ninfo)
  674.                          send(id, Ninfos)
  675.                     end
  676.                 elseif infos.Act == "AddMember" then
  677.                     if fs.exists("Banque/Entreprise/"..infos.Entreprise) then
  678.                          if fs.exists("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.Demandeur) then
  679.                              h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.Demandeur,"r")
  680.                              nTableB = h.readAll()
  681.                              h.close()
  682.                              nTable = textutils.unserialise(nTableB)
  683.                              nMembres = EntreReadMember(infos.Entreprise)
  684.                              local dejaMit = false
  685.                             for i = 1, #nMembres do
  686.                                 if nMembres[i] == infos.pseudo then
  687.                                     dejaMit = true
  688.                                 end
  689.                             end
  690.                             if dejaMit == false then
  691.                                  if nTable["AddMembre"] == true then
  692.                                      if fs.exists("Banque/Compte/"..infos.pseudo) then
  693.                                          EntrepriseAddMembre(infos.Entreprise,infos.pseudo)
  694.                                          nMembres = EntreReadMember(infos.Entreprise)
  695.                                          Ninfo = {Act="AddMemberConnecAut",membres=textutils.serialise(nMembres)}
  696.                                          Ninfos = textutils.serialise(Ninfo)
  697.                                          send(id, Ninfos)
  698.                                      else
  699.                                          Ninfo = {Act="CompteNExist"}
  700.                                          Ninfos = textutils.serialise(Ninfo)
  701.                                          send(id, Ninfos)
  702.                                     end
  703.                                  else
  704.                                      Ninfo = {Act="AddMemberConnecRef"}
  705.                                      Ninfos = textutils.serialise(Ninfo)
  706.                                      send(id, Ninfos)
  707.                                  end
  708.                              end
  709.                         end
  710.                     else
  711.                         Ninfo = {Act="EntrepriseNExist"}
  712.                          Ninfos = textutils.serialise(Ninfo)
  713.                          send(id, Ninfos)
  714.                     end
  715.                 elseif infos.Act == "ReplyPerm" then
  716.                     if fs.exists("Banque/Entreprise/"..infos.Entreprise) then
  717.                          if fs.exists("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.pseudo) then
  718.                              h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.pseudo,"w")
  719.                             h.write(infos.permissions)
  720.                              h.close()
  721.                          end
  722.                     end
  723.                 elseif infos.Act == "PermMember" then
  724.                     if fs.exists("Banque/Entreprise/"..infos.Entreprise) then
  725.                          if fs.exists("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.Demandeur) then
  726.                              h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.Demandeur,"r")
  727.                              nTableB = h.readAll()
  728.                              h.close()
  729.                              nTable = textutils.unserialise(nTableB)
  730.                              if nTable["ModifPerm"] == true then
  731.                                  if fs.exists("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.pseudo) then
  732.                                      h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.pseudo,"r")
  733.                                      perm = h.readAll()
  734.                                      h.close()
  735.                                      Ninfo = {Act="PermEdit",permissions=perm,pseudo=infos.pseudo,entrep=infos.Entreprise}
  736.                                      Ninfos = textutils.serialise(Ninfo)
  737.                                      send(id, Ninfos)
  738.                                  else
  739.                                      Ninfo = {Act="CompteNExist"}
  740.                                      Ninfos = textutils.serialise(Ninfo)
  741.                                      send(id, Ninfos)
  742.                                 end
  743.                              else
  744.                                  Ninfo = {Act="PermMemberConnecRef"}
  745.                                  Ninfos = textutils.serialise(Ninfo)
  746.                                  send(id, Ninfos)
  747.  
  748.                              end
  749.                         end
  750.                     else
  751.                         Ninfo = {Act="EntrepriseNExist"}
  752.                          Ninfos = textutils.serialise(Ninfo)
  753.                          send(id, Ninfos)
  754.                     end
  755.                 elseif infos.Act == "DelMember" then
  756.                     if fs.exists("Banque/Entreprise/"..infos.Entreprise) then
  757.                          if fs.exists("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.Demandeur) then
  758.                             if infos.pseudo == infos.Demandeur then
  759.                                 Ninfo = {Act="DelMemberImpossible"}
  760.                                  Ninfos = textutils.serialise(Ninfo)
  761.                                  send(id, Ninfos)
  762.  
  763.                             else
  764.                                 h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.Demandeur,"r")
  765.                                  nTableB = h.readAll()
  766.                                  h.close()
  767.                                  nTable = textutils.unserialise(nTableB)
  768.                                  if nTable["DeleteMembre"] == true then
  769.                                      if fs.exists("Banque/Compte/"..infos.pseudo) then
  770.                                          DeleteEntrepPlayer(infos.Entreprise,infos.pseudo)
  771.                                          nMembres = EntreReadMember(infos.Entreprise)
  772.                                          Ninfo = {Act="AddMemberConnecAut",membres=textutils.serialise(nMembres)}
  773.                                          Ninfos = textutils.serialise(Ninfo)
  774.                                          send(id, Ninfos)
  775.                                      else
  776.                                          Ninfo = {Act="CompteNExist"}
  777.                                          Ninfos = textutils.serialise(Ninfo)
  778.                                          send(id, Ninfos)
  779.                                     end
  780.                                  else
  781.                                      Ninfo = {Act="DelMemberConnecRef"}
  782.                                      Ninfos = textutils.serialise(Ninfo)
  783.                                      send(id, Ninfos)
  784.  
  785.                                  end
  786.                              end
  787.                         end
  788.                     else
  789.                         Ninfo = {Act="EntrepriseNExist"}
  790.                          Ninfos = textutils.serialise(Ninfo)
  791.                          send(id, Ninfos)
  792.                     end
  793.                 elseif infos.Act == "SupprEntreprise" then
  794.                     if fs.exists("Banque/Entreprise/"..infos.Entreprise) then
  795.                          if fs.exists("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.Demandeur) then
  796.                              h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.Demandeur,"r")
  797.                              nTableB = h.readAll()
  798.                              h.close()
  799.                              nTable = textutils.unserialise(nTableB)
  800.                              if nTable["DeleteEntrep"] == true then
  801.                                  Membres = EntreReadMember(infos.Entreprise)
  802.                                 for i = 1, #Membres do
  803.                                     h = fs.open("Banque/Compte/"..Membres[i].."/Solde","r")
  804.                                     solde =  h.readAll()
  805.                                     h.close()
  806.                                     h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Solde","r")
  807.                                     soldeE = h.readAll()
  808.                                     h.close()
  809.                                     solde = solde + (soldeE/#Membres)
  810.                                     h = fs.open("Banque/Compte/"..Membres[i].."/Solde","w")
  811.                                     h.write(solde)
  812.                                     h.close()
  813.                                     DeleteEntrepPlayer(infos.Entreprise,Membres[i])
  814.                                 end
  815.                                 fs.delete("Banque/Entreprise/"..infos.Entreprise)
  816.                                 ActualiserC(infos.Demandeur, id)
  817.                              else
  818.                                  Ninfo = {Act="DeleteEntrepRef"}
  819.                                  Ninfos = textutils.serialise(Ninfo)
  820.                                  send(id, Ninfos)
  821.                              end
  822.                          else
  823.                              Ninfo = {Act="DeleteEntrepRef"}
  824.                              Ninfos = textutils.serialise(Ninfo)
  825.                              send(id, Ninfos)
  826.                         end
  827.                     else
  828.                         Ninfo = {Act="EntrepriseNExist"}
  829.                          Ninfos = textutils.serialise(Ninfo)
  830.                          send(id, Ninfos)
  831.                     end
  832.                 elseif infos.Act == "CreeEntreprise" then
  833.                     if fs.exists("Banque/Entreprise/"..infos.Nom) then
  834.                         Ninfo = {Act="ErreurCreeEntreprise"}
  835.                         Ninfos = textutils.serialise(Ninfo)
  836.                         send(id, Ninfos)
  837.                     else
  838.                         h = fs.open("Banque/Entreprise/"..infos.Nom.."/Solde","w")
  839.                         h.write(0)
  840.                         h.close()
  841.                         h = fs.open("Banque/Entreprise/"..infos.Nom.."/Historique","w")
  842.                         h.write("")
  843.                         h.close()
  844.                         h = fs.open("Banque/Entreprise/"..infos.Nom.."/Permissions/"..infos.Proprio,"w")
  845.                         nTable = {ModifPerm=true,Depos=true,Retrait=true,AddMembre=true,DeleteEntrep=true,DeleteMembre=true}
  846.                         h.write(textutils.serialise(nTable))
  847.                         h.close()
  848.                         h = fs.open("Banque/Entreprise/"..infos.Nom.."/Membres","w")
  849.                         h.write(infos.Proprio)
  850.                         h.close()
  851.                         h = fs.open("Banque/Compte/"..infos.Proprio.."/Entreprises","a")
  852.                         h.write("\n"..infos.Nom)
  853.                         h.close()
  854.  
  855.                         ActualiserC(infos.Proprio, id)
  856.                     end
  857.                 elseif infos.Act == "EntrepriseTransfers" then
  858.                     if fs.exists("Banque/Entreprise/"..infos.Entreprise) then
  859.                         Membres = EntreReadMember(infos.Entreprise)
  860.                         admit = false
  861.                         for i = 1, #Membres do
  862.                             if infos.Demandeur == Membres[i] then
  863.                                 admit = true
  864.                             end
  865.                         end
  866.  
  867.                         if admit == true then
  868.                             h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Solde","r")
  869.                             solde = h.readAll()
  870.                             h.close()
  871.                             histo = EHistoriqueCR(infos.Entreprise)
  872.                             Ninfo = {Act="TransferConnecAut",Solde=solde,Historique=histo}
  873.                             Ninfos = textutils.serialise(Ninfo)
  874.                             send(id, Ninfos)
  875.                         end
  876.                     end
  877.                 elseif infos.Act == "RetraitToEntreprise" then
  878.                     if infos.Somme > 0 then
  879.                         if fs.exists("Banque/Compte/"..infos.Proprio.."/Solde") then
  880.                             if fs.exists("Banque/Entreprise/"..infos.Entreprise.."/Solde") then
  881.  
  882.                                  h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.Proprio,"r")
  883.                                  nTableB = h.readAll()
  884.                                  h.close()
  885.                                  nTable = textutils.unserialise(nTableB)
  886.                                  if nTable["Retrait"] == true then
  887.                                     h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Solde","r")
  888.                                     soldeP = h.readAll()
  889.                                     h.close()
  890.                                     if infos.Somme+0 <= soldeP+0 then
  891.                                         h = fs.open("Banque/Compte/"..infos.Proprio.."/Solde","r")
  892.                                         soldeD = h.readAll()
  893.                                         h.close()
  894.  
  895.                                         soldeP = soldeP - infos.Somme
  896.                                         soldeD = soldeD + infos.Somme
  897.  
  898.                                         h = fs.open("Banque/Compte/"..infos.Proprio.."/Solde","w")
  899.                                         h.write(soldeD)
  900.                                         h.close()
  901.  
  902.                                         h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Solde","w")
  903.                                         h.write(soldeP)
  904.                                         h.close()
  905.  
  906.                                         HistoriqueCW(infos.Proprio,infos.Entreprise.."->"..infos.Proprio..":"..infos.Somme..":V")
  907.                                         EHistoriqueCW(infos.Entreprise,infos.Entreprise.."->"..infos.Proprio..":"..infos.Somme..":V")
  908.  
  909.  
  910.                                         ActualiserC(infos.Proprio,id)
  911.                                         ActualiserE(infos.Entreprise,id)
  912.                                         if IDConnecter[infos.Entreprise] == nil then
  913.                                         else
  914.                                             ActualiserC(infos.Entreprise,IDConnecter[infos.Entreprise]+0)
  915.                                         end
  916.                                     end
  917.                                  else
  918.                                      Ninfo = {Act="RetraitEntrepRef"}
  919.                                      Ninfos = textutils.serialise(Ninfo)
  920.                                      send(id, Ninfos)
  921.                                  end
  922.  
  923.                             else
  924.                                 EHistoriqueCW(infos.Proprio,infos.Entreprise.."->"..infos.Proprio..":"..infos.Somme..":X")
  925.                                 ActualiserE(infos.Entreprise, id)
  926.                             end
  927.                         end
  928.                     end
  929.                 elseif infos.Act == "setPLAYER" then
  930.                     if fs.exists("Banque/Compte/"..infos.Pseudo) then
  931.                         if infos.Pseudo == "" then
  932.                             error("Compte Inexistant !","MenuOP",id)
  933.                         else
  934.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/Statut","w")
  935.                             h.write("PLAYER")
  936.                             h.close()
  937.                             Succes("Compte mit PLAYER","MenuOP",id)
  938.                         end
  939.                     else
  940.                         error("Compte Inexistant !", "MenuOP",id)
  941.                     end
  942.                 elseif infos.Act == "setOP" then
  943.                     if fs.exists("Banque/Compte/"..infos.Pseudo) then
  944.                         if infos.Pseudo == "" then
  945.                             error("Compte Inexistant !","MenuOP",id)
  946.                         else
  947.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/Statut","w")
  948.                             h.write("OP")
  949.                             h.close()
  950.                             Succes("Compte mit OP","MenuOP",id)
  951.                         end
  952.                     else
  953.                         error("Compte Inexistant !","MenuOP",id)
  954.                     end
  955.  
  956.                 elseif infos.Act == "ChangerMdp" then
  957.                     if fs.exists("Banque/Compte/"..infos.Pseudo) then
  958.                         h = fs.open("Banque/Compte/"..infos.Pseudo.."/Mdp","w")
  959.                         h.write(infos.Mdp)
  960.                         h.close()
  961.                         Succes("Mot de passe modifié","MenuOP",id)
  962.                     else
  963.                         error("Compte Inexistant !","MenuOP",id)
  964.                     end
  965.                 elseif infos.Act == "ListeComptes" then
  966.                     Liste = ListeCompte()
  967.                     Ninfo = {Act="ListeComptesTab",Liste=Liste,ListeEnt=ListeEntreprise()}
  968.                     Ninfos = textutils.serialise(Ninfo)
  969.                     send(id, Ninfos)
  970.                 elseif infos.Act == "ListeComptesD" then
  971.                     Liste = ListeCompte()
  972.                     fs.delete("ListeCompte")
  973.                     h = fs.open("ListeCompte","w")
  974.                     for i =1, #Liste do
  975.                         h.write(Liste[i].."\n")
  976.                     end
  977.                     h.close()
  978.                     h = fs.open("ListeCompte","r")
  979.                     lst = h.readAll()
  980.                     h.close()
  981.                     Ninfo = {Act="ListesDComptes",Liste=lst}
  982.                     Ninfos = textutils.serialise(Ninfo)
  983.                     send(id, Ninfos)
  984.                 elseif infos.Act == "StealPercent" then
  985.  
  986.  
  987.                     ComptesR = ListeCompte()
  988.                     for i=1, #ComptesR do
  989.                         if fs.exists("Banque/Compte/"..ComptesR[i].."/Solde") then
  990.                             h = fs.open("Banque/Compte/"..ComptesR[i].."/Solde","r")
  991.                             solde =  h.readAll()
  992.                             h.close()
  993.                             pourcent = infos.Pourcent * solde / 100
  994.                             solde = solde - pourcent
  995.                             h = fs.open("Banque/Compte/"..ComptesR[i].."/Solde","w")
  996.                             h.write(solde)
  997.                             h.close()
  998.                         end
  999.                     end
  1000.                     Succes("Pourcentage retiré a *","MenuOP",id)
  1001.                 elseif infos.Act == "AddPercent" then
  1002.  
  1003.  
  1004.                     ComptesR = ListeCompte()
  1005.                     for i=1, #ComptesR do
  1006.                         if fs.exists("Banque/Compte/"..ComptesR[i].."/Solde") then
  1007.                             h = fs.open("Banque/Compte/"..ComptesR[i].."/Solde","r")
  1008.                             solde =  h.readAll()
  1009.                             h.close()
  1010.                             pourcent = infos.Pourcent * solde / 100
  1011.                             solde = solde + pourcent
  1012.                             h = fs.open("Banque/Compte/"..ComptesR[i].."/Solde","w")
  1013.                             h.write(solde)
  1014.                             h.close()
  1015.                         end
  1016.                     end
  1017.                     Succes("Pourcentage ajouté a *","MenuOP",id)
  1018.                 elseif infos.Act == "AddATM" then
  1019.                     AddATM(infos.ATMID.."")
  1020.                     Succes("ID ATM Ajouté","MenuOP",id)
  1021.                 elseif infos.Act == "DelATM" then
  1022.                     DelATM(infos.ATMID.."")
  1023.                     Succes("ID ATM Retiré","MenuOP",id)
  1024.                 elseif infos.Act == "StealMonney" then
  1025.                     if fs.exists("Banque/Compte/"..infos.Pseudo.."/Solde") then
  1026.                         h = fs.open("Banque/Compte/"..infos.Pseudo.."/Solde","r")
  1027.                         solde = h.readAll()
  1028.                         h.close()
  1029.                         solde = solde - infos.Somme
  1030.                         h = fs.open("Banque/Compte/"..infos.Pseudo.."/Solde","w")
  1031.                         h.write(solde)
  1032.                         h.close()
  1033.                         Succes("Compte Débité","MenuOP",id)
  1034.                     else
  1035.                         error("Compte Inexistant !","MenuOP",id)
  1036.                     end
  1037.                 elseif infos.Act == "AddMonney" then
  1038.                     if fs.exists("Banque/Compte/"..infos.Pseudo.."/Solde") then
  1039.                         h = fs.open("Banque/Compte/"..infos.Pseudo.."/Solde","r")
  1040.                         solde =  h.readAll()
  1041.                         h.close()
  1042.                         solde = solde + infos.Somme
  1043.                         h = fs.open("Banque/Compte/"..infos.Pseudo.."/Solde","w")
  1044.                         h.write(solde)
  1045.                         h.close()
  1046.                         Succes("Compte Créditer","MenuOP",id)
  1047.                     else
  1048.                         error("Compte Inexistant !","MenuOP",id)
  1049.                     end
  1050.                 elseif infos.Act == "DelCompte" then
  1051.                     if CompteExist(infos.Pseudo) then
  1052.                         if infos.Pseudo == "" then
  1053.                             error("Compte Inexistant !","MenuOP",id)
  1054.                         else
  1055.                             DeleteCompte(infos.Pseudo)
  1056.                             for nPseudo, nID in pairs(IDConnecter) do
  1057.                                 Liste = ListeCompte()
  1058.                                 Ninfo = {Act="ListeComptesTab",Liste=Liste,ListeEnt=ListeEntreprise()}
  1059.                                 Ninfos = textutils.serialise(Ninfo)
  1060.                                 send(nID, Ninfos)
  1061.                             end
  1062.                             Succes("Compte supprimé !","MenuOP",id)
  1063.                         end
  1064.                     else
  1065.                         error("Compte Inexistant !","MenuOP",id)
  1066.                     end
  1067.                 elseif infos.Act == "CreeCompte" then
  1068.                     if CompteExist(infos.Pseudo) == false then
  1069.                         CreateCompte(infos.Pseudo)
  1070.                         for nPseudo, nID in pairs(IDConnecter) do
  1071.                             Liste = ListeCompte()
  1072.                             Ninfo = {Act="ListeComptesTab",Liste=Liste,ListeEnt=ListeEntreprise()}
  1073.                             Ninfos = textutils.serialise(Ninfo)
  1074.                             send(nID, Ninfos)
  1075.                         end
  1076.                         Succes("Compte Crée !","MenuOP",id)
  1077.                     else
  1078.                         error("Compte déja existant !","MenuOP",id)
  1079.                     end
  1080.  
  1081.                 elseif infos.Act == "TransferToEntreprise" then
  1082.  
  1083.                     if infos.Somme > 0 then
  1084.                         if fs.exists("Banque/Compte/"..infos.Proprio.."/Solde") then
  1085.                             if fs.exists("Banque/Entreprise/"..infos.Entreprise.."/Solde") then
  1086.                                 Membres = EntreReadMember(infos.Entreprise)
  1087.                                 admit = false
  1088.                                 for i = 1, #Membres do
  1089.                                     if infos.Proprio == Membres[i] then
  1090.                                         admit = true
  1091.                                     end
  1092.                                 end
  1093.                                 if admit == true then
  1094.                                     h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Permissions/"..infos.Proprio,"r")
  1095.                                      nTableB = h.readAll()
  1096.                                      h.close()
  1097.                                      nTable = textutils.unserialise(nTableB)
  1098.                                      if nTable["Depos"] == true then
  1099.                                         h = fs.open("Banque/Compte/"..infos.Proprio.."/Solde","r")
  1100.                                         soldeP = h.readAll()
  1101.                                         h.close()
  1102.                                         if infos.Somme+0 <= soldeP+0 then
  1103.                                             h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Solde","r")
  1104.                                             soldeD = h.readAll()
  1105.                                             h.close()
  1106.  
  1107.                                             soldeP = soldeP - infos.Somme
  1108.                                             soldeD = soldeD + infos.Somme
  1109.  
  1110.                                             h = fs.open("Banque/Compte/"..infos.Proprio.."/Solde","w")
  1111.                                             h.write(soldeP)
  1112.                                             h.close()
  1113.  
  1114.                                             h = fs.open("Banque/Entreprise/"..infos.Entreprise.."/Solde","w")
  1115.                                             h.write(soldeD)
  1116.                                             h.close()
  1117.  
  1118.                                             HistoriqueCW(infos.Proprio,infos.Proprio.."->"..infos.Entreprise..":"..infos.Somme..":V")
  1119.                                             EHistoriqueCW(infos.Entreprise,infos.Proprio.."->"..infos.Entreprise..":"..infos.Somme..":V")
  1120.  
  1121.  
  1122.                                             ActualiserC(infos.Proprio,id)
  1123.                                             ActualiserE(infos.Entreprise,id)
  1124.                                             if IDConnecter[infos.Entreprise] == nil then
  1125.                                             else
  1126.                                                 ActualiserC(infos.Entreprise,IDConnecter[infos.Entreprise]+0)
  1127.                                             end
  1128.                                         end
  1129.                                      else
  1130.                                          Ninfo = {Act="DeposEntrepRef"}
  1131.                                          Ninfos = textutils.serialise(Ninfo)
  1132.                                          send(id, Ninfos)
  1133.                                      end
  1134.  
  1135.                                 else
  1136.                                     EHistoriqueCW(infos.Proprio,infos.Proprio.."->"..infos.Entreprise..":"..infos.Somme..":X")
  1137.                                     ActualiserE(infos.Entreprise, id)
  1138.                                 end
  1139.                             else
  1140.                             end
  1141.                         end
  1142.                     end
  1143.                 elseif infos.Act == "RecupHisto" then
  1144.                     if CompteExist(infos.Pseudo) then
  1145.                         if fs.exists("Banque/Compte/"..infos.Pseudo.."/HistoriqueSave") then
  1146.                             h = fs.open("Banque/Compte/"..infos.Pseudo.."/HistoriqueSave","r")
  1147.                             hst = h.readAll()
  1148.                             h.close()
  1149.                             Ninfo = {Act="ReplyHisto",Historique=hst}
  1150.                             Ninfos = textutils.serialise(Ninfo)
  1151.                             send(id, Ninfos)
  1152.                         end
  1153.                     else
  1154.                         error("Compte Inexistant !","MenuOP",id)
  1155.                     end
  1156.                 elseif infos.Act == "Transfer" then
  1157.                     if infos.Somme > 0 then
  1158.                         if fs.exists("Banque/Compte/"..infos.Proprio.."/Solde") then
  1159.                             if fs.exists("Banque/Compte/"..infos.Destinataire.."/Solde") then
  1160.                                 if infos.Proprio == infos.Destinataire then
  1161.                                 else
  1162.                                     h = fs.open("Banque/Compte/"..infos.Proprio.."/Solde","r")
  1163.                                     soldeP = h.readAll()
  1164.                                     h.close()
  1165.                                     if infos.Somme+0 <= soldeP+0 then
  1166.                                         h = fs.open("Banque/Compte/"..infos.Destinataire.."/Solde","r")
  1167.                                         soldeD = h.readAll()
  1168.                                         h.close()
  1169.  
  1170.                                         soldeP = soldeP - infos.Somme
  1171.                                         soldeD = soldeD + infos.Somme
  1172.  
  1173.                                         h = fs.open("Banque/Compte/"..infos.Proprio.."/Solde","w")
  1174.                                         h.write(soldeP)
  1175.                                         h.close()
  1176.  
  1177.                                         h = fs.open("Banque/Compte/"..infos.Destinataire.."/Solde","w")
  1178.                                         h.write(soldeD)
  1179.                                         h.close()
  1180.  
  1181.                                         HistoriqueCW(infos.Proprio,infos.Proprio.."->"..infos.Destinataire..":"..infos.Somme..":V")
  1182.                                         HistoriqueCW(infos.Destinataire,infos.Proprio.."->"..infos.Destinataire..":"..infos.Somme..":V")
  1183.  
  1184.  
  1185.                                         ActualiserC(infos.Proprio,id)
  1186.  
  1187.                                         if IDConnecter[infos.Destinataire] == nil then
  1188.                                         else
  1189.                                             ActualiserC(infos.Destinataire,IDConnecter[infos.Destinataire]+0)
  1190.                                         end
  1191.                                     end
  1192.                                 end
  1193.                             elseif fs.exists("Banque/Entreprise/"..infos.Destinataire.."/Solde") then
  1194.                                     h = fs.open("Banque/Compte/"..infos.Proprio.."/Solde","r")
  1195.                                     soldeP = h.readAll()
  1196.                                     h.close()
  1197.                                     if infos.Somme+0 <= soldeP+0 then
  1198.                                         h = fs.open("Banque/Entreprise/"..infos.Destinataire.."/Solde","r")
  1199.                                         soldeD = h.readAll()
  1200.                                         h.close()
  1201.  
  1202.                                         soldeP = soldeP - infos.Somme
  1203.                                         soldeD = soldeD + infos.Somme
  1204.  
  1205.                                         h = fs.open("Banque/Compte/"..infos.Proprio.."/Solde","w")
  1206.                                         h.write(soldeP)
  1207.                                         h.close()
  1208.  
  1209.                                         h = fs.open("Banque/Entreprise/"..infos.Destinataire.."/Solde","w")
  1210.                                         h.write(soldeD)
  1211.                                         h.close()
  1212.  
  1213.                                         HistoriqueCW(infos.Proprio,infos.Proprio.."->"..infos.Destinataire..":"..infos.Somme..":V")
  1214.  
  1215.                                         ActualiserC(infos.Proprio,id)
  1216.  
  1217.                                         if IDConnecter[infos.Destinataire] == nil then
  1218.                                         else
  1219.                                             ActualiserC(infos.Destinataire,IDConnecter[infos.Destinataire]+0)
  1220.                                         end
  1221.                                     end
  1222.                             else
  1223.                                 HistoriqueCW(infos.Proprio,infos.Proprio.."->"..infos.Destinataire..":"..infos.Somme..":X")
  1224.                                 ActualiserC(infos.Proprio, id)
  1225.                             end
  1226.                         end
  1227.                     end
  1228.                 elseif infos.Act == "ActualiserC" then
  1229.                     ActualiserC(infos.Proprio, id)
  1230.                 elseif infos.Act == "ActualiserE" then
  1231.                     ActualiserE(infos.Entreprise, id)
  1232.                 elseif infos.Act == "EffHistorique" then
  1233.                     EffHistorique(infos.Pseudo)
  1234.                     ActualiserC(infos.Pseudo, id)
  1235.                 elseif infos.Act == "Deconnection" then
  1236.                     local nTempo = {}
  1237.                     for pseudo, IDn in pairs(IDConnecter) do
  1238.                         if IDn == id then
  1239.                             nTempo[#nTempo+1] = pseudo
  1240.                         end
  1241.                     end
  1242.                     for i=1,#nTempo do
  1243.                         IDConnecter[nTempo[i]]= nil
  1244.                     end
  1245.                 end
  1246.             end
  1247.         end
  1248. end
  1249.  
  1250. function diskEject()
  1251.     while true do
  1252.         event, side = os.pullEvent("disk")
  1253.         disk.eject(side)
  1254.     end
  1255. end
  1256.  
  1257. parallel.waitForAll(startup,diskEject,HaveAModem)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement