X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Frecentlyaddedpage.cpp;fp=src%2Fhttp%2Fpages%2Frecentlyaddedpage.cpp;h=2b09ce8d8da2e7101f4c55514753b88bb22cebcc;hp=0000000000000000000000000000000000000000;hb=fcb124f8d6d3f5678e82049fb8e5e23c8cfaec6d;hpb=a558b16c8034966d14e1d63db44dcb952d849618 diff --git a/src/http/pages/recentlyaddedpage.cpp b/src/http/pages/recentlyaddedpage.cpp new file mode 100644 index 0000000..2b09ce8 --- /dev/null +++ b/src/http/pages/recentlyaddedpage.cpp @@ -0,0 +1,95 @@ +#include "../../../include/http/pages/recentlyaddedpage.h" +#include "../../../include/global.h" +#include "../../../include/stringfunctions.h" + +#include +#include +#include + +const std::string RecentlyAddedPage::GeneratePage(const std::string &method, const std::map &queryvars) +{ + std::string content=""; + Poco::DateTime date; + int count=0; + std::string countstr="0"; + + if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="delete" && ValidateFormPassword(queryvars)) + { + std::vector identityids; + CreateArgArray(queryvars,"chkdel",identityids); + + SQLite3DB::Statement del=m_db->Prepare("DELETE FROM tblIdentity WHERE IdentityID=?;"); + + for(std::vector::iterator i=identityids.begin(); i!=identityids.end(); i++) + { + if((*i)!="") + { + del.Bind(0,(*i)); + del.Step(); + del.Reset(); + } + } + + } + + content="

Recently Added Peers

"; + + SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID, PublicKey, Name, DateAdded, AddedMethod FROM tblIdentity WHERE DateAdded>=? ORDER BY DateAdded DESC;"); + date-=Poco::Timespan(5,0,0,0,0); + st.Bind(0,Poco::DateTimeFormatter::format(date,"%Y-%m-%d %H:%M:%S")); + st.Step(); + + content+="
"; + content+=CreateFormPassword(); + content+=""; + content+=""; + content+=""; + + while(st.RowReturned()) + { + std::string identityidstr=""; + std::string publickey=""; + std::string name=""; + std::string dateadded=""; + std::string addedmethod=""; + + st.ResultText(0,identityidstr); + st.ResultText(1,publickey); + st.ResultText(2,name); + st.ResultText(3,dateadded); + st.ResultText(4,addedmethod); + + StringFunctions::Convert(count,countstr); + + content+=""; + content+=""; + content+=""; + content+=""; + content+=""; + content+=""; + + count++; + + st.Step(); + } + content+=""; + content+="
NameDate AddedAdded Method
"; + content+=""; + content+=SanitizeOutput(CreateShortIdentityName(name,publickey)); + content+=""; + content+=""+dateadded+""+SanitizeOutput(addedmethod)+"
"; + + return StringFunctions::Replace(m_template,"[CONTENT]",content); +} + +const bool RecentlyAddedPage::WillHandleURI(const std::string &uri) +{ + if(uri.find("recentlyadded.")!=std::string::npos) + { + return true; + } + else + { + return false; + } +}