diff options
Diffstat (limited to 'modules/admin-mini/luasrc/model')
-rw-r--r-- | modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua | 38 | ||||
-rw-r--r-- | modules/admin-mini/luasrc/model/cbi/mini/passwd.lua | 43 |
2 files changed, 78 insertions, 3 deletions
diff --git a/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua b/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua index 3d26d6a9d6..85b2c86aad 100644 --- a/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua +++ b/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua @@ -14,6 +14,7 @@ $Id$ ]]-- require("luci.model.uci") require("luci.sys") +require("luci.tools.webadmin") m = Map("dhcp", "DHCP") @@ -21,7 +22,7 @@ s = m:section(TypedSection, "dhcp", "DHCP-Server") s.anonymous = true s:depends("interface", "lan") -enable = s:option(ListValue, "ignore", "", "") +enable = s:option(ListValue, "ignore", translate("enable"), "") enable:value(0, translate("enable")) enable:value(1, translate("disable")) @@ -52,9 +53,40 @@ time = s:option(Value, "leasetime") time:depends("ignore", "0") time.rmempty = true -m2 = Map("luci_ethers", translate("luci_ethers")) -s = m2:section(TypedSection, "static_lease", "") + +m2 = Map("luci_ethers", translate("dhcp_leases")) + +local leasefn, leasefp, leases +luci.model.uci.foreach("dhcp", "dnsmasq", + function(section) + leasefn = section.leasefile + end +) +local leasefp = leasefn and luci.fs.access(leasefn) and io.lines(leasefn) +if leasefp then + leases = {} + for lease in leasefp do + table.insert(leases, luci.util.split(lease, " ")) + end +end + +if leases then + v = m2:section(Table, leases, translate("dhcp_leases_active")) + ip = v:option(DummyValue, 3, translate("ipaddress")) + + mac = v:option(DummyValue, 2, translate("macaddress")) + + ltime = v:option(DummyValue, 1, translate("dhcp_timeremain")) + function ltime.cfgvalue(self, ...) + local value = DummyValue.cfgvalue(self, ...) + return luci.tools.webadmin.date_format( + os.difftime(tonumber(value), os.time()) + ) + end +end + +s = m2:section(TypedSection, "static_lease", translate("luci_ethers")) s.addremove = true s.anonymous = true s.template = "cbi/tblsection" diff --git a/modules/admin-mini/luasrc/model/cbi/mini/passwd.lua b/modules/admin-mini/luasrc/model/cbi/mini/passwd.lua new file mode 100644 index 0000000000..8ff18cb5cf --- /dev/null +++ b/modules/admin-mini/luasrc/model/cbi/mini/passwd.lua @@ -0,0 +1,43 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- +f = SimpleForm("password", translate("a_s_changepw"), translate("a_s_changepw1")) + +pw1 = f:field(Value, "pw1", translate("password")) +pw1.password = true + +pw2 = f:field(Value, "pw2", translate("confirmation")) +pw2.password = true + +function pw2.validate(self, value, section) + return pw1:formvalue(section) == value and value +end + +function f.handle(self, state, data) + if state == FORM_VALID then + local stat = luci.sys.user.setpasswd("root", data.pw1) == 0 + + if stat then + f.message = translate("a_s_changepw_changed") + else + f.errmessage = translate("unknownerror") + end + + data.pw1 = nil + data.pw2 = nil + end + return true +end + +return f
\ No newline at end of file |