Advertisement
pepeknamornik

BOOT

Jun 19th, 2019 (edited)
10,696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 27.29 KB | None | 0 0
  1. verze = "24.0914.R1"
  2. shell.exit()
  3. shell.run( "set shell.allow_disk_startup false" )
  4. shell.setPath(shell.path() .. ":/C/system/api/")
  5. shell.setPath(shell.path() .. ":/C/system/.core/desktop.lua")
  6.  
  7. if fs.exists("/C/system/.core/logon") then --docasna oprava chyby prihlaseni
  8. fs.delete("/C/system/.core/logon")
  9. end
  10.  
  11. local tArgs = { ... }
  12. local w,h = term.getSize()
  13. local ADC = false
  14. local localAD = false
  15. local displayload = false
  16. local idPC = os.getComputerID()
  17. local anim = 0.1
  18. local edice = "Standard"
  19. local sound = false
  20. local modem = nil
  21. local pass = ""
  22.  
  23. logoPD = {
  24. " bbbbbbb 888888 ",
  25. " bb    bb88    88",
  26. " bb    bb88dddd88",
  27. " bb55555588   d88",
  28. " bb55bbb 88  d 88",
  29. " bb55555588 d  88",
  30. " bb    5588 d  88",
  31. " 55555555888888"}
  32.  
  33. local function bgc(barvaP) term.setBackgroundColor(barvaP) end
  34. local function txc(barvaP) term.setTextColor(barvaP) end
  35. local function curs(xi,yi) term.setCursorPos(xi,yi) end
  36.  
  37. local function Barvy()
  38.     if fs.exists ("/C/system/Users/"..user.."/.Registry/colors") then
  39.     local data = fs.open("/C/system/Users/"..user.."/.Registry/colors", "r")
  40.     BarPoz = tonumber(data.readLine())
  41.     BarTxt = tonumber(data.readLine())
  42.     data.close()
  43.     end
  44.     if BarPoz == nil or BarTxt == nil then BarPoz = 2048 BarTxt = 1 end
  45. end
  46.  
  47. local function prc(text, y)
  48.   local w = term.getSize()
  49.   local _, cy = term.getCursorPos()
  50.   curs(math.ceil((w-#text)/2), y or cy)
  51.   write(text)
  52. end
  53.  
  54. local function logo()
  55. bgc(colors.white)
  56. txc(colors.blue)
  57. curs(w/2-5,h-1)
  58. write"  Pepek"
  59. curs(w/2+3,h-1)
  60. write"Soft  "
  61. curs(w/2+2,h-1)
  62. txc(colors.lime)
  63. write"@"
  64. end
  65.  
  66. function downloading(kod, cestaP)
  67.     bgc(colors.white)
  68.     txc(colors.white)
  69.     curs(1,1)
  70.     shell.run("/C/system/api/stahni.api get "..kod.." "..cestaP)
  71. end
  72.  
  73. function checkModem()
  74.     if fs.exists("/C/system/.core/defmodem") then
  75.         local data = fs.open ("/C/system/.core/defmodem","r")
  76.         modemPos = data.readLine()
  77.         data.close()
  78.         if peripheral.isPresent(modemPos) and peripheral.getType(modemPos)=="modem" then
  79.         modem = peripheral.wrap(modemPos)
  80.         modem.open(idPC)
  81.         else
  82.         fs.delete("/C/system/.core/defmodem")
  83.         modemPos = "offline"
  84.         end
  85.     else
  86.     modemPos = "offline"
  87.     end
  88. end
  89.  
  90. function song(type)
  91. if sound and not fs.exists("/C/system/Users/"..user.."/.Registry/.disableSound") then shell.run("/C/system/api/sound.api "..type) end
  92. end
  93.  
  94. function sit()
  95.  
  96.     if fs.exists ("/C/system/.core/AD") then
  97.         ADC = true
  98.         local f=fs.open("/C/system/.core/AD","r")
  99.         ADServer=f.readLine()
  100.         f.close()
  101.     end
  102. end
  103.  
  104. function vypnout()
  105. bgc(colors.lightGray)
  106. term.clear()
  107. sleep (0.1)
  108. bgc(colors.gray)
  109. term.clear()
  110. sleep (0.1)
  111. bgc(colors.white)
  112. txc(colors.black)
  113. term.clear()
  114. curs(w-28, h/2-2)
  115. prc "Shutting down..."
  116. logo()
  117. song("shutdown")   
  118. sleep (1)
  119. fs.delete("/C/system/RAM/logout")
  120. if not ServerMode then
  121.         fs.delete("/C/system/RAM")
  122.     end
  123. local data = fs.open ("/C/system/RAM/vypnuto", "w")
  124. data.close ()
  125. bgc(colors.black)
  126. term.clear()
  127. os.shutdown ()
  128. end
  129.  
  130. function restart ()
  131. bgc(colors.lightGray)
  132. term.clear()
  133. sleep (0.1)
  134. bgc(colors.gray)
  135. term.clear()
  136. sleep (0.1)
  137. bgc(colors.black)
  138. txc(colors.black)
  139. term.clear()
  140. bgc(colors.white)
  141. txc(colors.black)
  142. term.clear()
  143. curs(w-28, h/2-2)
  144. prc "Restarting..."
  145. logo()
  146. song("shutdown")
  147. sleep (1)
  148. fs.delete("/C/system/RAM/logout")
  149. local data = fs.open ("/C/system/RAM/vypnuto", "w")
  150. data.close ()
  151. bgc(colors.black)
  152. term.clear()
  153. os.reboot ()
  154. end
  155.  
  156. function hotrezimy ()
  157.     local myWindow = window.create(term.current(),1,16,12,19)
  158.     myWindow.setBackgroundColor(colors.gray)
  159.     myWindow.clear()
  160.     txc(colors.white)
  161.     bgc(colors.gray)
  162.     curs(2,17)
  163.     write "Restart"
  164.  
  165.     curs(2,18)
  166.     write "Shut down"
  167.    
  168.     while true do
  169.     local event, button, x, y = os.pullEvent("mouse_click")
  170.     xy = x..","..y
  171.    
  172.         if x == 1 and y == 18 and button == 1 then
  173.         heslo ()
  174.         elseif x >= 2 and x <= 11 and y == 17 and button == 1 then
  175.             local data = fs.open ("/C/system/RAM/RES", "w")
  176.             data.close()
  177.             restart()
  178.         elseif x >= 2 and x <= 11 and y == 18 and button == 1 then
  179.             local data = fs.open ("/C/system/RAM/VYP", "w")
  180.             data.close()
  181.             vypnout()
  182.         else
  183.         heslo ()
  184.         end
  185. end
  186. end
  187.  
  188. local function service()
  189.     Update()
  190.  
  191.     if fs.exists("/C/service/") then
  192.       si = 0
  193.       sluzba = {}
  194.       local FileList = fs.list("/C/service/")
  195.         for _, file in ipairs(FileList) do
  196.           si = si + 1
  197.           sluzba[si] = file
  198.         end
  199.            
  200.             local sa = 1
  201.             repeat
  202.                 shell.openTab("/C/service/"..sluzba[sa])
  203.                 sa = sa + 1
  204.             until sa == si+1
  205.     end
  206. end
  207.  
  208. function kontrola ()
  209.     if not term.isColor() then
  210.         curs(5,9)
  211.         write "Sorry, you must have a Advanced computer"
  212.         sleep (5)
  213.         os.shutdown ()
  214.     end
  215.    
  216.     boot()
  217. end
  218.  
  219. function checkonline()
  220.     txc(colors.white)
  221.     shell.run("pastebin run LiwNqcDW /C/system/RAM/online")
  222.     if not fs.exists("/C/system/RAM/online") then shell.run("wget run https://devbin.dev/raw/r8ez7cvc") end
  223. end
  224.  
  225. function uvod()
  226.     bgc(colors.white)
  227.     txc(colors.black)
  228.     term.clear()
  229.     logo()
  230.     txc(colors.lightGray)
  231.     curs(1, h-1)
  232.     write (verze)
  233.     bgc(colors.white)
  234.     txc(colors.black)
  235.     prc ("Pepdroll Seven "..edice,h-3)
  236.     APIS.loadLogo(logoPD, w/2-8,h/2-7)
  237. end
  238.  
  239. function boot ()
  240.  
  241.     if fs.exists ("/C/system/RAM/versions.tmp") then fs.delete("/C/system/RAM/versions.tmp") end
  242.  
  243.     local v = fs.open("/C/system/RAM/versions.tmp","w") v.writeLine(verze) v.close()
  244.    
  245.     if fs.exists("/C/system/RAM/online") then
  246.         local data = fs.open("/C/system/RAM/online", "r")
  247.         local Conser = data.readLine()
  248.         if (Conser == "pastebin.com") then PastebinMode = true  DevbinMode = false
  249.         elseif (Conser == "devbin.dev") then DevbinMode = true PastebinMode = false
  250.         else DevbinMode = false PastebinMode = false end
  251.         data.close()
  252.     else DevbinMode = false PastebinMode = false end
  253.    
  254.     if not fs.exists("/C/system/api/stahni.api") then
  255.     shell.run("pastebin get GssKCexp /C/system/api/stahni.api")
  256.     end
  257.  
  258.  if PastebinMode or DevbinMode then
  259.    
  260.     if fs.exists("/C/system/api/emuCheck.lua") then curs(1,-10) shell.run("/C/system/api/emuCheck.lua")
  261.     else downloading("XRfNZpEy", "/C/system/api/emuCheck.lua") boot() end
  262.    
  263.     if fs.exists("/C/system/api/device.api") then shell.run("/C/system/api/device.api")
  264.     else downloading("x", "/C/system/api/device.api") boot() end
  265.    
  266.     if not fs.exists("/C/system/api/dns_check.api") then
  267.     downloading("XZYYRSPy", "/C/system/api/dns_check.api")
  268.     local data = fs.open("/C/system/.core/.Registry/defdns.cfg", "w") data.writeLine("0") data.close()
  269.     boot() end
  270.    
  271.     checkModem()
  272.    
  273.     if not fs.exists("/C/system/api/sound.api") and fs.exists("/C/system/RAM/devices/speaker.tmp") then
  274.             downloading("Td7gSZZq", "/C/system/api/sound.api")
  275.             boot()
  276.     end
  277.    
  278.     if not fs.exists("/C/system/api/print.api") and fs.exists("/C/system/RAM/devices/printer.tmp") then
  279.         downloading("VEfwuEHM", "/C/system/api/print.api")
  280.         boot()
  281.     end
  282.    
  283.     if not fs.exists("/C/system/api/APIS.lua") then
  284.         downloading("rt2e0GLX", "/C/system/api/APIS.lua")
  285.         boot()
  286.     end
  287.    
  288.     if not fs.exists("/C/system/api/smbc.lua") then
  289.             downloading("gQVYieMJ", "/C/system/api/smbc.lua")
  290.         boot()
  291.     end
  292.    
  293.     if not fs.exists("/C/system/api/crypt.lua") then
  294.             downloading("ZmrnX1Cu", "/C/system/api/crypt.lua")
  295.         boot()
  296.     end
  297.    
  298.     if not fs.exists("/C/system/api/decrypt.lua") then
  299.             downloading("hTBwuXKz", "/C/system/api/decrypt.lua")
  300.         boot()
  301.     end
  302.    
  303.     if fs.exists("/C/system/RAM/devices/speaker.tmp") then
  304.     sound = true
  305.     end
  306. end
  307.    
  308.     os.loadAPI("/C/system/api/APIS.lua")
  309.     dofile("/C/system/api/decrypt.lua")
  310.     uvod()
  311.     APIS.loadingS(w/2-2,h-9, 2, 1, 2048)
  312.     if ServerMode or edice == "Workstation" then service() uvod() w,h = term.getSize() end
  313.     APIS.loadingS(w/2-2,h-9, 2, 1, 2048)
  314.     bgc(colors.lightGray)
  315.     term.clear()
  316.     sleep (0.1)
  317.     bgc(colors.gray)
  318.     term.clear()
  319.     Update()
  320.  
  321.     if fs.exists("/C/system/.core/logon") then
  322.         stavlog = true
  323.         local na=fs.open("/C/system/.core/defuser","r")
  324.         user = na.readLine ()
  325.         na.close()
  326.         data = fs.open("/C/system/Users/"..user.."/.data","r")
  327.         user = data.readLine ()
  328.         pass = data.readLine ()
  329.         data.close()
  330.         login ()
  331.     else
  332.         stavlog = false
  333.         heslo()
  334.     end
  335.     error()
  336. end
  337.  
  338. function Update()
  339.     if not fs.exists("/C/system/api/update.lua") then downloading("KV6zGsz0", "/C/system/api/update.lua") end
  340.     shell.run("/C/system/api/update.lua nogui")
  341. end
  342.  
  343. function ADClogin(ADuser)
  344.     modem.transmit(tonumber(ADServer),554,idPC)
  345.     modem.transmit(tonumber(ADServer),555,ADuser)
  346. end
  347.  
  348. function UserExist()   
  349.         if not fs.exists("/C/system/Users/"..user) then
  350.         bgc(colors.white)
  351.           txc(colors.red)
  352.           curs(5,13)
  353.           prc ("Login failed: User not exists!", 2)
  354.           passI = ""
  355.           sleep (1)
  356.           login = 0
  357.           heslo ()
  358.         end
  359.        
  360.     if fs.isDir("/C/system/Users/"..user) then
  361.       if fs.exists("/C/system/Users/"..user.."/.data") then
  362.       shell.run("/C/system/api/crypt.lua "..idPC.." /C/system/Users/"..user.."/.data true")
  363.       end
  364.      
  365.         if fs.exists("/C/system/Users/"..user.."/.data.pcr") then
  366.             shell.run("/C/system/api/crypt.lua "..idPC.." /C/system/Users/"..user.."/.data.pcr true")
  367.             local data = fs.open("/C/system/Users/"..user.."/.data","r")
  368.             userO = data.readLine()
  369.             passO = data.readLine()
  370.             if (passO == "nil") then passO = "" end
  371.             data.close()
  372.         end
  373.    
  374.         if user == userO and pass == passO then
  375.         if not stavlog then
  376.             logWin.setBackgroundColor(BarPoz)
  377.             logWin.setTextColor(colors.lime)
  378.             logWin.setCursorPos(9,3)
  379.             logWin.write "  Login successful!  "
  380.             userDir = "/C/system/Users/"..user
  381.             success = true
  382.             sleep ((anim)*10)
  383.             data = fs.open ("/C/system/.core/defuser", "w")
  384.             data.writeLine (user)
  385.             data.close ()
  386.         end
  387.             vitejte ()
  388.         else
  389.             if stavlog then
  390.             stavlog = false
  391.             heslo()
  392.             end
  393.             logWin.setBackgroundColor(BarPoz)
  394.             logWin.setTextColor(colors.red)
  395.             logWin.setCursorPos(9,2)
  396.             logWin.write "    Login failed!    "
  397.             logWin.setCursorPos(8,3)
  398.             logWin.write "Wrong name or password."
  399.             pass = ""
  400.             sleep ((anim)*20)
  401.             heslo ()
  402.         end
  403.   end
  404.   os.exit()
  405. end
  406.  
  407. function ADuserCopy()
  408. local Levent, side, freq, rfreq, message = os.pullEvent('modem_message')
  409.  
  410.     if (rfreq == 1) then
  411.     nameUser = message
  412.     end
  413.     if (rfreq == 2) then
  414.     passUser = message
  415.     end
  416.     if (rfreq == 3) then
  417.     Fname = message
  418.     end
  419.    
  420.     if (rfreq == 4) then
  421.     Lname = message
  422.     end
  423.    
  424.     if (rfreq == 5) then
  425.     IsAdmin = message
  426.     local file = fs.open("/C/system/Users/"..nameUser.."/.data","w")
  427.     file.writeLine(nameUser)
  428.     file.writeLine(passUser)
  429.     file.writeLine(Fname)
  430.     file.writeLine(Lname)
  431.     file.writeLine(IsAdmin)
  432.     file.close()
  433.     end
  434.    
  435.     if (rfreq == 571) then
  436.         if not (message == "fail") then
  437.             local file = fs.open("/C/system/Users/"..nameUser.."/.Registry/bar.nfp","w")
  438.             file.write(message)
  439.             file.close()
  440.         end
  441.     end
  442.    
  443.     if (rfreq == 572) then
  444.         if not (message == "fail") then
  445.             local file = fs.open("/C/system/Users/"..nameUser.."/.Registry/colors","w")
  446.             file.write(message)
  447.             file.close()
  448.         end
  449.     end
  450.    
  451.     if (rfreq == 575) then
  452.         if not (message == "fail") then
  453.             local file = fs.open("/startup.lua","w")
  454.             file.write(message)
  455.             file.close()
  456.             updateBar = true
  457.         end
  458.     end
  459.    
  460.     if (rfreq == 576) then
  461.         if not (message == "fail") then
  462.             local file = fs.open("/C/system/.core/desktop.lua","w")
  463.             file.write(message)
  464.             file.close()
  465.             updateBar = true
  466.         end
  467.     end
  468.    
  469.     if (rfreq == 577) then
  470.         if not (message == "fail") then
  471.             local file = fs.open("/C/system/api/setting.lua","w")
  472.             file.write(message)
  473.             file.close()
  474.             updateBar = true
  475.         end
  476.     end
  477.    
  478.     if (rfreq == 580) then
  479.     cReg = tonumber(message)
  480.     end
  481.    
  482. end
  483.  
  484. function ADImportRegistry()
  485. local Levent, side, freq, rfreq, message = os.pullEvent('modem_message')
  486.  
  487.     if (rfreq == 581) then
  488.     registerPath = ("/C/system/Users/"..user.."/.Registry/"..message)
  489.     end
  490.    
  491.     if (rfreq == 582) then
  492.         if message == "true" then
  493.             if not fs.exists(registerPath) then
  494.             local file = fs.open(registerPath, "w")
  495.             file.close()
  496.             end
  497.         elseif message == "false" then
  498.             if fs.exists(registerPath) then fs.delete(registerPath) end
  499.         end
  500.     end
  501.  
  502.  
  503. end
  504.  
  505. function AD_dotazy()
  506. modem.transmit(tonumber(ADServer),570,"bar")
  507. ADuserCopy()
  508. modem.transmit(tonumber(ADServer),570,"Bcol")
  509. ADuserCopy()
  510. local data = fs.open("/startup.lua", "r")
  511. obsah = data.readLine()
  512. data.close()
  513. modem.transmit(tonumber(ADServer),575, obsah)
  514. modem.transmit(tonumber(ADServer),570,"updateStart")
  515. ADuserCopy()
  516. if fs.exists("/C/system/.core/desktop.lua") then
  517. data = fs.open("/C/system/.core/desktop.lua", "r")
  518. obsah = data.readLine()
  519. data.close()
  520. end
  521. modem.transmit(tonumber(ADServer),576, obsah)
  522. modem.transmit(tonumber(ADServer),570,"updateDesk")
  523. ADuserCopy()
  524. if fs.exists("/C/system/api/setting.lua") then
  525. data = fs.open("/C/system/api/setting.lua", "r")
  526. obsah = data.readLine()
  527. data.close()
  528. modem.transmit(tonumber(ADServer),577, obsah)
  529. modem.transmit(tonumber(ADServer),570,"updateSett")
  530. ADuserCopy()
  531. end
  532.  
  533. end
  534.  
  535. function Logovat(textLog)
  536. local file = fs.open("/log.txt","w")
  537. file.write(textLog)
  538. file.close()
  539. end
  540.  
  541. function ADCprijem()
  542. timerRX = os.startTimer(1)
  543.     while true do
  544.     local event,p1,p2,p3,p4 = os.pullEvent()
  545.       if event == ("modem_message") then
  546.           if (p3 == 556) then
  547.                 if (p4 == "true") then
  548.                 for i=1,6 do
  549.                    ADuserCopy()
  550.                 end
  551.                 if cReg > 0 then
  552.                     modem.transmit(tonumber(ADServer),570,"Reg")
  553.                     for i=1,cReg*2 do
  554.                     ADImportRegistry()
  555.                     end
  556.                 end
  557.  
  558.                 nazevUser = ""
  559.                 obsahuser = ""
  560.                 AD_dotazy()
  561.                 UserExist()
  562.                 elseif (p4 == "block") then
  563.                 fs.delete("/C/system/Users/"..user.."/.data")
  564.                 UserExist()
  565.                 else
  566.                 UserExist()
  567.                 end
  568.             end
  569.       elseif event == "timer" then
  570.         if p1 >= timerRX then
  571.         logWin.setBackgroundColor(BarPoz)
  572.         logWin.setTextColor(colors.red)
  573.         logWin.setCursorPos(9,2)
  574.         logWin.write "Connection not found!"
  575.         logWin.setCursorPos(9,3)
  576.         logWin.write "   Go offline mode.  "
  577.         sleep(1.5)
  578.         logWin.setCursorPos(9,2)
  579.         logWin.write "                     "
  580.         UserExist()
  581.         end
  582.       end
  583.     end
  584. end
  585.  
  586. function login()
  587.     checkModem()
  588.    
  589.     if (ADServer == idPC) then
  590.     os.reboot()
  591.     end
  592.    
  593.         if not fs.exists("/C/system/Users/"..user.."/.data") then
  594.         novaplocha = true
  595.         else
  596.         novaplocha = false
  597.         end
  598.    
  599.     if localAD then
  600.         if fs.exists ("/C/system/server/rules/AD/Users/"..user.."/.data") then
  601.         fs.delete("/C/system/Users/"..user.."/.data")
  602.         fs.copy("/C/system/server/rules/AD/Users/"..user.."/.data", "/C/system/Users/"..user.."/.data")
  603.         end
  604.     end
  605.    
  606.     if ADC and not fs.exists ("/C/system/server/rules/AD/Users/") and not (modemPos == "offline") then
  607.     ADClogin(user)
  608.     ADCprijem()
  609.     else
  610.     UserExist()
  611.     end
  612. end
  613.  
  614. function samotny()
  615.  
  616.       local q = 0
  617.       local jmenoP = {}
  618.       local FileList = fs.list("/C/system/Users")
  619.         for _, file in ipairs(FileList) do
  620.           q = q + 1
  621.           jmenoP[q] = file
  622.         end
  623.  
  624.     if q == 1 then
  625.     user = jmenoP[1]
  626.         if fs.exists ("/C/system/Users/"..user.."/.data") then
  627.             local f=fs.open("/C/system/Users/"..user.."/.data","r")
  628.             user=f.readLine()
  629.             pass=f.readLine()
  630.             Fname=f.readLine()
  631.             Lname=f.readLine()
  632.             f.close()
  633.         end
  634.        
  635.         if pass == "" then
  636.         vitejte()
  637.         end
  638.     end
  639. end
  640.  
  641. function heslo()
  642.     if fs.exists("/C/system/.core/ucet") or fs.exists("/C/system/Users") then else
  643.         downloading("McRCnrpM", "/C/system/RAM/AccountCreate.lua")
  644.         local Loader = os.loadAPI("/C/system/RAM/AccountCreate.lua")
  645.         if (Loader) then
  646.         AccountCreate.account()
  647.             if fs.exists("/C/system/RAM/NewUser") then local data = fs.open("/C/system/RAM/NewUser", "r") nUser = data.readLine() data.close()
  648.                 if not ServerMode then downloading("ZQ8BBcVQ","/C/system/Users/"..nUser.."/.Registry/bar.nfp") end
  649.             end
  650.         else os.shutdown() end
  651.         local ucet = fs.open("/C/system/.core/ucet","w")
  652.         ucet.close()
  653.     end
  654.  
  655.     if not ADC and not fs.exists("/C/system/RAM/logout") and not ServerMode then
  656.         samotny()
  657.     end
  658.  
  659. sit()
  660.  
  661.     function LogAccess()
  662.     logWin.setBackgroundColor(colors.lightGray)
  663.     logWin.setTextColor(colors.white)
  664.     logWin.setCursorPos(14,9)
  665.     logWin.write " Login "
  666.     sleep(anim)
  667.     login()
  668.     end
  669.    
  670.     function PassAccess()
  671.     logWin.setBackgroundColor(colors.lightBlue)
  672.     bgc(colors.lightBlue)
  673.     logWin.setTextColor(colors.black)
  674.     logWin.setCursorPos(14,7)
  675.     logWin.write "              "
  676.     logWin.setCursorPos(15,7)
  677.     pass = read(string.char(7))
  678.     logWin.setBackgroundColor(colors.white)
  679.     bgc(colors.white)
  680.     logWin.setCursorPos(14,7)
  681.     logWin.write "              "
  682.     logWin.setCursorPos(15,7)
  683.     for i=1,#pass do
  684.       write(string.char(7))
  685.     end
  686.     end
  687.    
  688. if user == nil then
  689.     if fs.exists ("/C/system/.core/defuser") then
  690.     local na=fs.open("/C/system/.core/defuser","r")
  691.     user = na.readLine ()
  692.     na.close()
  693.     else
  694.     user = ""
  695.     end
  696. end
  697.  
  698.     if displayload  then
  699.     monitor.setBackgroundColor(colors.white)
  700.     monitor.setCursorPos(e/2-12,j/2+4)
  701.     monitor.setTextColor(colors.gray)
  702.     monitor.write("Waiting for user login...")
  703.     end
  704.  
  705.     if fs.exists ("/C/system/RAM/startuplog") then
  706.         local data = fs.open ("/C/system/RAM/startuplog", "r")
  707.         login = data.readLine ()
  708.         data.close ()
  709.     end
  710.  
  711.     bgc(colors.white)
  712.     txc(colors.lightGray)
  713.     term.clear()
  714.  
  715.     if (ADC) then
  716.     curs(1,1)
  717.     print ("AD server: "..ADServer)
  718.     print ("My adress: "..idPC)
  719.     end
  720.  
  721.     if pocket then
  722.     Xl = 1
  723.     else
  724.     Xl = w/2-15
  725.     end
  726.  
  727. if fs.exists("/C/system/Users/"..user.."/.Registry/colors") then
  728.         Barvy()
  729. else
  730.         BarPoz = 2048
  731.         BarTxt = 1
  732. end
  733.  
  734.     logWin = window.create(term.current(),Xl,5,30,10)
  735.     logWin.setBackgroundColor(BarPoz)
  736.     logWin.clear()
  737.  
  738.     logo()
  739.     if not ServerMode then
  740.     curs(1,18)
  741.     bgc(colors.gray)
  742.     txc(colors.white)
  743.     write " Power "
  744.     pass=""
  745.     end
  746.    
  747.     logWin.setTextColor(colors.lightBlue)
  748.     logWin.setCursorPos(29,5)
  749.     logWin.write "V"
  750.     logWin.setTextColor(BarTxt)
  751.     logWin.setCursorPos(2,3)
  752.     logWin.write "Login"
  753.     logWin.setCursorPos(2,5)
  754.     logWin.write("User name: ")
  755.     logWin.setCursorPos(2,7)
  756.     logWin.write("Password:")
  757.     logWin.setBackgroundColor(colors.white)
  758.     logWin.setTextColor(colors.black)
  759.     logWin.setCursorPos(14,5)
  760.     logWin.write "              "
  761.     logWin.setCursorPos(14,7)
  762.     logWin.write "              "
  763.     logWin.setCursorPos(14,9)
  764.     logWin.write " Login "
  765.     logWin.setCursorPos(15,5)
  766.     logWin.write (user)
  767.    
  768.    
  769.     while true do
  770.     x,y = term.getSize()
  771.     os.startTimer(1)
  772.  
  773.     if ServerMode and fs.exists("/C/system/RAM/shutdown.pdr") then
  774.         vypnout()
  775.     end
  776.    
  777.     local event,p1,p2,p3, p4 = os.pullEvent()
  778.     button = p1
  779.         x = p2
  780.         y = p3
  781.         key = p1
  782.    
  783.    
  784.     if event == "mouse_click" and x >= 1 and x <= 7 and y == 18 and button == 1 and not ServerMode then
  785.     hotrezimy ()
  786.     elseif x == math.floor(Xl+28) and y == 9 and button == 1 then
  787.     if fs.exists ("/C/system/Users") then
  788.       txc(colors.black)
  789.       curs(Xl+28,9)
  790.       write "V"
  791.       i = 0
  792.       jmeno = {}
  793.       local FileList = fs.list("/C/system/Users") --Table with all the files and directories available
  794.         for _, file in ipairs(FileList) do
  795.           i = i + 1
  796.           jmeno[i] = file
  797.         end
  798.        
  799.         if (i>9) then
  800.         i = 9
  801.         end
  802.     end
  803.    
  804.     local myWindow = window.create(term.current(),Xl+13,10,14,i)
  805.         myWindow.setBackgroundColor(colors.lightBlue)
  806.         myWindow.clear()
  807.        
  808.         local a = 1
  809.         repeat
  810.             myWindow.setCursorPos(2,a)
  811.             myWindow.write(jmeno[a])
  812.             a = a + 1
  813.         until a == i+1
  814.        
  815.         while true do
  816.        
  817.         local event, button, x, y = os.pullEvent("mouse_click")
  818.         xy = x..","..y
  819.        
  820.     if x >= Xl+12 and x <= Xl+26 and y >= 10 and y <= 18 and button == 1 then
  821.             user = jmeno[y-9]
  822.             heslo()
  823.             else
  824.             heslo()
  825.             end
  826.         end
  827.     elseif event == "mouse_click" and x >= Xl+12 and x <= Xl+26 and y == 9 and button == 1 then
  828.     logWin.setBackgroundColor(colors.lightBlue)
  829.     bgc(colors.lightBlue)
  830.     logWin.setTextColor(colors.black)
  831.     logWin.setCursorPos(14,5)
  832.     logWin.write "              "
  833.     logWin.setCursorPos(15,5)
  834.     user = read()
  835.    
  836.     logWin.setBackgroundColor(colors.white)
  837.     logWin.setTextColor(colors.black)
  838.     logWin.setCursorPos(14,5)
  839.     logWin.write "              "
  840.     logWin.setCursorPos(15,5)
  841.     logWin.write (user)
  842.     elseif (event == "mouse_click" and x >= Xl+12 and x <= Xl+26 and y == 11 and button == 1) or event == "key" then PassAccess() LogAccess()
  843.     elseif event == "mouse_click" and x >= Xl+12 and x <= Xl+19 and y == 13 and button == 1  then LogAccess()
  844.     elseif event == "key" and p1 == keys.enter then LogAccess()
  845.     elseif event == "key" and p1 == keys.numEnter then LogAccess()
  846.     end
  847.     end
  848. end
  849.  
  850. function vitejte ()
  851.    
  852. if fs.exists ("/C/system/Users/"..user.."/.data") then
  853.     local f=fs.open("/C/system/Users/"..user.."/.data","r")
  854.     user=f.readLine()
  855.     pass=f.readLine()
  856.     Fname=f.readLine()
  857.     Lname=f.readLine()
  858.     f.close()
  859.     shell.run("/C/system/api/crypt.lua "..idPC.." /C/system/Users/"..user.."/.data true")
  860. end
  861.  
  862.     if fs.exists("/C/system/Users/"..user.."/.Registry/.disableSound") then
  863.     sound = false
  864.     end
  865.    
  866.     if novaplocha then
  867.     local data = fs.open("/C/system/Users/"..user.."/Desktop/This PC.src", "w")
  868.     data.close()
  869.     end
  870.  
  871. if (novaplocha) then
  872.     downloading("ZQ8BBcVQ", "/C/system/Users/"..user.."/.Registry/bar.nfp")
  873.     local data = fs.open("/C/system/Users/"..user.."/Desktop/This PC.src", "w")
  874.     data.close()
  875.     novaplocha = false
  876. end
  877.                
  878. if displayload then
  879. monitor.setBackgroundColor(colors.white)
  880. monitor.setCursorPos(e/2-12,j/2+4)
  881. monitor.setTextColor(colors.gray)
  882. monitor.write("Connecting...            ")
  883. end
  884.  
  885. bgc(colors.lightGray)
  886.     term.clear()
  887.     sleep (0.1)
  888.     bgc(colors.gray)
  889.     term.clear()
  890.     sleep (0.1)
  891.     bgc(colors.black)
  892.     txc(colors.black)
  893.     term.clear()
  894.     bgc(colors.white)
  895.     txc(colors.black)
  896.     term.clear ()
  897. data = fs.open ("/C/system/RAM/user", "w")
  898.         data.writeLine (user)
  899.         data.writeLine (pass)
  900. data.close ()
  901. if not fs.exists("/C/system/RAM/logout") then
  902.     if updateBar then
  903.     prc ("Please wait", 9)
  904.     sleep(0.4)
  905.     prc ("Working on updates", 9)
  906.     prc ("Don't turn off your computer", 11)
  907.     updt = 0
  908.     repeat
  909.         txc(colors.black)
  910.         bgc(colors.white)
  911.         prc (updt.."% complete", 10)
  912.         updt = updt + 20
  913.         curs(1,12)
  914.         txc(colors.white)
  915.         bgc(colors.white)
  916.         if updt == 20 then
  917.             if pastebinUpdate then fs.delete("/C/system/api/stahni.api") downloading("GssKCexp", "/C/system/api/stahni.api") end
  918.             if soundUpdate then fs.delete("/C/system/api/sound.api") downloading("Td7gSZZq", "/C/system/api/sound.api") end
  919.         elseif updt == 40 then
  920.             if BSODUpdate then fs.delete("/C/system/api/bluescreen.lua") downloading("DSNcZuMZ", "/C/system/api/bluescreen.lua") end
  921.             if SMBUpdate then fs.delete("/C/system/api/smbc.lua") downloading("gQVYieMJ", "/C/system/api/smbc.lua") end
  922.         elseif updt == 60 then
  923.             if CMDUpdate then fs.delete("/C/system/api/commands.lua") downloading("r18V4xrG", "/C/system/api/commands.lua") end
  924.             if APIUpdate then fs.delete("/C/system/api/APIS.lua") downloading("GssKCexp", "/C/system/api/APIS.lua") end
  925.         elseif updt == 80 then
  926.             if printUpdate then  fs.delete("/C/system/api/print.api") downloading("VEfwuEHM", "/C/system/api/print.api") end
  927.         end
  928.         sleep(0.4)
  929.     until updt == 120
  930.     prc ("                            ", 9)
  931.     prc ("                            ", 10)
  932.     prc ("                            ", 11)
  933.     end
  934. end
  935. txc(colors.black)
  936.  
  937. if not (Fname == "") and not (Lname == "") and not (Fname == nil) and not (Lname == nil) and not (Fname == " ") and not (Lname == " ") then
  938. prc ("Welcome "..Fname.." "..Lname, h/2-2)
  939. else
  940. prc ("Welcome "..user, h/2-2)
  941. end
  942.  
  943. if fs.exists("/C/system/Users/"..user.."/bar.nfp") and not fs.exists("/C/system/Users/"..user.."/.Registry/bar.nfp") then fs.move("/C/system/Users/"..user.."/bar.nfp", "/C/system/Users/"..user.."/.Registry/bar.nfp") end
  944.  
  945. logo()
  946. curs(1,10)
  947.  
  948. if fs.exists("/C/system/RAM/logout") then
  949.     shell.exit()
  950.     fs.delete("/C/system/RAM/logout")
  951.     if fs.exists("/C/system/RAM/devices/speaker.tmp") then
  952.         sound = true
  953.     end
  954.    
  955.     song("login")
  956.     else
  957.     song("startup")
  958. end
  959.  
  960. if not sound then sleep(0.5) end
  961.  
  962. sleep (0.1)
  963. bgc(colors.gray)
  964. term.clear()
  965.  
  966. if fs.exists("/C/desktop.lua") then
  967. fs.delete("/C/desktop.lua")
  968. end
  969.  
  970.     if not fs.exists ("/C/system/api/bluescreen.lua") then
  971.     downloading("DSNcZuMZ", "/C/system/api/bluescreen.lua")
  972.     end
  973.  
  974. os.unloadAPI("/C/system/api/APIS.lua")
  975.  
  976. fs.delete("/C/system/RAM/bluescreen")
  977. local data = fs.open ("/C/system/RAM/FirstLogin", "w") data.close ()
  978. shell.run ("/C/system/api/bluescreen.lua")
  979. error()
  980. end
  981.  
  982. if fs.exists("/C/system/RAM/logout") then
  983. heslo()
  984. end
  985.  
  986. if fs.exists("/C/system/RAM/displayreboot") then
  987.         if ServerMode then
  988.             service()
  989.         end
  990.        
  991.         fs.delete("/C/system/RAM/displayreboot")
  992.             if fs.exists("/C/system/.core/display") then
  993.                 local f=fs.open("/C/system/.core/display","r")
  994.                 monitor=f.readLine()
  995.                 f.close()
  996.                 bgc(colors.black)
  997.                 term.clear()
  998.                 prc("Connected to an external monitor",h/2-2)
  999.                 txc(colors.black)
  1000.                 shell.run("monitor "..monitor.." /C/system/.core/desktop.lua")
  1001.             else
  1002.                 shell.run ("/C/system/.core/desktop.lua")
  1003.             end
  1004.         shell.run("/C/system/.core/desktop.lua")
  1005.     end
  1006.  
  1007.     if fs.exists("/C/system/.core/display") then
  1008.    
  1009.         if fs.exists("/C/system/.core/display") then
  1010.         local f=fs.open("/C/system/.core/display","r")
  1011.         monitor=f.readLine()
  1012.         f.close()
  1013.        
  1014.         if peripheral.isPresent(monitor) and peripheral.getType(monitor)=="monitor" then
  1015.         monitor = peripheral.wrap(monitor)
  1016.         displayload = true
  1017.         else
  1018.         fs.delete("/C/system/.core/display")
  1019.         boot()
  1020.         end
  1021.         e,j = monitor.getSize()
  1022.         monitor.setBackgroundColor(colors.white)
  1023.         monitor.clear()
  1024.         monitor.setTextColor(colors.blue)
  1025.         monitor.setCursorPos(e/2-5,j-1)
  1026.         monitor.write"  Pepek"
  1027.         monitor.setCursorPos(e/2+3,j-1)
  1028.         monitor.write"Soft  "
  1029.         monitor.setCursorPos(e/2+2,j-1)
  1030.         monitor.setTextColor(colors.lime)
  1031.         monitor.write"@"
  1032.         monitor.setBackgroundColor(colors.white)
  1033.         monitor.setTextColor(colors.black)
  1034.         monitor.setCursorPos(e/2-11,j/2)
  1035.         monitor.write("Pepdroll Seven "..edice)
  1036.         monitor.setCursorPos(e/2-12,j/2+4)
  1037.         monitor.setTextColor(colors.gray)
  1038.         monitor.write("Waiting for connection...")
  1039.         monitor.setCursorPos(e/2-11,j/2)
  1040.         monitor.setBackgroundColor(colors.blue)
  1041.         textutils.slowPrint "                        "
  1042.     end
  1043. end
  1044.  
  1045. sit()
  1046.    
  1047. if fs.exists ("/server") then
  1048.     local data = fs.open ("/C/system/.core/system", "w")
  1049.     data.writeLine("Server")
  1050.     data.close()
  1051.     fs.delete("/server")
  1052.     os.reboot()
  1053. end
  1054.  
  1055. if fs.exists ("/stahni.lua") then
  1056.     fs.delete("/stahni.lua")
  1057. end
  1058.  
  1059. if fs.exists("/C/system/.core/system") then
  1060.     local data = fs.open ("/C/system/.core/system", "r")
  1061.     edice = data.readLine()
  1062.     data.close()
  1063. else
  1064.     local data = fs.open ("/C/system/.core/system", "w")
  1065.     edice = "Standard"
  1066.     data.writeLine(edice)
  1067.     data.close()
  1068. end
  1069.  
  1070. if fs.exists ("/C/system/.core/AD") then
  1071.     ADC = true
  1072.     local f=fs.open("/C/system/.core/AD","r")
  1073.     ADServer=f.readLine()
  1074.     f.close()
  1075. end
  1076.        
  1077. if (edice == "Server") then
  1078.     ServerMode = true
  1079.     if fs.exists ("/C/system/.core/AD") then
  1080.     localAD = true
  1081.     end
  1082. end
  1083.  
  1084. if not fs.exists("/C/system/.core/colors") then
  1085.     local f=fs.open("/C/system/.core/colors","w")
  1086.     local text={barva=colors.blue}
  1087.     f.write(textutils.serialize(text))
  1088.     f.close()
  1089. end
  1090.  
  1091. BarPoz = 2048 BarTxt = 1
  1092.  
  1093. if not fs.exists("/C/system/api/closeApp") then
  1094.     downloading("EEVJPR7F", "/C/system/api/closeApp")
  1095. end
  1096.  
  1097. if fs.exists ("/C/system/RAM/startuplog") then
  1098.     fs.delete ("/C/system/RAM/startuplog")
  1099.     heslo ()
  1100. end
  1101.  
  1102. if #tArgs > 0 then
  1103.         if (tArgs[1] == "shutdown") then
  1104.             vypnout()
  1105.         elseif (tArgs[1] == "reboot") then
  1106.             restart()
  1107.         end
  1108.     else
  1109.         if not ServerMode then fs.delete("/C/system/RAM") end
  1110.         checkonline()
  1111.         boot()
  1112. end
  1113.  
  1114. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement