<% local values = ... local function onoff ( bool ) if bool then return "on" else return "off" end end local function xml_elem(elem,value,permissions,i) local output = {"<", elem, ' perm="', permissions, '"'} if i then output[#output+1] = ' idx="'..i..'"' end output[#output+1] = ">" if type(value) == "boolean" then output[#output+1] = onoff(value) elseif value then output[#output+1] = value end output[#output+1] = "" io.write(table.concat(output)) end %> <% io.write(values.device.adminpassword) %> <% xml_elem('eth_pc',values.device.pcportenable,'R') %> <% io.write(values.device.adminpassword) %> admin <% io.write(values.device.sntpserver) %> <% for pg, pg_t in pairs(values) do -- Is it of the form regX ? local num = string.match(pg, 'reg(%d+)') if num then if pg_t.extension ~= "" then xml_elem('user_active', 'on', 'RW', num ) xml_elem('record_dialed_calls', pg_t.callhistoryenable, 'R', num) xml_elem('record_missed_calls', pg_t.callhistoryenable, 'R', num) xml_elem('record_received_calls', pg_t.callhistoryenable, 'R', num) -- SNOMs do not support per-line forwarding xml_elem('redirect_allways',pg_t.forwardallenable,'RW') xml_elem('redirect_number',pg_t.forwardall,'RW') xml_elem('redirect_on_busy',pg_t.forwardbusyenable,'RW') xml_elem('redirect_busy_number',pg_t.forwardbusy,'RW') xml_elem('redirect_on_timeout',pg_t.forwardnoanswerenable,'RW') xml_elem('redirect_time_number',pg_t.forwardnoanswer,'RW') xml_elem('user_host', values.device.registrar, 'R', num ) xml_elem('user_moh', 'sip:'..values.device.musiconhold, 'R', num) xml_elem('user_name', pg_t.extension, 'R', num) xml_elem('user_outbound', values.device.registrar, 'R', num) xml_elem('user_pass', pg_t.password, 'R', num) -- Caller ID string if string.len(pg_t.callerid) == 0 then xml_elem( 'user_realname', pg_t.extension,'R', num) else xml_elem( 'user_realname', pg_t.callerid,'R', num) end end end end %>