隐藏配置文件上传功能..规则太难了
This commit is contained in:
parent
613766ec51
commit
12af1c0baf
@ -16,28 +16,11 @@ local m, s
|
||||
m = Map("appfilter",
|
||||
translate("App Filter"),
|
||||
translate(""))
|
||||
|
||||
|
||||
s = m:section(TypedSection, "global", translate("Basic Settings"))
|
||||
s:option(Flag, "enable", translate("Enable App Filter"),translate(""))
|
||||
s.anonymous = true
|
||||
|
||||
local rule_count=0
|
||||
local version=""
|
||||
if nixio.fs.access("/tmp/feature.cfg") then
|
||||
rule_count=tonumber(SYS.exec("cat /tmp/feature.cfg | wc -l"))
|
||||
version=SYS.exec("cat /tmp/feature.cfg |grep \"#version\" | awk '{print $2}'")
|
||||
end
|
||||
|
||||
|
||||
local display_str="<strong>"..translate("Current Version")..": </strong>"..version.."<br><strong>"..translate("App Feature Num")..":</strong> "..rule_count
|
||||
s = m:section(TypedSection, "feature", translate("Update feature"), display_str )
|
||||
|
||||
fu = s:option(FileUpload, "")
|
||||
fu.template = "cbi/oaf_upload"
|
||||
s.anonymous = true
|
||||
|
||||
um = s:option(DummyValue, "rule_data")
|
||||
|
||||
s=m:section(TypedSection,"time",translate("Time Setting")) s.anonymous = true
|
||||
hv = s:option(Value, "start_time", translate("Start Time")) hv.default="00:00"
|
||||
hv.optional=false
|
||||
@ -173,56 +156,5 @@ if config_users~=nil and config_users~=false then
|
||||
end
|
||||
end
|
||||
m:section(SimpleSection).template = "admin_network/user_status"
|
||||
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
|
||||
return
|
||||
end
|
||||
end
|
||||
if chunk and fd then
|
||||
fd:write(chunk)
|
||||
end
|
||||
if eof and fd then
|
||||
fd:close()
|
||||
local fd2 = io.open("/tmp/upload/"..meta.file)
|
||||
local line=fd2:read("*l");
|
||||
fd2:close()
|
||||
local ret=string.match(line, "#version")
|
||||
local lang=m.uci:get_all("luci.main.lang")
|
||||
local feature_file=""
|
||||
if "" == lang or "auto" == lang then
|
||||
feature_file="/etc/appfilter/feature.cfg"
|
||||
else
|
||||
feature_file="/etc/appfilter/feature_"..lang..".cfg"
|
||||
end
|
||||
if ret ~= nil then
|
||||
local cmd="cp /tmp/upload/"..meta.file.." "..feature_file;
|
||||
os.execute(cmd);
|
||||
os.execute("chmod 666 "..feature_file);
|
||||
os.execute("rm /tmp/appfilter -fr");
|
||||
luci.sys.exec("/etc/init.d/appfilter restart &");
|
||||
um.value = translate("Update the feature file successfully, please refresh the page")
|
||||
else
|
||||
um.value = translate("Failed to update feature file, format error")
|
||||
end
|
||||
os.execute("rm /tmp/upload/* -fr");
|
||||
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
|
||||
return m
|
||||
|
@ -1,5 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<label class="cbi-value" style="display:inline-block; width: 130px" for="ulfile"><%:Select feature file:%></label>
|
||||
<input class="cbi-input-file" style="width: 500px" type="file" id="ulfile" name="ulfile" />
|
||||
<input type="submit" class="cbi-button cbi-input-apply" name="upload" value="<%:Upload%>" />
|
||||
<%+cbi/valuefooter%>
|
Loading…
Reference in New Issue
Block a user