From 107bd97018964d48425306026d06afd038e84db0 Mon Sep 17 00:00:00 2001 From: SomeDude Date: Mon, 31 Mar 2008 19:15:00 +0200 Subject: [PATCH] version 0.2.6 --- include/board.h | 20 ++++++++------- include/datetime.h | 15 +++++++----- include/freenet/boardlistrequester.h | 2 ++ include/freenet/messagerequester.h | 2 +- include/global.h | 3 ++- readme.txt | 14 +++++------ src/board.cpp | 12 ++++++--- src/boardlist.cpp | 6 +++-- src/datetime.cpp | 29 ++++++++++++++++++++++ src/freenet/boardlistrequester.cpp | 36 ++++++++++++++++++++++++++- src/freenet/boardlistxml.cpp | 8 ++++++ src/freenet/freenetmasterthread.cpp | 40 +++++++++++++++++------------- src/freenet/identityxml.cpp | 5 ++++ src/freenet/messagerequester.cpp | 9 ++++--- src/freenet/messagexml.cpp | 8 ++++++ src/freenet/periodicdbmaintenance.cpp | 6 +++++ src/global.cpp | 45 +++++++++++++++++++++++++--------- src/http/pages/boardspage.cpp | 16 +++++++----- src/http/pages/createidentitypage.cpp | 2 +- src/http/pages/localidentitiespage.cpp | 22 ++++++++++++++++- src/http/pages/peerdetailspage.cpp | 37 ++++++++++++++++++++++++++-- src/http/pages/peertrustpage.cpp | 15 +++++++++--- 22 files changed, 276 insertions(+), 76 deletions(-) diff --git a/include/board.h b/include/board.h index a5479d3..bdc5852 100644 --- a/include/board.h +++ b/include/board.h @@ -13,19 +13,20 @@ public: Board(); Board(const long boardid); Board(const std::string &boardname); - Board(const long boardid, const std::string &boardname, const std::string &boarddescription, const std::string datecreated, const long lowmessageid, const long highmessageid, const long messagecount, const bool savereceivedmessages); + Board(const long boardid, const std::string &boardname, const std::string &boarddescription, const std::string datecreated, const long lowmessageid, const long highmessageid, const long messagecount, const bool savereceivedmessages, const std::string &addedmethod); const bool Load(const long boardid); const bool Load(const std::string &boardname); - const long GetBoardID() const { return m_boardid; } - std::string GetBoardName() const { return m_boardname; } - std::string GetBoardDescription() const { return m_boarddescription; } - DateTime GetDateCreated() const { return m_datecreated; } - const long GetLowMessageID() const { return m_lowmessageid; } - const long GetHighMessageID() const { return m_highmessageid; } - const long GetMessageCount() const { return m_messagecount; } - const bool GetSaveReceivedMessages() const { return m_savereceivedmessages; } + const long GetBoardID() const { return m_boardid; } + std::string GetBoardName() const { return m_boardname; } + std::string GetBoardDescription() const { return m_boarddescription; } + DateTime GetDateCreated() const { return m_datecreated; } + const long GetLowMessageID() const { return m_lowmessageid; } + const long GetHighMessageID() const { return m_highmessageid; } + const long GetMessageCount() const { return m_messagecount; } + const bool GetSaveReceivedMessages() const { return m_savereceivedmessages; } + std::string GetAddedMethod() const { return m_addedmethod; } private: void SetDateFromString(const std::string &datestring); @@ -38,6 +39,7 @@ private: long m_highmessageid; // highest id of all message currently in this board long m_messagecount; // number of messages in this board bool m_savereceivedmessages; + std::string m_addedmethod; }; #endif // _board_ diff --git a/include/datetime.h b/include/datetime.h index c1f549f..cd6df2c 100644 --- a/include/datetime.h +++ b/include/datetime.h @@ -67,25 +67,28 @@ public: DateTime &operator-=(const double &rhs); DateTime &operator-=(const DateTime &rhs); - const bool operator==(const DateTime &rhs) const { return m_timet==rhs.m_timet; } + const bool operator==(const DateTime &rhs) const { return *this==rhs.m_tm; } const bool operator==(const time_t &rhs) const { return m_timet==rhs; } const bool operator==(const struct tm &rhs) const; - const bool operator<(const DateTime &rhs) const { return (m_timet(const DateTime &rhs) const { return (m_timet>rhs.m_timet); } + const bool operator>(const DateTime &rhs) const { return !(*this<=rhs.m_tm); } const bool operator>(const time_t &rhs) const { return (m_timet>rhs); } - const bool operator>=(const DateTime &rhs) const { return (*this>rhs || *this==rhs); } + const bool operator>=(const DateTime &rhs) const { return !(*this=(const time_t &rhs) const { return (m_timet>=rhs); } private: + const time_t TimeGM(struct tm *gmtimein); - time_t m_timet; + time_t m_timet; // don't use timet for any comparisons struct tm m_tm; }; diff --git a/include/freenet/boardlistrequester.h b/include/freenet/boardlistrequester.h index 580b4f8..a917e0a 100644 --- a/include/freenet/boardlistrequester.h +++ b/include/freenet/boardlistrequester.h @@ -16,6 +16,8 @@ private: const bool HandleAllData(FCPMessage &message); const bool HandleGetFailed(FCPMessage &message); + std::string GetIdentityName(const long identityid); + bool m_savemessagesfromnewboards; }; diff --git a/include/freenet/messagerequester.h b/include/freenet/messagerequester.h index fd453ee..31eb580 100644 --- a/include/freenet/messagerequester.h +++ b/include/freenet/messagerequester.h @@ -16,7 +16,7 @@ private: const bool HandleAllData(FCPMessage &message); const bool HandleGetFailed(FCPMessage &message); - const long GetBoardID(const std::string &boardname); + const long GetBoardID(const std::string &boardname, const std::string &identityname); const bool SaveToBoard(const std::string &boardname); const std::string GetIdentityName(const long identityid); diff --git a/include/global.h b/include/global.h index f2b227b..8b781f9 100644 --- a/include/global.h +++ b/include/global.h @@ -4,7 +4,7 @@ #include #include "pthreadwrapper/thread.h" -#define FMS_VERSION "0.2.5" +#define FMS_VERSION "0.2.6" // opens database and creates tables and initial inserts if necessary void SetupDB(); @@ -13,6 +13,7 @@ void ConvertDB0101To0103(); void ConvertDB0103To0104(); void ConvertDB0104To0105(); void ConvertDB0105To0106(); +void ConvertDB0106To0107(); // inserts default options into the database void SetupDefaultOptions(); // opens logfile and sets it up diff --git a/readme.txt b/readme.txt index e853ecb..593a99f 100644 --- a/readme.txt +++ b/readme.txt @@ -13,13 +13,13 @@ to the cmake command. UPGRADING --------- It is always a good idea to make copies of your current FMS installation before -continuing. First shut down FMS and then replace the binary and template.htm -with those from the new version. You may keep the same database unless -otherwise noted. +continuing. First shut down FMS and then replace the binary and templates with +those from the new version. You may keep the same database unless otherwise +noted. INSTALLATION ------------ -Place the binary and template.htm in a directory of your choice. On the first +Place the binary and any templates in a directory of your choice. On the first run, a database file will also be created in this directory. Make sure the user that runs FMS has read/write access to this directory. @@ -85,8 +85,8 @@ web interface. A note on NULL trust: If you neither trust or distrust an identity, they will have NULL trust (no trust at all). You will download messages and trust lists -from identities with NULL peer trust as long as the local trust level is above -your configured minimum. You will also download messages from identities with -NULL local message trust (the peer message trust must be NULL or > your +from identities with NULL peer trust as long as the local trust level is at or +above your configured minimum. You will also download messages from identities +with NULL local message trust (the peer message trust must be NULL or >= your configured minimum as well), but you will not download trust lists from identities with NULL local trust list trust. diff --git a/src/board.cpp b/src/board.cpp index 99350f5..7ccac3b 100644 --- a/src/board.cpp +++ b/src/board.cpp @@ -15,6 +15,7 @@ Board::Board() m_highmessageid=0; m_messagecount=0; m_savereceivedmessages=true; + m_addedmethod=""; } Board::Board(const long boardid) @@ -27,7 +28,7 @@ Board::Board(const std::string &boardname) Load(boardname); } -Board::Board(const long boardid, const std::string &boardname, const std::string &boarddescription, const std::string datecreated, const long lowmessageid, const long highmessageid, const long messagecount, const bool savereceivedmessages) +Board::Board(const long boardid, const std::string &boardname, const std::string &boarddescription, const std::string datecreated, const long lowmessageid, const long highmessageid, const long messagecount, const bool savereceivedmessages, const std::string &addedmethod) { m_boardid=boardid; m_boardname=boardname; @@ -36,6 +37,7 @@ Board::Board(const long boardid, const std::string &boardname, const std::string m_highmessageid=highmessageid; m_messagecount=messagecount; m_savereceivedmessages=savereceivedmessages; + m_addedmethod=addedmethod; SetDateFromString(datecreated); @@ -52,8 +54,9 @@ const bool Board::Load(const long boardid) m_lowmessageid=0; m_highmessageid=0; m_messagecount=0; + m_addedmethod=""; - SQLite3DB::Statement st=m_db->Prepare("SELECT BoardName, BoardDescription, DateAdded, HighMessageID, LowMessageID, MessageCount, SaveReceivedMessages FROM tblBoard LEFT JOIN vwBoardStats ON tblBoard.BoardID=vwBoardStats.BoardID WHERE tblBoard.BoardID=?;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT BoardName, BoardDescription, DateAdded, HighMessageID, LowMessageID, MessageCount, SaveReceivedMessages, AddedMethod FROM tblBoard LEFT JOIN vwBoardStats ON tblBoard.BoardID=vwBoardStats.BoardID WHERE tblBoard.BoardID=?;"); st.Bind(0,boardid); st.Step(); @@ -88,6 +91,7 @@ const bool Board::Load(const long boardid) { m_savereceivedmessages=false; } + st.ResultText(7,m_addedmethod); return true; } @@ -124,8 +128,9 @@ const bool Board::Load(const std::string &boardname) // same as loading form bo m_highmessageid=0; m_messagecount=0; int tempint=-1; + m_addedmethod=""; - SQLite3DB::Statement st=m_db->Prepare("SELECT BoardName, BoardDescription, DateAdded, HighMessageID, LowMessageID, MessageCount, SaveReceivedMessages, tblBoard.BoardID FROM tblBoard LEFT JOIN vwBoardStats ON tblBoard.BoardID=vwBoardStats.BoardID WHERE tblBoard.BoardName=?;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT BoardName, BoardDescription, DateAdded, HighMessageID, LowMessageID, MessageCount, SaveReceivedMessages, tblBoard.BoardID, AddedMethod FROM tblBoard LEFT JOIN vwBoardStats ON tblBoard.BoardID=vwBoardStats.BoardID WHERE tblBoard.BoardName=?;"); st.Bind(0,boardname); st.Step(); @@ -161,6 +166,7 @@ const bool Board::Load(const std::string &boardname) // same as loading form bo { m_savereceivedmessages=false; } + st.ResultText(8,m_addedmethod); return true; } diff --git a/src/boardlist.cpp b/src/boardlist.cpp index cd6e071..931e096 100644 --- a/src/boardlist.cpp +++ b/src/boardlist.cpp @@ -17,8 +17,9 @@ void BoardList::Load() int highmessageid=0; int lowmessageid=0; int messagecount=0; + std::string addedmethod=""; - SQLite3DB::Statement st=m_db->Prepare("SELECT tblBoard.BoardID, BoardName, BoardDescription, DateAdded, HighMessageID, LowMessageID, MessageCount, SaveReceivedMessages FROM tblBoard LEFT JOIN vwBoardStats ON tblBoard.BoardID=vwBoardStats.BoardID ORDER BY BoardName COLLATE NOCASE;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT tblBoard.BoardID, BoardName, BoardDescription, DateAdded, HighMessageID, LowMessageID, MessageCount, SaveReceivedMessages, AddedMethod FROM tblBoard LEFT JOIN vwBoardStats ON tblBoard.BoardID=vwBoardStats.BoardID ORDER BY BoardName COLLATE NOCASE;"); st.Step(); while(st.RowReturned()) @@ -31,6 +32,7 @@ void BoardList::Load() st.ResultInt(5,lowmessageid); st.ResultInt(6,messagecount); st.ResultText(7,savereceivedstr); + st.ResultText(8,addedmethod); if(savereceivedstr=="true") { @@ -41,7 +43,7 @@ void BoardList::Load() savereceived=false; } - push_back(Board(boardid,boardname,boarddescription,dateadded,lowmessageid,highmessageid,messagecount,savereceived)); + push_back(Board(boardid,boardname,boarddescription,dateadded,lowmessageid,highmessageid,messagecount,savereceived,addedmethod)); st.Step(); } } diff --git a/src/datetime.cpp b/src/datetime.cpp index f2d85e9..404cb31 100644 --- a/src/datetime.cpp +++ b/src/datetime.cpp @@ -187,6 +187,11 @@ const bool DateTime::operator==(const struct tm &rhs) const return (m_tm.tm_year==rhs.tm_year && m_tm.tm_mon==rhs.tm_mon && m_tm.tm_mday==rhs.tm_mday && m_tm.tm_hour==rhs.tm_hour && m_tm.tm_min==rhs.tm_min && m_tm.tm_sec==rhs.tm_sec) ? true : false; } +const bool DateTime::operator<(const struct tm &rhs) const +{ + return (m_tm.tm_year(fcp) Initialize(); } +std::string BoardListRequester::GetIdentityName(const long identityid) +{ + SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey FROM tblIdentity WHERE IdentityID=?;"); + st.Bind(0,identityid); + st.Step(); + if(st.RowReturned()) + { + std::vector keyparts; + std::string key; + std::string name; + st.ResultText(0,name); + st.ResultText(1,key); + + StringFunctions::SplitMultiple(key,"@,",keyparts); + + if(keyparts.size()>1) + { + return name+"@"+keyparts[1]; + } + else + { + return name+"@invalidpublickey"; + } + } + else + { + return ""; + } +} + const bool BoardListRequester::HandleAllData(FCPMessage &message) { DateTime now; @@ -25,6 +55,7 @@ const bool BoardListRequester::HandleAllData(FCPMessage &message) BoardListXML xml; long identityid; long index; + std::string identityname=""; now.SetToGMTime(); StringFunctions::Split(message["Identifier"],"|",idparts); @@ -32,6 +63,8 @@ const bool BoardListRequester::HandleAllData(FCPMessage &message) StringFunctions::Convert(idparts[1],identityid); StringFunctions::Convert(idparts[2],index); + identityname=GetIdentityName(identityid); + // wait for all data to be received from connection while(m_fcp->Connected() && m_fcp->ReceiveBufferSize()Prepare("SELECT BoardID,BoardName,BoardDescription FROM tblBoard WHERE BoardName=?;"); - SQLite3DB::Statement ins=m_db->Prepare("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,SaveReceivedMessages) VALUES(?,?,?,?);"); + SQLite3DB::Statement ins=m_db->Prepare("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,SaveReceivedMessages,AddedMethod) VALUES(?,?,?,?,?);"); SQLite3DB::Statement upd=m_db->Prepare("UPDATE tblBoard SET BoardDescription=? WHERE BoardID=?;"); for(long i=0; i40) + { + lowername.erase(40); + } m_boards.push_back(board(lowername,description)); } } @@ -100,6 +104,10 @@ const bool BoardListXML::ParseXML(const std::string &xml) { name=txt->ValueStr(); StringFunctions::LowerCase(name,name); + if(name.size()>40) + { + name.erase(40); + } } txt=hnd2.FirstChild("Description").FirstChild().ToText(); if(txt) diff --git a/src/freenet/freenetmasterthread.cpp b/src/freenet/freenetmasterthread.cpp index 4ca447e..4e7b570 100644 --- a/src/freenet/freenetmasterthread.cpp +++ b/src/freenet/freenetmasterthread.cpp @@ -20,7 +20,6 @@ #include "../../include/freenet/boardlistrequester.h" #include "../../include/freenet/siteinserter.h" -//#include #include "../../include/pthreadwrapper/thread.h" #ifdef XMEM @@ -171,10 +170,14 @@ void FreenetMasterThread::Run() { DateTime lastreceivedmessage; + DateTime lastconnected; DateTime now; FCPMessage message; bool done=false; + lastconnected.SetToGMTime(); + lastconnected.Add(0,-1); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"FreenetMasterThread::run thread started."); Setup(); @@ -183,30 +186,29 @@ void FreenetMasterThread::Run() { if(m_fcp.Connected()==false) { - if(FCPConnect()==false) + // wait at least 1 minute since last successful connect + now.SetToGMTime(); + if(lastconnected<=(now-(1.0/1440.0))) { + if(FCPConnect()==false) + { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::run could not connect to node. Waiting 60 seconds."); + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::run could not connect to node. Waiting 60 seconds."); - // wait 60 seconds - will then try to connect again - /* - try - { - ZThread::Thread::sleep(60000); - } - catch(...) - { - done=true; + for(int i=0; i<60 && !IsCancelled(); i++) + { + Sleep(1000); + } } - */ - for(int i=0; i<60 && !IsCancelled(); i++) + else { - Sleep(1000); + lastreceivedmessage.SetToGMTime(); + lastconnected.SetToGMTime(); } } else { - lastreceivedmessage.SetToGMTime(); + Sleep(1000); } } // fcp is connected @@ -241,8 +243,12 @@ void FreenetMasterThread::Run() m_fcp.Disconnect(); } + if(m_fcp.Connected()==false) + { + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::Run Disconnected from Freenet node."); + } + } -// }while(!ZThread::Thread::interrupted() && done==false); }while(!IsCancelled() && done==false); m_fcp.Disconnect(); diff --git a/src/freenet/identityxml.cpp b/src/freenet/identityxml.cpp index f4e8c54..e3905a9 100644 --- a/src/freenet/identityxml.cpp +++ b/src/freenet/identityxml.cpp @@ -59,6 +59,11 @@ const bool IdentityXML::ParseXML(const std::string &xml) m_name=txt->ValueStr(); } + if(m_name.size()>40) + { + m_name.erase(40); + } + m_singleuse=XMLGetBooleanElement(hnd.FirstChild("Identity").ToElement(),"SingleUse"); m_publishtrustlist=XMLGetBooleanElement(hnd.FirstChild("Identity").ToElement(),"PublishTrustList"); diff --git a/src/freenet/messagerequester.cpp b/src/freenet/messagerequester.cpp index e298271..5b6d271 100644 --- a/src/freenet/messagerequester.cpp +++ b/src/freenet/messagerequester.cpp @@ -17,7 +17,7 @@ MessageRequester::MessageRequester(FCPv2 *fcp):IIndexRequester(fcp) Initialize(); } -const long MessageRequester::GetBoardID(const std::string &boardname) +const long MessageRequester::GetBoardID(const std::string &boardname, const std::string &identityname) { std::string lowerboard=boardname; StringFunctions::LowerCase(lowerboard,lowerboard); @@ -35,7 +35,7 @@ const long MessageRequester::GetBoardID(const std::string &boardname) { DateTime now; now.SetToGMTime(); - st=m_db->Prepare("INSERT INTO tblBoard(BoardName,DateAdded,SaveReceivedMessages) VALUES(?,?,?);"); + st=m_db->Prepare("INSERT INTO tblBoard(BoardName,DateAdded,SaveReceivedMessages,AddedMethod) VALUES(?,?,?,?);"); st.Bind(0,boardname); st.Bind(1,now.Format("%Y-%m-%d %H:%M:%S")); if(m_savemessagesfromnewboards) @@ -46,6 +46,7 @@ const long MessageRequester::GetBoardID(const std::string &boardname) { st.Bind(2,"false"); } + st.Bind(3,"Message from "+identityname); st.Step(true); return st.GetLastInsertRowID(); } @@ -212,7 +213,7 @@ const bool MessageRequester::HandleAllData(FCPMessage &message) st.Bind(3,xml.GetTime()); st.Bind(4,xml.GetSubject()); st.Bind(5,xml.GetMessageID()); - st.Bind(6,GetBoardID(xml.GetReplyBoard())); + st.Bind(6,GetBoardID(xml.GetReplyBoard(),GetIdentityName(identityid))); st.Bind(7,xml.GetBody()); st.Bind(8,index); inserted=st.Step(true); @@ -227,7 +228,7 @@ const bool MessageRequester::HandleAllData(FCPMessage &message) if(SaveToBoard((*i))) { st.Bind(0,messageid); - st.Bind(1,GetBoardID((*i))); + st.Bind(1,GetBoardID((*i),GetIdentityName(identityid))); st.Step(); st.Reset(); } diff --git a/src/freenet/messagexml.cpp b/src/freenet/messagexml.cpp index 8f5006e..ec5946e 100644 --- a/src/freenet/messagexml.cpp +++ b/src/freenet/messagexml.cpp @@ -104,6 +104,10 @@ const bool MessageXML::ParseXML(const std::string &xml) { m_replyboard=txt->ValueStr(); StringFunctions::LowerCase(m_replyboard,m_replyboard); + if(m_replyboard.size()>40) + { + m_replyboard.erase(40); + } } txt=hnd.FirstChild("Message").FirstChild("Body").FirstChild().ToText(); if(txt) @@ -118,6 +122,10 @@ const bool MessageXML::ParseXML(const std::string &xml) { std::string boardname=node2->FirstChild()->ValueStr(); StringFunctions::LowerCase(boardname,boardname); + if(boardname.size()>40) + { + boardname.erase(40); + } m_boards.push_back(boardname); } node2=node2->NextSibling("Board"); diff --git a/src/freenet/periodicdbmaintenance.cpp b/src/freenet/periodicdbmaintenance.cpp index 2ac1e07..84e7e94 100644 --- a/src/freenet/periodicdbmaintenance.cpp +++ b/src/freenet/periodicdbmaintenance.cpp @@ -155,6 +155,12 @@ void PeriodicDBMaintenance::Do1DayMaintenance() date.Add(0,0,0,-2); m_db->Execute("DELETE FROM tblIdentityRequests WHERE Day<'"+date.Format("%Y-%m-%d")+"';"); + // delete old board list inserts/requests - we don't need them anymore + date.SetToGMTime(); + date.Add(0,0,0,-2); + m_db->Execute("DELETE FROM tblBoardListInserts WHERE Day<'"+date.Format("%Y-%m-%d")+"';"); + m_db->Execute("DELETE FROM tblBoardListRequests WHERE Day<'"+date.Format("%Y-%m-%d")+"';"); + // delete old local identity inserts - we don't need them anymore date.SetToGMTime(); date.Add(0,0,0,-2); diff --git a/src/global.cpp b/src/global.cpp index 035cdc3..aa87b99 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -73,13 +73,19 @@ void SetupDB() major=1; minor=6; } + if(major==1 && minor==6) + { + ConvertDB0106To0107(); + major=1; + minor=7; + } } else { - db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,6);"); + db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,7);"); } - db->Execute("UPDATE tblDBVersion SET Major=1, Minor=6;"); + db->Execute("UPDATE tblDBVersion SET Major=1, Minor=7;"); db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\ Option TEXT UNIQUE,\ @@ -156,7 +162,8 @@ void SetupDB() PeerTrustListTrust INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\ AddedMethod TEXT,\ MessageTrustComment TEXT,\ - TrustListTrustComment TEXT\ + TrustListTrustComment TEXT,\ + Hidden BOOL CHECK(Hidden IN('true','false')) DEFAULT 'false'\ );"); db->Execute("CREATE TABLE IF NOT EXISTS tblIdentityRequests(\ @@ -202,13 +209,14 @@ void SetupDB() BoardName TEXT UNIQUE,\ BoardDescription TEXT,\ DateAdded DATETIME,\ - SaveReceivedMessages BOOL CHECK(SaveReceivedMessages IN('true','false')) DEFAULT 'true'\ + SaveReceivedMessages BOOL CHECK(SaveReceivedMessages IN('true','false')) DEFAULT 'true',\ + AddedMethod TEXT\ );"); - db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES('fms','Freenet Message System','2007-12-01 12:00:00');"); - db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES('freenet','Discussion about Freenet','2007-12-01 12:00:00');"); - db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES('public','Public discussion','2007-12-01 12:00:00');"); - db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES('test','Test board','2007-12-01 12:00:00');"); + db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('fms','Freenet Message System','2007-12-01 12:00:00','Initial Board');"); + db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('freenet','Discussion about Freenet','2007-12-01 12:00:00','Initialt Board');"); + db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('public','Public discussion','2007-12-01 12:00:00','Initial Board');"); + db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('test','Test board','2007-12-01 12:00:00','Initial Board');"); db->Execute("CREATE TABLE IF NOT EXISTS tblMessage(\ MessageID INTEGER PRIMARY KEY,\ @@ -231,11 +239,14 @@ void SetupDB() ReplyOrder INTEGER\ );"); + db->Execute("CREATE INDEX IF NOT EXISTS idxMessageReplyTo_MessageID ON tblMessageReplyTo (MessageID);"); + db->Execute("CREATE TABLE IF NOT EXISTS tblMessageBoard(\ MessageID INTEGER,\ BoardID INTEGER\ );"); + db->Execute("CREATE INDEX IF NOT EXISTS idxMessageBoard_MessageID ON tblMessageBoard (MessageID);"); db->Execute("CREATE INDEX IF NOT EXISTS idxMessageBoard_BoardID ON tblMessageBoard (BoardID);"); db->Execute("CREATE TABLE IF NOT EXISTS tblMessageListRequests(\ @@ -403,11 +414,11 @@ void SetupDB() date.SetToGMTime(); // insert SomeDude's public key - db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,LocalTrustListTrust) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"',50);"); + db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,LocalTrustListTrust,AddedMethod) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"',50,'Initial Identity');"); // insert Shadow Panther's public key - db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('SSK@~mimyB1kmH4f7Cgsd2wM2Qv2NxrZHRMM6IY8~7EWRVQ,fxTKkR0TYhgMYb-vEGAv55sMOxCGD2xhE4ZxWHxdPz4,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"');"); + db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@~mimyB1kmH4f7Cgsd2wM2Qv2NxrZHRMM6IY8~7EWRVQ,fxTKkR0TYhgMYb-vEGAv55sMOxCGD2xhE4ZxWHxdPz4,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');"); // insert garfield's public key - db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('SSK@T8l1IEGU4-PoASFzgc2GYhIgRzUvZsKdoQWeuLHuTmM,QLxAPfkGis8l5NafNpSCdbxzXhBlu9WL8svcqJw9Mpo,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"');"); + db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@T8l1IEGU4-PoASFzgc2GYhIgRzUvZsKdoQWeuLHuTmM,QLxAPfkGis8l5NafNpSCdbxzXhBlu9WL8svcqJw9Mpo,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');"); // TODO remove sometime after 0.1.17 FixCapitalBoardNames(); @@ -508,6 +519,16 @@ void ConvertDB0105To0106() db->Execute("UPDATE tblDBVersion SET Major=1, Minor=6;"); } +void ConvertDB0106To0107() +{ + // add AddedMethod to tblBoard + SQLite3DB::DB *db=SQLite3DB::DB::Instance(); + db->Execute("ALTER TABLE tblBoard ADD COLUMN AddedMethod TEXT;"); + db->Execute("ALTER TABLE tblIdentity ADD COLUMN Hidden BOOL CHECK(Hidden IN('true','false')) DEFAULT 'false';"); + db->Execute("UPDATE tblIdentity SET Hidden='false' WHERE Hidden IS NULL;"); + db->Execute("UPDATE tblDBVersion SET Major=1, Minor=7;"); +} + 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 @@ -777,7 +798,7 @@ void FixCapitalBoardNames() SQLite3DB::Statement st=db->Prepare("SELECT BoardID,BoardName FROM tblBoard WHERE BoardID NOT IN (SELECT BoardID FROM tblAdministrationBoard);"); SQLite3DB::Statement st2=db->Prepare("SELECT BoardID FROM tblBoard WHERE BoardName=?;"); - SQLite3DB::Statement del=db->Prepare("DELTE FROM tblBoard WHERE BoardID=?;"); + SQLite3DB::Statement del=db->Prepare("DELETE FROM tblBoard WHERE BoardID=?;"); SQLite3DB::Statement upd=db->Prepare("UPDATE tblBoard SET BoardName=? WHERE BoardID=?;"); SQLite3DB::Statement upd2=db->Prepare("UPDATE tblMessage SET ReplyBoardID=? WHERE ReplyBoardID=?;"); SQLite3DB::Statement upd3=db->Prepare("UPDATE tblMessageBoard SET BoardID=? WHERE BoardID=?;"); diff --git a/src/http/pages/boardspage.cpp b/src/http/pages/boardspage.cpp index dce33b8..4adab89 100644 --- a/src/http/pages/boardspage.cpp +++ b/src/http/pages/boardspage.cpp @@ -55,10 +55,11 @@ const std::string BoardsPage::GeneratePage(const std::string &method, const std: StringFunctions::LowerCase(boardname,boardname); boarddescription=(*queryvars.find("boarddescription")).second; - SQLite3DB::Statement addst=m_db->Prepare("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES(?,?,?);"); + SQLite3DB::Statement addst=m_db->Prepare("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES(?,?,?,?);"); addst.Bind(0,boardname); addst.Bind(1,boarddescription); addst.Bind(2,now.Format("%Y-%m-%d %H:%M:%S")); + addst.Bind(3,"Added manually"); addst.Step(); } if((*queryvars.find("formaction")).second=="remove0messages") @@ -152,7 +153,7 @@ const std::string BoardsPage::GeneratePage(const std::string &method, const std: st.Finalize(); - sql="SELECT BoardID,BoardName,BoardDescription,SaveReceivedMessages FROM tblBoard WHERE BoardID NOT IN (SELECT BoardID FROM tblAdministrationBoard)"; + sql="SELECT BoardID,BoardName,BoardDescription,SaveReceivedMessages,AddedMethod FROM tblBoard WHERE BoardID NOT IN (SELECT BoardID FROM tblAdministrationBoard)"; if(boardsearch!="") { sql+=" AND (BoardName LIKE '%' || ? || '%' OR BoardDescription LIKE '%' || ? || '%')"; @@ -186,9 +187,9 @@ const std::string BoardsPage::GeneratePage(const std::string &method, const std: content+="
"; content+=""; - content+="
"; + content+="
"; content+=""; - content+="NameDescriptionSave Received Messages *"; + content+="NameDescriptionSave Received Messages *Added Method"; content+=""; while(st.RowReturned() && rownum"+SanitizeOutput(addedmethod)+""; content+="\r\n"; st.Step(); rownum++; @@ -238,7 +242,7 @@ const std::string BoardsPage::GeneratePage(const std::string &method, const std: } if(startrow+rowsperpage
"; + content+="
"; content+=""; content+=""; content+="

"; diff --git a/src/http/pages/createidentitypage.cpp b/src/http/pages/createidentitypage.cpp index 8d67e07..f993a39 100644 --- a/src/http/pages/createidentitypage.cpp +++ b/src/http/pages/createidentitypage.cpp @@ -12,7 +12,7 @@ const std::string CreateIdentityPage::GeneratePage(const std::string &method, co if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="create") { - SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name,PublishTrustList,DateCreated) VALUES(?,'true',?);"); + SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name,PublishTrustList,DateCreated) VALUES(?,'false',?);"); std::string name=""; DateTime date; date.SetToGMTime(); diff --git a/src/http/pages/localidentitiespage.cpp b/src/http/pages/localidentitiespage.cpp index f84362e..c0b6105 100644 --- a/src/http/pages/localidentitiespage.cpp +++ b/src/http/pages/localidentitiespage.cpp @@ -210,6 +210,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;"); st.Step(); + 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;"); + count=0; while(st.RowReturned()) { @@ -243,6 +245,22 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c content+=""+CreateTrueFalseDropDown("publishtrustlist["+countstr+"]",publishtrustlist)+""; content+=""+CreateTrueFalseDropDown("publishboardlist["+countstr+"]",publishboardlist)+""; content+=""+CreateTrueFalseDropDown("publishfreesite["+countstr+"]",publishfreesite)+""; + + trustst.Bind(0,publickey); + trustst.Step(); + if(trustst.RowReturned()) + { + std::string numlists=""; + trustst.ResultText(0,numlists); + content+="Yes ("+numlists+")"; + } + else + { + content+="No"; + } + trustst.Reset(); + +/* if(st.ResultNull(6)) { content+="No"; @@ -251,6 +269,8 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c { content+="Yes"; } +*/ + content+=""; content+="

"; content+=""; @@ -260,7 +280,7 @@ const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, c // content+="
"; content+=""; - content+="

* An identity is considered successfully announced when you have downloaded a trust list from someone that contains the identity.

"; + content+="

* 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.

"; content+="

Single Use Identities will automatically be deleted 7 days after creation.

"; return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content); diff --git a/src/http/pages/peerdetailspage.cpp b/src/http/pages/peerdetailspage.cpp index fc522b0..6d05231 100644 --- a/src/http/pages/peerdetailspage.cpp +++ b/src/http/pages/peerdetailspage.cpp @@ -21,6 +21,7 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const std::string addedmethod=""; std::string usk=""; std::string fcphost=""; + std::string hidden=""; if(queryvars.find("identityid")!=queryvars.end() && (*queryvars.find("identityid")).second!="") { @@ -35,9 +36,23 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const del.Step(); } + if(identityid!=0 && queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="hide") + { + SQLite3DB::Statement del=m_db->Prepare("UPDATE tblIdentity SET Hidden='true' WHERE IdentityID=?;"); + del.Bind(0,identityid); + del.Step(); + } + + if(identityid!=0 && queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="show") + { + SQLite3DB::Statement del=m_db->Prepare("UPDATE tblIdentity SET Hidden='false' WHERE IdentityID=?;"); + del.Bind(0,identityid); + del.Step(); + } + Option::Instance()->Get("FCPHost",fcphost); - SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen,AddedMethod FROM tblIdentity WHERE IdentityID=?;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen,AddedMethod,Hidden FROM tblIdentity WHERE IdentityID=?;"); st.Bind(0,identityid); st.Step(); @@ -49,12 +64,13 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const st.ResultText(2,dateadded); st.ResultText(3,lastseen); st.ResultText(4,addedmethod); + st.ResultText(5,hidden); usk=publickey; if(usk.find("SSK@")==0) { usk.erase(0,3); - usk="USK"+usk+"/fms/0/"; + usk="USK"+usk+"fms/0/"; } content+="Name"+SanitizeOutput(name)+""; @@ -63,6 +79,22 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const content+="Date Added"+dateadded+""; content+="Last Seen"+lastseen+""; content+="Added Method"+SanitizeOutput(addedmethod)+""; + content+="Hidden in Main Peer Trust Page"; + content+=""+hidden; + content+=" 
"; + content+=""; + if(hidden=="false") + { + content+=""; + content+=""; + } + else + { + content+=""; + content+=""; + } + content+="
"; + content+=""; } // get message count posted by this identity @@ -132,6 +164,7 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const st.Bind(0,identityid); st.Step(); + content+="
"; content+=""; content+="Trust of this identity from other identities"; content+=""; diff --git a/src/http/pages/peertrustpage.cpp b/src/http/pages/peertrustpage.cpp index ea01cc4..9429ede 100644 --- a/src/http/pages/peertrustpage.cpp +++ b/src/http/pages/peertrustpage.cpp @@ -165,7 +165,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s } content+="

Peer Trust

"; - content+="Message Trust is how much you trust the identity to post good messages. Trust List Trust is how much weight you want the trust list of that identity to have when calculating the total. The local trust levels are set by you, and the peer trust levels are calculated by a weighted average using other identities' trust lists."; + content+="Message Trust is how much you trust the identity to post good messages. Trust List Trust is how much weight you want the trust list of that identity to have when calculating the total. The local trust levels are set by you, and the peer trust levels are calculated by a weighted average using other identities' trust lists. Trust is recalculated once an hour from received trust lists."; content+="
"; content+="
"; content+=""; @@ -194,7 +194,11 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s sql="SELECT COUNT(*) FROM tblIdentity"; if(namesearch!="") { - sql+=" WHERE Name LIKE '%' || ? || '%'"; + sql+=" WHERE Name LIKE '%' || ? || '%' AND tblIdentity.Hidden='false'"; + } + else + { + sql+=" WHERE tblIdentity.Hidden='false'"; } sql+=";"; SQLite3DB::Statement st=m_db->Prepare(sql); @@ -209,7 +213,11 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s sql="SELECT tblIdentity.IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey,MessageTrustComment,TrustListTrustComment,COUNT(MessageID) AS 'MessageCount' FROM tblIdentity LEFT JOIN tblMessage ON tblIdentity.IdentityID=tblMessage.IdentityID"; if(namesearch!="") { - sql+=" WHERE Name LIKE '%' || ? || '%'"; + sql+=" WHERE (Name LIKE '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%') AND tblIdentity.Hidden='false'"; + } + else + { + sql+=" WHERE tblIdentity.Hidden='false'"; } sql+=" GROUP BY tblIdentity.IdentityID"; sql+=" ORDER BY"; @@ -230,6 +238,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s if(namesearch!="") { st.Bind(0,namesearch); + st.Bind(1,namesearch); } st.Step(); -- 2.7.4