+#include "../../../include/http/pages/showpendingmessagepage.h"\r
+#include "../../../include/stringfunctions.h"\r
+#include "../../../include/global.h"\r
+#include "../../../include/fmsapp.h"\r
+#include "../../../include/option.h"\r
+#include "../../../include/localidentity.h"\r
+#include "../../../include/freenet/messagexml.h"\r
+\r
+#ifdef XMEM\r
+ #include <xmem.h>\r
+#endif\r
+\r
+const std::string ShowPendingMessagePage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
+{\r
+ if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="delete" && ValidateFormPassword(queryvars))\r
+ {\r
+ m_log->information("User requested to delete message "+(*queryvars.find("uuid")).second);\r
+ m_db->Execute("DELETE FROM tblMessageInserts WHERE MessageUUID=\""+(*queryvars.find("uuid")).second+"\"");\r
+ }\r
+\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID, MessageXML, SendDate, MessageUUID FROM tblMessageInserts WHERE Inserted='false';");\r
+ st.Step();\r
+ int msgcount=0;\r
+ std::string tblcontent="";\r
+ std::string content="";\r
+ tblcontent+="<table><tr><td>Identity</td><td>Boards</td><td>Subject</td><td>Time</td></tr>";\r
+ while (st.RowReturned())\r
+ { \r
+ int identityid=0;\r
+ std::string time("");\r
+ std::string uuid("");\r
+ std::string subject("");\r
+\r
+ st.ResultInt(0,identityid);\r
+ st.ResultText(2,time);\r
+ st.ResultText(3, uuid);\r
+\r
+ LocalIdentity ident(m_db); //found a canned way, thanks SomeDude!\r
+ ident.Load(identityid);\r
+\r
+ tblcontent+="<tr><td>";\r
+ tblcontent+=SanitizeOutput(ident.GetName())+"</td><td>";\r
+ //yes, the next bit sucks but there's no better way to do it (that I could find)\r
+ //we will look at the message XML to find the board(s) posted to.... \r
+ std::string xml="";\r
+ st.ResultText(1,xml);\r
+ MessageXML mxml;\r
+ mxml.ParseXML(xml);\r
+ std::vector<std::string> boards=mxml.GetBoards();\r
+ std::vector<std::string>::iterator iter;\r
+ for (iter=boards.begin(); iter!=boards.end(); iter++) tblcontent+=*iter+", ";\r
+ tblcontent.erase(tblcontent.length()-2); //strip final ", "\r
+ tblcontent+="</td><td>";\r
+ subject=mxml.GetSubject();\r
+ tblcontent+=subject;\r
+ tblcontent+="</td><td>";\r
+ tblcontent+=time+"</td><td>";\r
+ //button\r
+ tblcontent+="<form name=\"frmdelete\" method=\"POST\">";\r
+ tblcontent+=CreateFormPassword();\r
+ tblcontent+="<input type=\"hidden\" name=\"formaction\" value=\"delete\">";\r
+ tblcontent+="<input type=\"hidden\" name=\"uuid\" value=\""+uuid+"\">";\r
+ tblcontent+="<input type=\"submit\" value=\"Delete Message\">";\r
+ tblcontent+="</form>";\r
+ tblcontent+="</td></tr>";\r
+ st.Step();\r
+ msgcount++;\r
+ }\r
+ tblcontent+="</table>";\r
+\r
+ std::string msgcountstr("");\r
+ StringFunctions::Convert(msgcount,msgcountstr);\r
+ content="<h2>"+msgcountstr+" messages waiting to be inserted</h2>";\r
+\r
+ content+=tblcontent;\r
+\r
+ return StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+}\r