BananeMan

Untitled

Sep 15th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 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(ronda)
  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. print("Ecoute activée !")
  69. while true do
  70. local senderid, mess, proto = rondanet.receive("superproto")
  71. print("[BANQUE]", "[SenderID]:",senderid,"[Message]:", mess)
  72. local table = textutils.unserialize(mess)
  73. if table.action == "login" then
  74. local user = table.User
  75. local pass = table.Pass
  76. if fs.exists("/files/users/"..user) then
  77. local file fs.open("/files/users/"..user, "r")
  78.  
  79. local id = file.readLine()
  80. local pseudo = file.readLine()
  81. local mot = file.readLine()
  82. local argent = file.readLine()
  83. local historique = file.readLine()
  84. local entreprise = file.readLine()
  85. file.close()
  86. if user == pseudo and mot == pass then
  87. local table = {action = "login", response = "yes"}
  88. rondanet.send(senderid, table)
  89. else
  90. local table = {action = "login", response = "no"}
  91. rondanet.send(senderid, table)
  92. end
  93. else
  94. print("Pas implementer", table.action)
  95. end
  96. end
  97. end
  98. rondanet.close()
  99. end
  100.  
  101. function shell2()
  102. shell.openTab("shell")
  103. end
  104.  
  105. function acces()
  106. end
  107.  
  108. function idre()
  109. while true do
  110. if rondanet.isOpen("left") then
  111. print("Host has opened")
  112. rondanet.host("babanque", "server")
  113. else
  114. sleep(5)
  115. end
  116. end
  117. end
  118.  
  119. parallel.waitForAll(startup, shell2)
Add Comment
Please, Sign In to add comment