X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fpeermaintenancepage.cpp;h=502cea608dd556ab52c52ba9fe8199717b1f5071;hp=5daaa01b87f576e7f4ea2751acdb3d89377048a6;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af diff --git a/src/http/pages/peermaintenancepage.cpp b/src/http/pages/peermaintenancepage.cpp index 5daaa01..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,date.Format("%Y-%m-%d")); + st.Bind(0,Poco::DateTimeFormatter::format(date,"%Y-%m-%d")); st.Step(); } else if((*queryvars.find("formaction")).second=="removeadded20daysneversent") { - 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 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"; @@ -121,10 +125,10 @@ const std::string PeerMaintenancePage::GeneratePage(const std::string &method, c content+=""; content+=""; - date.SetToGMTime(); - date.Add(0,0,0,-30); + 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,date.Format("%Y-%m-%d")); + st.Bind(0,Poco::DateTimeFormatter::format(date,"%Y-%m-%d")); st.Step(); st.ResultText(0,tempval); content+=""; @@ -152,10 +156,10 @@ 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"; @@ -169,10 +173,10 @@ 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.LastSeen"; @@ -200,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)