Advertisement
COOLGAMETUBEorginal

[ComputerCraft]Wicows SecurityDoorLock 1.6

May 23rd, 2015
982
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 29.11 KB | None | 0 0
  1. --Install [EN]:
  2. -- 1) Goto your Computer, place a Monitor and a Redstone-Output Signal.
  3. -- 2) Type in your Computer following Command: "pastebin run jdeg8qfu".
  4. -- 3) Reboot your Computer.
  5.  
  6. --Install [DE]:
  7. -- 1) Gehe zu deinem Computer und baue einen Monitor und ein Redstone Signal an ihm dran.
  8. -- 2) Tippe in deinem Computer folgenden Befehl: "pastebin run jdeg8qfu" ein.
  9. -- 3) Starte deinen Computer neu.
  10.  
  11. -- [License] --
  12.  -- This Program is under Open source license!
  13.  -- Developed by COOLGAMETUBE
  14.  -- ©COOLGAMETUBE 2015 - now
  15.  -- Don't say, it's your Programm!
  16.  -- Don't remove this lincense part!
  17.  -- Using on Servers accepted! (If point 4 and 5 done)
  18.  -- Enjoy it!
  19. -- [License] --
  20.  
  21. Content = {
  22.   Folders = {
  23.     "/lib",
  24.     "/res",
  25.     "/res/flags",
  26.   },
  27.   Files = {
  28.     {
  29.       Path = "/lib/WicowsTools",
  30.       Content = "--[[DONT REMOVE THIS NOTICE!!!\
  31. Download: pastebin get REaZXV7W WicowsTools || http://www.pastebin.com/REaZXV7W\
  32. Copyright ©COOLGAMETUBE\
  33. Copyright ©Buschrolle\
  34. Copyright ©JcraftxD\
  35. \
  36. Release: 11.08.2015\
  37. \
  38. EULA:\
  39. -I will not share this API whithout this notice!\
  40. -I able to modify and reupload it, if this notice was not removed.\
  41. -I will credit COOLGAMETUBE.\
  42. -I able to set my Credit, if this Programm has modified(New Functions)\
  43. -This API will be FREE avaiable (no money)\
  44. -If i upload a programm, that include this API, i will set the Credits of COOLGAMETUBE]]\
  45. \
  46. function packmanSystem()\
  47.     if fs.exists(\"/usr/bin/packman\") then\
  48.         return true\
  49.     else\
  50.         return false\
  51.     end\
  52. end\
  53. \
  54. local tArgs = {...}\
  55. \
  56. function GetAuthor()\
  57.        return \"COOLGAMETUBE\"\
  58. end\
  59. \
  60. function GetVersion()\
  61.        return 1.23\
  62. end\
  63. \
  64. function MagicClear(t)\
  65.        if not t then t = 0.5 end\
  66.        l = {\"[\", \"-\", \"]\", \" \", t}\
  67.        x, y = term.getSize()\
  68.        lt = \"\"\
  69.        ct = \"\"\
  70.        for i = 1, x do\
  71.                le = l[2]\
  72.                if i == 1 then le = l[1] end\
  73.                if i == x then le = l[3] end\
  74.                lt = lt .. le\
  75.                ct = ct .. l[4]\
  76.        end\
  77.        for i = 1, y do\
  78.                term.setCursorPos(1, i -1)\
  79.                write(ct)\
  80.                term.setCursorPos(1, i)\
  81.                write(lt)\
  82.                sleep(l[5])\
  83.        end\
  84.        term.setCursorPos(1, 1)\
  85.        term.clear()\
  86. end\
  87. \
  88. function MagicSpam()\
  89.        s = 0.1\
  90.        x, y = term.getSize()\
  91.        lt = \"\"\
  92.        scnd = true\
  93.        for i = 1, y do\
  94.                for i = 1, x do\
  95.                        lt = lt .. tostring(math.random(0,9))\
  96.                end\
  97.                term.setCursorPos(1, i)\
  98.                write(lt)\
  99.                if scnd then\
  100.                        sleep(s)\
  101.                        scnd = false\
  102.                else\
  103.                        scnd = true\
  104.                end\
  105.        end\
  106.        term.setCursorPos(1,y)\
  107. end\
  108. \
  109. function toInt(str)\
  110.        num = \"\"\
  111.        sp = false\
  112.        for a = 1, string.len(str) do\
  113.            l = string.sub(str, a,a)\
  114.            if l == \"0\" or l == \"1\" or l == \"2\" or l == \"3\" or l == \"4\" or l == \"5\" or l == \"6\" or l == \"7\" or l == \"8\" or l == \"9\" or l == \".\" then\
  115.                if l == \".\" and not sp then\
  116.                     num = num .. l\
  117.                 elseif l ~= \".\" then\
  118.                     num = num .. l\
  119.                end\
  120.            end\
  121.        end\
  122.        if num == \"\" or num == nil then num = 0 end\
  123.        return tonumber(num)\
  124. end\
  125. \
  126. function digit_sum(num)\
  127.        num = toInt(num)\
  128.        num = tostring(num)\
  129.       \
  130.        numlet = {}\
  131.        if string.len(num) > 1 then\
  132.            for a = 1, string.len(num) do\
  133.                numlet[a] = string.sub(num, a,a)\
  134.            end\
  135.        else\
  136.            numlet[1] = num\
  137.        end\
  138.        local result = nil\
  139.        if #numlet > 1 then\
  140.                local rn = 0\
  141.                for i = 1, #numlet do\
  142.                        rn = rn + toInt(numlet[i])\
  143.                end\
  144.                result = rn\
  145.        else\
  146.                result = toInt(numlet[1])\
  147.        end\
  148.        return result\
  149. end\
  150. \
  151. function invert(num)\
  152.        num = toInt(num)\
  153.        num = tostring(num)\
  154.        numlet = {}\
  155.        if string.len(num) > 1 then\
  156.                for a = 1, string.len(num) do\
  157.                        numlet[a] = string.sub(num, a,a)\
  158.                end\
  159.        else\
  160.                numlet[1] = num\
  161.        end\
  162. \
  163.        local result = nil\
  164.        if #numlet > 1 then\
  165.                local rn = \"\"\
  166.                for i = 1, (#numlet) do\
  167.                        rn = rn..numlet[#numlet-i+1]\
  168.                end\
  169.                result = rn\
  170.        else\
  171.                result = numlet[1]\
  172.        end\
  173.        return result\
  174. end\
  175. \
  176. function SplitStr(inputstr, sep)\
  177.        if sep == nil then\
  178.                sep = \"%s\"\
  179.        end\
  180.        local t={} ; i=1\
  181.        for str in string.gmatch(inputstr, \"([^\"..sep..\"]+)\") do\
  182.                t[i] = str\
  183.                i = i + 1\
  184.        end\
  185.        return t\
  186. end\
  187. \
  188. function ReplaceStr(str, rep, to)  \
  189.        if not rep then return nil end\
  190.        str = tostring(str)\
  191.        local pcs = SplitStr(str, rep)\
  192.        str = pcs[1]\
  193.        for n=2,#pcs do\
  194.                str = str..to..pcs[n]\
  195.        end\
  196.        return str\
  197. end\
  198. \
  199. function WriteFile(file, text, append)\
  200.        local m = \"w\"\
  201.        if append == true then\
  202.                m = \"a\"\
  203.        end\
  204.        if not fs.exists(file) then\
  205.                if not fs.isReadOnly(file) then\
  206.                        f = fs.open(file, m)\
  207.                        f.write(text)\
  208.                        f.close()\
  209.                        return true\
  210.                else\
  211.                        return false\
  212.                end\
  213.        else\
  214.                return false\
  215.        end\
  216. end\
  217. \
  218. function ReadFile(file)\
  219.    if fs.exists(file) then\
  220.        local f = fs.open(file, \"r\")\
  221.        local text = f.readAll()\
  222.        f.close()\
  223.        if text ~= nil then\
  224.             return text\
  225.        else\
  226.            return \"ERROR!\"\
  227.        end\
  228.    else\
  229.        return false\
  230.    end\
  231. end\
  232. \
  233. function SimpleClear()\
  234.    term.setBackgroundColor(colors.black)\
  235.    term.setTextColor(colors.white)\
  236.    term.clear()\
  237.    term.setCursorPos(1, 1)\
  238. end\
  239. \
  240. function CreateBorder()\
  241.    term.clear()\
  242.    local letters = {\"+\",\"-\",\"|\",}\
  243.    local x,y = term.getSize()\
  244.    local cy = 1   \
  245.    local lt = \"\"\
  246.    for i = 1, y do\
  247.        cy = i\
  248.        lt = \"\"\
  249.        for i = 1, x do\
  250.            if cy == 1 and i == 1 then\
  251.                lt = lt..letters[1]\
  252.            elseif cy == 1 and i == x then\
  253.                lt = lt..letters[1]\
  254.            elseif cy == y and i == 1 then\
  255.                lt = lt..letters[1]\
  256.            elseif cy == y and i == x then\
  257.                lt = lt..letters[1]\
  258.            elseif cy == 1 then\
  259.                lt = lt..letters[2]\
  260.            elseif cy == y then\
  261.                lt = lt..letters[2]\
  262.            elseif i == 1 then\
  263.                lt = lt..letters[3]\
  264.            elseif i == x then\
  265.               lt = lt..letters[3]\
  266.            else\
  267.            lt = lt..\" \"\
  268.        end\
  269.    end\
  270.    term.setCursorPos(1, i)\
  271.    write(lt)\
  272.    end\
  273.    term.setCursorPos(2, 2)\
  274. end\
  275. \
  276. function is(var)\
  277.    if var then\
  278.        return true\
  279.    else\
  280.        return false\
  281.    end\
  282. end\
  283. \
  284. function Log(msg, terminal, add)\
  285.    if terminal then\
  286.        if terminal == term or terminal == term.current() then\
  287.            if add then\
  288.                term.write(msg)\
  289.            else\
  290.                print(msg)\
  291.            end\
  292.        else\
  293.            if add then\
  294.                terminal.write(msg)\
  295.            else\
  296.                x, y = terminal.getCursorPos()\
  297.                terminal.write(msg)\
  298.                terminal.setCursorPos(1, y+1)\
  299.            end\
  300.        end\
  301.    end\
  302. end\
  303. \
  304. function GetRawWebString(url)\
  305.     if type(url) ~=\"string\" then error(\"Can't execute function GetRawWebString(string) because parameter[1] is not a string!\") return false end\
  306.     local connection = http.get(url)\
  307.    if connection then\
  308.         local result = connection.readAll()\
  309.         connection.close()\
  310.         return result\
  311.     else\
  312.         return false\
  313.     end\
  314. end\
  315. function CheckCompatible(file, returnVersion, outputTerm)\
  316.     t = nil\
  317.    o = nil\
  318.    funcList = nil\
  319.    osv = nil\
  320.    fo = nil\
  321.    f = nil\
  322.    foundMv = nil\
  323.    -------------\
  324.    t = outputTerm\
  325.    o = is(returnVersion)\
  326.    funcList = textutils.unserialize(GetRawWebString(\"http://pastebin.com/raw.php?i=tvVjyfHD\"))\
  327.     osv = toInt(_CC_VERSION)\
  328.     fo = fs.open(file, \"r\")\
  329.    f = fo.readAll()\
  330.    fo.close()\
  331.    foundMv = false\
  332.    for i = 1, #funcList[\"list\"] do\
  333.        if not foundMv then\
  334.            Log(\"Check Version: \"..funcList[\"list\"][i][\"vers\"]..\" ...\", t)\
  335.            sleep(0.01) --yielding!\
  336.            for fu = 1, #funcList[\"list\"][i][\"funcList\"] do\
  337.                sleep(0.01) --yielding!\
  338.                if string.find(f, \"turtle.\") and trutle or not string.find(f, \"turtle.\") and not turtle then\
  339.                    if string.find(f, funcList[\"list\"][i][\"funcList\"][fu]) then foundMv = funcList[\"list\"][i][\"vers\"] end\
  340.                end\
  341.            end\
  342.        end\
  343.    end\
  344.    r = nil\
  345.    if foundMv then\
  346.        if foundMv > osv then\
  347.            Log(\"false, NOT compatible! Min Version: \"..foundMv, t)\
  348.            r = false\
  349.        else\
  350.            Log(\"true, Min Version: \"..foundMv, t)\
  351.            r = true\
  352.        end\
  353.    else\
  354.        Log(\"true, Min Version: First Release!\", t)\
  355.        r = true\
  356.    end\
  357.    if o then\
  358.        return r, foundMv\
  359.    else\
  360.        return r\
  361.    end\
  362. end\
  363. \
  364. function GetWebHash(HashType, Data)\
  365.     GetRawWebString(\"http://coolgametube.net/cc/hash.php?mode=\"..HashType\"&str=\"..Data)\
  366. end\
  367. \
  368. function BigChar(char)\
  369.        if char == \"a\" then return \"A\"\
  370.    elseif char == \"b\" then return \"B\"\
  371.    elseif char == \"c\" then return \"C\"\
  372.    elseif char == \"d\" then return \"D\"\
  373.    elseif char == \"e\" then return \"E\"\
  374.    elseif char == \"f\" then return \"F\"\
  375.    elseif char == \"g\" then return \"G\"\
  376.    elseif char == \"h\" then return \"H\"\
  377.    elseif char == \"i\" then return \"I\"\
  378.    elseif char == \"j\" then return \"J\"\
  379.    elseif char == \"k\" then return \"K\"\
  380.    elseif char == \"l\" then return \"L\"\
  381.    elseif char == \"m\" then return \"M\"\
  382.    elseif char == \"n\" then return \"N\"\
  383.    elseif char == \"o\" then return \"O\"\
  384.    elseif char == \"p\" then return \"P\"\
  385.    elseif char == \"q\" then return \"Q\"\
  386.    elseif char == \"r\" then return \"R\"\
  387.    elseif char == \"s\" then return \"S\"\
  388.    elseif char == \"t\" then return \"T\"\
  389.    elseif char == \"u\" then return \"U\"\
  390.    elseif char == \"v\" then return \"V\"\
  391.    elseif char == \"w\" then return \"W\"\
  392.    elseif char == \"x\" then return \"X\"\
  393.    elseif char == \"y\" then return \"Y\"\
  394.    elseif char == \"z\" then return \"Z\"\
  395.    else return char end\
  396. end \
  397. \
  398. function BigLetters(text)\
  399.    local BStr = \"\"\
  400.    for i = 1, string.len(text) + 1 do \
  401.        BStr = BStr..BigChar(string.sub(text, i,i)) \
  402.    end \
  403.    return BStr\
  404. end",
  405.     },
  406.     {
  407.       Path = "/res/boot.img",
  408.       Content = "\
  409.         dd55             55dd\
  410.         d115             511d\
  411.         d115             511d\
  412.         d115           55511d\
  413.         d115           51100d\
  414.         d115           511ddd\
  415.         d115  555      511d\
  416.         d115 55155   55511d\
  417.         d115 51115   51100d\
  418.         d115 51115   511ddd\
  419.         d115 51115 55511d\
  420.         d115 51115 51100d\
  421.         d1155511155511ddd\
  422.         d0011100011100d   eee  ee  ee\
  423.         ddd010ddd010ddd  e    e   e\
  424.           dd0dd dd0dd     ee  eee e\
  425.            ddd   ddd        e e   e\
  426.                           ee   ee  eee",
  427.     },
  428.     {
  429.       Path = "/res/changelog.txt",
  430.       Content = "--Install [EN]:\
  431. -- 1) Goto your Computer, place a Monitor and a Redstone-Output Signal.\
  432. -- 2) Type in your Computer following Command: \"pastebin run jdeg8qfu\".\
  433. -- 3) Reboot your Computer.\
  434. \
  435. --Install [DE]:\
  436. -- 1) Gehe zu deinem Computer und baue einen Monitor und ein Redstone Signal an ihm dran.\
  437. -- 2) Tippe in deinem Computer folgenden Befehl: \"pastebin run jdeg8qfu\".\
  438. -- 3) STarte deinen Computer neu.\
  439. \
  440. -- [License] --\
  441. -- This Program is under Open source license!\
  442. -- Developed by COOLGAMETUBE\
  443. -- ©COOLGAMETUBE 2015 - now\
  444. -- Don't say, it's your Programm!\
  445. -- Don't remove this lincense part!\
  446. -- Using on Servers accepted! (If point 4 and 5 done)\
  447. -- Enjoy it!\
  448. -- [License] --\
  449. \
  450. -- +[CHANGELOG] --\
  451. \
  452. -- [Vers. 1.1]\
  453.     -- Fixed Crash at the first start, if the http api is deactivated while downloading the Boot-Image\
  454.     -- Version display on Computer while running\
  455.     -- Code Optimizations (Redstone)\
  456. --------------\
  457. -- [Vers. 1.2]\
  458.     -- Don't show pin/Puk Field if pressed Clear\
  459.     -- Code Optimizations (Numpad)\
  460. --------------\
  461. -- [Vers. 1.3]\
  462.     -- Split ConfigFile to Config and Settings\
  463.     -- Add VersionTAG to ConfigFile\
  464.     -- Code Optimisations (VariableNames)\
  465.     -- Fixed Bug: Register your PIN/PUK and you clear it, the orange field is still there\
  466. --------------\
  467. -- [Vers. 1.3.1]\
  468.     -- 1 function, that wrote in 2 functions is now once\
  469. --------------\
  470. -- [Vers. 1.3.2]\
  471.     -- Fixed code damage\
  472.     -- Seconds now min. 1sec\
  473.     -- Code Optimizations (Boolean Name)\
  474. --------------\
  475. -- [Vers. 1.4]\
  476.     -- SettingsFile now will be loaded!\
  477.     -- [Custom.] customColors now loading!\
  478.     -- Starting Costumization implemention\
  479.     -- Code Optimizations (ColorNames)\
  480.     -- Fixed another Code damage\
  481.     -- Starting MuliLanguage implementation\
  482. --------------\
  483. -- [Vers. 1.4.0.1]\
  484.     -- VersString now get VersionNumber from vers float\
  485. --------------\
  486. -- [Vers. 1.5]\
  487.     -- Transforming all files into --> 1 <-- CCInstall-Installation-File! Thaz AMAZING! :D\
  488.     -- Moved Changelog from Script into a textfile\
  489. --------------\
  490. -- [Vers. 1.6]\
  491.     -- English languagePack implementet! Awesome!\
  492.     -- New languagePacks can be easylie hardcoded!\
  493.     -- Updated WicowsTools Lib to 1.23!\
  494.     -- Code Optimizations\
  495. --------------\
  496. -- [Planned]\
  497.     --{[!CS] == ComingSoon!}\
  498.     -- Full controlable colors [!CS]\
  499.     --\
  500.     -- Shorter Code (At time its a code Jungle :P)\
  501.     --\
  502.     -- Fails and Sucess Display getting an UI\
  503.     --\
  504.     -- New Monitor UI\
  505. -- -[CHANGELOG] --\
  506. \
  507. --[TODO]\
  508. --Implement Settings\
  509. ----------------",
  510.     },
  511.     {
  512.       Path = "/res/flags/flagSite_1.img",
  513.       Content = "fff 0e0\
  514.  e e\
  515. 444 0e0",
  516.     },
  517.     {
  518.       Path = "/res/lang.dat",
  519.       Content = "{ en = {\"Welcome to Wicows Security!\",\
  520.         \"Please go to your monitor and make that\\n  computer accessible only to you!\",\
  521.         \"New\",\
  522.         \"OPN\",\
  523.         \"SEC\",\
  524.         \"Fails\",\
  525.         \"Succeed\",\
  526.         \"Settings\",\
  527.         \"Languages\",\
  528.         \"Colors\",\
  529.         \"OPN time\",\
  530.         \"Sucess\",\
  531.     },\
  532.     de = {\
  533.         \"Willkommen zu Wicows Security!\",\
  534.         \"Bitte gehe zu deinem Monitor und mach diesen\\n  Computer nur fuer dich zugaenglich!\",\
  535.         \"Neu\",\
  536.         \"OFN\",\
  537.         \"SEK\",\
  538.         \"Fehlschlaege\",\
  539.         \"Erfolge\",\
  540.         \"Einstellungen\",\
  541.         \"Sprachen\",\
  542.         \"Farben\",\
  543.         \"OFN Zeit\",\
  544.         \"Erfolg\",\
  545.     },\
  546. }",
  547.     },
  548.     {
  549.       Path = "/startup",
  550.       Content = "\
  551. local SoftwareVersion = 1.6\
  552. \
  553. os.loadAPI(\"lib/WicowsTools\")\
  554. \
  555. local vers = \"Wicows Security \"..SoftwareVersion..\" -by COOLGAMETUBE        \"\
  556. \
  557. local cfgfile = \"cfg/config.cfg\"\
  558. local settingfile = \"cfg/settings.cfg\"\
  559. \
  560. if not fs.exists(\"cfg/\") then fs.makeDir(\"cfg/\") end\
  561. \
  562. local ss = WicowsTools.SplitStr(cfgfile,\"/\") ss[2] = \"/\"..ss[2]\
  563. if not fs.exists(cfgfile) and fs.exists(ss[2]) then shell.run(\"copy \"..ss[2]..\" \"..cfgfile) fs.delete(ss[2]) end\
  564. \
  565. local ss = WicowsTools.SplitStr(settingfile, \"/\") ss[2] = \"/\"..ss[2]\
  566. if not fs.exists(settingfile) and fs.exists(ss[2]) then shell.run(\"copy \"..ss[2]..\" \"..settingfile) fs.delete(ss[2]) end\
  567. \
  568. \
  569. if not fs.exists(\"res/boot.img\") or not fs.exists(\"res/lang.dat\") then\
  570.     error(\"InstallationError!\")\
  571. end\
  572. \
  573. \
  574. term.setBackgroundColor(512)\
  575. term.clear()\
  576. \
  577. if fs.exists(\"res/boot.img\") then\
  578.     paintutils.drawImage(paintutils.loadImage(\"res/boot.img\"), 1, 1)\
  579. end\
  580. \
  581. term.setCursorPos(1, 1)\
  582. term.write(vers)\
  583. sleep(0.5)\
  584. term.setBackgroundColor(512)\
  585. term.clear()\
  586. term.setCursorPos(1, 19)\
  587. \
  588. local new = false\
  589. local monPos = nil\
  590. for k,v in pairs(rs.getSides()) do\
  591.  if peripheral.getType(v)=='monitor' then\
  592.     monPos=v\
  593.     break\
  594.  end\
  595. end\
  596. \
  597. local mon = peripheral.wrap(monPos)\
  598. local m1 = false\
  599. local pin = \"\"\
  600. local cfgTable = {[\"ConfigVersion\"] = 2, [\"pin\"] = nil, [\"puk\"] = nil, [\"fails\"] = 0, [\"sucess\"] = 0, [\"locked\"] = false, [\"tries\"] = 3, [\"open\"] = nil}\
  601. local settingsTable = {[\"SettingsVersion\"] = 1, [\"lang\"] = \"en\", [\"Colors\"] = {[\"TextColor\"] = colors.white, [\"ButtonBackgroundColor\"] = 8192, [\"TextFieldBackgroundColor\"] = 2, [\"DesktopColor\"] = 512}}\
  602. local lang = textutils.unserialize(WicowsTools.ReadFile(\"res/lang.dat\"))\
  603. \
  604. function t(lid)\
  605.     return lang[settingsTable[\"lang\"]][lid]\
  606. end\
  607. \
  608. function getColor(color)\
  609.     return settingsTable[\"Colors\"][color]\
  610. end\
  611. \
  612. \
  613. function UpgradeV2()\
  614.     fs.delete(settingfile)\
  615. \
  616.     h = fs.open(cfgfile, \"r\")\
  617.     local cfgTablefile = textutils.unserialize(h.readAll())\
  618.     h.close()\
  619. \
  620.     fs.delete(cfgfile)\
  621. \
  622.     cfgTable[\"pin\"] = cfgTablefile[\"pin\"]\
  623.     cfgTable[\"puk\"] = cfgTablefile[\"puk\"]\
  624.     cfgTable[\"fails\"] = cfgTablefile[\"fails\"]\
  625.     cfgTable[\"sucess\"] = cfgTablefile[\"sucess\"]\
  626.     cfgTable[\"locked\"] = cfgTablefile[\"locked\"]\
  627.     cfgTable[\"tries\"] = cfgTablefile[\"tries\"]\
  628.     cfgTable[\"open\"] = cfgTablefile[\"open\"]\
  629. \
  630.     local h = fs.open(cfgfile, \"w\")\
  631.     h.write(textutils.serialize(cfgTable))\
  632.     h.close()\
  633. \
  634.     local h = fs.open(settingfile, \"w\")\
  635.     h.write(textutils.serialize(settingsTable))\
  636.     h.close()\
  637. end\
  638. \
  639. function DrawKeyboard(n)\
  640.     mon.setBackgroundColor(getColor(\"DesktopColor\"))\
  641.     mon.clear()\
  642.     mon.setBackgroundColor(getColor(\"ButtonBackgroundColor\"))\
  643.     mon.setTextColor(getColor(\"TextColor\"))\
  644.     mon.setCursorPos(1, 2)\
  645.     mon.write(\"1\")\
  646.     mon.setCursorPos(4, 2)\
  647.     mon.write(\"2\")\
  648.     mon.setCursorPos(7, 2)\
  649.     mon.write(\"3\")\
  650. \
  651.     mon.setCursorPos(1, 3)\
  652.     mon.write(\"4\")\
  653.     mon.setCursorPos(4, 3)\
  654.     mon.write(\"5\")\
  655.     mon.setCursorPos(7, 3)\
  656.     mon.write(\"6\")\
  657. \
  658.     mon.setCursorPos(1, 4)\
  659.     mon.write(\"7\")\
  660.     mon.setCursorPos(4, 4)\
  661.     mon.write(\"8\")\
  662.     mon.setCursorPos(7, 4)\
  663.     mon.write(\"9\")\
  664. \
  665.     mon.setCursorPos(1, 5)\
  666.     mon.write(\"R\")\
  667.     mon.setCursorPos(4, 5)\
  668.     mon.write(\"0\")\
  669.     mon.setCursorPos(7, 5)\
  670.     if m1 then\
  671.         mon.write(\">\")\
  672.     else\
  673.         mon.write(\"X\")\
  674.     end\
  675. \
  676.     pinlen = n\
  677.     pinlencur = 0\
  678.     pin = \"\"\
  679.     while pinlencur < pinlen do\
  680.         if pinlencur == 0 then\
  681.                 mon.setBackgroundColor(getColor(\"DesktopColor\"))\
  682.                 mon.write(\"       \")\
  683.                 mon.setCursorPos(1, 1)\
  684.                 if pinlen == 2 then\
  685.                     mon.write(t(4)..\" \"..t(5))\
  686.                 else\
  687.                     if new then\
  688.                         if pinlen == 4 then\
  689.                             mon.write(t(3)..\" PIN\")\
  690.                         end\
  691. \
  692.                         if pinlen == 7 then\
  693.                             mon.write(t(3)..\" PUK\")\
  694.                         end\
  695.                     else\
  696.                         if pinlen == 4 then\
  697.                             mon.write(\"PIN\"..\":\")\
  698.                         end\
  699. \
  700.                         if pinlen == 7 then\
  701.                             mon.write(\"PUK\"..\":\")\
  702.                         end\
  703.                     end\
  704.                 end\
  705.             end \
  706.         mon.setCursorPos(1, 1)\
  707.         mon.setTextColor(getColor(\"TextColor\"))\
  708.             \
  709.         event, side, x, y = os.pullEvent()\
  710.         if event == \"mouse_click\" then\
  711.             if x == 1 and y == 1 then\
  712.                 term.clear()\
  713.                 term.setCursorPos(1, 1)\
  714.                 term.write(\"Resetting...\")\
  715.                 sleep(0.3)\
  716.                 fs.delete(cfgfile)\
  717.                 fs.delete(settingfile)\
  718.                 os.reboot()\
  719.             end\
  720.         end\
  721.         if event == \"monitor_touch\" then\
  722.             local doSkipPressed = false\
  723. \
  724.             if x == 1 and y == 2 then\
  725.                 pin = pin..\"1\"\
  726.             end\
  727.             if x == 4 and y == 2 then\
  728.                 pin = pin..\"2\"\
  729.             end\
  730.             if x == 7 and y == 2 then\
  731.                 pin = pin..\"3\"\
  732.             end\
  733.             if x == 1 and y == 3 then\
  734.                 pin = pin..\"4\"\
  735.             end\
  736.             if x == 4 and y == 3 then\
  737.                 pin = pin..\"5\"\
  738.             end\
  739.             if x == 7 and y == 3 then\
  740.                 pin = pin..\"6\"\
  741.             end\
  742.             if x == 1 and y == 4 then\
  743.                 pin = pin..\"7\"\
  744.             end\
  745.             if x == 4 and y == 4 then\
  746.                 pin = pin..\"8\"\
  747.             end\
  748.             if x == 7 and y == 4 then\
  749.                 pin = pin..\"9\"\
  750.             end\
  751.             if x == 1 and y == 5 then\
  752.                 mon.setBackgroundColor(32768)\
  753.                 mon.clear()\
  754.                 mon.setTextColor(getColor(\"TextColor\"))\
  755.                 mon.setCursorPos(1, 1)\
  756.                 mon.write(\"...\") mon.setCursorPos(1, 2)\
  757.                 os.reboot()\
  758.             end\
  759.             if x == 4 and y == 5 then\
  760.                 if m1 then\
  761.                     if pinlencur > 0 then\
  762.                         pin = pin..\"0\"\
  763.                     else\
  764.                         doSkipPressed = true\
  765.                     end\
  766.                 else\
  767.                     pin = pin..\"0\"\
  768.                 end\
  769.             end\
  770.             \
  771.             local showcfgTableField = true\
  772.             if x == 7 and y == 5 then\
  773.                 if m1 then\
  774.                     pinlencur = 2\
  775.                 else\
  776.                     doSkipPressed = true\
  777.                     pin = \"\"\
  778.                     pinlencur = 0\
  779.                     showcfgTableField = false\
  780.                 end\
  781.             end\
  782. \
  783.             \
  784.             if pinlencur > 0 then\
  785.                 showcfgTableField = true\
  786.             end\
  787.             \
  788. \
  789.             if showcfgTableField then\
  790.                 mon.setBackgroundColor(getColor(\"TextFieldBackgroundColor\"))\
  791.                 mon.write(\"       \")\
  792.                 mon.setCursorPos(1, 1)\
  793.                 mon.write(pin)\
  794.             else\
  795.                 mon.setCursorPos(1, 1)\
  796.                 mon.setBackgroundColor(getColor(\"DesktopColor\"))\
  797.                 mon.write(\"       \")\
  798.             end\
  799.             \
  800.             if doSkipPressed == true then\
  801.                 pinlencur = 0\
  802.                 doSkipPressed = false\
  803.             else\
  804.                 pinlencur = pinlencur + 1\
  805.                 doSkipPressed = false\
  806.             end\
  807. \
  808.         end\
  809.     end\
  810. end\
  811. \
  812. function rsout(bool)\
  813.     rs.setOutput(\"left\", bool)\
  814.     rs.setOutput(\"right\", bool)\
  815.     rs.setOutput(\"front\", bool)\
  816.     rs.setOutput(\"back\", bool)\
  817.     rs.setOutput(\"top\", bool)\
  818.     rs.setOutput(\"bottom\", bool)\
  819. end\
  820. \
  821. function sucess()\
  822.     mon.setBackgroundColor(8192)\
  823.     mon.setTextColor(getColor(\"TextColor\"))\
  824.     mon.clear()\
  825.     mon.setCursorPos(1, 3)\
  826.     mon.write(\"SUCESS!\")\
  827. \
  828.     rsout(true)\
  829. \
  830.     for i = 1, cfgTable[\"open\"]  do\
  831.         mon.setCursorPos(1, 5)\
  832.         mon.write(t(4)..\": \" .. cfgTable[\"open\"] - (i - 1)  .. \" \")\
  833.         sleep(1)\
  834.     end\
  835. \
  836.     mon.setBackgroundColor(32768)\
  837.     mon.clear()\
  838. \
  839.     rsout(false)\
  840. \
  841.     fs.delete(cfgfile)\
  842.     h = fs.open(cfgfile, \"w\")\
  843.     h.write(textutils.serialize(cfgTable))\
  844.     if rb then\
  845.         os.reboot()\
  846.     end\
  847.     \
  848.     os.reboot()\
  849. end\
  850. local loaded = false\
  851. function DrawOnComputer()\
  852.         term.setBackgroundColor(getColor(\"DesktopColor\"))\
  853.         term.clear()\
  854. \
  855.         term.setBackgroundColor(16384)\
  856.         term.setCursorPos(1, 1)\
  857.         term.write(vers)\
  858.         term.setBackgroundColor(getColor(\"DesktopColor\"))\
  859. \
  860.         term.setCursorPos(2, 3)\
  861.         term.write(t(6)..\": \"..cfgTable[\"fails\"])\
  862. \
  863.         term.setCursorPos(2, 5)\
  864.         term.write(t(7)..\": \"..cfgTable[\"sucess\"])\
  865. \
  866.         term.setCursorPos(44-4, 19)\
  867.         --term.write(t(8)) ----------------------------------------------------------------------------------<<<<<<<<<<<<<<<<<<<<<<\
  868.         term.write(\"Coming Soon!\")\
  869. \
  870. end\
  871. \
  872. function LangLeftName(bgcolor,fgcolor,text)\
  873.     mon.setCursorPos(1, 2)\
  874.     mon.setBackgroundColor(bgcolor)\
  875.     mon.setTextColor(fgcolor)\
  876.     mon.write(text)\
  877. end\
  878. \
  879. function LangRightName(bgcolor,fgcolor,text)\
  880.     mon.setCursorPos(6, 2)\
  881.     mon.setBackgroundColor(bgcolor)\
  882.     mon.setTextColor(fgcolor)\
  883.     mon.write(text)\
  884. end\
  885. \
  886. function PerfectWrite(x,y,bgcolor,fgcolor,text)\
  887.     mon.setCursorPos(x, y)\
  888.     mon.setBackgroundColor(bgcolor)\
  889.     mon.setTextColor(fgcolor)\
  890.     mon.write(text)\
  891. end\
  892. \
  893. function SelectLanguage(cs)\
  894.     local mx = 1\
  895.     if not  cs then cs =  1 end\
  896.     if cs == 0 then cs = mx end\
  897.     if cs > mx then cs =  1 end\
  898. \
  899.     local flags = {\
  900.         {\"de\", \"en\"},\
  901.     }\
  902. \
  903.     shell.run(\"monitor \"..monPos..\" clear\")\
  904.     local mon = peripheral.find(\"monitor\")\
  905.     term.redirect(mon)\
  906.     paintutils.drawImage(paintutils.loadImage(\"res/flags/flagSite_\"..cs..\".img\"), 1, 1)\
  907. \
  908.     LangLeftName (colors.red, colors.white, WicowsTools.BigLetters(flags[cs][1]))\
  909.     LangRightName(colors.red, colors.white, WicowsTools.BigLetters(flags[cs][2]))\
  910. \
  911.     PerfectWrite(4,1,colors.lightGray,colors.black,\"|\")\
  912.     PerfectWrite(4,2,colors.lightGray,colors.black,\"|\")\
  913.     PerfectWrite(4,3,colors.lightGray,colors.black,\"|\")\
  914. \
  915.     PerfectWrite(1,4,colors.lime,colors.orange,\"SELECT!\")\
  916. \
  917.     PerfectWrite(1,5,colors.lightGray,colors.black,\"<<<\")\
  918.     PerfectWrite(4,5,colors.gray,colors.red,  cs )\
  919.     PerfectWrite(5,5,colors.lightGray,colors.black,\">>>\")\
  920.     local compl = false\
  921.     while not comp do\
  922.         event, side, x, y = os.pullEvent()\
  923.         if event == \"monitor_touch\" then\
  924.             if x < 4 and y < 4 then --LeftLang\
  925.                 settingsTable[\"lang\"] = flags[cs][1]\
  926.                 comp = true\
  927.             elseif x > 4 and y < 4 then --RightLang\
  928.                 settingsTable[\"lang\"] = flags[cs][2]\
  929.                 comp = true\
  930.             elseif x < 4 and y > 4 then --PrevSite\
  931.                 SelectLanguage(cs-1)\
  932.             elseif x > 4 and y > 4 then --NextSite\
  933.                 SelectLanguage(cs+1)\
  934.             end\
  935.         end\
  936.     end\
  937. end\
  938. \
  939. \
  940. if fs.exists(cfgfile) then\
  941.     if not fs.exists(settingfile) then\
  942.         UpgradeV2()\
  943.     end\
  944. \
  945. \
  946.     h = fs.open(cfgfile, \"r\")\
  947.     cfgTable = textutils.unserialize(h.readAll())\
  948.     h.close()\
  949. \
  950.     h = fs.open(settingfile, \"r\")\
  951.     settingsTable = textutils.unserialize(h.readAll())\
  952.     h.close()\
  953.     term.setTextColor(getColor(\"TextColor\"))\
  954.     DrawOnComputer()\
  955. \
  956.     rb = false\
  957.     if cfgTable[\"tries\"] == 0 then\
  958.         cfgTable[\"locked\"] = true\
  959.     end\
  960. \
  961.     if not cfgTable[\"locked\"] then\
  962. \
  963.         DrawKeyboard(4)\
  964.         \
  965.         if pin == cfgTable[\"pin\"] then\
  966.             cfgTable[\"sucess\"] = cfgTable[\"sucess\"] + 1\
  967.             cfgTable[\"tries\"] = 3\
  968.             DrawOnComputer()\
  969.             sucess()\
  970.         else\
  971.             cfgTable[\"tries\"] = cfgTable[\"tries\"] - 1\
  972.             cfgTable[\"fails\"] = cfgTable[\"fails\"] + 1\
  973.             DrawOnComputer()\
  974.             rb = true\
  975.         end\
  976.     else\
  977.         \
  978. \
  979.         DrawKeyboard(7)\
  980. \
  981.         if pin == cfgTable[\"puk\"] then\
  982.             cfgTable[\"locked\"] = false\
  983.             cfgTable[\"tries\"] = 3\
  984.             rb = true\
  985.         else\
  986.             rb = true\
  987.         end\
  988.     end\
  989.     fs.delete(cfgfile)\
  990.     h = fs.open(cfgfile, \"w\")\
  991.     h.write(textutils.serialize(cfgTable))\
  992.     if rb then\
  993.         os.reboot()\
  994.     end\
  995. else\
  996. \
  997.         new = true\
  998. \
  999.         term.setCursorPos(5, 2)\
  1000.         print(t(1))\
  1001.         term.setCursorPos(3, 4)\
  1002.         print(t(2))\
  1003. \
  1004. \
  1005.         SelectLanguage()\
  1006. \
  1007. \
  1008.         DrawKeyboard(4)\
  1009.         cfgTable[\"pin\"] = pin\
  1010. \
  1011.         DrawKeyboard(7)\
  1012.         cfgTable[\"puk\"] = pin\
  1013. \
  1014. \
  1015.         m1 = true\
  1016. \
  1017.         DrawKeyboard(2)\
  1018.         cfgTable[\"open\"] = tonumber(pin)\
  1019.         m1 = false\
  1020.         mon.setBackgroundColor(32768)\
  1021.         mon.setTextColor(getColor(\"TextColor\"))\
  1022.         mon.clear()\
  1023. \
  1024.         local h = fs.open(\"/config.cfg\", \"w\")\
  1025.         h.write(textutils.serialize(cfgTable))\
  1026.         h.close()\
  1027. \
  1028.         os.reboot()\
  1029. \
  1030. end",
  1031.     },
  1032.   },
  1033.   Title = "Wicows Security 1,6",
  1034. }
  1035. if not http then print("You need Internet!") return false end
  1036. shell.run("clear")
  1037. print("Getting Resources...")
  1038.  
  1039. function HiddenPastebinGET(pstbinID, savLocFile)
  1040.     if not noUpdate then
  1041.         local sCode = pstbinID
  1042.         local sFile = savLocFile
  1043.         local sPath = shell.resolve( sFile )
  1044.         if fs.exists( sPath ) then
  1045.             fs.delete(sPath)
  1046.         end
  1047.        
  1048.         local response = http.get(
  1049.             "http://pastebin.com/raw.php?i="..textutils.urlEncode( pstbinID )
  1050.         )
  1051.            
  1052.         if response then
  1053.             local sResponse = response.readAll()
  1054.             response.close()
  1055.             res = sResponse
  1056.         end
  1057.  
  1058.         if res then        
  1059.             local file = fs.open( sPath, "w" )
  1060.             file.write( res )
  1061.             file.close()
  1062.         end
  1063.     end
  1064. end
  1065.  
  1066. HiddenPastebinGET("REaZXV7W", "CCInstaller_WicowsTools")
  1067. os.loadAPI("CCInstaller_WicowsTools")
  1068. local WicowsTools = CCInstaller_WicowsTools
  1069.  
  1070. x, y = term.getSize()
  1071. DebugLog = window.create(term.current(), 2, 2, x -2, y-2)
  1072.  
  1073. WicowsTools.CreateBorder()
  1074.  
  1075. function Log(str, add)
  1076. x, y = DebugLog.getCursorPos()
  1077. w, h = DebugLog.getSize()
  1078. if y > h then
  1079.     term.setBackgroundColor(colors.black)
  1080.     term.clear()DebugLog.clear()
  1081.     WicowsTools.CreateBorder()
  1082.     DebugLog.setCursorPos(1, 1)
  1083. end
  1084. x, y = DebugLog.getCursorPos()
  1085. DebugLog.write(str)
  1086. if not add then
  1087. DebugLog.setCursorPos(1, y+1)
  1088. end end
  1089.  
  1090. Log("Welcome to the CCInstaller") Log("for: " .. Content["Title"]) Log("") sleep(2.5)
  1091. Log("Initalizing Content...") sleep(0.5)
  1092. Log("Folders: "..tostring(#Content["Folders"])) Log("  Files: "..tostring(#Content["Files"])) Log("")
  1093. local fc = #Content["Folders"]
  1094. if fc > 0 then
  1095.     Log("Creating Folders...")
  1096.     for i = 1, fc do
  1097.         Log("Create Folder: "..Content["Folders"][i])
  1098.         if not fs.exists(Content["Folders"][i]) then fs.makeDir(Content["Folders"][i]) end
  1099.         sleep(0.1)
  1100.     end
  1101. end
  1102. Log("") Log("Extract Files...") Log("")
  1103. local fc = #Content["Files"]
  1104. for i = 1, fc do
  1105.     Log("Extract File: "..Content["Files"][i]["Path"])
  1106.     WicowsTools.WriteFile(Content["Files"][i]["Path"], Content["Files"][i]["Content"])
  1107.     sleep(0.1)
  1108. end
  1109. sleep(1)
  1110.  
  1111. Log("Done! Rebooting...")
  1112. sleep(2.5)
  1113.  
  1114. os.loadAPI("CCInstaller_WicowsTools")
  1115. fs.delete("CCInstaller_WicowsTools")
  1116.  
  1117. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement