summaryrefslogtreecommitdiffhomepage
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rwxr-xr-xcore/contrib/index.cgi2
-rw-r--r--core/src/ffluci/sys.lua6
-rw-r--r--core/src/ffluci/util.lua34
-rw-r--r--core/src/ffluci/view/header.htm1
4 files changed, 20 insertions, 23 deletions
diff --git a/core/contrib/index.cgi b/core/contrib/index.cgi
index c9c98b0b29..31705ccf27 100755
--- a/core/contrib/index.cgi
+++ b/core/contrib/index.cgi
@@ -1,3 +1,3 @@
#!/usr/bin/haserl --shell=luac
print("Status: 302 Found")
-print("Location: ffluci/admin\n")
+print("Location: ffluci\n")
diff --git a/core/src/ffluci/sys.lua b/core/src/ffluci/sys.lua
index f50b014f08..b9d529a8c8 100644
--- a/core/src/ffluci/sys.lua
+++ b/core/src/ffluci/sys.lua
@@ -162,7 +162,7 @@ end
-- Returns the binary IP to a given IP
function net.ip4bin(ip)
- local parts = ffluci.util.split(ip, '%.')
+ local parts = ffluci.util.split(ip, '.')
if #parts ~= 4 then
return nil
end
@@ -265,7 +265,7 @@ function _parse_delimited_table(iter, delimiter)
local trim = ffluci.util.trim
local split = ffluci.util.split
- local keys = split(trim(iter()), delimiter)
+ local keys = split(trim(iter()), delimiter, nil, true)
for i, j in pairs(keys) do
keys[i] = trim(keys[i])
end
@@ -274,7 +274,7 @@ function _parse_delimited_table(iter, delimiter)
local row = {}
line = trim(line)
if #line > 0 then
- for i, j in pairs(split(line, delimiter)) do
+ for i, j in pairs(split(line, delimiter, nil, true)) do
if keys[i] then
row[keys[i]] = j
end
diff --git a/core/src/ffluci/util.lua b/core/src/ffluci/util.lua
index dfc88e3e41..9cb1e1420c 100644
--- a/core/src/ffluci/util.lua
+++ b/core/src/ffluci/util.lua
@@ -145,33 +145,29 @@ function sessionid()
end
--- Splits a string into an array (Adapted from lua-users.org)
-function split(str, pat, max)
+-- Splits a string into an array
+function split(str, pat, max, regex)
pat = pat or "\n"
- max = max or -1
+ max = max or #str
local t = {}
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
+ local c = 1
- while s do
- max = max - 1
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- if max == 0 then
- break
- end
- s, e, cap = str:find(fpat, last_end)
+ if #pat == 0 then
+ return nil
end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
+ if max == 0 then
+ return str
end
+ repeat
+ local s, e = str:find(pat, c, not regex)
+ table.insert(t, str:sub(c, s and s - 1))
+ max = max - 1
+ c = e and e + 1 or #str + 1
+ until not s or max < 0
+
return t
end
diff --git a/core/src/ffluci/view/header.htm b/core/src/ffluci/view/header.htm
index 1bfc7a02db..ac76e0ab51 100644
--- a/core/src/ffluci/view/header.htm
+++ b/core/src/ffluci/view/header.htm
@@ -3,6 +3,7 @@ require("ffluci.sys")
local load1, load5, load15 = ffluci.sys.loadavg()
local req = require("ffluci.dispatcher").request
local menu = require("ffluci.menu").get()[req.category]
+menu = menu or {}
require("ffluci.i18n").loadc("default")
require("ffluci.http").htmlheader()
%><?xml version="1.0" encoding="utf-8"?>