X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fsiteinserter.cpp;h=4c71c3084efb04289360e2b3b5aa6dc2e3bed885;hb=b7f3b3e6ae9dc527f02b5c06e2eeae0e9cac3ad8;hp=f7d9ef245b6d8ef17d321aa1cf0bb2fba2096e2f;hpb=7ddb1aeb0b3dc7384597e75f7b3557f2d8f6d14c;p=fms.git diff --git a/src/freenet/siteinserter.cpp b/src/freenet/siteinserter.cpp index f7d9ef2..4c71c30 100644 --- a/src/freenet/siteinserter.cpp +++ b/src/freenet/siteinserter.cpp @@ -1,6 +1,10 @@ #include "../../include/freenet/siteinserter.h" #include "../../include/global.h" +#include +#include +#include + #ifdef XMEM #include #endif @@ -20,11 +24,11 @@ void SiteInserter::CheckForNeededInsert() // only do 1 insert at a time if(m_inserting.size()==0) { - DateTime date; - date.SetToGMTime(); + Poco::DateTime date; + date.assign(date.year(),date.month(),date.day(),0,0,0); SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID FROM tblLocalIdentity WHERE PublishFreesite='true' AND (LastInsertedFreesite IS NULL OR LastInsertedFreesiteWriteLog(LogFile::LOGLEVEL_ERROR,"SiteInserter::GeneratePages unable to open "+filename+" or site-template.htm."); + m_log->error("SiteInserter::GeneratePages unable to open "+filename+" or site-template.htm."); } // get extra files that the user wants to add to the Freesite filename=name+"-files.txt"; - infile=fopen(filename.c_str(),"r+b"); + infile=fopen(filename.c_str(),"rb"); if(infile) { std::vector files; @@ -224,7 +228,7 @@ void SiteInserter::GeneratePages(const long localidentityid, std::string &uskkey if((*i)!="" && (*i).find("index.htm")==std::string::npos && (*i).find("trustlist.htm")==std::string::npos && (*i).find("files.htm")==std::string::npos) { filename=(*i); - infile=fopen(filename.c_str(),"r+b"); + infile=fopen(filename.c_str(),"rb"); if(infile) { fseek(infile,0,SEEK_END); @@ -252,7 +256,7 @@ void SiteInserter::GeneratePages(const long localidentityid, std::string &uskkey } else { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"SiteInserter::GeneratePages could not include user file "+(*i)); + m_log->error("SiteInserter::GeneratePages could not include user file "+(*i)); } } } @@ -265,20 +269,19 @@ void SiteInserter::GeneratePages(const long localidentityid, std::string &uskkey std::string SiteInserter::GenerateTrustList(const std::string &htmltemplate, const long localidentityid, const std::string &name) { std::string content=""; - DateTime date; + Poco::DateTime date; - date.SetToGMTime(); - date.Add(0,0,0,-20); + date-=Poco::Timespan(20,0,0,0,0); SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,tblIdentityTrust.LocalMessageTrust,tblIdentityTrust.LocalTrustListTrust,tblIdentity.IdentityID,tblIdentityTrust.MessageTrustComment,tblIdentityTrust.TrustListTrustComment,tblIdentity.FreesiteEdition FROM tblIdentity LEFT JOIN (SELECT IdentityID,LocalMessageTrust,LocalTrustListTrust,MessageTrustComment,TrustListTrustComment FROM tblIdentityTrust WHERE LocalIdentityID=?) AS 'tblIdentityTrust' ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID WHERE PublicKey IS NOT NULL AND LastSeen IS NOT NULL AND LastSeen>=? ORDER BY Name COLLATE NOCASE;"); st.Bind(0,localidentityid); - st.Bind(1,date.Format("%Y-%m-%d %H:%M:%S")); + st.Bind(1,Poco::DateTimeFormatter::format(date,"%Y-%m-%d %H:%M:%S")); st.Step(); - content+=""; - content+="
"; + content+=""; + content+=""; content+="Trust List of "+SanitizeOutput(name); content+=""; - content+=""; + content+=""; while(st.RowReturned()) { std::string idname=""; @@ -314,11 +317,11 @@ std::string SiteInserter::GenerateTrustList(const std::string &htmltemplate, con content+=""; if(freesiteedition!="") { - content+=""; + content+=""; } else { - content+=""; + content+=""; } content+=""; content+=""; @@ -328,6 +331,7 @@ std::string SiteInserter::GenerateTrustList(const std::string &htmltemplate, con st.Step(); } + content+="
Message TrustMessage CommentTrust List TrustTrust Comment
Message TrustMessage CommentTrust List TrustTrust Comment
"+SanitizeOutput(CreateShortIdentityName(idname,publickey))+""+SanitizeOutput(CreateShortIdentityName(idname,publickey))+"
"+SanitizeOutput(CreateShortIdentityName(idname,publickey))+"
"+messagetrust+""+SanitizeOutput(messagetrustcomment)+"
"; return StringFunctions::Replace(htmltemplate,"[CONTENT]",content); @@ -362,7 +366,7 @@ const bool SiteInserter::HandlePutFailed(FCPMessage &message) RemoveFromInsertList(localidentityid); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"SiteInserter::HandlePutFailed failed to insert Freesite, Freenet error code : "+message["Code"]); + m_log->error("SiteInserter::HandlePutFailed failed to insert Freesite, Freenet error code : "+message["Code"]); return true; } @@ -373,9 +377,7 @@ const bool SiteInserter::HandlePutSuccessful(FCPMessage &message) std::vector uriparts; long localidentityid; int edition=-1; - DateTime now; - - now.SetToGMTime(); + Poco::DateTime now; StringFunctions::Split(message["Identifier"],"|",idparts); StringFunctions::Convert(idparts[1],localidentityid); @@ -388,12 +390,12 @@ const bool SiteInserter::HandlePutSuccessful(FCPMessage &message) } SQLite3DB::Statement st=m_db->Prepare("UPDATE tblLocalIdentity SET LastInsertedFreesite=?, FreesiteEdition=? WHERE LocalIdentityID=?;"); - st.Bind(0,now.Format("%Y-%m-%d %H:%M:%S")); + st.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S")); st.Bind(1,edition); st.Bind(2,localidentityid); st.Step(); - m_log->WriteLog(LogFile::LOGLEVEL_INFO,"SiteInserter::HandlePutSuccessful successfully inserted Freesite."); + m_log->information("SiteInserter::HandlePutSuccessful successfully inserted Freesite."); RemoveFromInsertList(localidentityid);