<%+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("
") end end local function main() local base_info_code, device_sn, device_pwd, device_status, public_ip = luci.phtunnel.get_base_info() if not base_info_code then print("phtunnel is not running") return end if base_info_code ~= 0 then print("get sn failed and code = " .. base_info_code) return end --输出基本信息 print('SN:' .. (device_sn and device_sn or "no sn") .. "
") print('Device Status:' .. (device_status and luci.phtunnel.convert_status(device_status) or "no status") .. "
") print('Public IP:' .. (public_ip and public_ip or "no public ip") .. "
") --登录信息查看 local login_info_code, url, bind_account = luci.phtunnel.get_login_info() if not login_info_code then print("get manager url failed") return end if login_info_code ~= 0 then print("get manger url failed and code = " .. login_info_code) return end if not url or url == "" then display_qrimage(device_sn, device_pwd) print("
") return end print("bind account:" .. (bind_account and bind_account or "*") .. "") print("(log off)"); print("manager link"); end main() display_download_log() %> <%+footer%>