version 0.2.14
[fms.git] / src / http / pages / localidentitiespage.cpp
index f84362e..3fd3c48 100644 (file)
@@ -1,33 +1,12 @@
 #include "../../../include/http/pages/localidentitiespage.h"\r
 #include "../../../include/stringfunctions.h"\r
 #include "../../../include/http/identityexportxml.h"\r
+#include "../../../include/global.h"\r
 \r
 #ifdef XMEM\r
        #include <xmem.h>\r
 #endif\r
 \r
-const std::string LocalIdentitiesPage::CreateTrueFalseDropDown(const std::string &name, const std::string &selected)\r
-{\r
-       std::string rval="";\r
-\r
-       rval+="<select name=\""+name+"\">";\r
-       rval+="<option value=\"true\"";\r
-       if(selected=="true")\r
-       {\r
-               rval+=" SELECTED";\r
-       }\r
-       rval+=">true</option>";\r
-       rval+="<option value=\"false\"";\r
-       if(selected=="false")\r
-       {\r
-               rval+=" SELECTED";\r
-       }\r
-       rval+=">false</option>";\r
-       rval+="</select>";\r
-\r
-       return rval;\r
-}\r
-\r
 const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
 {\r
        int count;\r
@@ -210,6 +189,8 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
        SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID,tblLocalIdentity.Name,tblLocalIdentity.PublicKey,tbLLocalIdentity.PublishTrustList,tblLocalIdentity.SingleUse,tblLocalIdentity.PublishBoardList,tblIdentity.IdentityID,tblLocalIdentity.PublishFreesite FROM tblLocalIdentity LEFT JOIN tblIdentity ON tblLocalIdentity.PublicKey=tblIdentity.PublicKey ORDER BY tblLocalIdentity.Name;");\r
        st.Step();\r
 \r
+       SQLite3DB::Statement trustst=m_db->Prepare("SELECT COUNT(*) FROM tblPeerTrust LEFT JOIN tblIdentity ON tblPeerTrust.TargetIdentityID=tblIdentity.IdentityID WHERE tblIdentity.PublicKey=? GROUP BY tblPeerTrust.TargetIdentityID;");\r
+\r
        count=0;\r
        while(st.RowReturned())\r
        {\r
@@ -219,7 +200,6 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
                std::string publickey="";\r
                std::string publishtrustlist="";\r
                std::string singleuse="";\r
-               std::string keypart="";\r
                std::string publishboardlist="";\r
                std::string publishfreesite="";\r
 \r
@@ -231,18 +211,29 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
                st.ResultText(5,publishboardlist);\r
                st.ResultText(7,publishfreesite);\r
 \r
-               if(publickey.size()>8)\r
-               {\r
-                       keypart=publickey.substr(3,5);\r
-               }\r
-\r
                content+="<tr>";\r
 //             content+="<td><input type=\"checkbox\" name=\"chkidentityid["+countstr+"]\" value=\""+id+"\"></td>";\r
-               content+="<td title=\""+publickey+"\"><form name=\"frmupdate\""+countstr+"\" method=\"POST\"><input type=\"hidden\" name=\"formaction\" value=\"update\"><input type=\"hidden\" name=\"chkidentityid["+countstr+"]\" value=\""+id+"\">"+SanitizeOutput(name+keypart)+"...</td>";\r
+               content+="<td title=\""+publickey+"\"><form name=\"frmupdate\""+countstr+"\" method=\"POST\"><input type=\"hidden\" name=\"formaction\" value=\"update\"><input type=\"hidden\" name=\"chkidentityid["+countstr+"]\" value=\""+id+"\">"+SanitizeOutput(CreateShortIdentityName(name,publickey))+"</td>";\r
                content+="<td>"+CreateTrueFalseDropDown("singleuse["+countstr+"]",singleuse)+"</td>";\r
                content+="<td>"+CreateTrueFalseDropDown("publishtrustlist["+countstr+"]",publishtrustlist)+"</td>";\r
                content+="<td>"+CreateTrueFalseDropDown("publishboardlist["+countstr+"]",publishboardlist)+"</td>";\r
                content+="<td>"+CreateTrueFalseDropDown("publishfreesite["+countstr+"]",publishfreesite)+"</td>";\r
+               \r
+               trustst.Bind(0,publickey);\r
+               trustst.Step();\r
+               if(trustst.RowReturned())\r
+               {\r
+                       std::string numlists="";\r
+                       trustst.ResultText(0,numlists);\r
+                       content+="<td>Yes ("+numlists+")</td>";\r
+               }\r
+               else\r
+               {\r
+                       content+="<td>No</td>";\r
+               }\r
+               trustst.Reset();\r
+\r
+/*\r
                if(st.ResultNull(6))\r
                {\r
                        content+="<td>No</td>";\r
@@ -251,6 +242,8 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
                {\r
                        content+="<td>Yes</td>";\r
                }\r
+*/\r
+\r
                content+="<td><input type=\"submit\" value=\"Update\"></form></td>";\r
                content+="<td><form name=\"frmdel\""+countstr+"\" method=\"POST\"><input type=\"hidden\" name=\"formaction\" value=\"delete\"><input type=\"hidden\" name=\"chkidentityid["+countstr+"]\" value=\""+id+"\"><input type=\"submit\" value=\"Delete\"></form></td>";\r
                content+="</tr>";\r
@@ -260,7 +253,7 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
 \r
 //     content+="<tr><td colspan=\"5\"><center><input type=\"submit\" value=\"Update Selected\"> <input type=\"submit\" value=\"Delete Selected\" onClick=\"if(confirm('Delete Selected Identities?')){frmlocalidentity.formaction.value='delete';}else{return false;}\"></td></tr>";\r
        content+="</table>";\r
-       content+="<p class=\"paragraph\">* An identity is considered successfully announced when you have downloaded a trust list from someone that contains the identity.</p>";\r
+       content+="<p class=\"paragraph\">* An identity is considered successfully announced when you have downloaded a trust list from someone that contains the identity.  The number in parenthesis is how many trust lists that identity appears in.</p>";\r
        content+="<p class=\"paragraph\">Single Use Identities will automatically be deleted 7 days after creation.</p>";\r
 \r
        return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r