#!/usr/fb/bin/lua require 'lua.inc' --[[---------------------------------------------------------------------- Main ----------------------------------------------------------------------]]-- mydump("top.inc") print('
') mydump("middle1.inc") mydump("middle2.inc") String=os.getenv("QUERY_STRING") if string.find(String,"x")== 1 then String = nil else String=string.sub(String,1,(string.find(String,"x")-2)) end Send={} Delete={} SendPrint={} DeletePrint={} doubleChecked={} --[[---------------------------------------------------------- Return Name of a File in QUERY_STRING ----------------------------------------------------------]]-- function dataOfQuery(data, position) local nBegin, nEnd if position == nil then nBegin, nEnd = string.find(data, "%d+.%d+%.pdf") return string.sub(data, nBegin, nEnd) else nBegin, nEnd = string.find(data, "%d+.%d+%.pdf", position) return string.sub(data, nBegin, nEnd) end end --[[---------------------------------------------------------- Check if file is marked as delete ----------------------------------------------------------]]-- function isDelete(data, position) local nBegin, nEnd if string.sub(data, position, position) == "D" then return true else return false end end --[[---------------------------------------------------------- Check if file is marked as send ----------------------------------------------------------]]-- function isSend(data, position) local nBegin, nEnd if string.sub(data, position, position) == "S" then return true else return false end end --[[---------------------------------------------------------- Delete files ----------------------------------------------------------]]-- function doDelete(data) if data ~= nil then data2=string.gsub(data,".pdf",".mail") dPDF=os.remove(string.format("%s%s","/data/fax/good/",data)) dMAIL=os.remove(string.format("%s%s","/data/fax/good/",data2)) if dPDF==true and dMAIL==true then return 1 elseif dPDF==true and dMAIL==nil then return 2 elseif dPDF==nil and dMAIL== true then return 3 else return 0 end end end --[[---------------------------------------------------------- Resend file ----------------------------------------------------------]]-- function resend(data) -- execute Befehl fehlt noch if data ~= nil then file=string.sub(data,1,15) file=string.format("%s%s%s",'/sbin/omgfaxdeliver -q /data/fax/good/',file,'.mail') local state = os.execute(file) if tonumber(state or "1")==0 then return true else return false end end end --[[---------------------------------------------------------- Check if a file is double marked and save the name of file ----------------------------------------------------------]]-- function sendAndDelete() for k,v in pairs(Send) do if Delete[k] ~= nil then table.insert(doubleChecked, k) else if resend(k) then table.insert(SendPrint, k) else table.insert(doubleChecked, k) end end end for k,v in pairs(Delete) do if Send[k] ~= nil then else success=doDelete(k) if success==1 then table.insert(DeletePrint, k) elseif success==2 then k=string.format("%s%s",k,' wM') table.insert(DeletePrint,k) k=string.sub(k,1,(string.len(k)-3)) elseif success==3 then k=string.format("%s%s",k,' wP') table.insert(DeletePrint,k) k=string.sub(k,1,(string.len(k)-3)) else table.insert(doubleChecked,k) end end end end function printTable(data) if data ~= nil then print('