From 05ef25de71be91442b4cbd22dc7cc45629c5d5bb Mon Sep 17 00:00:00 2001 From: SomeDude Date: Tue, 12 Aug 2008 16:20:00 +0200 Subject: [PATCH] version 0.3.17 --- include/freenet/captcha/alternatecaptchafonts.h | 3 ++- include/freenet/captcha/freeimage/bitmap.h | 2 +- include/global.h | 2 +- src/freenet/captcha/alternatecaptcha1.cpp | 8 +++++- src/freenet/captcha/alternatecaptcha2.cpp | 12 ++++++--- src/freenet/captcha/alternatecaptchafonts.cpp | 36 ++++++++++++++++++------- src/freenet/introductionpuzzleinserter.cpp | 3 +-- src/http/pages/peermaintenancepage.cpp | 2 +- src/optionssetup.cpp | 2 +- 9 files changed, 49 insertions(+), 21 deletions(-) diff --git a/include/freenet/captcha/alternatecaptchafonts.h b/include/freenet/captcha/alternatecaptchafonts.h index 741d0b2..e681285 100644 --- a/include/freenet/captcha/alternatecaptchafonts.h +++ b/include/freenet/captcha/alternatecaptchafonts.h @@ -3,11 +3,12 @@ #ifdef ALTERNATE_CAPTCHA +#include "../../ilogger.h" #include "freeimage/bitmap.h" #include "freeimage/font.h" #include -class AlternateCaptchaFonts +class AlternateCaptchaFonts:public ILogger { public: AlternateCaptchaFonts(); diff --git a/include/freenet/captcha/freeimage/bitmap.h b/include/freenet/captcha/freeimage/bitmap.h index 9e00af3..406ca4b 100644 --- a/include/freenet/captcha/freeimage/bitmap.h +++ b/include/freenet/captcha/freeimage/bitmap.h @@ -61,6 +61,6 @@ private: }; -} +} // namespace #endif // _freeimage_bitmap_ diff --git a/include/global.h b/include/global.h index 182dafe..2a9478d 100644 --- a/include/global.h +++ b/include/global.h @@ -7,7 +7,7 @@ #define VERSION_MAJOR "0" #define VERSION_MINOR "3" -#define VERSION_RELEASE "16" +#define VERSION_RELEASE "17" #define FMS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE typedef Poco::ScopedLock Guard; diff --git a/src/freenet/captcha/alternatecaptcha1.cpp b/src/freenet/captcha/alternatecaptcha1.cpp index 83b2ca5..0b9db08 100644 --- a/src/freenet/captcha/alternatecaptcha1.cpp +++ b/src/freenet/captcha/alternatecaptcha1.cpp @@ -1,6 +1,7 @@ #include "../../../include/freenet/captcha/alternatecaptcha1.h" #include +#include #ifdef ALTERNATE_CAPTCHA @@ -12,6 +13,11 @@ AlternateCaptcha1::AlternateCaptcha1() void AlternateCaptcha1::Generate() { + if(m_fonts.size()==0) + { + return; + } + std::string puzzlestring=GenerateRandomString(5); FreeImage::Bitmap tempchar(50,50,32); tempchar.SetTransparent(); @@ -50,7 +56,7 @@ void AlternateCaptcha1::Generate() white.rgbGreen=255; white.rgbBlue=255; white.rgbReserved=255; - int numlines=(rand()%5)+10; + int numlines=(rand()%5)+5; for(int i=0; i #include +#include #ifdef ALTERNATE_CAPTCHA @@ -16,6 +17,11 @@ AlternateCaptcha2::AlternateCaptcha2() void AlternateCaptcha2::Generate() { + if(m_fonts.size()==0) + { + return; + } + std::string puzzlestring=GenerateRandomString(6); std::vector fontnums(puzzlestring.size(),0); @@ -42,9 +48,9 @@ void AlternateCaptcha2::Generate() for(int i=0; i #include +#include bool AlternateCaptchaFonts::m_fontsloaded(false); std::vector AlternateCaptchaFonts::m_fonts; @@ -21,19 +22,34 @@ AlternateCaptchaFonts::AlternateCaptchaFonts() void AlternateCaptchaFonts::LoadFonts() { - FreeImage::Bitmap bmp; - Poco::Path path("fonts"); - Poco::DirectoryIterator di(path); - Poco::DirectoryIterator end; - - while(di!=end) + try { - if(di.name().find("bmp")!=std::string::npos) + FreeImage::Bitmap bmp; + Poco::Path path("fonts"); + Poco::DirectoryIterator di(path); + Poco::DirectoryIterator end; + + while(di!=end) + { + if(di.name().find("bmp")!=std::string::npos) + { + bmp.Load("bmp",di.path().toString()); + m_fonts.push_back(FreeImage::Font(bmp)); + } + ++di; + } + if(m_fonts.size()==0) { - bmp.Load("bmp",di.path().toString()); - m_fonts.push_back(FreeImage::Font(bmp)); + m_log->fatal("AlternateCaptchaFonts::LoadFonts You have no loadable fonts in the font directory!"); } - ++di; + } + catch(Poco::Exception &e) + { + m_log->error("AlternateCaptchaFonts::LoadFonts caught "+e.displayText()); + } + catch(...) + { + m_log->error("AlternateCaptchaFonts::LoadFonts caught unknown exception"); } } diff --git a/src/freenet/introductionpuzzleinserter.cpp b/src/freenet/introductionpuzzleinserter.cpp index 60f7bb6..cac3879 100644 --- a/src/freenet/introductionpuzzleinserter.cpp +++ b/src/freenet/introductionpuzzleinserter.cpp @@ -87,8 +87,7 @@ void IntroductionPuzzleInserter::GenerateCaptcha(std::string &encodeddata, std:: } m_log->trace("IntroductionPuzzleInserter::GenerateCaptcha using alternate captcha generator"); #else - SimpleCaptcha captcha; - cap=&captcha; + cap=new SimpleCaptcha(); #endif std::vector puzzle; std::vector puzzlesolution; diff --git a/src/http/pages/peermaintenancepage.cpp b/src/http/pages/peermaintenancepage.cpp index 573306b..240c12e 100644 --- a/src/http/pages/peermaintenancepage.cpp +++ b/src/http/pages/peermaintenancepage.cpp @@ -39,7 +39,7 @@ const std::string PeerMaintenancePage::GeneratePage(const std::string &method, c { date=Poco::Timestamp(); date-=Poco::Timespan(20,0,0,0,0); - st=m_db->Prepare("DELETE FROM tblIdentity WHERE IdentityID NOT IN (SELECT IdentityID FROM tblMessage GROUP BY IdentityID WHERE IdentityID IS NOT NULL) AND LastSeenPrepare("DELETE FROM tblIdentity WHERE IdentityID NOT IN (SELECT IdentityID FROM tblMessage WHERE IdentityID IS NOT NULL GROUP BY IdentityID) AND LastSeen