⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form.lua

📁 嵌入式无线路由系统openwrt的web配置工具
💻 LUA
字号:
#!/usr/bin/lua-- Copyright (C) 2008 OpenRB.comrequire('fslib')data = datajson()cfgvars = {  values = { proto = 'none' },  params = {},  wifidevice = {},  wifiiface = {},  iwinfo = {},  bridges = {}}if (data ~= nil and data['id'] ~= nil) then  -- find config name for given interface if it's wireless  cfgvars['params']['wifidevice'] = checkwifi(data['id'])  cfgName = iftocfg(data['id'])  -- check that config entry was found  if (cfgName ~= nil) then    cfgvars['values'] = uci.init('network', cfgName)    cfgvars['params']['id'] = cfgName  end  cfgvars['params']['ifname'] = data['id']  -- interface has wext, add wifi values  if (cfgvars['params']['wifidevice'] ~= nil) then    -- find section to load from wireless config file    wifiCfgName = findstate('wireless', {nil, nil, 'ifname', data['id']}, 2)    -- get wifi device options    if (wifiCfgName ~= nil) then      cfgvars['wifiiface'] = uci.init('wireless', wifiCfgName)      cfgvars['wifimode'] = 'sta'      wlancmd = 'list ap'      if (cfgvars['wifiiface'] ~= nil) then        cfgvars['params']['wifiiface'] = cfgvars['wifiiface']['.name']        if (cfgvars['wifiiface']['mode'] == 'ap') then          wlancmd = 'list sta'          cfgvars['wifimode'] = 'ap'        end      end      cfgvars['wifiinfo'] = readlines('wlanconfig ' .. data['id'] .. ' ' .. wlancmd, 1, true)    end        -- get wifi iface options    cfgvars['wifidevice'] = uci.init('wireless', cfgName)        -- get channel list    cfgvars['iwinfo'] = proc('iw-info ' .. data['id'])    cfgvars['wificcode'] = wifigetcc()    bridges = proc('if-json -s')    -- show possible bridge list    for bridge, status in pairs(bridges) do      -- ifname must start with "eth"      if (bridge:find('eth', 1, true) ~= nil) then        cfgname = iftocfg(bridge)        if (cfgname ~= nil) then          table.insert(cfgvars['bridges'], {cfgname, bridge})        end      end    end  endelseif (data ~= nil and data['bridge']) then  cfgvars.values['type'] = 'bridge'  cfgvars.params['new'] = true  cfgvars.params['new_bridge'] = true  -- find next name for bridge  for i=0,9,1 do    brname = 'br' .. i    if (uci.get('network', brname) == nil) then      cfgvars.values['brname'] = brname      break    end  endendio.write(json.encode(cfgvars))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -