<%# Copyright 2008 Steven Barth Copyright 2008-2011 Jo-Philipp Wich Licensed to the public under the Apache License 2.0. -%> <% local fs = require("nixio.fs") local http = require("luci.http") local util = require("luci.util") local sys = require("luci.sys") local dir = '/var/spool/sms/sent/' msg = {} function directory(dir) local p = io.popen('find "'..dir..'" -type f') for file in p:lines() do table.insert(msg, file) msg[#msg + 1] = sms end end start_string = '
' end_string = '
' foot = '' function exist(dir) directory(dir) for k,v in pairs(msg) do msg[k] = v --print(v) if (k%2==0) then head = '
' else head = '
' end local f = io.open(v, "rb") if f then f:close() end lines = {} for r in io.lines(v) do lines[#lines + 1] = r end if (lines[1] ~= nil) then for fr in lines[1]:gmatch("%w+") do if (tonumber(fr)) and (#fr >= 7 ) then fromto = fr fromto = ('+'..fromto..'') elseif string.sub(fr, 1, 1) == "s" then fromto = string.gsub(fr, "s", "") else fromto = fr end end send = {} for sn in lines[4]:gmatch("%S+") do send[#send + 1] = sn end recieved ={} for res in lines[5]:gmatch("%S+") do recieved[#recieved + 1] = res end local utf8str = luci.sys.exec('cat '..v..' | tail -1') if (utf8str ~= "[Aa-Zz]") then utf8str = luci.sys.exec('cat '..v..' | tail -1 | iconv -t UTF-8 -f UCS-2') end print(head, start_string, fromto, end_string, start_string, send[2], send[3], end_string, start_string, recieved[2], end_string, start_string, utf8str, end_string, foot) end end end %> <%+header%>

<%:Smstools3: Outcoming Messages%>

<%:To%>
<%:Send%>
<%:Send Time%>
<%:Message%>
<% exist(dir) %>
<%+footer%>