X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fpeertrustpage.cpp;h=b90a1060c0c6fb754b9e62e9d0b3642a4f510447;hp=21b07305491472bda5e1dacb28435d2770c90587;hb=HEAD;hpb=b4f4686250878cdf4fcb2986a2ea6546cba867d1 diff --git a/src/http/pages/peertrustpage.cpp b/src/http/pages/peertrustpage.cpp index 21b0730..b90a106 100644 --- a/src/http/pages/peertrustpage.cpp +++ b/src/http/pages/peertrustpage.cpp @@ -23,7 +23,7 @@ const std::string PeerTrustPage::BuildQueryString(const long startrow, const std { returnval+="&"; } - returnval+="namesearch="+namesearch; + returnval+="namesearch="+StringFunctions::UriEncode(namesearch); } if(sortby!="") @@ -119,19 +119,36 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s { localidentityidstr=(*queryvars.find("localidentityid")).second; StringFunctions::Convert(localidentityidstr,localidentityid); + // insert the ID into the temporary table so we remember the identity if we load the page later + m_db->Execute("DELETE FROM tmpLocalIdentityPeerTrustPage;"); + SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tmpLocalIdentityPeerTrustPage(LocalIdentityID) VALUES(?);"); + st.Bind(0,localidentityid); + st.Step(); } else { - SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID FROM tblLocalIdentity;"); + // try to get the localidentityid if it exists in the temp table, otherwise load the first identity in the database + SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID FROM tmpLocalIdentityPeerTrustPage;"); st.Step(); if(st.RowReturned()) { st.ResultInt(0,localidentityid); StringFunctions::Convert(localidentityid,localidentityidstr); } + else + { + st=m_db->Prepare("SELECT LocalIdentityID FROM tblLocalIdentity;"); + st.Step(); + if(st.RowReturned()) + { + st.ResultInt(0,localidentityid); + StringFunctions::Convert(localidentityid,localidentityidstr); + } + st.Finalize(); + } } - if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="update") + if(localidentityid!=-1 && queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="update" && ValidateFormPassword(queryvars)) { std::vector identityids; std::vector oldlmt; @@ -216,6 +233,10 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s if(queryvars.find("sortby")!=queryvars.end()) { sortby=(*queryvars.find("sortby")).second; + if(sortby!="Name" && sortby!="tblIdentityTrust.LocalMessageTrust" && sortby!="PeerMessageTrust" && sortby!="tblIdentityTrust.LocalTrustListTrust" && sortby!="PeerTrustListTrust" && sortby!="MessageCount") + { + sortby="Name"; + } } else { @@ -226,6 +247,10 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s if(queryvars.find("sortorder")!=queryvars.end()) { sortorder=(*queryvars.find("sortorder")).second; + if(sortorder!="ASC" && sortorder!="DESC") + { + sortorder="ASC"; + } } else { @@ -239,18 +264,19 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s } content+="

Peer Trust

"; - 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."; - + 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.
"; + content+="* - This identity is not publishing a trust list
"; + // search drop down content+="
"; - content+="
"; + content+=""; content+=""; content+=""; content+="
"; content+="
"; content+="
"; - content+="
"; + content+=""; content+="Load Trust List of "; content+=CreateLocalIdentityDropDown("localidentityid",localidentityid); content+=""; @@ -258,6 +284,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s content+="
"; content+=""; + content+=CreateFormPassword(); content+=""; content+=""; content+=""; @@ -266,20 +293,19 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s content+=""; } content+=""; - content+=""; - content+=""; + content+=""; + content+=""; content+=""; - content+=""; - content+=""; + content+=""; + content+=""; content+=""; - content+=""; - content+=""; + content+=""; + content+=""; content+="\r\n"; -//TODO - modify this query // get count of identities we are showing - sql="SELECT COUNT(*) FROM tblIdentity LEFT JOIN (SELECT IdentityID FROM tblIdentityTrust WHERE LocalIdentityID=?) AS 'tblIdentityTrust' ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID "; - sql+="WHERE tblIdentity.Hidden='false'"; + sql="SELECT COUNT(*) FROM tblIdentity LEFT JOIN tblIdentityTrust ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID "; + sql+="WHERE tblIdentityTrust.LocalIdentityID=? AND tblIdentity.Hidden='false'"; if(namesearch!="") { sql+=" AND (Name LIKE '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%')"; @@ -296,9 +322,9 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s st.ResultInt(0,identitycount); st.Finalize(); - sql="SELECT tblIdentity.IdentityID,Name,tblIdentityTrust.LocalMessageTrust,PeerMessageTrust,tblIdentityTrust.LocalTrustListTrust,PeerTrustListTrust,PublicKey,tblIdentityTrust.MessageTrustComment,tblIdentityTrust.TrustListTrustComment,COUNT(MessageID) AS 'MessageCount' "; - sql+="FROM tblIdentity LEFT JOIN (SELECT LocalIdentityID,IdentityID,LocalMessageTrust,LocalTrustListTrust,MessageTrustComment,TrustListTrustComment FROM tblIdentityTrust WHERE LocalIdentityID=?) AS tblIdentityTrust ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID "; - sql+="WHERE tblIdentity.Hidden='false'"; + sql="SELECT tblIdentity.IdentityID,Name,tblIdentityTrust.LocalMessageTrust,PeerMessageTrust,tblIdentityTrust.LocalTrustListTrust,PeerTrustListTrust,PublicKey,tblIdentityTrust.MessageTrustComment,tblIdentityTrust.TrustListTrustComment,COUNT(MessageID) AS 'MessageCount',tblIdentity.PublishTrustList "; + sql+="FROM tblIdentity LEFT JOIN tblIdentityTrust ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID "; + sql+="WHERE tblIdentityTrust.LocalIdentityID=? AND tblIdentity.Hidden='false'"; if(namesearch!="") { sql+=" AND (Name LIKE '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%')"; @@ -339,6 +365,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s std::string messagetrustcomment=""; std::string trustlisttrustcomment=""; std::string messagecountstr=""; + std::string publishtrustlist=""; StringFunctions::Convert(count,countstr); @@ -352,6 +379,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s st.ResultText(7,messagetrustcomment); st.ResultText(8,trustlisttrustcomment); st.ResultText(9,messagecountstr); + st.ResultText(10,publishtrustlist); content+=""; content+=""; content+=""; + content+=""; + if(publishtrustlist=="false") + { + content+="*"; + } + content+=""; content+=""; + content+=""; cols+=3; } if(startrow+rowsperpageNext Page -->"; + content+=""; } content+=""; } - content+=""; + content+=""; content+="
NameLocal Message Trust
NameLocal Message TrustMessage CommentPeer Message TrustLocal Trust List TrustPeer Message TrustLocal Trust List TrustTrust CommentPeer Trust List TrustMessage CountPeer Trust List TrustMessage Count
"; @@ -378,7 +406,12 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s content+=peermessagetrust+""; content+=""; - content+=""; content+=""; content+=""; @@ -400,7 +433,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s if(startrow>0) { StringFunctions::Convert(startrow-rowsperpage,tempstr); - content+="<-- Previous Page<-- Previous PageNext Page -->
"; content+=""; - return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content); + return StringFunctions::Replace(m_template,"[CONTENT]",content); } const std::string PeerTrustPage::GetClassString(const std::string &trustlevel) @@ -459,15 +492,3 @@ const std::string PeerTrustPage::ReverseSort(const std::string &sortname, const return currentsortorder; } } - -const bool PeerTrustPage::WillHandleURI(const std::string &uri) -{ - if(uri.find("peertrust.")!=std::string::npos) - { - return true; - } - else - { - return false; - } -}