1 #include "../../../include/http/pages/showpendingmessagepage.h"
\r
2 #include "../../../include/stringfunctions.h"
\r
3 #include "../../../include/global.h"
\r
4 #include "../../../include/fmsapp.h"
\r
5 #include "../../../include/option.h"
\r
6 #include "../../../include/localidentity.h"
\r
7 #include "../../../include/freenet/messagexml.h"
\r
13 const std::string ShowPendingMessagePage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)
\r
15 if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="delete" && ValidateFormPassword(queryvars))
\r
17 m_log->information("User requested to delete message "+(*queryvars.find("uuid")).second);
\r
18 m_db->Execute("DELETE FROM tblMessageInserts WHERE MessageUUID=\""+(*queryvars.find("uuid")).second+"\"");
\r
21 SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID, MessageXML, SendDate, MessageUUID FROM tblMessageInserts WHERE Inserted='false';");
\r
24 std::string tblcontent="";
\r
25 std::string content="";
\r
26 tblcontent+="<table><tr><td>Identity</td><td>Boards</td><td>Subject</td><td>Time</td></tr>";
\r
27 while (st.RowReturned())
\r
30 std::string time("");
\r
31 std::string uuid("");
\r
32 std::string subject("");
\r
34 st.ResultInt(0,identityid);
\r
35 st.ResultText(2,time);
\r
36 st.ResultText(3, uuid);
\r
38 LocalIdentity ident(m_db); //found a canned way, thanks SomeDude!
\r
39 ident.Load(identityid);
\r
41 tblcontent+="<tr><td>";
\r
42 tblcontent+=SanitizeOutput(ident.GetName())+"</td><td>";
\r
43 //yes, the next bit sucks but there's no better way to do it (that I could find)
\r
44 //we will look at the message XML to find the board(s) posted to....
\r
46 st.ResultText(1,xml);
\r
49 std::vector<std::string> boards=mxml.GetBoards();
\r
50 std::vector<std::string>::iterator iter;
\r
51 for (iter=boards.begin(); iter!=boards.end(); iter++) tblcontent+=*iter+", ";
\r
52 tblcontent.erase(tblcontent.length()-2); //strip final ", "
\r
53 tblcontent+="</td><td>";
\r
54 subject=mxml.GetSubject();
\r
55 tblcontent+=subject;
\r
56 tblcontent+="</td><td>";
\r
57 tblcontent+=time+"</td><td>";
\r
59 tblcontent+="<form name=\"frmdelete\" method=\"POST\">";
\r
60 tblcontent+=CreateFormPassword();
\r
61 tblcontent+="<input type=\"hidden\" name=\"formaction\" value=\"delete\">";
\r
62 tblcontent+="<input type=\"hidden\" name=\"uuid\" value=\""+uuid+"\">";
\r
63 tblcontent+="<input type=\"submit\" value=\"Delete Message\">";
\r
64 tblcontent+="</form>";
\r
65 tblcontent+="</td></tr>";
\r
69 tblcontent+="</table>";
\r
71 std::string msgcountstr("");
\r
72 StringFunctions::Convert(msgcount,msgcountstr);
\r
73 content="<h2>"+msgcountstr+" messages waiting to be inserted</h2>";
\r
75 content+=tblcontent;
\r
77 return StringFunctions::Replace(m_template,"[CONTENT]",content);
\r