X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzleinserter.cpp;h=fef42f13ea59eb3758983724972eea8e36bcbd3c;hp=ea78ace464a38be2e1ee346ec89326506b604fc6;hb=f60495a029c54358f82956482fe203fe2b7b5b23;hpb=1b0c3b7f86935a772aad271bad4f3d1f37243c2d diff --git a/src/freenet/introductionpuzzleinserter.cpp b/src/freenet/introductionpuzzleinserter.cpp index ea78ace..fef42f1 100644 --- a/src/freenet/introductionpuzzleinserter.cpp +++ b/src/freenet/introductionpuzzleinserter.cpp @@ -27,11 +27,17 @@ void IntroductionPuzzleInserter::CheckForNeededInsert() while(!rs.AtEnd()) { + std::string localidentityidstr; DateTime now; now.SetToGMTime(); + if(rs.GetField(0)) + { + localidentityidstr=rs.GetField(0); + } + // if this identity has any non-solved puzzles for today, we don't need to insert a new puzzle - SQLite3DB::Recordset rs2=m_db->Query("SELECT UUID FROM tblIntroductionPuzzleInserts WHERE Day='"+now.Format("%Y-%m-%d")+"' AND FoundSolution='false';"); + SQLite3DB::Recordset rs2=m_db->Query("SELECT UUID FROM tblIntroductionPuzzleInserts WHERE Day='"+now.Format("%Y-%m-%d")+"' AND FoundSolution='false' AND LocalIdentityID="+localidentityidstr+";"); // identity doesn't have any non-solved puzzles for today - start a new insert if(rs2.Empty()==true) @@ -118,7 +124,7 @@ const bool IntroductionPuzzleInserter::HandlePutFailed(FCPMessage &message) m_db->Execute("UPDATE tblIntroductionPuzzleInserts SET Day='"+idparts[5]+"', InsertIndex="+idparts[2]+", FoundSolution='true' WHERE UUID='"+idparts[3]+"';"); } - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" failed to insert puzzle "+idparts[3]); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IntroductionPuzzleInserter::HandlePutFailed failed to insert puzzle "+idparts[3]); return true; } @@ -149,7 +155,7 @@ const bool IntroductionPuzzleInserter::HandlePutSuccessful(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" inserted puzzle "+idparts[3]); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IntroductionPuzzleInserter::HandlePutSuccessful inserted puzzle "+idparts[3]); return true; } @@ -217,14 +223,14 @@ void IntroductionPuzzleInserter::StartInsert(const long localidentityid) privatekey=rs2.GetField(0); } - Option::instance()->Get("MessageBase",messagebase); + Option::Instance()->Get("MessageBase",messagebase); GenerateCaptcha(encodedpuzzle,solutionstring); xml.SetType("captcha"); xml.SetUUID(uuid.Generate()); xml.SetPuzzleData(encodedpuzzle); - xml.SetMimeType("bitmap/image"); + xml.SetMimeType("image/bmp"); xmldata=xml.GetXML(); StringFunctions::Convert(xmldata.size(),xmldatasizestr); @@ -240,6 +246,6 @@ void IntroductionPuzzleInserter::StartInsert(const long localidentityid) m_db->Execute("UPDATE tblLocalIdentity SET InsertingPuzzle='true' WHERE LocalIdentityID="+idstring+";"); m_db->Execute("INSERT INTO tblIntroductionPuzzleInserts(UUID,Type,MimeType,LocalIdentityID,PuzzleData,PuzzleSolution) VALUES('"+xml.GetUUID()+"','captcha','image/bmp',"+idstring+",'"+encodedpuzzle+"','"+solutionstring+"');"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" started insert for id "+idstring); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IntroductionPuzzleInserter::StartInsert started insert for id "+idstring); }