X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fforumcreatepostpage.cpp;fp=src%2Fhttp%2Fpages%2Fforumcreatepostpage.cpp;h=ac9ed16766bfeba4359688bf6964b25d9131f7ad;hp=0000000000000000000000000000000000000000;hb=221236a4d3aac4144529d418ce368db5c98facb0;hpb=d5c9f7e6c1dd263dfc85a3cb5941a378a5ddd923 diff --git a/src/http/pages/forumcreatepostpage.cpp b/src/http/pages/forumcreatepostpage.cpp new file mode 100644 index 0000000..ac9ed16 --- /dev/null +++ b/src/http/pages/forumcreatepostpage.cpp @@ -0,0 +1,227 @@ +#include "../../../include/http/pages/forumcreatepostpage.h" +#include "../../../include/stringfunctions.h" +#include "../../../include/message.h" + +#ifdef XMEM + #include +#endif + +const std::string ForumCreatePostPage::GeneratePage(const std::string &method, const std::map &queryvars) +{ + int page=0; + std::string content=""; + std::string boardidstr=""; + std::string currentpagestr=""; + std::string threadidstr=""; + std::string replytomessageidstr=""; + std::string error=""; + std::string boardname=""; + std::string subject=""; + std::string body=""; + std::string localidentityidstr=""; + + if(queryvars.find("boardid")!=queryvars.end()) + { + boardidstr=(*queryvars.find("boardid")).second; + } + if(queryvars.find("currentpage")!=queryvars.end()) + { + currentpagestr=(*queryvars.find("currentpage")).second; + } + if(queryvars.find("threadid")!=queryvars.end()) + { + threadidstr=(*queryvars.find("threadid")).second; + } + if(queryvars.find("replytomessageid")!=queryvars.end()) + { + replytomessageidstr=(*queryvars.find("replytomessageid")).second; + } + + if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="send") + { + if(queryvars.find("localidentityid")!=queryvars.end() && (*queryvars.find("localidentityid")).second!="") + { + localidentityidstr=(*queryvars.find("localidentityid")).second; + } + else + { + error="You must select a local identity as the sender
"; + } + + if(queryvars.find("subject")!=queryvars.end() && (*queryvars.find("subject")).second!="") + { + subject=(*queryvars.find("subject")).second; + } + else + { + error+="You must enter a subject
"; + } + + if(queryvars.find("body")!=queryvars.end() && (*queryvars.find("body")).second!="") + { + body=(*queryvars.find("body")).second; + body=StringFunctions::Replace(body,"\r\n","\n"); + } + else + { + error+="You must enter a message body
"; + } + + if(error=="") + { + Message mess; + + long localidentityid=-1; + long boardid=-1; + std::string references=""; + + StringFunctions::Convert(localidentityidstr,localidentityid); + StringFunctions::Convert(boardidstr,boardid); + + if(replytomessageidstr!="") + { + SQLite3DB::Statement st=m_db->Prepare("SELECT MessageUUID FROM tblMessage WHERE MessageID=?;"); + st.Bind(0,replytomessageidstr); + st.Step(); + if(st.RowReturned()) + { + st.ResultText(0,references); + } + } + + if(mess.Create(localidentityid,boardid,subject,body,references)) + { + if(mess.PostedToAdministrationBoard()==true) + { + mess.HandleAdministrationMessage(); + } + if(mess.StartFreenetInsert()) + { + page=1; + } + } + else + { + error="Could not create message"; + } + } + } + else + { + if(replytomessageidstr!="") + { + SQLite3DB::Statement replyst=m_db->Prepare("SELECT Subject, Body FROM tblMessage WHERE MessageID=?;"); + replyst.Bind(0,replytomessageidstr); + replyst.Step(); + if(replyst.RowReturned()) + { + replyst.ResultText(0,subject); + replyst.ResultText(1,body); + + if(subject.size()<3 || (subject.substr(0,2)!="re:" && subject.substr(0,2)!="Re:")) + { + subject="Re: "+subject; + } + + if(body.size()>0) + { + if(body[0]=='>') + { + body=">"+body; + } + else + { + body="> "+body; + } + std::string::size_type pos=body.find("\n"); + while(pos!=std::string::npos) + { + if(pos+1') + { + body.insert(pos+1,">"); + } + else + { + body.insert(pos+1,"> "); + } + pos=body.find("\n",pos+2); + } + body+="\n"; + } + } + } + } + + SQLite3DB::Statement boardnamest=m_db->Prepare("SELECT BoardName FROM tblBoard WHERE BoardID=?;"); + boardnamest.Bind(0,boardidstr); + boardnamest.Step(); + if(boardnamest.RowReturned()) + { + boardnamest.ResultText(0,boardname); + } + + content+=CreateForumHeader(); + + content+=""; + content+=""; + content+=""; + content+=""; + content+="
Forum : "+SanitizeOutput(boardname)+"
\r\n"; + + if(error!="") + { + content+="
"+error+"
\r\n"; + } + + if(page==0) + { + content+="
"; + content+=""; + content+=""; + content+=""; + content+=""; + content+=""; + content+=""; + content+=""; + content+=""; + content+=""; + content+=""; + content+="
From"+LocalIdentityDropDown("localidentityid",localidentityidstr)+"
Subject
Message
\r\n"; + content+="
"; + } + else if(page==1) + { + content+="You have sent your message. It will show up in the thread after it has been successfully inserted and retrieved by FMS."; + } + + return StringFunctions::Replace(m_template,"[CONTENT]",content); +} + +const std::string ForumCreatePostPage::LocalIdentityDropDown(const std::string &name, const std::string &selectedid) +{ + std::string html=""; + return html; +}