X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Flocalidentitiespage.cpp;h=84c28b322969641963c22283d215f3d8bef28cff;hp=e926b2f2418e6dd44aaace5ac8a226576ee53587;hb=f60495a029c54358f82956482fe203fe2b7b5b23;hpb=b9c3763a932cebaa015a27fe111017f6f34dfbaa diff --git a/src/http/pages/localidentitiespage.cpp b/src/http/pages/localidentitiespage.cpp index e926b2f..84c28b3 100644 --- a/src/http/pages/localidentitiespage.cpp +++ b/src/http/pages/localidentitiespage.cpp @@ -1,5 +1,6 @@ #include "../../../include/http/pages/localidentitiespage.h" #include "../../../include/stringfunctions.h" +#include "../../../include/http/identityexportxml.h" #ifdef XMEM #include @@ -33,7 +34,6 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c std::string countstr; std::string content=""; - if(queryvars.find("formaction")!=queryvars.end()) { int id; @@ -75,9 +75,111 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c } } } + if((*queryvars.find("formaction")).second=="export") + { + IdentityExportXML xml; + SQLite3DB::Statement exp=m_db->Prepare("SELECT Name,PublicKey,PrivateKey,SingleUse,PublishTrustList,PublishBoardList FROM tblLocalIdentity WHERE PublicKey IS NOT NULL AND PrivateKey IS NOT NULL;"); + exp.Step(); + while(exp.RowReturned()) + { + std::string name=""; + std::string publickey=""; + std::string privatekey=""; + std::string tempval=""; + bool singleuse=false; + bool publishtrustlist=false; + bool publishboardlist=false; + + exp.ResultText(0,name); + exp.ResultText(1,publickey); + exp.ResultText(2,privatekey); + exp.ResultText(3,tempval); + if(tempval=="true") + { + singleuse=true; + } + exp.ResultText(4,tempval); + if(tempval=="true") + { + publishtrustlist=true; + } + exp.ResultText(5,tempval); + if(tempval=="true") + { + publishboardlist=true; + } + + xml.AddIdentity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist); + + exp.Step(); + } + return "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nContent-Disposition: attachment; filename=identities.xml\r\n\r\n"+xml.GetXML(); + } + if((*queryvars.find("formaction")).second=="import") + { + if(queryvars.find("file")!=queryvars.end()) + { + IdentityExportXML xml; + if(xml.ParseXML((*queryvars.find("file")).second)) + { + SQLite3DB::Statement imp=m_db->Prepare("INSERT INTO tblLocalIdentity(Name,PublicKey,PrivateKey,SingleUse,PublishTrustList,PublishBoardList) VALUES(?,?,?,?,?,?);"); + for(int i=0; i"; + content+=""; + content+=""; + content+=""; + content+=""; + content+="
"; + content+=""; + content+=""; + content+=""; + content+="
"; + content+=""; + content+="
"; content+=""; content+="";
NameSingle UsePublish Trust ListAnnounced? *