BananeMan

Untitled

Sep 15th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. --*****************************--
  2. --********BANQUE SERVEUR*******--
  3. --*****************************--
  4.  
  5. --Décalaration de variable
  6.  
  7. local checkstartup = false
  8. local checkfiles = false
  9. local checkshell2 = false
  10. local filesnumb = 0
  11. fileserror = 0
  12. local id = os.getComputerID()
  13. local st = ""
  14. local ver = "0.0.1"
  15. local string = ""
  16.  
  17. local usersf = "/files/users/"
  18. local adminsf = "/files/admins.txt"
  19. local atmsf = "/files/atms.txt"
  20. local ronda = "/libs/rondanet"
  21. --Fin de décalaration de variable
  22.  
  23. function startup()
  24. print("Démarage du serveur")
  25. print("Id de l'ordinateur:", id)
  26. print("Version: "..ver)
  27. print("Vérification des fichiers utilisateur")
  28. verif(usersf)
  29. verif(adminsf)
  30. verif("/libs/crypto")
  31. verif(atmsf)
  32. verif(ronda)
  33. if fileserror == 0 then
  34. print(filesnumb, "fichiers on été vérifier")
  35. else
  36. print(fileserror, "fichiers on n'on pas été vérifier !")
  37. sleep(2)
  38. os.shutdown()
  39. end
  40.  
  41. print("\n\n\n")
  42. print("Ouverture de rondanet")
  43. os.loadAPI("/libs/rondanet")
  44. rondanet.open("front")
  45. print("Fin du startup")
  46. parallel.waitForAll(redne, idre)
  47. end
  48.  
  49. function verif(var)
  50. if fs.exists(var) then
  51. print(var.." existant")
  52. filesnumb = filesnumb + 1
  53. else
  54. print(var.." n'existe pas !")
  55. fileserror = fileserror + 1
  56. sleep(10)
  57. os.shutdown()
  58. end
  59. end
  60.  
  61. function files(string)
  62. local response
  63.  
  64. return(response)
  65. end
  66.  
  67. function redne()
  68. while true do
  69. local senderid, mess, proto = rondanet.receive("superproto")
  70. print("[BANQUE]", "[SenderID]:"senderid,"[Message]:" mess)
  71. local table = textutils.unserialize(mess)
  72. if table.action == "login" then
  73. local user = table.User
  74. local pass = table.Pass
  75. if fs.exists("/files/users/"..user) then
  76. local file fs.open("/files/users/"..user, "r")
  77.  
  78. local id = file.readLine()
  79. local pseudo = file.readLine()
  80. local mot = file.readLine()
  81. local argent = file.readLine()
  82. local historique = file.readLine()
  83. local entreprise = file.readLine()
  84. file.close()
  85. if user == pseudo and mot == pass then
  86. local table = {action = "login", response = "yes"}
  87. rondanet.send(senderid, table)
  88. else
  89. local table = {action = "login", response = "no"}
  90. rondanet.send(senderid, table)
  91. end
  92. else
  93. print("Pas implementer", table.action)
  94. end
  95. end
  96. end
  97. rondanet.close()
  98. end
  99.  
  100. function shell2()
  101. shell.openTab("shell")
  102. end
  103.  
  104. function acces()
  105. end
  106.  
  107. function idre()
  108. while true do
  109. if rondanet.isOpen("top") then
  110. rondanet.host("babanque", "server")
  111. else
  112. sleep(5)
  113. end
  114. end
  115.  
  116. parallel.waitForAll(startup, shell2)
Add Comment
Please, Sign In to add comment