X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fpeertrustpage.cpp;h=21b07305491472bda5e1dacb28435d2770c90587;hp=9429ede25a745e135869ebd410467d2f790761ad;hb=b4f4686250878cdf4fcb2986a2ea6546cba867d1;hpb=107bd97018964d48425306026d06afd038e84db0 diff --git a/src/http/pages/peertrustpage.cpp b/src/http/pages/peertrustpage.cpp index 9429ede..21b0730 100644 --- a/src/http/pages/peertrustpage.cpp +++ b/src/http/pages/peertrustpage.cpp @@ -1,11 +1,12 @@ #include "../../../include/http/pages/peertrustpage.h" #include "../../../include/stringfunctions.h" +#include "../../../include/global.h" #ifdef XMEM #include #endif -const std::string PeerTrustPage::BuildQueryString(const long startrow, const std::string &namesearch, const std::string &sortby, const std::string &sortorder) +const std::string PeerTrustPage::BuildQueryString(const long startrow, const std::string &namesearch, const std::string &sortby, const std::string &sortorder, const int localidentityid) { std::string returnval=""; std::string tempval=""; @@ -43,10 +44,57 @@ const std::string PeerTrustPage::BuildQueryString(const long startrow, const std returnval+="sortorder="+sortorder; } + if(localidentityid>=0) + { + std::string localidentityidstr=""; + StringFunctions::Convert(localidentityid,localidentityidstr); + if(returnval!="") + { + returnval+="&"; + } + returnval+="localidentityid="+localidentityidstr; + } + return returnval; } +const std::string PeerTrustPage::CreateLocalIdentityDropDown(const std::string &name, const int selectedlocalidentityid) +{ + std::string result=""; + + result+=""; + + return result; +} + const std::string PeerTrustPage::GeneratePage(const std::string &method, const std::map &queryvars) { int count=0; @@ -61,9 +109,28 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s std::string sql; std::string sortby=""; std::string sortorder=""; + std::string localidentityidstr=""; + int localidentityid=-1; StringFunctions::Convert(rowsperpage,rowsperpagestr); + // get localidentityid from querystring or load one from the database + if(queryvars.find("localidentityid")!=queryvars.end()) + { + localidentityidstr=(*queryvars.find("localidentityid")).second; + StringFunctions::Convert(localidentityidstr,localidentityid); + } + else + { + SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID FROM tblLocalIdentity;"); + st.Step(); + if(st.RowReturned()) + { + st.ResultInt(0,localidentityid); + StringFunctions::Convert(localidentityid,localidentityidstr); + } + } + if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="update") { std::vector identityids; @@ -77,7 +144,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s std::vector tltc; int localmessagetrust=0; int localtrustlisttrust=0; - int identityid; + int identityid=-1; CreateArgArray(queryvars,"identityid",identityids); CreateArgArray(queryvars,"oldlocalmessagetrust",oldlmt); @@ -88,8 +155,9 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s CreateArgArray(queryvars,"messagetrustcomment",mtc); CreateArgArray(queryvars,"oldtrustlisttrustcomment",oldtltc); CreateArgArray(queryvars,"trustlisttrustcomment",tltc); - - SQLite3DB::Statement update=m_db->Prepare("UPDATE tblIdentity SET LocalMessageTrust=?, LocalTrustListTrust=?, MessageTrustComment=?, TrustListTrustComment=? WHERE IdentityID=?;"); + + SQLite3DB::Statement ins=m_db->Prepare("INSERT INTO tblIdentityTrust(LocalIdentityID,IdentityID) VALUES(?,?);"); + SQLite3DB::Statement update=m_db->Prepare("UPDATE tblIdentityTrust SET LocalMessageTrust=?, LocalTrustListTrust=?, MessageTrustComment=?, TrustListTrustComment=? WHERE LocalIdentityID=? AND IdentityID=?;"); for(int i=0; i"; - content+="
"; + 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."; + + // search drop down + content+="
"; + content+=""; content+=""; content+=""; content+=""; content+="
"; + + content+="
"; + content+="
"; + content+="Load Trust List of "; + content+=CreateLocalIdentityDropDown("localidentityid",localidentityid); + content+=""; + content+="
"; + content+="
"; + content+="
"; content+=""; + content+=""; content+=""; if(namesearch!="") { 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"; + 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'"; if(namesearch!="") { - sql+=" WHERE Name LIKE '%' || ? || '%' AND tblIdentity.Hidden='false'"; - } - else - { - sql+=" WHERE tblIdentity.Hidden='false'"; + sql+=" AND (Name LIKE '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%')"; } sql+=";"; SQLite3DB::Statement st=m_db->Prepare(sql); + st.Bind(0,localidentityid); if(namesearch!="") { - st.Bind(0,namesearch); + st.Bind(1,namesearch); + st.Bind(2,namesearch); } st.Step(); st.ResultInt(0,identitycount); st.Finalize(); - sql="SELECT tblIdentity.IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey,MessageTrustComment,TrustListTrustComment,COUNT(MessageID) AS 'MessageCount' FROM tblIdentity LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID"; + 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'"; if(namesearch!="") { - sql+=" WHERE (Name LIKE '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%') AND tblIdentity.Hidden='false'"; - } - else - { - sql+=" WHERE tblIdentity.Hidden='false'"; + sql+=" AND (Name LIKE '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%')"; } sql+=" GROUP BY tblIdentity.IdentityID"; sql+=" ORDER BY"; @@ -235,10 +319,11 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s } sql+=" LIMIT "+startrowstr+","+rowsperpagestr+";"; st=m_db->Prepare(sql); + st.Bind(0,localidentityid); if(namesearch!="") { - st.Bind(0,namesearch); st.Bind(1,namesearch); + st.Bind(2,namesearch); } st.Step(); @@ -251,7 +336,6 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s std::string localtrustlisttrust; std::string peertrustlisttrust; std::string publickey; - std::string keypart=""; std::string messagetrustcomment=""; std::string trustlisttrustcomment=""; std::string messagecountstr=""; @@ -269,18 +353,13 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s st.ResultText(8,trustlisttrustcomment); st.ResultText(9,messagecountstr); - if(publickey.size()>8) - { - keypart=publickey.substr(3,5); - } - content+=""; content+=""; + content+=""; cols+=3; } if(startrow+rowsperpageNext Page -->"; + 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
"; content+=""; content+=""; if(name!="") { - content+=SanitizeOutput(name+keypart)+"..."; + content+=SanitizeOutput(CreateShortIdentityName(name,publickey)); } else { @@ -321,7 +400,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 -->