X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fipagehandler.cpp;h=1ec7947dbba72488785cdd4085377b8082dd56a1;hb=59a5414ec47a2932a7802fcd1d98c4d80166564f;hp=230da65e55e04491936e56f65a5726d5aba2f579;hpb=d8ccfe2b3944adf07d35534459cdda19d15217c8;p=fms.git diff --git a/src/http/ipagehandler.cpp b/src/http/ipagehandler.cpp index 230da65..1ec7947 100644 --- a/src/http/ipagehandler.cpp +++ b/src/http/ipagehandler.cpp @@ -1,96 +1,216 @@ #include "../../include/http/ipagehandler.h" -#include "../../include/http/httpdefs.h" #include "../../include/stringfunctions.h" +#include "../../include/http/multipartparser.h" + +#include +#include +#include +#include +#include +#include + +#include #ifdef XMEM #include #endif -const bool IPageHandler::Handle(shttpd_arg *arg) +void IPageHandler::CreateArgArray(const std::map &vars, const std::string &basename, std::vector &args) { - const char *uri=shttpd_get_env(arg,"REQUEST_URI"); - const char *method=shttpd_get_env(arg,"REQUEST_METHOD"); - std::string methodstr=""; - if(method) - { - methodstr=method; - } - - if(uri && WillHandleURI(std::string(uri))) + for(std::map::const_iterator i=vars.begin(); i!=vars.end(); i++) { - httpstate *mystate=(httpstate *)arg->state; - // this is a new request - create a new arg object - if(arg->state==NULL) + if((*i).first.find(basename)==0 && (*i).first.find("[")!=std::string::npos && (*i).first.find("]")!=std::string::npos) { - arg->state=new httpstate; - memset(arg->state,0,sizeof(httpstate)); - mystate=(httpstate *)arg->state; + int index=0; + std::string indexstr; + std::string::size_type startpos; + std::string::size_type endpos; + startpos=(*i).first.find("["); + endpos=(*i).first.find("]"); - // if post then create input buffer - if(methodstr=="POST") - { - const char *lenstr=shttpd_get_header(arg,"Content-Length"); - if(lenstr) - { - long len; - StringFunctions::Convert(std::string(lenstr),len); - mystate->m_indata=new char[len]; - mystate->m_indatalen=len; - mystate->m_indatapos=0; - } - } - } + indexstr=(*i).first.substr(startpos+1,(endpos-startpos)-1); + StringFunctions::Convert(indexstr,index); - // we have more POST data to get - if(arg->in.len>0) - { - int pos=0; - while(arg->in.num_bytesin.len) + while(args.size()m_indata[mystate->m_indatapos++]=arg->in.buf[pos++]; + args.push_back(""); } - arg->in.num_bytes=arg->in.len; + args[index]=(*i).second; } + } +} - // we have all POST data (or it was 0 to begin with) - generate the page - if(mystate->m_indatalen==mystate->m_indatapos && mystate->m_outdata==NULL) - { - //TODO parse POST data and any QUERY_STRING before generating page - std::string page=GeneratePage(methodstr,std::map()); - mystate->m_outdata=new char[page.size()]; - memcpy(mystate->m_outdata,page.c_str(),page.size()); - mystate->m_outdatalen=page.size(); - mystate->m_outdatapos=0; - } +const std::string IPageHandler::CreateFormPassword() +{ + Poco::DateTime date; + Poco::UUIDGenerator uuidgen; + Poco::UUID uuid; + try + { + uuid=uuidgen.createRandom(); + } + catch(...) + { + } + + SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tmpFormPassword(Date,Password) VALUES(?,?);"); + st.Bind(0,Poco::DateTimeFormatter::format(date,"%Y-%m-%d %H:%M:%S")); + st.Bind(1,uuid.toString()); + st.Step(); - // if we have output data, push next block of data onto out buffer - if(mystate->m_outdata && mystate->m_outdataposm_outdatalen) + return ""; + +} + +const std::string IPageHandler::CreateTrueFalseDropDown(const std::string &name, const std::string &selected) +{ + std::string rval=""; + + rval+="