X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fshowcaptchapage.cpp;fp=src%2Fhttp%2Fpages%2Fshowcaptchapage.cpp;h=abd65b34928a8c00f74c6e6c12241ac5e411bfb1;hb=f208e33c29132aacaec448e74341edea1b925a2a;hp=0000000000000000000000000000000000000000;hpb=d8ccfe2b3944adf07d35534459cdda19d15217c8;p=fms.git diff --git a/src/http/pages/showcaptchapage.cpp b/src/http/pages/showcaptchapage.cpp new file mode 100644 index 0000000..abd65b3 --- /dev/null +++ b/src/http/pages/showcaptchapage.cpp @@ -0,0 +1,48 @@ +#include "../../../include/http/pages/showcaptchapage.h" +#include "../../../include/base64.h" +#include "../../../include/stringfunctions.h" + +#ifdef XMEM + #include +#endif + +const std::string ShowCaptchaPage::GeneratePage(const std::string &method, const std::map &queryvars) +{ + std::string content="HTTP/1.1 200 OK\r\n"; + if(queryvars.find("UUID")!=queryvars.end()) + { + SQLite3DB::Statement st=m_db->Prepare("SELECT MimeType,PuzzleData FROM tblIntroductionPuzzleRequests WHERE UUID=?;"); + st.Bind(0,(*queryvars.find("UUID")).second); + st.Step(); + + if(st.RowReturned()) + { + std::string mime; + std::string b64data; + std::vector data; + std::string lenstr; + + st.ResultText(0,mime); + st.ResultText(1,b64data); + Base64::Decode(b64data,data); + StringFunctions::Convert(data.size(),lenstr); + + content+="Content-Type: "+mime+"\r\n"; + content+="Content-Length: "+lenstr+"\r\n\r\n"; + content+=std::string(data.begin(),data.end()); + } + } + return content; +} + +const bool ShowCaptchaPage::WillHandleURI(const std::string &uri) +{ + if(uri.find("showcaptcha.")!=std::string::npos) + { + return true; + } + else + { + return false; + } +}