X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fpeermaintenancepage.cpp;h=502cea608dd556ab52c52ba9fe8199717b1f5071;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hp=3ded4eb2426bc3be3c46f2fdd95efddab8b745fb;hpb=befd91205eff729a182f66de15374a577a8718f7;p=fms.git diff --git a/src/http/pages/peermaintenancepage.cpp b/src/http/pages/peermaintenancepage.cpp index 3ded4eb..502cea6 100644 --- a/src/http/pages/peermaintenancepage.cpp +++ b/src/http/pages/peermaintenancepage.cpp @@ -1,6 +1,10 @@ #include "../../../include/http/pages/peermaintenancepage.h" #include "../../../include/stringfunctions.h" -#include "../../../include/datetime.h" + +#include +#include +#include +#include #ifdef XMEM #include @@ -11,7 +15,7 @@ const std::string PeerMaintenancePage::GeneratePage(const std::string &method, c std::string content=""; SQLite3DB::Statement st; std::string tempval; - DateTime date; + Poco::DateTime date; if(queryvars.find("formaction")!=queryvars.end()) { @@ -21,10 +25,10 @@ const std::string PeerMaintenancePage::GeneratePage(const std::string &method, c } else if((*queryvars.find("formaction")).second=="removelastseen20") { - date.SetToGMTime(); - date.Add(0,0,0,-20); + date=Poco::Timestamp(); + date-=Poco::Timespan(20,0,0,0,0); st=m_db->Prepare("DELETE FROM tblIdentity WHERE LastSeenPrepare("DELETE FROM tblIdentity WHERE IdentityID NOT IN (SELECT IdentityID FROM tblMessage GROUP BY IdentityID) AND LastSeenPrepare("DELETE FROM tblIdentity WHERE LastSeenPrepare("DELETE FROM tblIdentity WHERE LastSeenPrepare("DELETE FROM tblIdentity WHERE IdentityID IN (SELECT tblIdentity.IdentityID FROM tblIdentity INNER JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID WHERE (SELECT MAX(MessageDate) FROM tblMessage WHERE tblMessage.IdentityID=tblIdentity.IdentityID)<=? GROUP BY tblIdentity.IdentityID);"); + st.Bind(0,Poco::DateTimeFormatter::format(date,"%Y-%m-%d")); + st.Step(); + } + else if((*queryvars.find("formaction")).second=="removeadded20daysneversent") + { + date=Poco::Timestamp(); + date-=Poco::Timespan(20,0,0,0,0); + st=m_db->Prepare("DELETE FROM tblIdentity WHERE IdentityID IN (SELECT tblIdentity.IdentityID FROM tblIdentity LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID WHERE tblMessage.IdentityID IS NULL AND tblIdentity.DateAdded"; content+=""; - date.SetToGMTime(); - date.Add(0,0,0,-20); + date=Poco::Timestamp(); + date-=Poco::Timespan(20,0,0,0,0); st=m_db->Prepare("SELECT COUNT(*) FROM tblIdentity WHERE LastSeen"; @@ -105,6 +125,23 @@ const std::string PeerMaintenancePage::GeneratePage(const std::string &method, c content+=""; content+=""; + date=Poco::Timestamp(); + date-=Poco::Timespan(30,0,0,0,0); + st=m_db->Prepare("SELECT COUNT(*) FROM (SELECT tblIdentity.IdentityID FROM tblIdentity INNER JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID WHERE (SELECT MAX(MessageDate) FROM tblMessage WHERE tblMessage.IdentityID=tblIdentity.IdentityID)<=? GROUP BY tblIdentity.IdentityID);"); + st.Bind(0,Poco::DateTimeFormatter::format(date,"%Y-%m-%d")); + st.Step(); + st.ResultText(0,tempval); + content+=""; + content+=""+tempval+""; + content+="last sent a message more than 30 days ago"; + content+=""; + content+="
"; + content+=""; + content+=""; + content+="
"; + content+=""; + content+=""; + st=m_db->Prepare("SELECT COUNT(*) FROM tblIdentity LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID WHERE tblMessage.IdentityID IS NULL;"); st.Step(); st.ResultText(0,tempval); @@ -119,10 +156,27 @@ const std::string PeerMaintenancePage::GeneratePage(const std::string &method, c content+=""; content+=""; - date.SetToGMTime(); - date.Add(0,0,0,-20); + date=Poco::Timestamp(); + date-=Poco::Timespan(20,0,0,0,0); + st=m_db->Prepare("SELECT COUNT(*) FROM tblIdentity LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID WHERE tblMessage.IdentityID IS NULL AND tblIdentity.DateAdded"; + content+=""+tempval+""; + content+="added more than 20 days ago and never sent a message"; + content+=""; + content+="
"; + content+=""; + content+=""; + content+="
"; + content+=""; + content+=""; + + date=Poco::Timestamp(); + date-=Poco::Timespan(20,0,0,0,0); st=m_db->Prepare("SELECT COUNT(*) FROM tblIdentity LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID WHERE tblMessage.IdentityID IS NULL AND tblIdentity.LastSeen"; @@ -150,7 +204,7 @@ const std::string PeerMaintenancePage::GeneratePage(const std::string &method, c content+=""; - return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content); + return StringFunctions::Replace(m_template,"[CONTENT]",content); } const bool PeerMaintenancePage::WillHandleURI(const std::string &uri)