<%# 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/incoming/' msg = {} function directory(dir) local p = io.popen('find "'..dir..'" -type f -iname [0-9]* | sort -r') for file in p:lines() do table.insert(msg, file) msg[#msg + 1] = sms end end start_string = '
' end_string = '
' foot = '' button = [[ ]] function exist(dir) directory(dir) for k,v in pairs(msg) do msg[k] = 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..'') 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 text = {} for t in table.concat(lines,"
",14,r):gmatch("%S+") do text[#text + 1] = t end print(head, start_string, fromto, end_string, start_string, send[2], send[3], end_string, start_string, recieved[2], recieved[3], end_string, start_string, table.concat(text, " "), end_string, foot) end end end %> <%+header%>

<%:Smstools3: Incoming Messages%>

<%:From%>
<%:Send%>
<%:Recieve%>
<%:Message%>
<% exist(dir) luci.sys.exec('/usr/share/luci-app-smstools3/led.sh off') %>
<%+footer%>