version 0.3.33
[fms.git] / src / http / pages / localidentitiespage.cpp
index 5fa76b5..7910789 100644 (file)
@@ -18,11 +18,13 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
        content+="<table><tr><th>Export Identities</th><th>Import Identities</th></tr>";\r
        content+="<tr><td>";\r
        content+="<form name=\"frmexport\" method=\"POST\">";\r
+       content+=CreateFormPassword();\r
        content+="<input type=\"hidden\" name=\"formaction\" value=\"export\">";\r
        content+="<input type=\"submit\" value=\"Export Identities\">";\r
        content+="</form>";\r
        content+="</td><td>";\r
        content+="<form name=\"frmimport\" method=\"POST\" enctype=\"multipart/form-data\">";\r
+       content+=CreateFormPassword();\r
        content+="<input type=\"hidden\" name=\"formaction\" value=\"import\">";\r
        content+="<input type=\"file\" name=\"file\">";\r
        content+="<input type=\"submit\" value=\"Import Identities\">";\r
@@ -31,10 +33,11 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
 \r
        content+="<hr>";\r
 \r
-       content+="<table><tr><th>Name</th><th>Single Use</th><th>Publish Trust List</th><th>Publish Board List</th><th>Publish Freesite</th><th>Min Message Delay</th><th>Max Message Delay</th><th>Announced? *</th></tr>";\r
+       content+="<table class=\"small90\"><tr><th>Name</th><th>Single Use</th><th>Publish Trust List</th><th>Publish Board List</th><th>Publish Freesite</th><th>Min Message Delay</th><th>Max Message Delay</th><th>Announced? *</th></tr>";\r
 \r
        SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID,tblLocalIdentity.Name,tblLocalIdentity.PublicKey,tbLLocalIdentity.PublishTrustList,tblLocalIdentity.SingleUse,tblLocalIdentity.PublishBoardList,tblIdentity.IdentityID,tblLocalIdentity.PublishFreesite,tblLocalIdentity.MinMessageDelay,tblLocalIdentity.MaxMessageDelay FROM tblLocalIdentity LEFT JOIN tblIdentity ON tblLocalIdentity.PublicKey=tblIdentity.PublicKey ORDER BY tblLocalIdentity.Name;");\r
        st.Step();\r
+       SQLite3DB::Statement st2=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey=?;");\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
@@ -51,6 +54,7 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
                std::string publishfreesite="";\r
                std::string minmessagedelay="0";\r
                std::string maxmessagedelay="0";\r
+               std::string identityidstr="";\r
 \r
                st.ResultText(0,id);\r
                st.ResultText(1,name);\r
@@ -62,8 +66,26 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
                st.ResultText(8,minmessagedelay);\r
                st.ResultText(9,maxmessagedelay);\r
 \r
+               st2.Bind(0,publickey);\r
+               st2.Step();\r
+               if(st2.RowReturned())\r
+               {\r
+                       st2.ResultText(0,identityidstr);\r
+               }\r
+               st2.Reset();\r
+\r
                content+="<tr>";\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 title=\""+publickey+"\"><form name=\"frmupdate\""+countstr+"\" method=\"POST\"><input type=\"hidden\" name=\"formaction\" value=\"update\">"+CreateFormPassword()+"<input type=\"hidden\" name=\"chkidentityid["+countstr+"]\" value=\""+id+"\">";\r
+               if(identityidstr!="")\r
+               {\r
+                       content+="<a href=\"peerdetails.htm?identityid="+identityidstr+"\">";\r
+               }\r
+               content+=SanitizeOutput(CreateShortIdentityName(name,publickey));\r
+               if(identityidstr!="")\r
+               {\r
+                       content+="</a>";\r
+               }\r
+               content+="</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
@@ -86,7 +108,7 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
                trustst.Reset();\r
 \r
                content+="<td><input type=\"submit\" value=\"Update\"></form></td>";\r
-               content+="<td><form name=\"frmdel\""+countstr+"\" method=\"POST\" action=\"confirm.htm\"><input type=\"hidden\" name=\"formaction\" value=\"delete\"><input type=\"hidden\" name=\"chkidentityid["+countstr+"]\" value=\""+id+"\"><input type=\"hidden\" name=\"targetpage\" value=\"localidentities.htm\"><input type=\"hidden\" name=\"confirmdescription\" value=\"Are you sure you want to delete "+SanitizeOutput(CreateShortIdentityName(name,publickey))+"?\"><input type=\"submit\" value=\"Delete\"></form></td>";\r
+               content+="<td><form name=\"frmdel\""+countstr+"\" method=\"POST\" action=\"confirm.htm\">"+CreateFormPassword()+"<input type=\"hidden\" name=\"formaction\" value=\"delete\"><input type=\"hidden\" name=\"chkidentityid["+countstr+"]\" value=\""+id+"\"><input type=\"hidden\" name=\"targetpage\" value=\"localidentities.htm\"><input type=\"hidden\" name=\"confirmdescription\" value=\"Are you sure you want to delete "+SanitizeOutput(CreateShortIdentityName(name,publickey))+"?\"><input type=\"submit\" value=\"Delete\"></form></td>";\r
                content+="</tr>";\r
                content+="<tr><td></td><td colspan=\"7\" class=\"smaller\">"+publickey+"</td></tr>";\r
                st.Step();\r
@@ -94,7 +116,7 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c
        }\r
 \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.  The number in parenthesis is how many trust lists that identity appears in.</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.  You must trust other identities' trust lists for this to happen.  The number in parenthesis is how many trust lists the identity appears in.</p>";\r
        content+="<p class=\"paragraph\">Single Use Identities will automatically be deleted 7 days after creation.</p>";\r
        content+="<p class=\"paragraph\">Messages that each identity sends may be delayed by a random number of minutes between min and max.  Set both to 0 to send messages as soon as possible.</p>";\r
 \r
@@ -232,7 +254,7 @@ void LocalIdentitiesPage::handleRequest(Poco::Net::HTTPServerRequest &request, P
        CreateQueryVarMap(request,vars);\r
 \r
        std::string formaction="";\r
-       if(vars.find("formaction")!=vars.end())\r
+       if(vars.find("formaction")!=vars.end() && ValidateFormPassword(vars))\r
        {\r
                formaction=(*vars.find("formaction")).second;\r
                if(formaction=="update")\r