X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fpeertrustpage.cpp;h=92f804cdec64667fb9708bb10e602c794633d0b6;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hp=ac6b053adc7caecfb63e9f32385d54bac8f5cafa;hpb=6836fbb5db8464f56e682989996b2210b14231d0;p=fms.git diff --git a/src/http/pages/peertrustpage.cpp b/src/http/pages/peertrustpage.cpp index ac6b053..92f804c 100644 --- a/src/http/pages/peertrustpage.cpp +++ b/src/http/pages/peertrustpage.cpp @@ -119,16 +119,33 @@ 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(localidentityid!=-1 && queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="update") @@ -278,8 +295,8 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s content+="\r\n"; // 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 tblIdentity.Hidden='false' AND tblIdentityTrust.LocalIdentityID=?"; if(namesearch!="") { sql+=" AND (Name LIKE '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%')"; @@ -297,8 +314,8 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s st.Finalize(); 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 (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+="FROM tblIdentity LEFT JOIN tblIdentityTrust ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID "; + sql+="WHERE tblIdentity.Hidden='false' AND tblIdentityTrust.LocalIdentityID=?"; if(namesearch!="") { sql+=" AND (Name LIKE '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%')"; @@ -426,7 +443,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s content+=""; 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)