Advertisement
Guest User

Untitled

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