From 18b45335ba24f3b6b6d4f4acfe8c5a5ae845ce00 Mon Sep 17 00:00:00 2001 From: SomeDude Date: Sun, 15 Jun 2008 13:14:00 +0200 Subject: [PATCH] version 0.2.22 --- CMakeLists.txt | 1 + include/global.h | 3 +- include/http/pages/confirmpage.h | 17 ++ include/http/pages/optionspage.h | 1 + src/global.cpp | 296 +++++++++++++++++++++++++++++---- src/http/httpthread.cpp | 2 + src/http/ipagehandler.cpp | 2 +- src/http/pages/confirmpage.cpp | 49 ++++++ src/http/pages/localidentitiespage.cpp | 2 +- src/http/pages/optionspage.cpp | 55 +++++- src/http/pages/peermaintenancepage.cpp | 2 +- src/http/pages/peertrustpage.cpp | 19 ++- 12 files changed, 413 insertions(+), 36 deletions(-) create mode 100644 include/http/pages/confirmpage.h create mode 100644 src/http/pages/confirmpage.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dad91d6..cfb7d40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,7 @@ src/http/ipagehandler.cpp src/http/pages/addpeerpage.cpp src/http/pages/announceidentitypage.cpp src/http/pages/boardspage.cpp +src/http/pages/confirmpage.cpp src/http/pages/controlboardpage.cpp src/http/pages/createidentitypage.cpp src/http/pages/execquerypage.cpp diff --git a/include/global.h b/include/global.h index 047c917..529ef3b 100644 --- a/include/global.h +++ b/include/global.h @@ -5,7 +5,7 @@ #include #include "pthreadwrapper/thread.h" -#define FMS_VERSION "0.2.21" +#define FMS_VERSION "0.2.22" // opens database and creates tables and initial inserts if necessary void SetupDB(); @@ -19,6 +19,7 @@ void ConvertDB0107To0108(); void ConvertDB0108To0109(); void ConvertDB0109To0110(); void ConvertDB0110To0111(); +void ConvertDB0111To0112(); // inserts default options into the database void SetupDefaultOptions(); // opens logfile and sets it up diff --git a/include/http/pages/confirmpage.h b/include/http/pages/confirmpage.h new file mode 100644 index 0000000..10ee226 --- /dev/null +++ b/include/http/pages/confirmpage.h @@ -0,0 +1,17 @@ +#ifndef _confirmpage_ +#define _confirmpage_ + +#include "../ipagehandler.h" + +class ConfirmPage:public IPageHandler +{ +public: + ConfirmPage(const std::string &templatestr):IPageHandler(templatestr) {} + +private: + const bool WillHandleURI(const std::string &uri); + const std::string GeneratePage(const std::string &method, const std::map &queryvars); + +}; + +#endif // _confirmpage_ diff --git a/include/http/pages/optionspage.h b/include/http/pages/optionspage.h index 6ca15db..414875d 100644 --- a/include/http/pages/optionspage.h +++ b/include/http/pages/optionspage.h @@ -12,6 +12,7 @@ public: private: const bool WillHandleURI(const std::string &uri); const std::string GeneratePage(const std::string &method, const std::map &queryvars); + const std::string CreateDropDown(const std::string &name, const std::vector &items, const std::string &selecteditem); }; #endif // _optionspage_ diff --git a/src/global.cpp b/src/global.cpp index cfd458c..872dfb7 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -126,18 +126,27 @@ void SetupDB() major=1; minor=11; } + if(major==1 && minor==11) + { + ConvertDB0111To0112(); + major=1; + minor=12; + } } else { - db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,11);"); + db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,12);"); } - db->Execute("UPDATE tblDBVersion SET Major=1, Minor=11;"); + db->Execute("UPDATE tblDBVersion SET Major=1, Minor=12;"); db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\ Option TEXT UNIQUE,\ OptionValue TEXT NOT NULL,\ - OptionDescription TEXT\ + OptionDescription TEXT,\ + Section TEXT,\ + SortOrder INTEGER,\ + ValidValues TEXT\ );"); db->Execute("CREATE TABLE IF NOT EXISTS tblLocalIdentity(\ @@ -210,7 +219,8 @@ void SetupDB() LocalTrustListTrust INTEGER CHECK(LocalTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\ PeerTrustListTrust INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\ AddedMethod TEXT,\ - Hidden BOOL CHECK(Hidden IN('true','false')) DEFAULT 'false'\ + Hidden BOOL CHECK(Hidden IN('true','false')) DEFAULT 'false',\ + PurgeDate DATETIME\ );"); db->Execute("CREATE TABLE IF NOT EXISTS tblIdentityRequests(\ @@ -395,6 +405,11 @@ void SetupDB() Date DATETIME\ );"); + // A temporary table that will hold a local identity id of the last identity who was loaded in the trust list page + db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpLocalIdentityPeerTrustPage(\ + LocalIdentityID INTEGER\ + );"); + // low / high / message count for each board db->Execute("CREATE VIEW IF NOT EXISTS vwBoardStats AS \ SELECT tblBoard.BoardID AS 'BoardID', IFNULL(MIN(MessageID),0) AS 'LowMessageID', IFNULL(MAX(MessageID),0) AS 'HighMessageID', COUNT(MessageID) AS 'MessageCount' \ @@ -739,6 +754,23 @@ void ConvertDB0110To0111() db->Execute("UPDATE tblDBVersion SET Major=1, Minor=11;"); } +void ConvertDB0111To0112() +{ + /* + Add Section, SortOrder, ValidValues to tblOption + Add PurgeDate to tblIdentity + */ + SQLite3DB::DB *db=SQLite3DB::DB::Instance(); + + db->Execute("ALTER TABLE tblOption ADD COLUMN Section TEXT;"); + db->Execute("ALTER TABLE tblOption ADD COLUMN SortOrder INTEGER;"); + db->Execute("ALTER TABLE tblOption ADD COLUMN ValidValues TEXT;"); + + db->Execute("ALTER TABLE tblIdentity ADD COLUMN PurgeDate DATETIME;"); + + db->Execute("UPDATE tblDBVersion SET Major=1, Minor=12;"); +} + void SetupDefaultOptions() { // OptionValue should always be inserted as a string, even if the option really isn't a string - just to keep the field data type consistent @@ -746,6 +778,8 @@ void SetupDefaultOptions() std::ostringstream tempstr; // must set tempstr to "" between db inserts SQLite3DB::DB *db=SQLite3DB::DB::Instance(); SQLite3DB::Statement st=db->Prepare("INSERT INTO tblOption(Option,OptionValue,OptionDescription) VALUES(?,?,?);"); + SQLite3DB::Statement upd=db->Prepare("UPDATE tblOption SET Section=?, SortOrder=?, ValidValues=? WHERE Option=?;"); + int order=0; // LogLevel tempstr.str(""); @@ -755,6 +789,49 @@ void SetupDefaultOptions() st.Bind(2,"The maximum logging level that will be written to file. 0=Fatal Errors, 1=Errors, 2=Warnings, 3=Informational Messages, 4=Debug Messages. Higher levels will include all messages from the previous levels."); st.Step(); st.Reset(); + upd.Bind(0,"Program"); + upd.Bind(1,order++); + upd.Bind(2,"0|0 - Fatal Errors|1|1 - Errors|2|2 - Warnings|3|3 - Informational Messages|4|4 - Debug Messages"); + upd.Bind(3,"LogLevel"); + upd.Step(); + upd.Reset(); + + st.Bind(0,"VacuumOnStartup"); + st.Bind(1,"false"); + st.Bind(2,"VACUUM the database every time FMS starts. This will defragment the free space in the database and create a smaller database file. Vacuuming the database can be CPU and disk intensive."); + st.Step(); + st.Reset(); + upd.Bind(0,"Program"); + upd.Bind(1,order++); + upd.Bind(2,"true|true|false|false"); + upd.Bind(3,"VacuumOnStartup"); + upd.Step(); + upd.Reset(); + + st.Bind(0,"MessageBase"); + st.Bind(1,"fms"); + st.Bind(2,"A unique string shared by all clients who want to communicate with each other. This should not be changed unless you want to create your own separate communications network."); + st.Step(); + st.Reset(); + upd.Bind(0,"Program"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MessageBase"); + upd.Step(); + upd.Reset(); + + // StartNNTP + st.Bind(0,"StartNNTP"); + st.Bind(1,"true"); + st.Bind(2,"Start NNTP server."); + st.Step(); + st.Reset(); + upd.Bind(0,"NNTP Server"); + upd.Bind(1,order++); + upd.Bind(2,"true|true|false|false"); + upd.Bind(3,"StartNNTP"); + upd.Step(); + upd.Reset(); // NNTPListenPort st.Bind(0,"NNTPListenPort"); @@ -762,6 +839,12 @@ void SetupDefaultOptions() st.Bind(2,"The port that the NNTP service will listen for incoming connections."); st.Step(); st.Reset(); + upd.Bind(0,"NNTP Server"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"NNTPListenPort"); + upd.Step(); + upd.Reset(); // NNTPBindAddresses st.Bind(0,"NNTPBindAddresses"); @@ -769,37 +852,60 @@ void SetupDefaultOptions() st.Bind(2,"A comma separated list of valid IPv4 or IPv6 addresses/hostnames that the NNTP service will try to bind to."); st.Step(); st.Reset(); + upd.Bind(0,"NNTP Server"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"NNTPBindAddresses"); + upd.Step(); + upd.Reset(); st.Bind(0,"NNTPAllowPost"); st.Bind(1,"true"); st.Bind(2,"Allow posting messages from NNTP. Setting to false will make the newsgroups read only."); st.Step(); st.Reset(); - - // StartNNTP - st.Bind(0,"StartNNTP"); - st.Bind(1,"true"); - st.Bind(2,"Start NNTP server."); - st.Step(); - st.Reset(); + upd.Bind(0,"NNTP Server"); + upd.Bind(1,order++); + upd.Bind(2,"true|true|false|false"); + upd.Bind(3,"NNTPAllowPost"); + upd.Step(); + upd.Reset(); st.Bind(0,"StartHTTP"); st.Bind(1,"true"); st.Bind(2,"Start HTTP server. WARNING: If you turn this off, you won't be able to access the administration pages."); st.Step(); st.Reset(); + upd.Bind(0,"HTTP Server"); + upd.Bind(1,order++); + upd.Bind(2,"true|true|false|false"); + upd.Bind(3,"StartHTTP"); + upd.Step(); + upd.Reset(); st.Bind(0,"HTTPListenPort"); st.Bind(1,"8080"); st.Bind(2,"Port HTTP server will listen on."); st.Step(); st.Reset(); + upd.Bind(0,"HTTP Server"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"HTTPListenPort"); + upd.Step(); + upd.Reset(); st.Bind(0,"HTTPAccessControl"); st.Bind(1,"-0.0.0.0/0,+127.0.0.1"); st.Bind(2,"Comma separated list of addresses and/or subnet masks that are allowed access to the administration pages. Default is localhost only. + allows a host, - denies a host."); st.Step(); st.Reset(); + upd.Bind(0,"HTTP Server"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"HTTPAccessControl"); + upd.Step(); + upd.Reset(); // StartFreenetUpdater st.Bind(0,"StartFreenetUpdater"); @@ -807,6 +913,12 @@ void SetupDefaultOptions() st.Bind(2,"Set to true to start the Freenet Updater thread and connect to Freenet. Set to false to prevent communication with Freenet."); st.Step(); st.Reset(); + upd.Bind(0,"Freenet Connection"); + upd.Bind(1,order++); + upd.Bind(2,"true|true|false|false"); + upd.Bind(3,"StartFreenetUpdater"); + upd.Step(); + upd.Reset(); // FCPHost st.Bind(0,"FCPHost"); @@ -814,6 +926,12 @@ void SetupDefaultOptions() st.Bind(2,"Host name or address of Freenet node."); st.Step(); st.Reset(); + upd.Bind(0,"Freenet Connection"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"FCPHost"); + upd.Step(); + upd.Reset(); // FCPPort st.Bind(0,"FCPPort"); @@ -821,144 +939,264 @@ void SetupDefaultOptions() st.Bind(2,"The port that Freenet is listening for FCP connections on."); st.Step(); st.Reset(); + upd.Bind(0,"Freenet Connection"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"FCPPort"); + upd.Step(); + upd.Reset(); st.Bind(0,"FProxyPort"); st.Bind(1,"8888"); st.Bind(2,"The port that Freenet is listening for http connections on."); st.Step(); st.Reset(); - - st.Bind(0,"MessageBase"); - st.Bind(1,"fms"); - st.Bind(2,"A unique string shared by all clients who want to communicate with each other. This should not be changed unless you want to create your own separate communications network."); - st.Step(); - st.Reset(); + upd.Bind(0,"Freenet Connection"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"FProxyPort"); + upd.Step(); + upd.Reset(); st.Bind(0,"MaxIdentityRequests"); st.Bind(1,"5"); st.Bind(2,"Maximum number of concurrent requests for new Identity xml files"); st.Step(); st.Reset(); + upd.Bind(0,"Requests"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MaxIdentityRequests"); + upd.Step(); + upd.Reset(); st.Bind(0,"MaxIdentityIntroductionRequests"); st.Bind(1,"5"); st.Bind(2,"Maximum number of concurrent identities requesting IdentityIntroduction xml files. Each identity may have multiple requests pending."); st.Step(); st.Reset(); + upd.Bind(0,"Requests"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MaxIdentityIntroductionRequests"); + upd.Step(); + upd.Reset(); st.Bind(0,"MaxIntroductionPuzzleRequests"); st.Bind(1,"5"); st.Bind(2,"Maximum number of concurrent requests for new IntroductionPuzzle xml files"); st.Step(); st.Reset(); + upd.Bind(0,"Requests"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MaxIntroductionPuzzleRequests"); + upd.Step(); + upd.Reset(); st.Bind(0,"MaxTrustListRequests"); st.Bind(1,"5"); st.Bind(2,"Maximum number of concurrent requests for new Trust Lists"); st.Step(); st.Reset(); + upd.Bind(0,"Requests"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MaxTrustListRequests"); + upd.Step(); + upd.Reset(); st.Bind(0,"MaxMessageListRequests"); st.Bind(1,"5"); st.Bind(2,"Maximum number of concurrent requests for new Message Lists"); st.Step(); st.Reset(); + upd.Bind(0,"Requests"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MaxMessageListRequests"); + upd.Step(); + upd.Reset(); st.Bind(0,"MaxMessageRequests"); st.Bind(1,"20"); st.Bind(2,"Maximum number of concurrent requests for new Messages"); st.Step(); st.Reset(); + upd.Bind(0,"Requests"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MaxMessageRequests"); + upd.Step(); + upd.Reset(); + + st.Bind(0,"MaxBoardListRequests"); + st.Bind(1,"5"); + st.Bind(2,"The maximum number of concurrent requests for new Board Lists. Set to 0 to disable."); + st.Step(); + st.Reset(); + upd.Bind(0,"Requests"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MaxBoardListRequests"); + upd.Step(); + upd.Reset(); st.Bind(0,"MinLocalMessageTrust"); st.Bind(1,"50"); st.Bind(2,"Specifies a local message trust level that a peer must have before its messages will be downloaded."); st.Step(); st.Reset(); + upd.Bind(0,"Trust"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MinLocalMessageTrust"); + upd.Step(); + upd.Reset(); st.Bind(0,"MinPeerMessageTrust"); st.Bind(1,"30"); st.Bind(2,"Specifies a peer message trust level that a peer must have before its messages will be downloaded."); st.Step(); st.Reset(); + upd.Bind(0,"Trust"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MinPeerMessageTrust"); + upd.Step(); + upd.Reset(); st.Bind(0,"MinLocalTrustListTrust"); st.Bind(1,"50"); st.Bind(2,"Specifies a local trust list trust level that a peer must have before its trust list will be included in the weighted average. Any peers below this number will be excluded from the results."); st.Step(); st.Reset(); + upd.Bind(0,"Trust"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MinLocalTrustListTrust"); + upd.Step(); + upd.Reset(); st.Bind(0,"MinPeerTrustListTrust"); st.Bind(1,"30"); st.Bind(2,"Specifies a peer trust list trust level that a peer must have before its trust list will be included in the weighted average. Any peers below this number will be excluded from the results."); st.Step(); st.Reset(); + upd.Bind(0,"Trust"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MinPeerTrustListTrust"); + upd.Step(); + upd.Reset(); st.Bind(0,"LocalTrustOverridesPeerTrust"); st.Bind(1,"false"); st.Bind(2,"Set to true if you want your local trust levels to override the peer levels when determining which identities you will poll."); st.Step(); st.Reset(); + upd.Bind(0,"Trust"); + upd.Bind(1,order++); + upd.Bind(2,"true|true|false|false"); + upd.Bind(3,"LocalTrustOverridesPeerTrust"); + upd.Step(); + upd.Reset(); st.Bind(0,"MessageDownloadMaxDaysBackward"); st.Bind(1,"5"); st.Bind(2,"The maximum number of days backward that messages will be downloaded from each identity"); st.Step(); st.Reset(); + upd.Bind(0,"Messages"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MessageDownloadMaxDaysBackward"); + upd.Step(); + upd.Reset(); st.Bind(0,"MessageListDaysBackward"); st.Bind(1,"5"); st.Bind(2,"The number of days backward that messages you have inserted will appear in your MessageLists"); st.Step(); st.Reset(); + upd.Bind(0,"Messages"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MessageListDaysBackward"); + upd.Step(); + upd.Reset(); st.Bind(0,"MaxPeerMessagesPerDay"); st.Bind(1,"200"); st.Bind(2,"The maximum number of messages you will download from each peer on a given day."); st.Step(); st.Reset(); - - st.Bind(0,"MaxBoardListRequests"); - st.Bind(1,"5"); - st.Bind(2,"The maximum number of concurrent requests for new Board Lists. Set to 0 to disable."); - st.Step(); - st.Reset(); + upd.Bind(0,"Messages"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MaxPeerMessagesPerDay"); + upd.Step(); + upd.Reset(); st.Bind(0,"MaxBoardsPerMessage"); st.Bind(1,"8"); st.Bind(2,"The maximum number of boards a received message may be sent to. Boards over this limit will be ignored."); st.Step(); st.Reset(); + upd.Bind(0,"Messages"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"MaxBoardsPerMessage"); + upd.Step(); + upd.Reset(); st.Bind(0,"SaveMessagesFromNewBoards"); st.Bind(1,"true"); st.Bind(2,"Set to true to automatically save messages posted to new boards. Set to false to ignore messages to new boards."); st.Step(); st.Reset(); + upd.Bind(0,"Messages"); + upd.Bind(1,order++); + upd.Bind(2,"true|true|false|false"); + upd.Bind(3,"SaveMessagesFromNewBoards"); + upd.Step(); + upd.Reset(); st.Bind(0,"ChangeMessageTrustOnReply"); st.Bind(1,"0"); st.Bind(2,"How much the local message trust level of an identity should change when you reply to one of their messages."); st.Step(); st.Reset(); + upd.Bind(0,"Messages"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"ChangeMessageTrustOnReply"); + upd.Step(); + upd.Reset(); st.Bind(0,"AddNewPostFromIdentities"); st.Bind(1,"false"); st.Bind(2,"Set to true to automatically create new identities when you send a message using a new name. If you set this to false, posting messages will fail until you manually create the identity."); st.Step(); st.Reset(); + upd.Bind(0,"Messages"); + upd.Bind(1,order++); + upd.Bind(2,"true|true|false|false"); + upd.Bind(3,"AddNewPostFromIdentities"); + upd.Step(); + upd.Reset(); st.Bind(0,"DeleteMessagesOlderThan"); st.Bind(1,"180"); st.Bind(2,"Automatically delete messages older than this many days."); st.Step(); st.Reset(); - - st.Bind(0,"VacuumOnStartup"); - st.Bind(1,"false"); - st.Bind(2,"VACUUM the database every time FMS starts. This will defragment the free space in the database and create a smaller database file. Vacuuming the database can be CPU and disk intensive."); - st.Step(); - st.Reset(); + upd.Bind(0,"Messages"); + upd.Bind(1,order++); + upd.Bind(2); + upd.Bind(3,"DeleteMessagesOlderThan"); + upd.Step(); + upd.Reset(); } diff --git a/src/http/httpthread.cpp b/src/http/httpthread.cpp index 4760f80..55f82b9 100644 --- a/src/http/httpthread.cpp +++ b/src/http/httpthread.cpp @@ -15,6 +15,7 @@ #include "../../include/http/pages/execquerypage.h" #include "../../include/http/pages/boardspage.h" #include "../../include/http/pages/insertedfilespage.h" +#include "../../include/http/pages/confirmpage.h" #include @@ -65,6 +66,7 @@ HTTPThread::HTTPThread() m_pagehandlers.push_back(new ExecQueryPage(templatestr)); m_pagehandlers.push_back(new BoardsPage(templatestr)); m_pagehandlers.push_back(new InsertedFilesPage(templatestr)); + m_pagehandlers.push_back(new ConfirmPage(templatestr)); // homepage must be last - catch all page handler m_pagehandlers.push_back(new HomePage(templatestr)); diff --git a/src/http/ipagehandler.cpp b/src/http/ipagehandler.cpp index 6edd8ac..4874365 100644 --- a/src/http/ipagehandler.cpp +++ b/src/http/ipagehandler.cpp @@ -103,7 +103,7 @@ const bool IPageHandler::Handle(shttpd_arg *arg) const char *lenstr=shttpd_get_header(arg,"Content-Length"); if(lenstr) { - long len; + long len=0; StringFunctions::Convert(std::string(lenstr),len); mystate->m_indata=new char[len+1]; mystate->m_indata[len]='\0'; diff --git a/src/http/pages/confirmpage.cpp b/src/http/pages/confirmpage.cpp new file mode 100644 index 0000000..4c64039 --- /dev/null +++ b/src/http/pages/confirmpage.cpp @@ -0,0 +1,49 @@ +#include "../../../include/http/pages/confirmpage.h" +#include "../../../include/stringfunctions.h" + +const std::string ConfirmPage::GeneratePage(const std::string &method, const std::map &queryvars) +{ + std::string content=""; + std::string target=""; + std::string confirmdescription=""; + + if(queryvars.find("targetpage")!=queryvars.end()) + { + target=(*queryvars.find("targetpage")).second; + } + if(queryvars.find("confirmdescription")!=queryvars.end()) + { + confirmdescription=(*queryvars.find("confirmdescription")).second; + } + + content+="

Confirm

"; + content+=confirmdescription+"
"; + content+="
"; + for(std::map::const_iterator i=queryvars.begin(); i!=queryvars.end(); i++) + { + if((*i).first!="targetpage" && (*i).first!="confirmdescription") + { + content+=""; + } + } + content+=""; + content+=""; + content+="
"; + content+=""; + content+="
"; + + return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content); +} + + +const bool ConfirmPage::WillHandleURI(const std::string &uri) +{ + if(uri.find("confirm.")!=std::string::npos) + { + return true; + } + else + { + return false; + } +} diff --git a/src/http/pages/localidentitiespage.cpp b/src/http/pages/localidentitiespage.cpp index f3a4967..9aca3f3 100644 --- a/src/http/pages/localidentitiespage.cpp +++ b/src/http/pages/localidentitiespage.cpp @@ -261,7 +261,7 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c */ content+=""; - content+="
"; + content+="
"; content+=""; content+=""+publickey+""; st.Step(); diff --git a/src/http/pages/optionspage.cpp b/src/http/pages/optionspage.cpp index 7743738..ff58489 100644 --- a/src/http/pages/optionspage.cpp +++ b/src/http/pages/optionspage.cpp @@ -5,6 +5,35 @@ #include #endif +const std::string OptionsPage::CreateDropDown(const std::string &name, const std::vector &items, const std::string &selecteditem) +{ + std::string rval=""; + + rval+=""+option+""; content+=""; - if(value!="true" && value!="false") + if(validvaluevec.size()>0) + { + content+=CreateDropDown("value["+countstr+"]",validvaluevec,value); + } + else if(value!="true" && value!="false") { content+=""; } diff --git a/src/http/pages/peermaintenancepage.cpp b/src/http/pages/peermaintenancepage.cpp index 33d1357..5daaa01 100644 --- a/src/http/pages/peermaintenancepage.cpp +++ b/src/http/pages/peermaintenancepage.cpp @@ -72,7 +72,7 @@ const std::string PeerMaintenancePage::GeneratePage(const std::string &method, c date.SetToGMTime(); date.Add(0,0,0,-20); st=m_db->Prepare("DELETE FROM tblIdentity WHERE IdentityID IN (SELECT tblIdentity.IdentityID FROM tblIdentity LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID WHERE tblMessage.IdentityID IS NULL AND tblIdentity.DateAddedExecute("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") -- 2.7.4