summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-splash
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-26 23:00:44 +0000
committerSteven Barth <steven@midlink.org>2008-08-26 23:00:44 +0000
commit91ba7c42f5b45614c9f4c803d09399f08a8e27b1 (patch)
tree21d1e1d67b3bee82eb123c0c5dbb274f2fcb6b59 /applications/luci-splash
parent43b3217e5595acc91ff6d7614a5c21c88696fbcc (diff)
UCI API changes
Diffstat (limited to 'applications/luci-splash')
-rw-r--r--applications/luci-splash/luasrc/controller/splash/splash.lua2
-rw-r--r--applications/luci-splash/luasrc/model/cbi/splash/splash.lua8
-rw-r--r--applications/luci-splash/luasrc/view/splash/splash.htm2
-rwxr-xr-xapplications/luci-splash/root/usr/bin/luci-splashd5
-rwxr-xr-xapplications/luci-splash/root/usr/sbin/luci-splash29
5 files changed, 24 insertions, 22 deletions
diff --git a/applications/luci-splash/luasrc/controller/splash/splash.lua b/applications/luci-splash/luasrc/controller/splash/splash.lua
index dbd266f46..b046ff409 100644
--- a/applications/luci-splash/luasrc/controller/splash/splash.lua
+++ b/applications/luci-splash/luasrc/controller/splash/splash.lua
@@ -22,7 +22,7 @@ function action_activate()
local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR"))
if mac and luci.http.formvalue("accept") then
os.execute("luci-splash add "..mac.." >/dev/null 2>&1")
- luci.http.redirect(luci.model.uci.get("freifunk", "community", "homepage"))
+ luci.http.redirect(luci.model.uci.cursor():get("freifunk", "community", "homepage"))
else
luci.http.redirect(luci.dispatcher.build_url())
end
diff --git a/applications/luci-splash/luasrc/model/cbi/splash/splash.lua b/applications/luci-splash/luasrc/model/cbi/splash/splash.lua
index 49257f1ba..29bc6d9ab 100644
--- a/applications/luci-splash/luasrc/model/cbi/splash/splash.lua
+++ b/applications/luci-splash/luasrc/model/cbi/splash/splash.lua
@@ -11,21 +11,23 @@ s.template = "cbi/tblsection"
s.addremove = true
s.anonymous = true
+local uci = luci.model.uci.cursor()
+
zone = s:option(ListValue, "zone", "Firewallzone")
-luci.model.uci.foreach("firewall", "zone",
+uci:foreach("firewall", "zone",
function (section)
zone:value(section.name)
end)
iface = s:option(ListValue, "network", "Netzwerk")
-luci.model.uci.foreach("network", "interface",
+uci:foreach("network", "interface",
function (section)
if section[".name"] ~= "loopback" then
iface:value(section[".name"])
end
end)
-luci.model.uci.foreach("network", "alias",
+uci:foreach("network", "alias",
function (section)
iface:value(section[".name"])
end)
diff --git a/applications/luci-splash/luasrc/view/splash/splash.htm b/applications/luci-splash/luasrc/view/splash/splash.htm
index 1988224d7..28a038409 100644
--- a/applications/luci-splash/luasrc/view/splash/splash.htm
+++ b/applications/luci-splash/luasrc/view/splash/splash.htm
@@ -12,7 +12,7 @@ You may obtain a copy of the License at
$Id$
-%>
-<% local c = luci.model.uci.get_all("freifunk", "community") %>
+<% local c = luci.model.uci.cursor():get_all("freifunk", "community") %>
<h1>Willkommen!</h1>
<p>
diff --git a/applications/luci-splash/root/usr/bin/luci-splashd b/applications/luci-splash/root/usr/bin/luci-splashd
index 3e0c938eb..267fbdf0a 100755
--- a/applications/luci-splash/root/usr/bin/luci-splashd
+++ b/applications/luci-splash/root/usr/bin/luci-splashd
@@ -4,7 +4,8 @@ require("socket")
require("luci.ip")
require("luci.model.uci")
-luci.model.uci.load_state("network")
+local uci = luci.model.uci.cursor_state()
+uci:load("network")
local server = socket.bind("0.0.0.0", arg[1] or 8082)
server:settimeout(0, "t")
@@ -16,7 +17,7 @@ while true do
client:settimeout(1)
local srv
local ip = luci.ip.IPv4(client:getpeername())
- luci.model.uci.foreach("network", "interface",
+ uci:foreach("network", "interface",
function (section)
if section.ipaddr then
local net = luci.ip.IPv4(section.ipaddr, section.netmask)
diff --git a/applications/luci-splash/root/usr/sbin/luci-splash b/applications/luci-splash/root/usr/sbin/luci-splash
index 520f87702..82662c871 100755
--- a/applications/luci-splash/root/usr/sbin/luci-splash
+++ b/applications/luci-splash/root/usr/sbin/luci-splash
@@ -5,8 +5,7 @@ require("luci.util")
require("luci.model.uci")
-- Init state session
-luci.model.uci.load_state("luci_splash")
-local uci = luci.model.uci
+local uci = luci.model.uci.cursor_state()
function main(argv)
@@ -60,13 +59,13 @@ end
-- Add a lease to state and invoke add_rule
function add_lease(mac)
- uci.section("luci_splash", "lease", nil, {
+ uci:section("luci_splash", "lease", nil, {
mac = mac,
start = os.time()
})
add_rule(mac)
- uci.save_state("luci_splash")
+ uci:save("luci_splash")
end
@@ -75,7 +74,7 @@ function remove_lease(mac)
mac = mac:lower()
local del = {}
- uci.foreach("luci_splash", "lease",
+ uci:foreach("luci_splash", "lease",
function (section)
if section.mac:lower() == mac then
table.insert(del, section[".name"])
@@ -84,10 +83,10 @@ function remove_lease(mac)
for i,j in ipairs(del) do
remove_rule(j)
- uci.delete("luci_splash", j)
+ uci:delete("luci_splash", j)
end
- uci.save_state("luci_splash")
+ uci:save("luci_splash")
end
@@ -108,7 +107,7 @@ function haslease(mac)
mac = mac:lower()
local stat = false
- uci.foreach("luci_splash", "lease",
+ uci:foreach("luci_splash", "lease",
function (section)
if section.mac:lower() == mac then
stat = true
@@ -124,7 +123,7 @@ end
function iswhitelisted(mac)
mac = mac:lower()
- uci.foreach("luci_splash", "whitelist",
+ uci:foreach("luci_splash", "whitelist",
function (section)
if section.mac:lower() == mac then
stat = true
@@ -150,14 +149,14 @@ function sync()
local time = os.time()
-- Current leases in state files
- local leases = uci.get_all("luci_splash")
+ local leases = uci:get_all("luci_splash")
-- Convert leasetime to seconds
- local leasetime = tonumber(uci.get("luci_splash", "general", "leasetime")) * 3600
+ local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime")) * 3600
-- Clean state file
- uci.load_state("luci_splash")
- uci.revert("luci_splash")
+ uci:load("luci_splash")
+ uci:revert("luci_splash")
-- For all leases
@@ -168,7 +167,7 @@ function sync()
remove_rule(v.mac)
else
-- Rewrite state
- uci.section("luci_splash", "lease", nil, {
+ uci:section("luci_splash", "lease", nil, {
mac = v.mac,
start = v.start
})
@@ -185,7 +184,7 @@ function sync()
end
end
- uci.save_state("luci_splash")
+ uci:save("luci_splash")
end
main(arg) \ No newline at end of file