version 0.3.33
[fms.git] / src / http / pages / peertrustpage.cpp
index 38bddbf..b90a106 100644 (file)
 #include "../../../include/http/pages/peertrustpage.h"\r
 #include "../../../include/stringfunctions.h"\r
+#include "../../../include/global.h"\r
 \r
 #ifdef XMEM\r
        #include <xmem.h>\r
 #endif\r
 \r
+const std::string PeerTrustPage::BuildQueryString(const long startrow, const std::string &namesearch, const std::string &sortby, const std::string &sortorder, const int localidentityid)\r
+{\r
+       std::string returnval="";\r
+       std::string tempval="";\r
+       \r
+       if(startrow>=0)\r
+       {\r
+               StringFunctions::Convert(startrow,tempval);\r
+               returnval+="startrow="+tempval;\r
+       }\r
+\r
+       if(namesearch!="")\r
+       {\r
+               if(returnval!="")\r
+               {\r
+                       returnval+="&";\r
+               }\r
+               returnval+="namesearch="+StringFunctions::UriEncode(namesearch);\r
+       }\r
+\r
+       if(sortby!="")\r
+       {\r
+               if(returnval!="")\r
+               {\r
+                       returnval+="&";\r
+               }\r
+               returnval+="sortby="+sortby;\r
+       }\r
+\r
+       if(sortorder!="")\r
+       {\r
+               if(returnval!="")\r
+               {\r
+                       returnval+="&";\r
+               }\r
+               returnval+="sortorder="+sortorder;\r
+       }\r
+\r
+       if(localidentityid>=0)\r
+       {\r
+               std::string localidentityidstr="";\r
+               StringFunctions::Convert(localidentityid,localidentityidstr);\r
+               if(returnval!="")\r
+               {\r
+                       returnval+="&";\r
+               }\r
+               returnval+="localidentityid="+localidentityidstr;\r
+       }\r
+\r
+       return returnval;\r
+\r
+}\r
+\r
+const std::string PeerTrustPage::CreateLocalIdentityDropDown(const std::string &name, const int selectedlocalidentityid)\r
+{\r
+       std::string result="";\r
+       \r
+       result+="<select name=\""+name+"\">";\r
+       \r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID,Name,PublicKey FROM tblLocalIdentity WHERE PublicKey IS NOT NULL ORDER BY Name COLLATE NOCASE;");\r
+       st.Step();\r
+\r
+       while(st.RowReturned())\r
+       {\r
+               int localidentityid=-1;\r
+               std::string localidentityidstr="";\r
+               std::string name="";\r
+               std::string publickey="";\r
+\r
+               st.ResultInt(0,localidentityid);\r
+               st.ResultText(1,name);\r
+               st.ResultText(2,publickey);\r
+\r
+               StringFunctions::Convert(localidentityid,localidentityidstr);\r
+\r
+               result+="<option value=\""+localidentityidstr+"\"";\r
+               if(localidentityid==selectedlocalidentityid)\r
+               {\r
+                       result+=" SELECTED";\r
+               }\r
+               result+=">"+SanitizeOutput(CreateShortIdentityName(name,publickey))+"</option>";\r
+               st.Step();\r
+       }\r
+\r
+       result+="</select>";\r
+\r
+       return result;\r
+}\r
+\r
 const std::string PeerTrustPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
 {\r
        int count=0;\r
@@ -17,39 +107,108 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
        std::string startrowstr="0";\r
        std::string namesearch="";\r
        std::string sql;\r
+       std::string sortby="";\r
+       std::string sortorder="";\r
+       std::string localidentityidstr="";\r
+       int localidentityid=-1;\r
 \r
        StringFunctions::Convert(rowsperpage,rowsperpagestr);\r
 \r
-       if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="update")\r
+       // get localidentityid from querystring or load one from the database\r
+       if(queryvars.find("localidentityid")!=queryvars.end())\r
+       {\r
+               localidentityidstr=(*queryvars.find("localidentityid")).second;\r
+               StringFunctions::Convert(localidentityidstr,localidentityid);\r
+               // insert the ID into the temporary table so we remember the identity if we load the page later\r
+               m_db->Execute("DELETE FROM tmpLocalIdentityPeerTrustPage;");\r
+               SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tmpLocalIdentityPeerTrustPage(LocalIdentityID) VALUES(?);");\r
+               st.Bind(0,localidentityid);\r
+               st.Step();\r
+       }\r
+       else\r
+       {\r
+               // try to get the localidentityid if it exists in the temp table, otherwise load the first identity in the database\r
+               SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID FROM tmpLocalIdentityPeerTrustPage;");\r
+               st.Step();\r
+               if(st.RowReturned())\r
+               {\r
+                       st.ResultInt(0,localidentityid);\r
+                       StringFunctions::Convert(localidentityid,localidentityidstr);\r
+               }\r
+               else\r
+               {\r
+                       st=m_db->Prepare("SELECT LocalIdentityID FROM tblLocalIdentity;");\r
+                       st.Step();\r
+                       if(st.RowReturned())\r
+                       {\r
+                               st.ResultInt(0,localidentityid);\r
+                               StringFunctions::Convert(localidentityid,localidentityidstr);\r
+                       }\r
+                       st.Finalize();\r
+               }\r
+       }\r
+\r
+       if(localidentityid!=-1 && queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="update" && ValidateFormPassword(queryvars))\r
        {\r
                std::vector<std::string> identityids;\r
                std::vector<std::string> oldlmt;\r
                std::vector<std::string> lmt;\r
                std::vector<std::string> oldltlt;\r
                std::vector<std::string> ltlt;\r
+               std::vector<std::string> oldmtc;\r
+               std::vector<std::string> mtc;\r
+               std::vector<std::string> oldtltc;\r
+               std::vector<std::string> tltc;\r
                int localmessagetrust=0;\r
                int localtrustlisttrust=0;\r
-               int identityid;\r
+               int identityid=-1;\r
 \r
                CreateArgArray(queryvars,"identityid",identityids);\r
                CreateArgArray(queryvars,"oldlocalmessagetrust",oldlmt);\r
                CreateArgArray(queryvars,"localmessagetrust",lmt);\r
                CreateArgArray(queryvars,"oldlocaltrustlisttrust",oldltlt);\r
                CreateArgArray(queryvars,"localtrustlisttrust",ltlt);\r
-               \r
-               SQLite3DB::Statement update=m_db->Prepare("UPDATE tblIdentity SET LocalMessageTrust=?, LocalTrustListTrust=? WHERE IdentityID=?;");\r
+               CreateArgArray(queryvars,"oldmessagetrustcomment",oldmtc);\r
+               CreateArgArray(queryvars,"messagetrustcomment",mtc);\r
+               CreateArgArray(queryvars,"oldtrustlisttrustcomment",oldtltc);\r
+               CreateArgArray(queryvars,"trustlisttrustcomment",tltc);\r
+\r
+               SQLite3DB::Statement ins=m_db->Prepare("INSERT INTO tblIdentityTrust(LocalIdentityID,IdentityID) VALUES(?,?);");\r
+               SQLite3DB::Statement update=m_db->Prepare("UPDATE tblIdentityTrust SET LocalMessageTrust=?, LocalTrustListTrust=?, MessageTrustComment=?, TrustListTrustComment=? WHERE LocalIdentityID=? AND IdentityID=?;");\r
 \r
                for(int i=0; i<identityids.size(); i++)\r
                {\r
-                       if(oldlmt[i]!=lmt[i] || oldltlt[i]!=ltlt[i])\r
+                       if(oldlmt[i]!=lmt[i] || oldltlt[i]!=ltlt[i] || oldmtc[i]!=mtc[i] || oldtltc[i]!=tltc[i])\r
                        {\r
                                StringFunctions::Convert(lmt[i],localmessagetrust);\r
                                StringFunctions::Convert(ltlt[i],localtrustlisttrust);\r
                                StringFunctions::Convert(identityids[i],identityid);\r
 \r
-                               update.Bind(0,localmessagetrust);\r
-                               update.Bind(1,localtrustlisttrust);\r
-                               update.Bind(2,identityid);\r
+                               ins.Bind(0,localidentityid);\r
+                               ins.Bind(1,identityid);\r
+                               ins.Step();\r
+                               ins.Reset();\r
+\r
+                               if(lmt[i]!="")\r
+                               {\r
+                                       update.Bind(0,localmessagetrust);\r
+                               }\r
+                               else\r
+                               {\r
+                                       update.Bind(0);\r
+                               }\r
+                               if(ltlt[i]!="")\r
+                               {\r
+                                       update.Bind(1,localtrustlisttrust);\r
+                               }\r
+                               else\r
+                               {\r
+                                       update.Bind(1);\r
+                               }\r
+                               update.Bind(2,mtc[i]);\r
+                               update.Bind(3,tltc[i]);\r
+                               update.Bind(4,localidentityid);\r
+                               update.Bind(5,identityid);\r
                                update.Step();\r
                                update.Reset();\r
                        }\r
@@ -70,6 +229,34 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                StringFunctions::Convert(startrow,startrowstr);\r
        }\r
 \r
+       // sort by\r
+       if(queryvars.find("sortby")!=queryvars.end())\r
+       {\r
+               sortby=(*queryvars.find("sortby")).second;\r
+               if(sortby!="Name" && sortby!="tblIdentityTrust.LocalMessageTrust" && sortby!="PeerMessageTrust" && sortby!="tblIdentityTrust.LocalTrustListTrust" && sortby!="PeerTrustListTrust" && sortby!="MessageCount")\r
+               {\r
+                       sortby="Name";\r
+               }\r
+       }\r
+       else\r
+       {\r
+               sortby="Name";\r
+       }\r
+\r
+       // sort order\r
+       if(queryvars.find("sortorder")!=queryvars.end())\r
+       {\r
+               sortorder=(*queryvars.find("sortorder")).second;\r
+               if(sortorder!="ASC" && sortorder!="DESC")\r
+               {\r
+                       sortorder="ASC";\r
+               }\r
+       }\r
+       else\r
+       {\r
+               sortorder="ASC";\r
+       }\r
+\r
        // if we are searching by name\r
        if(queryvars.find("namesearch")!=queryvars.end())\r
        {\r
@@ -77,45 +264,92 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
        }\r
 \r
        content+="<h2>Peer Trust</h2>";\r
-       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
-       content+="<div style=\"text-align:center;\">";\r
-       content+="<form name=\"frmsearch\" method=\"POST\" action=\"peertrust.htm\">";\r
-       content+="<input type=\"text\" name=\"namesearch\">";\r
+       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.  Trust is recalculated once an hour from received trust lists.  You must have at least 1 identity created and have received the SSK keypair for it from Freenet before setting trust.<br>";\r
+       content+="* - This identity is not publishing a trust list<br>";\r
+\r
+       // search drop down\r
+       content+="<div style=\"text-align:center;margin-bottom:5px;\">";\r
+       content+="<form name=\"frmsearch\" method=\"POST\" action=\""+m_pagename+"?"+BuildQueryString(0,"","","",localidentityid)+"\">";\r
+       content+="<input type=\"text\" name=\"namesearch\" value=\""+SanitizeOutput(namesearch)+"\">";\r
        content+="<input type=\"submit\" value=\"Search\">";\r
        content+="</form>";\r
        content+="</div>";\r
+\r
+       content+="<div style=\"text-align:center;\">";\r
+       content+="<form name=\"frmlocalidentity\" method=\"POST\" action=\""+m_pagename+"?"+BuildQueryString(startrow,namesearch,sortby,sortorder,-1)+"\">";\r
+       content+="Load Trust List of ";\r
+       content+=CreateLocalIdentityDropDown("localidentityid",localidentityid);\r
+       content+="<input type=\"submit\" value=\"Load List\">";\r
+       content+="</form>";\r
+       content+="</div>";\r
+\r
        content+="<form name=\"frmtrust\" method=\"POST\">";\r
+       content+=CreateFormPassword();\r
        content+="<input type=\"hidden\" name=\"formaction\" value=\"update\">";\r
+       content+="<input type=\"hidden\" name=\"localidentityid\" value=\""+localidentityidstr+"\">";\r
        content+="<input type=\"hidden\" name=\"startrow\" value=\""+startrowstr+"\">";\r
-       content+="<table>";\r
-       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
+       if(namesearch!="")\r
+       {\r
+               content+="<input type=\"hidden\" name=\"namesearch\" value=\""+SanitizeOutput(namesearch)+"\">";\r
+       }\r
+       content+="<table class=\"small90\">";\r
+       content+="<tr><th><a href=\""+m_pagename+"?"+BuildQueryString(startrow,namesearch,"Name",ReverseSort("Name",sortby,sortorder),localidentityid)+"\">Name</a></th>";\r
+       content+="<th><a href=\""+m_pagename+"?"+BuildQueryString(startrow,namesearch,"tblIdentityTrust.LocalMessageTrust",ReverseSort("tblIdentityTrust.LocalMessageTrust",sortby,sortorder),localidentityid)+"\">Local Message Trust</a></th>";\r
+       content+="<th>Message Comment</th>";\r
+       content+="<th><a href=\""+m_pagename+"?"+BuildQueryString(startrow,namesearch,"PeerMessageTrust",ReverseSort("PeerMessageTrust",sortby,sortorder),localidentityid)+"\">Peer Message Trust</a></th>";\r
+       content+="<th><a href=\""+m_pagename+"?"+BuildQueryString(startrow,namesearch,"tblIdentityTrust.LocalTrustListTrust",ReverseSort("tblIdentityTrust.LocalTrustListTrust",sortby,sortorder),localidentityid)+"\">Local Trust List Trust</a></th>";\r
+       content+="<th>Trust Comment</th>";\r
+       content+="<th><a href=\""+m_pagename+"?"+BuildQueryString(startrow,namesearch,"PeerTrustListTrust",ReverseSort("PeerTrustListTrust",sortby,sortorder),localidentityid)+"\">Peer Trust List Trust</a></th>";\r
+       content+="<th><a href=\""+m_pagename+"?"+BuildQueryString(startrow,namesearch,"MessageCount",ReverseSort("MessageCount",sortby,sortorder),localidentityid)+"\">Message Count</a></th>";\r
+       content+="</tr>\r\n";\r
        \r
        // get count of identities we are showing\r
-       sql="SELECT COUNT(*) FROM tblIdentity";\r
+       sql="SELECT COUNT(*) FROM tblIdentity LEFT JOIN tblIdentityTrust ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID ";\r
+       sql+="WHERE tblIdentityTrust.LocalIdentityID=? AND tblIdentity.Hidden='false'";\r
        if(namesearch!="")\r
        {\r
-               sql+=" WHERE Name LIKE '%' || ? || '%'";\r
+               sql+=" AND (Name LIKE '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%')";\r
        }\r
        sql+=";";\r
        SQLite3DB::Statement st=m_db->Prepare(sql);\r
+       st.Bind(0,localidentityid);\r
        if(namesearch!="")\r
        {\r
-               st.Bind(0,namesearch);\r
+               st.Bind(1,namesearch);\r
+               st.Bind(2,namesearch);\r
        }\r
        st.Step();\r
        st.ResultInt(0,identitycount);\r
        st.Finalize();\r
 \r
-       sql="SELECT IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey FROM tblIdentity";\r
+       sql="SELECT tblIdentity.IdentityID,Name,tblIdentityTrust.LocalMessageTrust,PeerMessageTrust,tblIdentityTrust.LocalTrustListTrust,PeerTrustListTrust,PublicKey,tblIdentityTrust.MessageTrustComment,tblIdentityTrust.TrustListTrustComment,COUNT(MessageID) AS 'MessageCount',tblIdentity.PublishTrustList ";\r
+       sql+="FROM tblIdentity LEFT JOIN tblIdentityTrust ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID ";\r
+       sql+="WHERE tblIdentityTrust.LocalIdentityID=? AND tblIdentity.Hidden='false'";\r
        if(namesearch!="")\r
        {\r
-               sql+=" WHERE Name LIKE  '%' || ? || '%'";\r
+               sql+=" AND (Name LIKE  '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%')";\r
+       }\r
+       sql+=" GROUP BY tblIdentity.IdentityID";\r
+       sql+=" ORDER BY";\r
+       if(sortby=="Name")\r
+       {\r
+               sql+=" Name COLLATE NOCASE";\r
+       }\r
+       else\r
+       {\r
+               sql+=" "+sortby;\r
        }\r
-       sql+=" ORDER BY Name COLLATE NOCASE LIMIT "+startrowstr+","+rowsperpagestr+";";\r
+       if(sortorder!="")\r
+       {\r
+               sql+=" "+sortorder;\r
+       }\r
+       sql+=" LIMIT "+startrowstr+","+rowsperpagestr+";";\r
        st=m_db->Prepare(sql);\r
+       st.Bind(0,localidentityid);\r
        if(namesearch!="")\r
        {\r
-               st.Bind(0,namesearch);\r
+               st.Bind(1,namesearch);\r
+               st.Bind(2,namesearch);\r
        }\r
        st.Step();\r
 \r
@@ -128,7 +362,10 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                std::string localtrustlisttrust;\r
                std::string peertrustlisttrust;\r
                std::string publickey;\r
-               std::string keypart="";\r
+               std::string messagetrustcomment="";\r
+               std::string trustlisttrustcomment="";\r
+               std::string messagecountstr="";\r
+               std::string publishtrustlist="";\r
 \r
                StringFunctions::Convert(count,countstr);\r
 \r
@@ -139,11 +376,10 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                st.ResultText(4,localtrustlisttrust);\r
                st.ResultText(5,peertrustlisttrust);\r
                st.ResultText(6,publickey);\r
-\r
-               if(publickey.size()>8)\r
-               {\r
-                       keypart=publickey.substr(3,5);\r
-               }\r
+               st.ResultText(7,messagetrustcomment);\r
+               st.ResultText(8,trustlisttrustcomment);\r
+               st.ResultText(9,messagecountstr);\r
+               st.ResultText(10,publishtrustlist);\r
 \r
                content+="<tr>";\r
                content+="<td title=\""+publickey+"\">";\r
@@ -151,7 +387,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                content+="<a href=\"peerdetails.htm?identityid="+identityid+"\">";\r
                if(name!="")\r
                {\r
-                       content+=SanitizeOutput(name+keypart)+"...";\r
+                       content+=SanitizeOutput(CreateShortIdentityName(name,publickey));\r
                }\r
                else\r
                {\r
@@ -161,15 +397,29 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                content+="</td>";\r
                content+="<td "+GetClassString(localmessagetrust)+">";\r
                content+="<input type=\"hidden\" name=\"oldlocalmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\">";\r
-               content+="<input type=\"text\" name=\"localmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\" size=\"2\" maxlength=\"3\"></td>";\r
+               content+="<input type=\"text\" name=\"localmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\" size=\"2\" maxlength=\"3\" class=\"small90\"></td>";\r
+               content+="<td "+GetClassString(localmessagetrust)+">";\r
+               content+="<input type=\"hidden\" name=\"oldmessagetrustcomment["+countstr+"]\" value=\""+SanitizeOutput(messagetrustcomment)+"\">";\r
+               content+="<input type=\"text\" name=\"messagetrustcomment["+countstr+"]\" value=\""+SanitizeOutput(messagetrustcomment)+"\" maxlength=\"50\" class=\"small90\">";\r
+               content+="</td>";               \r
                content+="<td "+GetClassString(peermessagetrust)+">";\r
                content+=peermessagetrust+"</td>";\r
                content+="<td "+GetClassString(localtrustlisttrust)+">";\r
                content+="<input type=\"hidden\" name=\"oldlocaltrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\">";\r
-               content+="<input type=\"text\" name=\"localtrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\" size=\"2\" maxlength=\"3\"></td>";\r
+               content+="<input type=\"text\" name=\"localtrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\" size=\"2\" maxlength=\"3\" class=\"small90\">";\r
+               if(publishtrustlist=="false")\r
+               {\r
+                       content+="*";\r
+               }\r
+               content+="</td>";\r
+               content+="<td "+GetClassString(localtrustlisttrust)+">";\r
+               content+="<input type=\"hidden\" name=\"oldtrustlisttrustcomment["+countstr+"]\" value=\""+SanitizeOutput(trustlisttrustcomment)+"\">";\r
+               content+="<input type=\"text\" name=\"trustlisttrustcomment["+countstr+"]\" value=\""+SanitizeOutput(trustlisttrustcomment)+"\" maxlength=\"50\" class=\"small90\">";\r
+               content+="</td>";\r
                content+="<td "+GetClassString(peertrustlisttrust)+">";\r
                content+=peertrustlisttrust+"</td>";\r
-               content+="</tr>";\r
+               content+="<td>"+messagecountstr+"</td>";\r
+               content+="</tr>\r\n";\r
                st.Step();\r
                count++;\r
        }\r
@@ -183,27 +433,26 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                if(startrow>0)\r
                {\r
                        StringFunctions::Convert(startrow-rowsperpage,tempstr);\r
-                       content+="<td colspan=\"2\" align=\"left\"><a href=\"peertrust.htm?startrow="+tempstr+"&namesearch="+namesearch+"\"><-- Previous Page</a></td>";\r
-                       cols+=2;\r
+                       content+="<td colspan=\"3\" align=\"left\"><a href=\""+m_pagename+"?"+BuildQueryString(startrow-rowsperpage,namesearch,sortby,sortorder,localidentityid)+"\"><-- Previous Page</a></td>";\r
+                       cols+=3;\r
                }\r
                if(startrow+rowsperpage<identitycount)\r
                {\r
-                       StringFunctions::Convert(startrow+rowsperpage,tempstr);\r
-                       while(cols<3)\r
+                       while(cols<5)\r
                        {\r
                                content+="<td></td>";\r
                                cols++;\r
                        }\r
-                       content+="<td colspan=\"2\" align=\"right\"><a href=\"peertrust.htm?startrow="+tempstr+"&namesearch="+namesearch+"\">Next Page --></a></td>";\r
+                       content+="<td colspan=\"3\" align=\"right\"><a href=\""+m_pagename+"?"+BuildQueryString(startrow+rowsperpage,namesearch,sortby,sortorder,localidentityid)+"\">Next Page --></a></td>";\r
                }\r
                content+="</tr>";\r
        }\r
 \r
-       content+="<tr><td colspan=\"5\"><input type=\"submit\" value=\"Update Trust\"></td></tr>";\r
+       content+="<tr><td colspan=\"8\"><center><input type=\"submit\" value=\"Update Trust\"></center></td></tr>";\r
        content+="</table>";\r
        content+="</form>";\r
 \r
-       return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+       return StringFunctions::Replace(m_template,"[CONTENT]",content);\r
 }\r
 \r
 const std::string PeerTrustPage::GetClassString(const std::string &trustlevel)\r
@@ -225,14 +474,21 @@ const std::string PeerTrustPage::GetClassString(const std::string &trustlevel)
        }\r
 }\r
 \r
-const bool PeerTrustPage::WillHandleURI(const std::string &uri)\r
+const std::string PeerTrustPage::ReverseSort(const std::string &sortname, const std::string &currentsortby, const std::string &currentsortorder)\r
 {\r
-       if(uri.find("peertrust.")!=std::string::npos)\r
+       if(sortname==currentsortby)\r
        {\r
-               return true;\r
+               if(currentsortorder=="ASC")\r
+               {\r
+                       return "DESC";\r
+               }\r
+               else\r
+               {\r
+                       return "ASC";\r
+               }\r
        }\r
        else\r
        {\r
-               return false;\r
+               return currentsortorder;\r
        }\r
 }\r