%+header%> <% local http = require("luci.http") local core = require("substore.core") -- meta.error / human_duration 返回的都是语言中立的 msgid(可能是组合消息), -- 翻译在视图侧做 —— 后端模块不能 require("luci.i18n"),见 msg.lua 的文件头。 local msg = require("substore.msg") local function tmsg(s) return msg.translate(s, luci.i18n.translate) end local id = http.formvalue("id") or "" local it = id ~= "" and core.get(id) or nil local is_edit = it ~= nil local cron_enabled = it and (it.cron_enable == true or it.cron_enable == "1") or false local cron = (it and it.cron_time and it.cron_time ~= "") and it.cron_time or "0 3 * * *" local cm, ch, cdom, cmon, cdow = cron:match("^(%S+) (%S+) (%S+) (%S+) (%S+)$") cm = cm or "0"; ch = ch or "3"; cdom = cdom or "*"; cmon = cmon or "*"; cdow = cdow or "*" local rules_enabled = it and (it.rules_enable == true or it.rules_enable == "1") or false local ki = (it and it.keyword_include) or "" local ke = (it and it.keyword_exclude) or "" local dedup = it and (it.dedup == "1" or it.dedup == true) -- 协议筛选 / 重命名:控制器一直在读这两项(read_rules_fields),但此前三个表单 -- 都没有提交它们的控件 —— 字段永远写空,且每次保存会把 UCI 里已有的值重置为 ""。 local proto_sel = {} for p in ((it and it.proto_filter) or ""):gmatch("[^,]+") do proto_sel[p:match("^%s*(.-)%s*$")] = true end local rm = (it and it.rename_map) or "" local proxy_enabled = it and (it.proxy_enable == true or it.proxy_enable == "1") or false -- 订阅客户端类型(User-Agent)。部分机场按 UA 决定返回真实节点还是占位内容: -- 同一个订单链接只有用绑定的客户端 UA 才拿得到真节点。预设见 core.UA_PRESETS。 local ua_preset = core.ua_preset_of(it and it.user_agent) local ua_custom = (ua_preset == "custom") and (it and it.user_agent or "") or "" local util = require("substore.util") -- 剩余流量 / 剩余时长(仅编辑页且有 subscription-userinfo 数据时显示,首页不显示) local traffic_str = nil local time_str = nil if is_edit and it then if it.total then local rem = (tonumber(it.total) or 0) - (tonumber(it.upload) or 0) - (tonumber(it.download) or 0) if rem < 0 then rem = 0 end traffic_str = util.human_bytes(rem) end if it.expire then time_str = tmsg(util.human_duration((tonumber(it.expire) or 0) - os.time())) end end %>