alexexe82

pstb.lua

Jan 7th, 2018
1,854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.48 KB | None | 0 0
  1. local component = require("component")
  2. local event = require("event")
  3. local term = require("term")
  4. local unicode = require("unicode")
  5. local ecs = require("ECSAPI")
  6. local fs = require("filesystem")
  7. local shell = require("shell")
  8. local internet = require("internet")
  9. local context = require("context")
  10. local xml = require("xmlParser")
  11. local unixtime = require("unixtime")
  12. local SHA2 = require("SHA2")
  13. -- local computer = require("computer")
  14. -- local keyboard = require("keyboard")
  15. -- local image = require("image")
  16.  
  17. local gpu = component.gpu
  18.  
  19. --//replace 1,3,12,11,13,7,16,15,14,582,56,73,166,165,21,167,168,228,229,10,11 0
  20. --
  21. --------------------------------------------------------------------------------------------------------------------------
  22.  
  23. local xSize, ySize = gpu.getResolution()
  24. local centerX, centerY = math.floor(xSize / 2), math.floor(ySize / 2)
  25.  
  26. local username = nil
  27. local password = nil
  28.  
  29. local userkey = nil
  30. local devKey = "e98db6da803203282d172156bc46137c"
  31. local pastebin_url = nil
  32.  
  33. local isNotLoggedIn = true
  34.  
  35. local pathToConfig = "System/Pastebin/Login.cfg"
  36.  
  37. --МАССИВ СО ВСЕМИ ПАСТАМИ С ПАСТЕБИНА
  38. local MyMassivWithPastes = {}
  39. local drawPastesFrom = 1
  40.  
  41. local tabColor1 = 0x103258
  42. local tabColor2 = 0x034879
  43. local tabTextColor = 0xffffff
  44.  
  45. --------------------------------------------------------------------------------------------------------------------------
  46.  
  47. --СОЗДАНИЕ ОБЪЕКТОВ
  48. local obj = {}
  49. local function newObj(class, name, ...)
  50.     obj[class] = obj[class] or {}
  51.     obj[class][name] = {...}
  52. end
  53.  
  54. --ЗАГРУЗИТЬ ФАЙЛ С ПАСТЕБИНА
  55. local function get(pasteId, filename)
  56.   local f, reason = io.open(filename, "w")
  57.   if not f then
  58.     io.stderr:write("Failed opening file for writing: " .. reason)
  59.     return
  60.   end
  61.  
  62.   --io.write("Downloading from pastebin.com... ")
  63.   local url = "http://pastebin.com/raw.php?i=" .. pasteId
  64.   local result, response = pcall(internet.request, url)
  65.   if result then
  66.     --io.write("success.\n")
  67.     for chunk in response do
  68.       --if not options.k then
  69.         chunk = string.gsub(chunk, "\r\n", "\n")
  70.         chunk = string.gsub(chunk, "    ", "  ")
  71.       --end
  72.       f:write(chunk)
  73.     end
  74.  
  75.     f:close()
  76.     --io.write("Saved data to " .. filename .. "\n")
  77.   else
  78.     --io.write("failed.\n")
  79.     f:close()
  80.     fs.remove(filename)
  81.     io.stderr:write("HTTP request failed: " .. response .. "\n")
  82.   end
  83. end
  84.  
  85. -- This makes a string safe for being used in a URL.
  86. local function encode(code)
  87.   if code then
  88.     code = string.gsub(code, "([^%w ])", function (c)
  89.       return string.format("%%%02X", string.byte(c))
  90.     end)
  91.     code = string.gsub(code, " ", "+")
  92.   end
  93.   return code
  94. end
  95.  
  96.  
  97.  
  98. --Удалить файлецкий
  99. local function delete(paste)
  100.     local result, response = pcall(internet.request,
  101.         "http://pastebin.com/api/api_post.php",
  102.         "api_option=delete&"..
  103.         "api_dev_key="..devKey.."&"..
  104.         "api_user_key="..userKey.."&"..
  105.         "api_paste_key="..paste
  106.     )
  107.  
  108.     if result then
  109.         return true
  110.     else
  111.         ecs.error("Отсутствует соединение с Pastebin.com")
  112.         return false
  113.     end
  114. end
  115.  
  116. --ЗАЛОГИНИТЬСЯ В АККАУНТ
  117. local function loginToAccount(username, password)
  118.  
  119.     --print("Логинюсь в пастебине... ")
  120.     local result, response = pcall(internet.request,
  121.         "http://pastebin.com/api/api_login.php",
  122.         "api_dev_key="..devKey..
  123.         "&api_user_name="..username..
  124.         "&api_user_password="..password
  125.     )
  126.  
  127.     if result then
  128.         --print("Запрос на пастебин пришел!")
  129.         local info = ""
  130.         for chunk in response do
  131.             info = info .. chunk
  132.         end
  133.         if string.match(info, "^Bad API request, ") then
  134.             --io.write(info)
  135.             return false, info
  136.         --ЕСЛИ ВСЕ ЗАЕБОК
  137.         else
  138.             --print("Получен юзеркей!")
  139.             userKey = info
  140.             --print("Вот так оно выглядит: "..info)
  141.             return true
  142.         end
  143.     else
  144.         --print("Хуйня произошла. Либо URL неверный, либо пастебин недоступен.\n")
  145.         --io.stderr:write(response)
  146.         return false, response
  147.     end
  148.  
  149. end
  150.  
  151. --ЗАГРУЗКА СПИСКА ФАЙЛОВ
  152. local function getFileListFromPastebin(countOfFilesToShow)
  153.     local result, response = pcall(internet.request,
  154.         "http://pastebin.com/api/api_post.php",
  155.         "api_dev_key="..devKey..
  156.         "&api_user_key="..userKey..
  157.         "&api_results_limit="..countOfFilesToShow..
  158.         "&api_option=list"
  159.     )
  160.  
  161.     --КИНУТЬ ОШИБКУ, ЕСЛИ ЧЕТ НЕ ТАК
  162.     if not result then io.stderr:write( response ) end
  163.  
  164.     --ПРОЧИТАТЬ ОТВЕТ С СЕРВЕРА ПАСТЕБИНА
  165.     local info = ""
  166.     for chunk in response do
  167.         info = info .. chunk
  168.     end
  169.  
  170.     --РАСПАСИТЬ ХМЛ
  171.     local x = xml.collect(info)
  172.  
  173.     --ЗАХУЯРИТЬ МАССИВ С ПАСТАМИ
  174.     MyMassivWithPastes = {}
  175.     for pasteID = 1, #x do
  176.         MyMassivWithPastes[pasteID]={}
  177.         MyMassivWithPastes[pasteID]["paste_key"] = x[pasteID][1][1]
  178.         MyMassivWithPastes[pasteID]["paste_date"] = x[pasteID][2][1]
  179.         MyMassivWithPastes[pasteID]["paste_title"] = x[pasteID][3][1]
  180.         MyMassivWithPastes[pasteID]["paste_size"] = x[pasteID][4][1]
  181.         MyMassivWithPastes[pasteID]["paste_expire_date"] = x[pasteID][5][1]
  182.         MyMassivWithPastes[pasteID]["paste_private"] = x[pasteID][6][1]
  183.         MyMassivWithPastes[pasteID]["paste_format_long"] = x[pasteID][7][1]
  184.         MyMassivWithPastes[pasteID]["paste_format_short"] = x[pasteID][8][1]
  185.         MyMassivWithPastes[pasteID]["paste_url"] = x[pasteID][9][1]
  186.         MyMassivWithPastes[pasteID]["paste_hits"] = x[pasteID][10][1]
  187.     end
  188. end
  189.  
  190. local xPos, yPos
  191. local widthTitle
  192. local widthOthers
  193. local xDate
  194. local xDownloads
  195. local xSyntax
  196. local maxPastesCountToShow = math.floor((ySize - 7) / 2)
  197.  
  198. local function displayPaste(i, background, foreground)
  199.  
  200.     ecs.square(1, yPos, xSize - 2, 1, background)
  201.  
  202.     --Нарисовать цветной кружочек
  203.     local color = ecs.colors.green
  204.     if tonumber(MyMassivWithPastes[i]["paste_private"]) == 1 then
  205.         color = ecs.colors.red
  206.     end
  207.     ecs.colorText(xPos, yPos, color, "●")
  208.     color = nil
  209.  
  210.     --Нарисовать имя пасты
  211.     ecs.colorText(xPos + 2, yPos, foreground, ecs.stringLimit("end", MyMassivWithPastes[i]["paste_title"], widthTitle - 3))
  212.    
  213.     --Нарисовать дату пасты
  214.     local date = unixtime.convert(tonumber(MyMassivWithPastes[i]["paste_date"]))
  215.     gpu.set(xDate, yPos, date)
  216.  
  217.     --Нарисовать Хитсы
  218.     gpu.set(xDownloads, yPos, MyMassivWithPastes[i]["paste_hits"])
  219.  
  220.     --Нарисовать формат
  221.     gpu.set(xSyntax, yPos, MyMassivWithPastes[i]["paste_format_long"])
  222. end
  223.  
  224. --Нарисовать пасты
  225. local function displayPastes(from)
  226.  
  227.     obj["Pastes"] = nil
  228.  
  229.     --Стартовые коорды
  230.     xPos, yPos = 2, 6
  231.  
  232.     --Размеры таблицы
  233.     widthTitle = math.floor((xSize - 2) / 2) + 5
  234.     widthOthers = math.floor((xSize - 2 - widthTitle) / 3)
  235.     xDate = xPos + widthTitle
  236.     xDownloads = xDate + widthOthers
  237.     xSyntax = xDownloads + widthOthers
  238.  
  239.     --Цвет фона на нужный сразу
  240.     gpu.setBackground(0xffffff)
  241.  
  242.     --Стартовая инфотаблица - ну, имя там, размер, дата и прочее
  243.     ecs.colorText(xPos, yPos, 0x990000, "Имя")
  244.     gpu.set(xDate, yPos, "Дата")
  245.     gpu.set(xDownloads, yPos, "Скачиваний")
  246.     gpu.set(xSyntax, yPos, "Синтакс")
  247.  
  248.     ecs.colorText(1, yPos + 1, 0x990000, string.rep("─", xSize - 2))
  249.     yPos = yPos + 2
  250.  
  251.     ecs.srollBar(xSize - 1, 6, 2, ySize - 5, #MyMassivWithPastes, from, 0xcccccc, ecs.colors.blue)
  252.  
  253.     --Все пасты рисуем
  254.     for i = from, (from + maxPastesCountToShow - 1) do
  255.  
  256.         if MyMassivWithPastes[i] then
  257.             displayPaste(i, 0xffffff, 0x000000)
  258.  
  259.             newObj("Pastes", i, 1, yPos, xSize - 2, yPos)
  260.  
  261.             --Нарисовать разделитель
  262.             if i ~= (from + maxPastesCountToShow - 1) then ecs.colorText(1, yPos + 1, 0xcccccc, string.rep("─", xSize - 2)) end
  263.         else
  264.             ecs.square(1, yPos, xSize - 2, 2, 0xffffff)
  265.         end
  266.  
  267.         yPos = yPos + 2
  268.     end
  269. end
  270.  
  271. local function getRandomCifri(length)
  272.     local cifri = ""
  273.     for i = 1, length do
  274.         cifri = cifri .. tostring(math.random(0, 1))
  275.     end
  276.     return cifri
  277. end
  278.  
  279. local function drawTopBar()
  280.  
  281.     --Полосочки
  282.     ecs.square(1, 1, xSize, 1, tabColor1)
  283.  
  284.     gpu.setBackground(tabColor2)
  285.     gpu.setForeground( tabColor1 )
  286.     gpu.fill(1, 2, xSize, 3, "░")
  287.  
  288.     ecs.square(1, 5, xSize, 1, tabColor1)
  289.  
  290.     --Листочек
  291.     local sheetWidth = 6
  292.     gpu.setForeground(0x000000)
  293.     gpu.setBackground(0xffffff)
  294.  
  295.     gpu.set(2, 2, getRandomCifri(sheetWidth))
  296.     gpu.set(3, 3, getRandomCifri(sheetWidth))
  297.     gpu.set(4, 4, getRandomCifri(sheetWidth))
  298.  
  299.     --Надписи всякие
  300.     ecs.colorTextWithBack(2, 1, tabColor2, tabColor1, "#1 paste tool since 2002")
  301.     ecs.colorTextWithBack(11, 3, tabTextColor, tabColor2, "PASTEBIN")
  302.     local name = "⛨Загрузить новый файл"; newObj("TopButtons", name, ecs.drawAdaptiveButton(1, 5, 1, 0, name, tabColor1, tabTextColor))
  303.    
  304.     local xPos = xSize - 23
  305.     if username then
  306.         name = "Разлогиниться"; newObj("TopButtons", name, ecs.drawAdaptiveButton(xPos, 5, 1, 0, name, tabColor1, tabTextColor)); xPos = xPos + unicode.len(name) + 3
  307.         name = "Выход"; newObj("TopButtons", name, ecs.drawAdaptiveButton(xPos, 5, 1, 0, name, tabColor1, tabTextColor)); xPos = xPos + unicode.len(name) + 3
  308.  
  309.         --Никнейм
  310.         ecs.colorTextWithBack(xSize - 1 - unicode.len(username), 3, tabTextColor, tabColor2, username)
  311.     end
  312. end
  313.  
  314. local function clear()
  315.     ecs.square(1, 6, xSize, ySize, 0xffffff)
  316. end
  317.  
  318. local function inputPassword()
  319.     --local massiv = ecs.input("auto", "auto", 20, "Войти в Pastebin", {"input", "Логин", ""},  {"input", "Пароль", ""})
  320.  
  321.     local data = ecs.universalWindow("auto", "auto", 24, tabColor1, true, {"EmptyLine"}, {"CenterText", 0xffffff, "Авторизация"}, {"EmptyLine"}, {"Input", 0xffffff, 0xccccff, "Логин"}, {"Input", 0xffffff, 0xccccff, "Пароль", "●"}, {"EmptyLine"}, {"Button", {tabColor2, 0xffffff, "Войти в аккаунт"}, {0x006dbf, 0xffffff, "Отмена"}})
  322.  
  323.     if data[3] == "Отмена" then return false end
  324.  
  325.     username = data[1] or ""
  326.     password = data[2] or ""
  327.     clear()
  328.  
  329.     return true
  330. end
  331.  
  332. local function analyseConfig()
  333.     if fs.exists(pathToConfig) then
  334.         local massiv = table.fromFile(pathToConfig)
  335.         username = massiv.username
  336.         password = massiv.password
  337.         massiv = nil
  338.     else
  339.         fs.makeDirectory(fs.path(pathToConfig))
  340.         local success = inputPassword()
  341.         if not success then return false end
  342.         table.toFile(pathToConfig, {username = username, password = password})
  343.     end
  344.  
  345.     return true
  346. end
  347.  
  348. local function waitForSuccessLogin()
  349.     while true do
  350.  
  351.         local success = analyseConfig()
  352.         if not success then return false end
  353.         ecs.info("auto", "auto", " ", "Захожу в аккаунт...")
  354.         local success, reason = loginToAccount(username, password)
  355.  
  356.         if success then
  357.             break
  358.         else
  359.             if string.match(reason, "^Bad API request, ") then
  360.                 reason = string.sub(reason, 18, -1)
  361.             end
  362.  
  363.             if reason == "invalid login" then fs.remove(pathToConfig); ecs.error("Неверное сочетание логин/пароль!"); clear() end
  364.         end
  365.        
  366.     end
  367.  
  368.     return true
  369. end
  370.  
  371. local function drawAll()
  372.     ecs.clearScreen(0xffffff)
  373.     drawTopBar()
  374. end
  375.  
  376. local function viewPaste(i)
  377.     local id = MyMassivWithPastes[i]["paste_key"]
  378.     local tmp = "System/Pastebin/tempfile.lua"
  379.     ecs.info("auto", "auto", " ", "Загружаю файл...")
  380.     os.sleep(0.3)
  381.     get(id, tmp)
  382.  
  383.     local file = io.open(tmp, "r")
  384.     local lines = {}
  385.     for line in file:lines() do
  386.         table.insert(lines, line)
  387.     end
  388.     file:close()
  389.  
  390.     ecs.clearScreen(0xffffff)
  391.  
  392.     local from = 1
  393.  
  394.     local back = 0xbbbbbb
  395.  
  396.     ecs.square(1, 1, xSize, 1, back)
  397.     gpu.setForeground(0xffffff)
  398.     ecs.centerText("x", 1, "Просмотр "..id)
  399.     ecs.colorTextWithBack(xSize, 1, 0x000000, back, "X")
  400.  
  401.     --ecs.error("#lines = ".. #lines)
  402.  
  403.     ecs.textField(1, 2, xSize, ySize - 1, lines, from, 0xffffff, 0x262626, 0xdddddd, ecs.colors.blue)
  404.  
  405.     fs.remove(tmp)
  406.  
  407.     while true do
  408.         local e = {event.pull()}
  409.         if e[1] == "scroll" then
  410.             if e[5] == 1 then
  411.                 if from > 1 then from = from - 1; ecs.textField(1, 2, xSize, ySize - 1, lines, from, 0xffffff, 0x262626, 0xdddddd, ecs.colors.blue) end
  412.             else
  413.                 if from < #lines then from = from + 1; ecs.textField(1, 2, xSize, ySize - 1, lines, from, 0xffffff, 0x262626, 0xdddddd, ecs.colors.blue) end
  414.             end
  415.         elseif e[1] == "touch" then
  416.             if e[3] == (xSize) and e[4] == 1 then
  417.                 ecs.colorTextWithBack(xSize, 1, 0xffffff, back, "X")
  418.                 os.sleep(0.3)
  419.                 return
  420.             end
  421.         end
  422.     end
  423. end
  424.  
  425. local function launch(i)
  426.     local tmp = "System/Pastebin/tempfile.lua"
  427.     ecs.info("auto", "auto", " ", "Загружаю файл...")
  428.     get(MyMassivWithPastes[i]["paste_key"], tmp)
  429.  
  430.     ecs.prepareToExit()
  431.     local s, r = shell.execute(tmp)
  432.     if not s then
  433.         ecs.displayCompileMessage(1, r, true, false)
  434.     else
  435.         ecs.prepareToExit()
  436.         print("Программа выполнена успешно. Нажмите любую клавишу, чтобы продолжить.")
  437.         ecs.waitForTouchOrClick()
  438.     end
  439.  
  440.  
  441.  
  442.     fs.remove(tmp)
  443. end
  444.  
  445. --ЗАГРУЗИТЬ ФАЙЛ НА ПАСТЕБИН
  446. local function upload(path, title)
  447.     ecs.info("auto", "auto", " ", "Загружаю \""..fs.name(path).."\"...")
  448.     local file = io.open(path, "r")
  449.     local sText = file:read("*a")
  450.     file:close()
  451.    
  452.     local result, response = pcall(internet.request,
  453.         "http://pastebin.com/api/api_post.php",
  454.         "api_option=paste&"..
  455.         "api_dev_key="..devKey.."&"..
  456.         "api_user_key="..userKey.."&"..
  457.         "api_paste_private=0&"..
  458.         "api_paste_format=lua&"..
  459.         "api_paste_name="..encode(title).."&"..
  460.         "api_paste_code="..encode(sText)
  461.     )
  462.        
  463.     if result then
  464.         --ecs.error(response)
  465.     else
  466.         ecs.error("Отсутствует соединение с Pastebin.com")
  467.         return false
  468.     end
  469. end
  470.  
  471.  
  472. --------------------------------------------------------------------------------------------------------------------------
  473.  
  474. local pasteLoadLimit = 50
  475. local args = {...}
  476.  
  477. drawAll()
  478. if not waitForSuccessLogin() then ecs.prepareToExit(); return true end
  479. drawTopBar()
  480.  
  481. if #args > 1 then
  482.     if args[1] == "upload" or args[1] == "load" then
  483.         if fs.exists(args[2]) and not fs.isDirectory(args[2]) then
  484.             upload(args[2], fs.name(args[2]))
  485.             os.sleep(5) -- Ждем, пока 100% прогрузится апи пастебина
  486.         else
  487.             ecs.error("Файл не существует или является директорией.")
  488.             return
  489.         end
  490.     end
  491. end
  492.  
  493. ecs.info("auto", "auto", " ", "Получаю список файлов...")
  494. getFileListFromPastebin(pasteLoadLimit)
  495.  
  496. displayPastes(drawPastesFrom)
  497.  
  498. while true do
  499.     local e = {event.pull()}
  500.     if e[1] == "scroll" then
  501.         if e[5] == 1 then
  502.             if drawPastesFrom > 1 then drawPastesFrom = drawPastesFrom - 1; displayPastes(drawPastesFrom) end
  503.         else
  504.             if drawPastesFrom < pasteLoadLimit then drawPastesFrom = drawPastesFrom + 1; displayPastes(drawPastesFrom) end
  505.         end
  506.     elseif e[1] == "touch" then
  507.         for key, val in pairs(obj["Pastes"]) do
  508.             if ecs.clickedAtArea(e[3], e[4], obj["Pastes"][key][1], obj["Pastes"][key][2], obj["Pastes"][key][3], obj["Pastes"][key][4] ) then
  509.                 --ecs.error("key = "..key)
  510.                 yPos = obj["Pastes"][key][2]
  511.                 displayPaste(key, ecs.colors.blue, 0xffffff)
  512.  
  513.                 if e[5] == 1 then
  514.                     local action = context.menu(e[3], e[4], {"Просмотр"}, "-", {"Запустить"}, {"Сохранить как"}, "-",{"Удалить"})
  515.  
  516.                     if action == "Сохранить как" then
  517.                         local data = ecs.universalWindow("auto", "auto", 36, tabColor1, true, {"EmptyLine"}, {"CenterText", 0xffffff, "Сохранить как"}, {"EmptyLine"}, {"Input", 0xffffff, 0xccccff, "Имя"}, {"EmptyLine"}, {"Button", {0xffffff, 0xccccff, "OK"}} )
  518.                         local path = data[1]
  519.                         if path ~= nil or path ~= "" or path ~= " " then
  520.                             fs.makeDirectory(fs.path(path))
  521.                             local action2 = ecs.askForReplaceFile(path)
  522.                             ecs.info("auto", "auto", " ", "Загружаю файл...")
  523.                             if action2 == nil or action2 == "replace" then
  524.                                 fs.remove(path)
  525.                                 get(MyMassivWithPastes[key]["paste_key"], path)
  526.                                 ecs.select("auto", "auto", " ", {{"Загрузка завершена."}}, {{"Заебись!"}})
  527.                             elseif action2 == "keepBoth" then
  528.                                 get(MyMassivWithPastes[key]["paste_key"], fs.path(path).."(copy)"..fs.name(path))
  529.                             end
  530.                             drawAll()
  531.                             displayPastes(drawPastesFrom)
  532.                         else
  533.                             ecs.error("Сохранение не удалось: не указан путь.")
  534.                         end
  535.                     elseif action == "Удалить" then
  536.                         ecs.info("auto", "auto", " ", "Удаляю файл...")
  537.                         delete(MyMassivWithPastes[key]["paste_key"])
  538.                         os.sleep(5)
  539.                         ecs.info("auto", "auto", " ", "Перезагружаю список файлов...")
  540.                         getFileListFromPastebin(pasteLoadLimit)
  541.                         drawAll()
  542.                         displayPastes(drawPastesFrom)
  543.                     elseif action == "Просмотр" then
  544.                         viewPaste(key)
  545.                         drawAll()
  546.                         displayPastes(drawPastesFrom)
  547.                     elseif action == "Запустить" then
  548.                         launch(key)
  549.                         drawAll()
  550.                         displayPastes(drawPastesFrom)
  551.                     end
  552.  
  553.                     displayPaste(key, 0xffffff, 0x000000)
  554.                 else
  555.                     --os.sleep(0.3)
  556.                     viewPaste(key)
  557.                     drawAll()
  558.                     displayPastes(drawPastesFrom)
  559.                 end
  560.  
  561.                 break
  562.             end
  563.         end
  564.  
  565.         for key, val in pairs(obj["TopButtons"]) do
  566.             if ecs.clickedAtArea(e[3], e[4], obj["TopButtons"][key][1], obj["TopButtons"][key][2], obj["TopButtons"][key][3], obj["TopButtons"][key][4] ) then
  567.                 ecs.drawAdaptiveButton(obj["TopButtons"][key][1], obj["TopButtons"][key][2], 1, 0, key, tabColor2, tabTextColor)
  568.  
  569.                 os.sleep(0.3)
  570.  
  571.                 if key == "Разлогиниться" then
  572.                     fs.remove("System/Pastebin/Login.cfg")
  573.                     drawAll()
  574.                     if not waitForSuccessLogin() then
  575.                         ecs.prepareToExit()
  576.                         return true    
  577.                     end
  578.                     drawTopBar()
  579.                     ecs.info("auto", "auto", " ", "Получаю список файлов...")
  580.                     getFileListFromPastebin(pasteLoadLimit)
  581.                     drawAll()
  582.                     displayPastes(drawPastesFrom)
  583.                 elseif key == "⛨Загрузить новый файл" then
  584.                     local data = ecs.universalWindow("auto", "auto", 36, tabColor1, true, {"EmptyLine"}, {"CenterText", 0xffffff, "Загрузить на Pastebin"}, {"EmptyLine"}, {"Input", 0xffffff, 0xccccff, "Путь к файлу"}, {"Input", 0xffffff, 0xccccff, "Имя на Pastebin"}, {"EmptyLine"}, {"Button", {tabColor2, 0xffffff, "OK"}})
  585.                     if fs.exists(data[1]) then
  586.                         if not fs.isDirectory(data[1]) then
  587.                             upload(data[1], data[2] or "Untitled")
  588.                             os.sleep(5)
  589.                             ecs.info("auto", "auto", " ", "Перезагружаю список файлов...")
  590.                            
  591.                             getFileListFromPastebin(pasteLoadLimit)
  592.                             drawAll()
  593.                             drawPastesFrom = 1
  594.                             displayPastes(drawPastesFrom)
  595.                         else
  596.                             ecs.error("Нельзя загружать папки.")
  597.                         end
  598.                     else
  599.                         ecs.error("Файл \""..fs.name(data[1]).."\" не существует.")
  600.                     end
  601.                 elseif key == "Выход" then
  602.                     ecs.prepareToExit()
  603.                     return true
  604.                 end
  605.  
  606.                 drawTopBar()
  607.  
  608.                 break
  609.             end
  610.         end
  611.     end
  612. end
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619. --------------------------------------------------------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment