%+header%>
<%
require("luci.sys")
require("luci.model.uci")
local uci = luci.model.uci.cursor()
local log_file = uci:get("phtunnel", "log", "path")
if not log_file or log_file == "" then
log_file = "/var/log/oraybox/phtunnel.log"
end
%>
<%
require("luci.phtunnel")
local utl = require "luci.util"
local function fileExists(path)
local file = io.open(path, "rb")
if file then file:close() end
return file ~= nil
end
local function grant_download_permission()
local dsp = require "luci.dispatcher"
local sid = dsp.context.authsession
local access, _ = utl.ubus("session", "access",
{ubus_rpc_session = sid,
scope = "file",
object = log_file,
["function"] = "read"})
if type(access) == "table" and access.access == false then
local acl = {}
acl[1] = {}
acl[1][1] = log_file
acl[1][2] = "read"
utl.ubus("session", "grant", { ubus_rpc_session = sid, scope = "file", objects = acl})
end
end
local function display_download_log()
if fileExists(log_file) then
print('Download Log File
')
grant_download_permission()
end
end
--输出二
local function display_qrimage(sn, pwd)
local qrcode, qrcodeimg, ttl = luci.phtunnel.get_qrimage(sn, pwd)
if qrcode and qrcodeimg then
print("