1 #include "../../../include/http/pages/peertrustpage.h"
\r
2 #include "../../../include/stringfunctions.h"
\r
8 const std::string PeerTrustPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)
\r
11 std::string countstr;
\r
12 std::string content="";
\r
14 if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="update")
\r
16 std::vector<std::string> identityids;
\r
17 std::vector<std::string> oldlmt;
\r
18 std::vector<std::string> lmt;
\r
19 std::vector<std::string> oldltlt;
\r
20 std::vector<std::string> ltlt;
\r
21 int localmessagetrust=0;
\r
22 int localtrustlisttrust=0;
\r
25 CreateArgArray(queryvars,"identityid",identityids);
\r
26 CreateArgArray(queryvars,"oldlocalmessagetrust",oldlmt);
\r
27 CreateArgArray(queryvars,"localmessagetrust",lmt);
\r
28 CreateArgArray(queryvars,"oldlocaltrustlisttrust",oldltlt);
\r
29 CreateArgArray(queryvars,"localtrustlisttrust",ltlt);
\r
31 SQLite3DB::Statement update=m_db->Prepare("UPDATE tblIdentity SET LocalMessageTrust=?, LocalTrustListTrust=? WHERE IdentityID=?;");
\r
33 for(int i=0; i<identityids.size(); i++)
\r
35 if(oldlmt[i]!=lmt[i] || oldltlt[i]!=ltlt[i])
\r
37 StringFunctions::Convert(lmt[i],localmessagetrust);
\r
38 StringFunctions::Convert(ltlt[i],localtrustlisttrust);
\r
39 StringFunctions::Convert(identityids[i],identityid);
\r
41 update.Bind(0,localmessagetrust);
\r
42 update.Bind(1,localtrustlisttrust);
\r
43 update.Bind(2,identityid);
\r
51 content+="<h2>Peer Trust</h2>";
\r
52 content+="Message Trust is how much you trust the identity to post good messages. Trust List Trust is how much weight you want the trust list of that identity to have when calculating the total. The local trust levels are set by you, and the peer trust levels are calculated by a weighted average using other identities trust lists.";
\r
53 content+="<form name=\"frmtrust\" method=\"POST\">";
\r
54 content+="<input type=\"hidden\" name=\"formaction\" value=\"update\">";
\r
56 content+="<tr><th>Name</th><th>Local Message Trust</th><th>Peer Message Trust</th><th>Local Trust List Trust</th><th>Peer Trust List Trust</th></tr>";
\r
58 SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey FROM tblIdentity ORDER BY Name;");
\r
61 while(st.RowReturned())
\r
63 std::string identityid;
\r
65 std::string localmessagetrust;
\r
66 std::string peermessagetrust;
\r
67 std::string localtrustlisttrust;
\r
68 std::string peertrustlisttrust;
\r
69 std::string publickey;
\r
71 StringFunctions::Convert(count,countstr);
\r
73 st.ResultText(0,identityid);
\r
74 st.ResultText(1,name);
\r
75 st.ResultText(2,localmessagetrust);
\r
76 st.ResultText(3,peermessagetrust);
\r
77 st.ResultText(4,localtrustlisttrust);
\r
78 st.ResultText(5,peertrustlisttrust);
\r
79 st.ResultText(6,publickey);
\r
82 content+="<td title=\""+publickey+"\">";
\r
83 content+="<input type=\"hidden\" name=\"identityid["+countstr+"]\" value=\""+identityid+"\">";
\r
90 content+="[Unknown Name]";
\r
94 content+="<input type=\"hidden\" name=\"oldlocalmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\">";
\r
95 content+="<input type=\"text\" name=\"localmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\" size=\"2\" maxlength=\"3\"></td>";
\r
96 content+="<td>"+peermessagetrust+"</td>";
\r
98 content+="<input type=\"hidden\" name=\"oldlocaltrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\">";
\r
99 content+="<input type=\"text\" name=\"localtrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\" size=\"2\" maxlength=\"3\"></td>";
\r
100 content+="<td>"+peertrustlisttrust+"</td>";
\r
106 content+="<tr><td colspan=\"5\"><input type=\"submit\" value=\"Update Trust\"></td></tr>";
\r
107 content+="</table>";
\r
108 content+="</form>";
\r
110 return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);
\r
113 const bool PeerTrustPage::WillHandleURI(const std::string &uri)
\r
115 if(uri.find("peertrust.")!=std::string::npos)
\r