<%# LuCI - Lua Configuration Interface Copyright 2008 Steven Barth Copyright 2008 Jo-Philipp Wich Copyright 2012 David Menting 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 -%> <% local sys = require "luci.sys" local http = require "luci.http" local disp = require "luci.dispatcher" local uci = require "luci.model.uci".cursor() local hostname = sys.hostname() reboot_flag=luci.util.trim(luci.util.exec('cat /tmp/noticeReboot')) if uci:get('functionlist','functionlist','SUPPORT_WLAN24G') ~= '1' then --[[ #### WLAN2.4G feature ### --]] export("filterRadio", "wifi0") else export("WLAN24G", "1") end if uci:get('functionlist','functionlist','SUPPORT_WLAN5G') ~= '1' then --[[ #### WLAN5G feature ### --]] export("filterRadio", "wifi1") else export("WLAN5G", "1") end if uci:get('functionlist','functionlist','SUPPORT_WLAN5G_2') == '1' then --[[ #### WLAN5G - 2 feature ### --]] export("WLAN5G_2", "1") end --[[ #### WLAN5G_2 feature ### --]] if uci:get('functionlist','functionlist','SUPPORT_COMBINED_SSID_SETTING') == '1' then --[[ #### SUPPORT_COMBINED_SSID_SETTING ### --]] export("COMBINED_SSID","1") end --[[ #### SUPPORT_COMBINED_SSID_SETTING ### --]] local request = disp.context.path local request2 = disp.context.request local category = request[1] local cattree = category and disp.node(category) local webaccount = luci.util.trim(luci.util.exec("cat /etc/webpasswd | awk -F \":\" '{ print $1 }'")) local webpasswd = luci.util.trim(luci.util.exec("cat /etc/webpasswd | awk -F \":\" '{ print $2 }'")) local webaccountDef = luci.util.trim(luci.util.exec("cat /rom/etc/webpasswd | awk -F \":\" '{ print $1 }'")) local webpasswdDef = luci.util.trim(luci.util.exec("cat /rom/etc/webpasswd | awk -F \":\" '{ print $2 }'")) local noAccessReset = luci.util.trim(luci.util.exec("cat /tmp/hide")) local leaf = request2[#request2] local tree = disp.node() local node = disp.context.dispatched local categories = disp.node_childs(tree) local ex_gui_port="0", ex_onboard_cam_gui_port, ex_onboard_cam_rtsp_port, ex_onboard_cam_rtmp_port local lan_ip = luci.util.trim(luci.util.exec("ifconfig br-lan | grep \"inet addr\" | awk -F \" \" '{print $2}' | awk -F \":\" '{print $2}'")) if uci:get('functionlist','functionlist','SUPPORT_IPCAM') == "1" then if nixio.fs.access("/etc/config/nat-traversal") then ex_gui_port = uci:get("nat-traversal","nattraversal","ex_gui_port") or "0" ex_onboard_cam_gui_port = uci:get("nat-traversal","nattraversal","ex_onboard_cam_gui_port") ex_onboard_cam_rtsp_port = uci:get("nat-traversal","nattraversal","ex_onboard_cam_rtsp_port") ex_onboard_cam_rtmp_port = uci:get("nat-traversal","nattraversal","ex_onboard_cam_rtmp_port") end end local c = tree local i, r local first_login = uci:get('system','firmware','first_login') or "0" local top_menu = uci:get("functionlist","functionlist","SUPPORT_TOP_MENU") local account = luci.util.trim(luci.util.exec("cat /tmp/md5tmp_account"))or " " local password = luci.util.trim(luci.util.exec("cat /tmp/md5tmp_pass"))or " " -- tag all nodes leading to this page for i, r in ipairs(request) do if c.nodes and c.nodes[r] then c = c.nodes[r] c._menu_selected = true end end -- send as HTML5 http.prepare_content("text/html") local function nodeurl(prefix, name, query) local url = controller .. prefix .. name .. "/" if query then url = url .. http.build_querystring(query) end return pcdata(url) end local function subtree(prefix, node, level) if not level then level = 1 end -- Skip subtree display if prefix == "/admin/network/wireless/" then return elseif prefix == "/admin/network/wireless_device/" then return elseif prefix == "/admin/network/network/" then return end local childs = disp.node_childs(node) if #childs > 0 then if level > 2 then %>
    <% end local selected_node local selected_name local i, v for i, v in ipairs(childs) do local nnode = node.nodes[v] if nnode._menu_selected then selected_node = nnode selected_name = v end if level > 2 then %>
  • <%=striptags(translate(nnode.title))%>
  • <% end end if level > 2 then %>
<% end if selected_node then subtree(prefix .. selected_name .. "/", selected_node, level + 1) end end end -%> <% local menu_advanced, menu_connections, cur_select, cur_node, menu_wifi_schedule if #request2 > 0 then cur_node = '' for i=1, #request2 do cur_node = cur_node .. request2[i] .. '/' end if request2[3] ~= "account_change" and uci:get("system","firmware","first_login") == "1" then luci.util.exec("echo '1' > /tmp/logout") else cur_select = disp.build_url(cur_node) end else if uci:get('functionlist','functionlist','SUPPORT_IPCAM') == "1" then local username = luci.util.trim(luci.util.exec('cat /tmp/md5tmp_account')) local isAdminAccount = luci.util.exec("/lib/auth.sh get_authority \""..username.."\""):sub(1,-2) if uci:get('apcontroller','capwap','enable') == "1" then uci:set("system","firmware","first_login","0") uci:save("system") uci:commit("system") luci.http.redirect(disp.build_url('admin/ipcam/Live/')) elseif uci:get('network','sys','EnMesh') == "1" then uci:set("system","firmware","first_login","0") uci:save("system") uci:commit("system") luci.http.redirect(disp.build_url('admin/ipcam/Live/')) elseif uci:get('system','firmware','first_login') == "1" and isAdminAccount == "0" then luci.util.exec("echo '1' > /tmp/hide") luci.http.redirect(disp.build_url('admin/system/account_change/')) else luci.http.redirect(disp.build_url('admin/ipcam/Live/')) end elseif uci:get('functionlist','functionlist','SUPPORT_AP_RP_SETUP_WIZARD') == "1" and uci:get("system","firmware","first_login") == "1" then luci.http.redirect(disp.build_url('admin/network/repeater_site_survey/')) elseif uci:get('functionlist','functionlist','SUPPORT_MESH_SETTING') == "1" then if uci:get('functionlist','functionlist','SUPPORT_HIDE_WIZARD') == "1" then luci.http.redirect(disp.build_url('admin/status/overview/')) else luci.http.redirect(disp.build_url('admin/network/wizard_init/')) end else if webaccount == webaccountDef and webpasswd == webpasswdDef and uci:get('functionlist','functionlist','SUPPORT_MYID') ~= '1' then luci.util.exec("echo '1' > /tmp/hide") luci.http.redirect(disp.build_url('admin/system/account_change/')) else cur_select = disp.build_url('admin/status/overview/') end end end if nixio.fs.access("/usr/lib/lua/luci/view/admin_network/advanced.htm") then menu_advanced = disp.build_url('admin/network/advanced') else menu_advanced = disp.build_url('admin/system/system/') end if nixio.fs.access("/usr/lib/lua/luci/view/admin_status/wireless_connections.htm") then menu_connections = disp.build_url('admin/status/wireless_conn') else menu_connections = disp.build_url('admin/status/overview/') end if nixio.fs.access("/usr/lib/lua/luci/view/admin_network/wifi_schedule.htm") then menu_wifi_schedule = disp.build_url('admin/network/wifi_schedule') else menu_wifi_schedule = disp.build_url('admin/system/admin/') end local ucichanges = 0 if tree.nodes[category] and tree.nodes[category].ucidata then for i, j in pairs(require("luci.model.uci").cursor():changes()) do for k, l in pairs(j) do if filterRadio and k==filterRadio then else for m, n in pairs(l) do ucichanges = ucichanges + 1; end end end end end %> <%=striptags(hostname) %> <% if node and node.css then %> <% end -%> <% if css then %> <% end -%> <% if uci:get('functionlist','functionlist','SUPPORT_IPCAM') == "1" then %> <% end %> <% local d if nixio.fs.access("/etc/config/sysProductInfo") then d = luci.model.uci.cursor():get_all("sysProductInfo","model") else d = {["modelName"]="ECB123", ["description"]="Hello World"} end local BANNER_LOGO = uci:get('functionlist','vendorlist','BANNER_LOGO') or "/Netgear_logo.png" if uci:get("functionlist","functionlist","SUPPORT_BUSINESS_SERIES") == "1" then BANNER_LOGO = "/Netgear_business_logo.png" end %> <%+functionlist%> <%if uci:get("system","firmware","first_login") == "0" and uci:get("functionlist","functionlist","SUPPORT_MYID") ~= '1' then %> <% else %> <% end %>
<% local authority = luci.util.exec("/lib/auth.sh get_authority \""..account.."\""):sub(1,-2) if uci:get("functionlist","functionlist","SUPPORT_MULTI_LOGIN") ~= "1" then %> <% if uci:get('functionlist','functionlist','SUPPORT_AP_RP_SETUP_WIZARD') == "1" and uci:get("system","firmware","first_login") == "1" or noAccessReset == "1" then %>
<% else %> <% if uci:get('sysProductInfo','model','modelName')=='EMD11' then %> <% end else%> <% if uci:get('functionlist','functionlist','SUPPORT_AP_RP_SETUP_WIZARD') == "1" and uci:get("system","firmware","first_login") == "1" or noAccessReset == "1" then %>
<%:Logout%>
<% else %>
<%:Logout%>
<% end %> <%end%>