mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-02 05:23:56 +08:00
🌴 Sync 2026-04-25 00:29:54
This commit is contained in:
1 parent
453c09be1f
commit
8182fc9511
86 files changed
+7913
-11013
No files matched your search
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI page for IPK upload
|
||||
LUCI_DEPENDS:=+luci-lib-fs
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_NAME:=luci-app-filetransfer
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@@ -0,0 +1,13 @@
|
||||
--[[
|
||||
luci-app-filetransfer
|
||||
Description: File upload / download
|
||||
Author: yuleniwo xzm2@qq.com QQ:529698939
|
||||
Modify: ayongwifi@126.com www.openwrtdl.com
|
||||
]]--
|
||||
|
||||
module("luci.controller.filetransfer", package.seeall)
|
||||
|
||||
function index()
|
||||
|
||||
entry({"admin", "system", "filetransfer"}, form("filetransfer"), _("FileTransfer"), 89).dependent = true
|
||||
end
|
||||
@@ -0,0 +1,164 @@
|
||||
local fs = require "luci.fs"
|
||||
local http = luci.http
|
||||
|
||||
ful = SimpleForm("upload", translate("Upload"), nil)
|
||||
ful.reset = false
|
||||
ful.submit = false
|
||||
|
||||
sul = ful:section(SimpleSection, "", translate("Upload file to '/tmp/upload/'"))
|
||||
|
||||
fu = sul:option(FileUpload, "")
|
||||
fu.template = "filetransfer/other_upload"
|
||||
|
||||
um = sul:option(DummyValue, "", nil)
|
||||
um.template = "filetransfer/other_dvalue"
|
||||
|
||||
fdl = SimpleForm("download", translate("Download"), nil)
|
||||
fdl.reset = false
|
||||
fdl.submit = false
|
||||
|
||||
sdl = fdl:section(SimpleSection, "", translate("Download file"))
|
||||
|
||||
fd = sdl:option(FileUpload, "")
|
||||
fd.template = "filetransfer/other_download"
|
||||
|
||||
dm = sdl:option(DummyValue, "", nil)
|
||||
dm.template = "filetransfer/other_dvalue"
|
||||
|
||||
function Download()
|
||||
local sPath, sFile, fd, block
|
||||
sPath = http.formvalue("dlfile")
|
||||
sFile = nixio.fs.basename(sPath)
|
||||
if luci.fs.isdirectory(sPath) then
|
||||
fd = io.popen('tar -C "%s" -cz .' % {sPath}, "r")
|
||||
sFile = sFile .. ".tar.gz"
|
||||
else
|
||||
fd = nixio.open(sPath, "r")
|
||||
end
|
||||
if not fd then
|
||||
dm.value = translate("Couldn't open file: ") .. sPath
|
||||
return
|
||||
end
|
||||
dm.value = nil
|
||||
http.header('Content-Disposition', 'attachment; filename="%s"' % {sFile})
|
||||
http.prepare_content("application/octet-stream")
|
||||
while true do
|
||||
block = fd:read(nixio.const.buffersize)
|
||||
if (not block) or (#block ==0) then
|
||||
break
|
||||
else
|
||||
http.write(block)
|
||||
end
|
||||
end
|
||||
fd:close()
|
||||
http.close()
|
||||
end
|
||||
|
||||
local dir, fd
|
||||
dir = "/tmp/upload/"
|
||||
nixio.fs.mkdir(dir)
|
||||
http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not fd then
|
||||
if not meta then return end
|
||||
|
||||
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
|
||||
|
||||
if not fd then
|
||||
um.value = translate("Create upload file error.")
|
||||
return
|
||||
end
|
||||
end
|
||||
if chunk and fd then
|
||||
fd:write(chunk)
|
||||
end
|
||||
if eof and fd then
|
||||
fd:close()
|
||||
fd = nil
|
||||
um.value = translate("File saved to") .. ' "/tmp/upload/' .. meta.file .. '"'
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
if luci.http.formvalue("upload") then
|
||||
|
||||
|
||||
local f = luci.http.formvalue("ulfile")
|
||||
if #f <= 0 then
|
||||
um.value = translate("No specify upload file.")
|
||||
end
|
||||
elseif luci.http.formvalue("download") then
|
||||
Download()
|
||||
end
|
||||
|
||||
local function getSizeStr(size)
|
||||
local i = 0
|
||||
local byteUnits = {' kB', ' MB', ' GB', ' TB'}
|
||||
repeat
|
||||
size = size / 1024
|
||||
i = i + 1
|
||||
until(size <= 1024)
|
||||
return string.format("%.1f", size) .. byteUnits[i]
|
||||
end
|
||||
|
||||
local inits, attr = {}
|
||||
for i, f in ipairs(fs.glob("/tmp/upload/*")) do
|
||||
attr = fs.stat(f)
|
||||
if attr then
|
||||
inits[i] = {}
|
||||
inits[i].name = fs.basename(f)
|
||||
inits[i].mtime = os.date("%Y-%m-%d %H:%M:%S", attr.mtime)
|
||||
inits[i].modestr = attr.modestr
|
||||
inits[i].size = getSizeStr(attr.size)
|
||||
inits[i].remove = 0
|
||||
inits[i].install = false
|
||||
end
|
||||
end
|
||||
|
||||
form = SimpleForm("filelist", translate("Upload file list"), nil)
|
||||
form.reset = false
|
||||
form.submit = false
|
||||
|
||||
tb = form:section(Table, inits)
|
||||
nm = tb:option(DummyValue, "name", translate("File name"))
|
||||
mt = tb:option(DummyValue, "mtime", translate("Modify time"))
|
||||
ms = tb:option(DummyValue, "modestr", translate("Attributes"))
|
||||
sz = tb:option(DummyValue, "size", translate("Size"))
|
||||
|
||||
btnrm = tb:option(Button, "remove", translate("Remove"))
|
||||
btnrm.render = function(self, section, scope)
|
||||
self.inputstyle = "remove"
|
||||
Button.render(self, section, scope)
|
||||
end
|
||||
|
||||
btnrm.write = function(self, section)
|
||||
local v = luci.fs.unlink("/tmp/upload/" .. luci.fs.basename(inits[section].name))
|
||||
if v then table.remove(inits, section) end
|
||||
return v
|
||||
end
|
||||
|
||||
function IsIpkFile(name)
|
||||
name = name or ""
|
||||
local ext = string.lower(string.sub(name, -4, -1))
|
||||
return ext == ".ipk"
|
||||
end
|
||||
|
||||
btnis = tb:option(Button, "install", translate("Install"))
|
||||
btnis.template = "filetransfer/other_button"
|
||||
btnis.render = function(self, section, scope)
|
||||
if not inits[section] then return false end
|
||||
if IsIpkFile(inits[section].name) then
|
||||
scope.display = ""
|
||||
else
|
||||
scope.display = "none"
|
||||
end
|
||||
self.inputstyle = "apply"
|
||||
Button.render(self, section, scope)
|
||||
end
|
||||
|
||||
btnis.write = function(self, section)
|
||||
local r = luci.sys.exec(string.format('opkg --force-depends install "/tmp/upload/%s"', inits[section].name))
|
||||
form.description = string.format('<span style="color: red">%s</span>', r)
|
||||
end
|
||||
|
||||
return ful, fdl, form
|
||||
@@ -0,0 +1,7 @@
|
||||
<%+cbi/valueheader%>
|
||||
<% if self:cfgvalue(section) ~= false then %>
|
||||
<input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" style="display: <%= display %>" type="submit"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.inputtitle or self.title)%> />
|
||||
<% else %>
|
||||
-
|
||||
<% end %>
|
||||
<%+cbi/valuefooter%>
|
||||
@@ -0,0 +1,5 @@
|
||||
<%+cbi/valueheader%>
|
||||
<label class="cbi-value" style="display:inline-block; width: 130px" for="dlfile"><%:Path on Route:%></label>
|
||||
<input class="cbi-input-file" style="width: 400px" type="text" id="dlfile" name="dlfile" />
|
||||
<input type="submit" class="cbi-button cbi-input-apply" name="download" value="<%:Download%>" />
|
||||
<%+cbi/valuefooter%>
|
||||
@@ -0,0 +1,8 @@
|
||||
<%+cbi/valueheader%>
|
||||
<span style="color: red">
|
||||
<%
|
||||
local val = self:cfgvalue(section) or self.default or ""
|
||||
write(pcdata(val))
|
||||
%>
|
||||
</span>
|
||||
<%+cbi/valuefooter%>
|
||||
@@ -0,0 +1,5 @@
|
||||
<%+cbi/valueheader%>
|
||||
<label class="cbi-value" style="display:inline-block; width: 130px" for="ulfile"><%:Choose local file:%></label>
|
||||
<input class="cbi-input-file" style="width: 400px" type="file" id="ulfile" name="ulfile" />
|
||||
<input type="submit" class="cbi-button cbi-input-apply" name="upload" value="<%:Upload%>" />
|
||||
<%+cbi/valuefooter%>
|
||||
@@ -0,0 +1,66 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: dingpengyu <dingpengyu06@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: zh_CN\n"
|
||||
"X-Generator: Poedit 2.3.1\n"
|
||||
|
||||
msgid "Choose local file:"
|
||||
msgstr "选择本地文件:"
|
||||
|
||||
msgid "Couldn't open file:"
|
||||
msgstr "无法打开文件:"
|
||||
|
||||
msgid "Create upload file error."
|
||||
msgstr "创建上传文件失败。"
|
||||
|
||||
msgid "Download"
|
||||
msgstr "下载"
|
||||
|
||||
msgid "Download file"
|
||||
msgstr "下载文件"
|
||||
|
||||
msgid "File name"
|
||||
msgstr "文件名"
|
||||
|
||||
msgid "File saved to"
|
||||
msgstr "文件保存到"
|
||||
|
||||
msgid "FileTransfer"
|
||||
msgstr "文件传输"
|
||||
|
||||
msgid "Install"
|
||||
msgstr "安装"
|
||||
|
||||
msgid "Attributes"
|
||||
msgstr "属性"
|
||||
|
||||
msgid "Modify time"
|
||||
msgstr "修改时间"
|
||||
|
||||
msgid "No specify upload file."
|
||||
msgstr "未指定上传文件。"
|
||||
|
||||
msgid "Path on Route:"
|
||||
msgstr "路由根目录:"
|
||||
|
||||
msgid "Remove"
|
||||
msgstr "移除"
|
||||
|
||||
msgid "Size"
|
||||
msgstr "大小"
|
||||
|
||||
msgid "Upload"
|
||||
msgstr "上传"
|
||||
|
||||
msgid "Upload file list"
|
||||
msgstr "上传文件列表"
|
||||
|
||||
msgid "Upload file to '/tmp/upload/'"
|
||||
msgstr "将文件上传到'/tmp/upload/'"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
zh-cn
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed -i 's/cbi.submit\"] = true/cbi.submit\"] = \"1\"/g' /usr/lib/lua/luci/dispatcher.lua
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
Reference in new issue
Block a user