<% include("language.html") if _SESSION["logined"] ~= nil then local domain = _GET["domain"] or _POST["domain"] local type = _GET["type"] or _POST["type"] or "" local username = _GET["username"] or _POST["username"] or "" local starttime = _GET["starttime"] or _POST["starttime"] or "" local endtime = _GET["endtime"] or _POST["endtime"] or "" local reportname = "" local strSQL = "" if (_SESSION["admin_readonly"] ~= nil and _SESSION["admin_readonly"] == 1) or (_SESSION["admin_domainadmin"] ~= nil and _SESSION["admin_domainadmin"] == 1) then print(RESULT_STR[-1]) exit() end if type == "0" then strSQL = "f_time >= datetime('now','localtime','-7 day')" reportname = LANG["title_weekly_report"] starttime = os.date("%Y-%m-%d %H:%M:%S",os.time()-3600*24*7) endtime = os.date("%Y-%m-%d %H:%M:%S",os.time()) end if type == "1" then strSQL = "f_time >= datetime('now','localtime','-30 day')" reportname = LANG["title_monthly_report"] starttime = os.date("%Y-%m-%d %H:%M:%S",os.time()-3600*24*30) endtime = os.date("%Y-%m-%d %H:%M:%S",os.time()) end if type == "2" then strSQL = "f_time >= '"..starttime.."' and f_time <= '"..endtime.."'" reportname = LANG["title_custom_report"] if username ~= "" then strSQL = strSQL.." and f_username = '"..username.."' " reportname = reportname.." for user ["..specialhtml_encode(username).."]" end end reportname = reportname.."
"..LANG["title_from"].." "..starttime.." "..LANG["title_to"].." "..endtime --total sessions local result = c_DoSQL("select count(*), count(DISTINCT(f_ip)) from wftp_dblogs where f_domain = '"..domain.."' and "..strSQL.." and f_action = 0") local totalsessions = result[1][0] or 0 --total unique ip local uniqueip = 0 if result[1] ~= nil then uniqueip = result[1][1] or 0 else uniqueip = "no" end --total download files result = c_DoSQL("select count(*), sum(f_filesize) from wftp_dblogs where f_domain = '"..domain.."' and "..strSQL.." and f_action = 8") local downloadfiles = result[1][0] or 0 local downloadbytes = result[1][1] or 0 --total upload files result = c_DoSQL("select count(*), sum(f_filesize) from wftp_dblogs where f_domain = '"..domain.."' and "..strSQL.." and f_action = 10") local uploadfiles = result[1][0] or 0 local uploadbytes = result[1][1] or 0 --top 10 downloads local top10downloads = c_DoSQL("select f_filename, count(f_filename) as f_num from wftp_dblogs where f_domain = '"..domain.."' and "..strSQL.." and f_action = 8 group by f_filename order by f_num desc limit 10") --top 10 uploads local top10uploads = c_DoSQL("select f_filename, count(f_filename) as f_num from wftp_dblogs where f_domain = '"..domain.."' and "..strSQL.." and f_action = 10 group by f_filename order by f_num desc limit 10") --top 10 logins local top10logins = c_DoSQL("select f_ip, count(f_ip) as f_num from wftp_dblogs where f_domain = '"..domain.."' and "..strSQL.." and f_action = 0 group by f_ip order by f_num desc limit 10") local weblinkfiles = 0 local weblinkbytes = 0 local top10users = {} if username == "" then --total download weblink files result = c_DoSQL("select count(*),sum(f_filesize) from wftp_dblogs where f_domain = '"..domain.."' and "..strSQL.." and f_username = '' and f_action = 8") weblinkfiles = result[1][0] or 0 weblinkbytes = result[1][1] or 0 --top 10 login users top10users = c_DoSQL("select f_username, count(f_username) as f_num from wftp_dblogs where f_domain = '"..domain.."' and "..strSQL.." and f_action = 0 group by f_username order by f_num desc limit 10") end %> Audit Report
[<%=specialhtml_encode(unescape(domain))%>] <%=reportname%>
<% if uniqueip ~= "no" then %> <% end %> <% if username == "" then %> <% end %>
<%=LANG["title_statistics"]%>
<%=LANG["str_total_session"]%> <%=totalsessions%>
<%=LANG["str_unique_ip"]%> <%=uniqueip%>
<%=LANG["str_total_downfile"]%> <%=downloadfiles%>
<%=LANG["str_total_upfile"]%> <%=uploadfiles%>
<%=LANG["str_total_download"]%> <%=formatSize(downloadbytes)%>
<%=LANG["str_total_upload"]%> <%=formatSize(uploadbytes)%>
<%=LANG["str_total_downfile"]%> (Weblink) <%=weblinkfiles%>
<%=LANG["str_total_download"]%> (Weblink) <%=formatSize(weblinkbytes)%>

<% for _,row in pairs(top10downloads) do print("") end %>
Top 10 <%=LANG["str_downloads"]%>
<%=LANG["str_filename"]%> <%=LANG["str_count"]%>
"..row[0]..""..row[1].."

<% for _,row in pairs(top10uploads) do print("") end %>
Top 10 <%=LANG["str_uploads"]%>
<%=LANG["str_filename"]%> <%=LANG["str_count"]%>
"..row[0]..""..row[1].."

<% for _,row in pairs(top10logins) do print("") end %>
Top 10 <%=LANG["str_ip"]%>
<%=LANG["str_ip"]%> <%=LANG["str_count"]%>
"..row[0]..""..row[1].."
<% if username == "" then %>
<% for _,row in pairs(top10users) do print("") end %>
Top 10 <%=LANG["str_username"]%>
<%=LANG["str_username"]%> <%=LANG["str_count"]%>
"..row[0]..""..row[1].."
<% end %>
<% else print("") print("") end %>