#include "../../include/stringfunctions.h"\r
#include "../../include/option.h"\r
#include "../../include/freenet/captcha/simplecaptcha.h"\r
+#ifdef ALTERNATE_CAPTCHA\r
+#include "../../include/freenet/captcha/alternatecaptcha1.h"\r
+#include "../../include/freenet/captcha/alternatecaptcha2.h"\r
+#endif\r
#include "../../include/base64.h"\r
\r
#include <Poco/DateTimeFormatter.h>\r
// identity doesn't have any non-solved puzzles for today - start a new insert\r
if(rs2.Empty()==true)\r
{\r
- if(m_lastinserted.find(rs.GetInt(0))==m_lastinserted.end() || m_lastinserted[rs.GetInt(0)]<=lastinsert)\r
+ // make sure we are on the next day or the appropriate amount of time has elapsed since the last insert\r
+ if(m_lastinserted.find(rs.GetInt(0))==m_lastinserted.end() || m_lastinserted[rs.GetInt(0)]<=lastinsert || m_lastinserted[rs.GetInt(0)].day()!=now.day())\r
{\r
StartInsert(rs.GetInt(0));\r
m_lastinserted[rs.GetInt(0)]=now;\r
\r
void IntroductionPuzzleInserter::GenerateCaptcha(std::string &encodeddata, std::string &solution)\r
{\r
- SimpleCaptcha captcha;\r
+ ICaptcha *cap=0;\r
+#ifdef ALTERNATE_CAPTCHA\r
+ if(rand()%2==0)\r
+ {\r
+ cap=new AlternateCaptcha1();\r
+ }\r
+ else\r
+ {\r
+ cap=new AlternateCaptcha2();\r
+ }\r
+ m_log->trace("IntroductionPuzzleInserter::GenerateCaptcha using alternate captcha generator");\r
+#else\r
+ cap=new SimpleCaptcha();\r
+#endif\r
std::vector<unsigned char> puzzle;\r
std::vector<unsigned char> puzzlesolution;\r
\r
- captcha.Generate();\r
- captcha.GetPuzzle(puzzle);\r
- captcha.GetSolution(puzzlesolution);\r
+ cap->Generate();\r
+ cap->GetPuzzle(puzzle);\r
+ cap->GetSolution(puzzlesolution);\r
\r
encodeddata.clear();\r
solution.clear();\r
Base64::Encode(puzzle,encodeddata);\r
solution.insert(solution.begin(),puzzlesolution.begin(),puzzlesolution.end());\r
\r
+ delete cap;\r
+\r
}\r
\r
const bool IntroductionPuzzleInserter::HandlePutFailed(FCPMessage &message)\r