X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fsiteinserter.cpp;h=77da44a9aa4b260ce09eac576314667cf8139dfd;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hp=c717d0d707e9ecfb1a8c60a8a6caa31634988c02;hpb=9a14c0d9f7f7c319e539583b93664953764e83b7;p=fms.git diff --git a/src/freenet/siteinserter.cpp b/src/freenet/siteinserter.cpp index c717d0d..77da44a 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 LastInsertedFreesiteFMS site of "+SanitizeOutput(name)+""; - content+="

My last few posts

"; SQLite3DB::Statement boardst=m_db->Prepare("SELECT tblBoard.BoardName FROM tblBoard INNER JOIN tblMessageBoard ON tblBoard.BoardID=tblMessageBoard.BoardID WHERE tblMessageBoard.MessageID=? ORDER BY tblBoard.BoardName COLLATE NOCASE;"); @@ -154,6 +156,15 @@ void SiteInserter::GeneratePages(const long localidentityid, std::string &uskkey StringFunctions::Convert(edition,editionstr); } + // make SSK a USK + if(key.find("SSK@")==0) + { + key.erase(0,3); + key="USK"+key; + } + key+=m_messagebase+"/"+editionstr+"/"; + uskkey=key; + filename=name+"-template.htm"; FILE *infile=fopen(filename.c_str(),"r+b"); if(!infile) @@ -174,6 +185,7 @@ void SiteInserter::GeneratePages(const long localidentityid, std::string &uskkey htmltemplate.append(data.begin(),data.end()); htmltemplate=StringFunctions::Replace(htmltemplate,"[LINKS]",GenerateLinks(publishtrustlist,publishboardlist)); + htmltemplate=StringFunctions::Replace(htmltemplate,"[IDENTITYNAME]",SanitizeOutput(name)); pages["index.htm"]=GenerateIndex(htmltemplate,localidentityid,name); if(publishtrustlist) @@ -185,19 +197,10 @@ void SiteInserter::GeneratePages(const long localidentityid, std::string &uskkey // pages["boardlist.htm"]=GenerateBoardList(htmltemplate,localidentityid,name); } - // make SSK a USK - if(key.find("SSK@")==0) - { - key.erase(0,3); - key="USK"+key; - } - key+=m_messagebase+"/"+editionstr+"/"; - uskkey=key; - } else { - LogFile::Instance()->WriteLog(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 @@ -253,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)); } } } @@ -266,13 +269,12 @@ 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+=""; @@ -363,7 +365,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; } @@ -374,9 +376,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); @@ -389,12 +389,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);