src/freenet/captcha/alternatecaptcha1.cpp\r
src/freenet/captcha/freeimage/bitmap.cpp\r
src/freenet/captcha/freeimage/font.cpp)\r
+ELSE(ALTERNATE_CAPTCHA)\r
+ MESSAGE(STATUS "You are using the old captcha generator. Add a -D ALTERNATE_CAPTCHA=ON to the command line to use the alternate captcha generator.")\r
ENDIF(ALTERNATE_CAPTCHA)\r
\r
IF(NOT I_HAVE_READ_THE_README)\r
IF(ALTERNATE_CAPTCHA)\r
FIND_FILE(FREEIMAGE_LIBRARY NAMES libfreeimage.a PATHS /usr/lib/)\r
IF(NOT FREEIMAGE_LIBRARY)\r
- FIND_LIBRARY(FREEIMAGE_LIBRARY NAMES FreeImage libFreeImage libfreeimage)\r
+ FIND_LIBRARY(FREEIMAGE_LIBRARY NAMES FreeImage libFreeImage libfreeimage freeimage)\r
ENDIF(NOT FREEIMAGE_LIBRARY)\r
ENDIF(ALTERNATE_CAPTCHA)\r
\r
class BitmapValidator:public DocumentTypeValidator\r
{\r
public:\r
+ BitmapValidator();\r
+ ~BitmapValidator();\r
+\r
const bool Validate(const std::vector<unsigned char> &data);\r
+ void SetMax(const int maxw, const int maxh) { m_maxwidth=maxw; m_maxheight=maxh; }\r
+\r
+private:\r
+ int m_maxwidth;\r
+ int m_maxheight;\r
};\r
\r
#endif // _bitmapvalidator_\r
class DocumentTypeValidator\r
{\r
public:\r
+ DocumentTypeValidator() {}\r
+ virtual ~DocumentTypeValidator() {}\r
virtual const bool Validate(const std::vector<unsigned char> &data)=0; \r
};\r
\r
\r
#define VERSION_MAJOR "0"\r
#define VERSION_MINOR "3"\r
-#define VERSION_RELEASE "14"\r
+#define VERSION_RELEASE "15"\r
#define FMS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE\r
\r
typedef Poco::ScopedLock<Poco::FastMutex> Guard;\r
#include <sstream>\r
#include <cstdlib>\r
\r
+BitmapValidator::BitmapValidator():m_maxwidth(-1),m_maxheight(-1)\r
+{\r
+ \r
+}\r
+\r
+BitmapValidator::~BitmapValidator()\r
+{\r
+ \r
+}\r
+\r
const bool BitmapValidator::Validate(const std::vector<unsigned char> &data)\r
{\r
bool validated=false;\r
BMP temp;\r
if(temp.ReadFromFile(tempname.c_str()))\r
{\r
- validated=true; \r
+ validated=true;\r
+ if(m_maxwidth!=-1 && temp.TellWidth()>m_maxwidth)\r
+ {\r
+ validated=false;\r
+ }\r
+ if(m_maxheight!=-1 && temp.TellHeight()>m_maxheight)\r
+ {\r
+ validated=false;\r
+ }\r
}\r
\r
unlink(tempname.c_str());\r
}\r
}\r
\r
+ // make output a little wavy\r
int offset=rand()%10000;\r
for(int y=0; y<bmp.Height(); y++)\r
{\r
\r
void AlternateCaptcha1::LoadFonts()\r
{\r
+\r
FreeImage::Bitmap bmp;\r
Poco::Path path("fonts");\r
Poco::DirectoryIterator di(path);\r
\r
// we can only validate bitmaps for now\r
BitmapValidator val;\r
+ val.SetMax(200,200);\r
std::vector<unsigned char> puzzledata;\r
Base64::Decode(xml.GetPuzzleData(),puzzledata);\r
if(xml.GetMimeType()!="image/bmp" || val.Validate(puzzledata)==false)\r
st.Finalize();\r
\r
// select identities that aren't single use, are publishing a trust list, and have been seen today ( order by trust DESC and limit to limitnum )\r
- st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublishTrustList='true' AND PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND LastSeen>='"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";");\r
+ st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublishTrustList='true' AND PublicKey IS NOT NULL AND PublicKey <> '' AND SingleUse='false' AND (LocalTrustListTrust IS NULL OR LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust')) AND LastSeen>='"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"' ORDER BY LocalMessageTrust DESC LIMIT 0,"+limitnum+";");\r
st.Step();\r
\r
m_ids.clear();\r
{\r
m_log->debug("HTTPThread::run thread started.");\r
\r
- Poco::Net::ServerSocket sock(m_listenport);\r
- Poco::Net::HTTPServerParams* pParams = new Poco::Net::HTTPServerParams;\r
- pParams->setMaxQueued(30);\r
- pParams->setMaxThreads(5);\r
- Poco::Net::HTTPServer srv(new FMSHTTPRequestHandlerFactory,sock,pParams);\r
+ try\r
+ {\r
+ Poco::Net::ServerSocket sock(m_listenport);\r
+ Poco::Net::HTTPServerParams* pParams = new Poco::Net::HTTPServerParams;\r
+ pParams->setMaxQueued(30);\r
+ pParams->setMaxThreads(5);\r
+ Poco::Net::HTTPServer srv(new FMSHTTPRequestHandlerFactory,sock,pParams);\r
+\r
+ srv.start();\r
+ m_log->trace("Started HTTPServer");\r
\r
- srv.start();\r
- m_log->trace("Started HTTPServer");\r
+ do\r
+ {\r
+ Poco::Thread::sleep(1000);\r
+ }while(!IsCancelled());\r
\r
- do\r
+ m_log->trace("Trying to stop HTTPServer");\r
+ srv.stop();\r
+ m_log->trace("Stopped HTTPServer");\r
+ \r
+ m_log->trace("Waiting for current HTTP requests to finish");\r
+ while(srv.currentConnections()>0)\r
+ {\r
+ Poco::Thread::sleep(500);\r
+ }\r
+ }\r
+ catch(Poco::Exception &e)\r
{\r
- Poco::Thread::sleep(1000);\r
- }while(!IsCancelled());\r
-\r
- m_log->trace("Trying to stop HTTPServer");\r
- srv.stop();\r
- m_log->trace("Stopped HTTPServer");\r
- \r
- m_log->trace("Waiting for current HTTP requests to finish");\r
- while(srv.currentConnections()>0)\r
+ m_log->fatal("HTTPThread::run caught "+e.displayText());\r
+ }\r
+ catch(...)\r
{\r
- Poco::Thread::sleep(500);\r
+ m_log->fatal("HTTPThread::run caught unknown exception");\r
}\r
\r
m_log->debug("HTTPThread::run thread exiting.");\r
std::string lastid="";\r
std::string thisid="";\r
std::string day="";\r
+ std::string name="";\r
+ std::string pubkey="";\r
int requestindex=0;\r
bool willshow=false;\r
\r
content+="<tr><td colspan=\"4\"><center>Select Identity : ";\r
content+=CreateLocalIdentityDropDown("localidentityid","");\r
content+="</td></tr>";\r
- content+="<tr><td colspan=\"4\"><center>Type the answers of a few puzzles. The puzzles are case sensitive. Getting announced will take some time. DO NOT continuously solve captchas. Solve 30 at most, wait a day, and if your identity has not been announced, repeat until it is.</td></tr>";\r
+ content+="<tr><td colspan=\"4\"><center>Type the answers of a few of the following puzzles. You don't need to get them all correct, but remember that they are case sensitive. Getting announced will take some time. DO NOT continuously solve captchas. Solve 30 at most, wait a day, and if your identity has not been announced, repeat until it is.</td></tr>";\r
content+="<tr>";\r
\r
date-=Poco::Timespan(1,0,0,0,0);\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT UUID,Day,IdentityID,RequestIndex FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='"+Poco::DateTimeFormatter::format(date,"%Y-%m-%d")+"' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;");\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT UUID,Day,tblIdentity.IdentityID,RequestIndex,tblIdentity.Name,tblIdentity.PublicKey FROM tblIntroductionPuzzleRequests INNER JOIN tblIdentity ON tblIntroductionPuzzleRequests.IdentityID=tblIdentity.IdentityID WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='"+Poco::DateTimeFormatter::format(date,"%Y-%m-%d")+"' AND Found='true' ORDER BY tblIdentity.IdentityID, Day DESC, RequestIndex DESC;");\r
st.Step();\r
\r
if(st.RowReturned()==false)\r
st.ResultText(1,day);\r
st.ResultText(2,thisid);\r
st.ResultInt(3,requestindex);\r
+ st.ResultText(4,name);\r
+ st.ResultText(5,pubkey);\r
\r
// if we are already inserting a solution for an identity - we shouldn't show any puzzles that are older than the one we are inserting\r
// get the last index # we are inserting this day from this identity\r
{\r
content+="</tr>\r\n<tr>";\r
}\r
- content+="<td>";\r
+ content+="<td title=\"From "+SanitizeOutput(CreateShortIdentityName(name,pubkey))+"\">";\r
content+="<img src=\"showcaptcha.htm?UUID="+uuid+"\"><br>";\r
content+="<input type=\"hidden\" name=\"uuid["+countstr+"]\" value=\""+uuid+"\">";\r
content+="<input type=\"hidden\" name=\"day["+countstr+"]\" value=\""+day+"\">";\r