\r
#ifdef ALTERNATE_CAPTCHA\r
\r
+#include "../../ilogger.h"\r
#include "freeimage/bitmap.h"\r
#include "freeimage/font.h"\r
#include <vector>\r
\r
-class AlternateCaptchaFonts\r
+class AlternateCaptchaFonts:public ILogger\r
{\r
public:\r
AlternateCaptchaFonts();\r
\r
};\r
\r
-}\r
+} // namespace\r
\r
#endif // _freeimage_bitmap_\r
\r
#define VERSION_MAJOR "0"\r
#define VERSION_MINOR "3"\r
-#define VERSION_RELEASE "16"\r
+#define VERSION_RELEASE "17"\r
#define FMS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE\r
\r
typedef Poco::ScopedLock<Poco::FastMutex> Guard;\r
#include "../../../include/freenet/captcha/alternatecaptcha1.h"\r
\r
#include <cmath>\r
+#include <cstdlib>\r
\r
#ifdef ALTERNATE_CAPTCHA\r
\r
\r
void AlternateCaptcha1::Generate()\r
{\r
+ if(m_fonts.size()==0)\r
+ {\r
+ return;\r
+ }\r
+\r
std::string puzzlestring=GenerateRandomString(5);\r
FreeImage::Bitmap tempchar(50,50,32);\r
tempchar.SetTransparent();\r
white.rgbGreen=255;\r
white.rgbBlue=255;\r
white.rgbReserved=255;\r
- int numlines=(rand()%5)+10;\r
+ int numlines=(rand()%5)+5;\r
for(int i=0; i<numlines; i++)\r
{\r
// draw 4 short lines very close to each other\r
\r
#include <cmath>\r
#include <vector>\r
+#include <cstdlib>\r
\r
#ifdef ALTERNATE_CAPTCHA\r
\r
\r
void AlternateCaptcha2::Generate()\r
{\r
+ if(m_fonts.size()==0)\r
+ {\r
+ return;\r
+ }\r
+\r
std::string puzzlestring=GenerateRandomString(6);\r
std::vector<int> fontnums(puzzlestring.size(),0);\r
\r
for(int i=0; i<numlines; i++)\r
{\r
int x1=rand()%150;\r
- int y1=(rand()%100)+100;\r
+ int y1=(rand()%80)+110;\r
int x2=(rand()%150)+150;\r
- int y2=(rand()%100)+100;\r
+ int y2=(rand()%80)+110;\r
bigbmp.Line(x1,y1,x2,y2,white);\r
bigbmp.Line(x1+1,y1,x2+1,y2,white);\r
}\r
}\r
\r
// rotate the big bitmap back to (almost) horizontal\r
- bigbmp.Rotate(-lastrot+((rand()%10)-5),0,0,150,150);\r
+ bigbmp.Rotate(-lastrot+((rand()%20)-10),0,0,150,150);\r
\r
// grab the center of the big bitmap as the final bitmap\r
FreeImage::Bitmap bmp(110,50,32);\r
\r
#include <Poco/Path.h>\r
#include <Poco/DirectoryIterator.h>\r
+#include <Poco/Exception.h>\r
\r
bool AlternateCaptchaFonts::m_fontsloaded(false);\r
std::vector<FreeImage::Font> AlternateCaptchaFonts::m_fonts;\r
void AlternateCaptchaFonts::LoadFonts()\r
{\r
\r
- FreeImage::Bitmap bmp;\r
- Poco::Path path("fonts");\r
- Poco::DirectoryIterator di(path);\r
- Poco::DirectoryIterator end;\r
-\r
- while(di!=end)\r
+ try\r
{\r
- if(di.name().find("bmp")!=std::string::npos)\r
+ FreeImage::Bitmap bmp;\r
+ Poco::Path path("fonts");\r
+ Poco::DirectoryIterator di(path);\r
+ Poco::DirectoryIterator end;\r
+\r
+ while(di!=end)\r
+ {\r
+ if(di.name().find("bmp")!=std::string::npos)\r
+ {\r
+ bmp.Load("bmp",di.path().toString());\r
+ m_fonts.push_back(FreeImage::Font(bmp));\r
+ }\r
+ ++di;\r
+ }\r
+ if(m_fonts.size()==0)\r
{\r
- bmp.Load("bmp",di.path().toString());\r
- m_fonts.push_back(FreeImage::Font(bmp));\r
+ m_log->fatal("AlternateCaptchaFonts::LoadFonts You have no loadable fonts in the font directory!");\r
}\r
- ++di;\r
+ }\r
+ catch(Poco::Exception &e)\r
+ {\r
+ m_log->error("AlternateCaptchaFonts::LoadFonts caught "+e.displayText());\r
+ }\r
+ catch(...)\r
+ {\r
+ m_log->error("AlternateCaptchaFonts::LoadFonts caught unknown exception");\r
}\r
\r
}\r
}\r
m_log->trace("IntroductionPuzzleInserter::GenerateCaptcha using alternate captcha generator");\r
#else\r
- SimpleCaptcha captcha;\r
- cap=&captcha;\r
+ cap=new SimpleCaptcha();\r
#endif\r
std::vector<unsigned char> puzzle;\r
std::vector<unsigned char> puzzlesolution;\r
{\r
date=Poco::Timestamp();\r
date-=Poco::Timespan(20,0,0,0,0);\r
- st=m_db->Prepare("DELETE FROM tblIdentity WHERE IdentityID NOT IN (SELECT IdentityID FROM tblMessage GROUP BY IdentityID WHERE IdentityID IS NOT NULL) AND LastSeen<?;");\r
+ st=m_db->Prepare("DELETE FROM tblIdentity WHERE IdentityID NOT IN (SELECT IdentityID FROM tblMessage WHERE IdentityID IS NOT NULL GROUP BY IdentityID) AND LastSeen<?;");\r
st.Bind(0,Poco::DateTimeFormatter::format(date,"%Y-%m-%d %H:%M:%S"));\r
st.Step();\r
}\r
upd.Reset();\r
\r
st.Bind(0,"FMSVersionEdition");\r
- st.Bind(1,"16");\r
+ st.Bind(1,"19");\r
st.Step();\r
st.Reset();\r
upd.Bind(0,"Program");\r