Board();\r
Board(const long boardid);\r
Board(const std::string &boardname);\r
- 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);\r
+ 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);\r
\r
const bool Load(const long boardid);\r
const bool Load(const std::string &boardname);\r
\r
- const long GetBoardID() const { return m_boardid; }\r
- std::string GetBoardName() const { return m_boardname; }\r
- std::string GetBoardDescription() const { return m_boarddescription; }\r
- DateTime GetDateCreated() const { return m_datecreated; }\r
- const long GetLowMessageID() const { return m_lowmessageid; }\r
- const long GetHighMessageID() const { return m_highmessageid; }\r
- const long GetMessageCount() const { return m_messagecount; }\r
- const bool GetSaveReceivedMessages() const { return m_savereceivedmessages; }\r
+ const long GetBoardID() const { return m_boardid; }\r
+ std::string GetBoardName() const { return m_boardname; }\r
+ std::string GetBoardDescription() const { return m_boarddescription; }\r
+ DateTime GetDateCreated() const { return m_datecreated; }\r
+ const long GetLowMessageID() const { return m_lowmessageid; }\r
+ const long GetHighMessageID() const { return m_highmessageid; }\r
+ const long GetMessageCount() const { return m_messagecount; }\r
+ const bool GetSaveReceivedMessages() const { return m_savereceivedmessages; }\r
+ std::string GetAddedMethod() const { return m_addedmethod; }\r
\r
private:\r
void SetDateFromString(const std::string &datestring);\r
long m_highmessageid; // highest id of all message currently in this board\r
long m_messagecount; // number of messages in this board\r
bool m_savereceivedmessages;\r
+ std::string m_addedmethod;\r
};\r
\r
#endif // _board_\r
DateTime &operator-=(const double &rhs);\r
DateTime &operator-=(const DateTime &rhs);\r
\r
- const bool operator==(const DateTime &rhs) const { return m_timet==rhs.m_timet; }\r
+ const bool operator==(const DateTime &rhs) const { return *this==rhs.m_tm; }\r
const bool operator==(const time_t &rhs) const { return m_timet==rhs; }\r
const bool operator==(const struct tm &rhs) const;\r
\r
- const bool operator<(const DateTime &rhs) const { return (m_timet<rhs.m_timet); }\r
+ const bool operator<(const DateTime &rhs) const { return (*this<rhs.m_tm); }\r
const bool operator<(const time_t &rhs) const { return (m_timet<rhs); }\r
+ const bool operator<(const struct tm &rhs) const;\r
\r
- const bool operator<=(const DateTime &rhs) const { return (*this<rhs || *this==rhs); }\r
+ const bool operator<=(const DateTime &rhs) const { return (*this<rhs.m_tm || *this==rhs.m_tm); }\r
const bool operator<=(const time_t &rhs) const { return (m_timet<=rhs); }\r
+ const bool operator<=(const struct tm &rhs) const { return (*this<rhs || *this==rhs); }\r
\r
- const bool operator>(const DateTime &rhs) const { return (m_timet>rhs.m_timet); }\r
+ const bool operator>(const DateTime &rhs) const { return !(*this<=rhs.m_tm); }\r
const bool operator>(const time_t &rhs) const { return (m_timet>rhs); }\r
\r
- const bool operator>=(const DateTime &rhs) const { return (*this>rhs || *this==rhs); }\r
+ const bool operator>=(const DateTime &rhs) const { return !(*this<rhs.m_tm); }\r
const bool operator>=(const time_t &rhs) const { return (m_timet>=rhs); }\r
\r
private:\r
+ const time_t TimeGM(struct tm *gmtimein);\r
\r
- time_t m_timet;\r
+ time_t m_timet; // don't use timet for any comparisons\r
struct tm m_tm;\r
};\r
\r
const bool HandleAllData(FCPMessage &message);\r
const bool HandleGetFailed(FCPMessage &message);\r
\r
+ std::string GetIdentityName(const long identityid);\r
+\r
bool m_savemessagesfromnewboards;\r
\r
};\r
const bool HandleAllData(FCPMessage &message);\r
const bool HandleGetFailed(FCPMessage &message);\r
\r
- const long GetBoardID(const std::string &boardname);\r
+ const long GetBoardID(const std::string &boardname, const std::string &identityname);\r
const bool SaveToBoard(const std::string &boardname);\r
const std::string GetIdentityName(const long identityid);\r
\r
#include <vector>\r
#include "pthreadwrapper/thread.h"\r
\r
-#define FMS_VERSION "0.2.5"\r
+#define FMS_VERSION "0.2.6"\r
\r
// opens database and creates tables and initial inserts if necessary\r
void SetupDB();\r
void ConvertDB0103To0104();\r
void ConvertDB0104To0105();\r
void ConvertDB0105To0106();\r
+void ConvertDB0106To0107();\r
// inserts default options into the database\r
void SetupDefaultOptions();\r
// opens logfile and sets it up\r
UPGRADING\r
---------\r
It is always a good idea to make copies of your current FMS installation before\r
-continuing. First shut down FMS and then replace the binary and template.htm\r
-with those from the new version. You may keep the same database unless\r
-otherwise noted.\r
+continuing. First shut down FMS and then replace the binary and templates with\r
+those from the new version. You may keep the same database unless otherwise\r
+noted.\r
\r
INSTALLATION\r
------------\r
-Place the binary and template.htm in a directory of your choice. On the first\r
+Place the binary and any templates in a directory of your choice. On the first\r
run, a database file will also be created in this directory. Make sure the\r
user that runs FMS has read/write access to this directory.\r
\r
\r
A note on NULL trust: If you neither trust or distrust an identity, they will\r
have NULL trust (no trust at all). You will download messages and trust lists\r
-from identities with NULL peer trust as long as the local trust level is above\r
-your configured minimum. You will also download messages from identities with\r
-NULL local message trust (the peer message trust must be NULL or > your\r
+from identities with NULL peer trust as long as the local trust level is at or\r
+above your configured minimum. You will also download messages from identities\r
+with NULL local message trust (the peer message trust must be NULL or >= your\r
configured minimum as well), but you will not download trust lists from\r
identities with NULL local trust list trust.\r
m_highmessageid=0;\r
m_messagecount=0;\r
m_savereceivedmessages=true;\r
+ m_addedmethod="";\r
}\r
\r
Board::Board(const long boardid)\r
Load(boardname);\r
}\r
\r
-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)\r
+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)\r
{\r
m_boardid=boardid;\r
m_boardname=boardname;\r
m_highmessageid=highmessageid;\r
m_messagecount=messagecount;\r
m_savereceivedmessages=savereceivedmessages;\r
+ m_addedmethod=addedmethod;\r
\r
SetDateFromString(datecreated);\r
\r
m_lowmessageid=0;\r
m_highmessageid=0;\r
m_messagecount=0;\r
+ m_addedmethod="";\r
\r
- 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=?;");\r
+ 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=?;");\r
st.Bind(0,boardid);\r
st.Step();\r
\r
{\r
m_savereceivedmessages=false;\r
}\r
+ st.ResultText(7,m_addedmethod);\r
\r
return true;\r
}\r
m_highmessageid=0;\r
m_messagecount=0;\r
int tempint=-1;\r
+ m_addedmethod="";\r
\r
- 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=?;");\r
+ 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=?;");\r
st.Bind(0,boardname);\r
st.Step();\r
\r
{\r
m_savereceivedmessages=false;\r
}\r
+ st.ResultText(8,m_addedmethod);\r
\r
return true;\r
}\r
int highmessageid=0;\r
int lowmessageid=0;\r
int messagecount=0;\r
+ std::string addedmethod="";\r
\r
- 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;");\r
+ 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;");\r
st.Step();\r
\r
while(st.RowReturned())\r
st.ResultInt(5,lowmessageid);\r
st.ResultInt(6,messagecount);\r
st.ResultText(7,savereceivedstr);\r
+ st.ResultText(8,addedmethod);\r
\r
if(savereceivedstr=="true")\r
{\r
savereceived=false;\r
}\r
\r
- push_back(Board(boardid,boardname,boarddescription,dateadded,lowmessageid,highmessageid,messagecount,savereceived));\r
+ push_back(Board(boardid,boardname,boarddescription,dateadded,lowmessageid,highmessageid,messagecount,savereceived,addedmethod));\r
st.Step();\r
}\r
}\r
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;\r
}\r
\r
+const bool DateTime::operator<(const struct tm &rhs) const\r
+{\r
+ return (m_tm.tm_year<rhs.tm_year || (m_tm.tm_year==rhs.tm_year && m_tm.tm_mon<rhs.tm_mon) || (m_tm.tm_year==rhs.tm_year && m_tm.tm_mon==rhs.tm_mon && m_tm.tm_mday<rhs.tm_mday) || (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_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_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));\r
+}\r
+\r
void DateTime::Set(const int year, const int month, const int day, const int hour, const int minute, const int second)\r
{\r
m_tm.tm_year=year-1900;\r
m_tm=*localtime(&m_timet);\r
Normalize();\r
}\r
+\r
+const time_t DateTime::TimeGM(struct tm *gmtimein)\r
+{\r
+ //This looks good but I don't think will work when TZ isn't set (Windows)\r
+ //http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/timegm.3.html\r
+ \r
+ //This should work\r
+ //http://lists2.ais.fraunhofer.de/pipermail/emx/1999-September/000874.html\r
+\r
+ struct tm ttm;\r
+ time_t t, t2;\r
+\r
+ ttm = *gmtimein; /* make a local copy to fiddle with */\r
+ ttm.tm_isdst = 0; /* treat it as standard time */\r
+\r
+ t2 = t = mktime(&ttm); /* calculate the time as a local time */\r
+\r
+ ttm = *gmtime(&t2); /* now calculate the difference between */\r
+ ttm.tm_isdst = 0; /* gm and local time */\r
+ t2 = mktime(&ttm);\r
+\r
+ t += t - t2; /* and adjust our answer by that difference */\r
+ return t;\r
+}\r
Initialize();\r
}\r
\r
+std::string BoardListRequester::GetIdentityName(const long identityid)\r
+{\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey FROM tblIdentity WHERE IdentityID=?;");\r
+ st.Bind(0,identityid);\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ std::vector<std::string> keyparts;\r
+ std::string key;\r
+ std::string name;\r
+ st.ResultText(0,name);\r
+ st.ResultText(1,key);\r
+ \r
+ StringFunctions::SplitMultiple(key,"@,",keyparts);\r
+ \r
+ if(keyparts.size()>1)\r
+ {\r
+ return name+"@"+keyparts[1];\r
+ }\r
+ else\r
+ {\r
+ return name+"@invalidpublickey";\r
+ }\r
+ }\r
+ else\r
+ {\r
+ return "";\r
+ }\r
+}\r
+\r
const bool BoardListRequester::HandleAllData(FCPMessage &message)\r
{ \r
DateTime now;\r
BoardListXML xml;\r
long identityid;\r
long index;\r
+ std::string identityname="";\r
\r
now.SetToGMTime();\r
StringFunctions::Split(message["Identifier"],"|",idparts);\r
StringFunctions::Convert(idparts[1],identityid);\r
StringFunctions::Convert(idparts[2],index);\r
\r
+ identityname=GetIdentityName(identityid);\r
+\r
// wait for all data to be received from connection\r
while(m_fcp->Connected() && m_fcp->ReceiveBufferSize()<datalength)\r
{\r
{\r
\r
SQLite3DB::Statement brd=m_db->Prepare("SELECT BoardID,BoardName,BoardDescription FROM tblBoard WHERE BoardName=?;");\r
- SQLite3DB::Statement ins=m_db->Prepare("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,SaveReceivedMessages) VALUES(?,?,?,?);");\r
+ SQLite3DB::Statement ins=m_db->Prepare("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,SaveReceivedMessages,AddedMethod) VALUES(?,?,?,?,?);");\r
SQLite3DB::Statement upd=m_db->Prepare("UPDATE tblBoard SET BoardDescription=? WHERE BoardID=?;");\r
for(long i=0; i<xml.GetCount(); i++)\r
{\r
{\r
ins.Bind(3,"false");\r
}\r
+ ins.Bind(4,"Board List of "+identityname);\r
ins.Step();\r
ins.Reset();\r
}\r
{\r
std::string lowername=name;\r
StringFunctions::LowerCase(lowername,lowername);\r
+ if(lowername.size()>40)\r
+ {\r
+ lowername.erase(40);\r
+ }\r
m_boards.push_back(board(lowername,description));\r
}\r
}\r
{\r
name=txt->ValueStr();\r
StringFunctions::LowerCase(name,name);\r
+ if(name.size()>40)\r
+ {\r
+ name.erase(40);\r
+ }\r
}\r
txt=hnd2.FirstChild("Description").FirstChild().ToText();\r
if(txt)\r
#include "../../include/freenet/boardlistrequester.h"\r
#include "../../include/freenet/siteinserter.h"\r
\r
-//#include <zthread/Thread.h>\r
#include "../../include/pthreadwrapper/thread.h"\r
\r
#ifdef XMEM\r
{\r
\r
DateTime lastreceivedmessage;\r
+ DateTime lastconnected;\r
DateTime now;\r
FCPMessage message;\r
bool done=false;\r
\r
+ lastconnected.SetToGMTime();\r
+ lastconnected.Add(0,-1);\r
+\r
m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"FreenetMasterThread::run thread started.");\r
\r
Setup();\r
{\r
if(m_fcp.Connected()==false)\r
{\r
- if(FCPConnect()==false)\r
+ // wait at least 1 minute since last successful connect\r
+ now.SetToGMTime();\r
+ if(lastconnected<=(now-(1.0/1440.0)))\r
{\r
+ if(FCPConnect()==false)\r
+ {\r
\r
- m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::run could not connect to node. Waiting 60 seconds.");\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::run could not connect to node. Waiting 60 seconds.");\r
\r
- // wait 60 seconds - will then try to connect again\r
- /*\r
- try\r
- {\r
- ZThread::Thread::sleep(60000);\r
- }\r
- catch(...)\r
- {\r
- done=true;\r
+ for(int i=0; i<60 && !IsCancelled(); i++)\r
+ {\r
+ Sleep(1000);\r
+ }\r
}\r
- */\r
- for(int i=0; i<60 && !IsCancelled(); i++)\r
+ else\r
{\r
- Sleep(1000);\r
+ lastreceivedmessage.SetToGMTime();\r
+ lastconnected.SetToGMTime();\r
}\r
}\r
else\r
{\r
- lastreceivedmessage.SetToGMTime();\r
+ Sleep(1000);\r
}\r
}\r
// fcp is connected\r
m_fcp.Disconnect();\r
}\r
\r
+ if(m_fcp.Connected()==false)\r
+ {\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"FreenetMasterThread::Run Disconnected from Freenet node.");\r
+ }\r
+\r
}\r
-// }while(!ZThread::Thread::interrupted() && done==false);\r
}while(!IsCancelled() && done==false);\r
\r
m_fcp.Disconnect();\r
m_name=txt->ValueStr();\r
}\r
\r
+ if(m_name.size()>40)\r
+ {\r
+ m_name.erase(40);\r
+ }\r
+\r
m_singleuse=XMLGetBooleanElement(hnd.FirstChild("Identity").ToElement(),"SingleUse");\r
\r
m_publishtrustlist=XMLGetBooleanElement(hnd.FirstChild("Identity").ToElement(),"PublishTrustList");\r
Initialize();\r
}\r
\r
-const long MessageRequester::GetBoardID(const std::string &boardname)\r
+const long MessageRequester::GetBoardID(const std::string &boardname, const std::string &identityname)\r
{\r
std::string lowerboard=boardname;\r
StringFunctions::LowerCase(lowerboard,lowerboard);\r
{\r
DateTime now;\r
now.SetToGMTime();\r
- st=m_db->Prepare("INSERT INTO tblBoard(BoardName,DateAdded,SaveReceivedMessages) VALUES(?,?,?);");\r
+ st=m_db->Prepare("INSERT INTO tblBoard(BoardName,DateAdded,SaveReceivedMessages,AddedMethod) VALUES(?,?,?,?);");\r
st.Bind(0,boardname);\r
st.Bind(1,now.Format("%Y-%m-%d %H:%M:%S"));\r
if(m_savemessagesfromnewboards)\r
{\r
st.Bind(2,"false");\r
}\r
+ st.Bind(3,"Message from "+identityname);\r
st.Step(true);\r
return st.GetLastInsertRowID();\r
} \r
st.Bind(3,xml.GetTime());\r
st.Bind(4,xml.GetSubject());\r
st.Bind(5,xml.GetMessageID());\r
- st.Bind(6,GetBoardID(xml.GetReplyBoard()));\r
+ st.Bind(6,GetBoardID(xml.GetReplyBoard(),GetIdentityName(identityid)));\r
st.Bind(7,xml.GetBody());\r
st.Bind(8,index);\r
inserted=st.Step(true);\r
if(SaveToBoard((*i)))\r
{\r
st.Bind(0,messageid);\r
- st.Bind(1,GetBoardID((*i)));\r
+ st.Bind(1,GetBoardID((*i),GetIdentityName(identityid)));\r
st.Step();\r
st.Reset();\r
}\r
{\r
m_replyboard=txt->ValueStr();\r
StringFunctions::LowerCase(m_replyboard,m_replyboard);\r
+ if(m_replyboard.size()>40)\r
+ {\r
+ m_replyboard.erase(40);\r
+ }\r
}\r
txt=hnd.FirstChild("Message").FirstChild("Body").FirstChild().ToText();\r
if(txt)\r
{\r
std::string boardname=node2->FirstChild()->ValueStr();\r
StringFunctions::LowerCase(boardname,boardname);\r
+ if(boardname.size()>40)\r
+ {\r
+ boardname.erase(40);\r
+ }\r
m_boards.push_back(boardname);\r
}\r
node2=node2->NextSibling("Board");\r
date.Add(0,0,0,-2);\r
m_db->Execute("DELETE FROM tblIdentityRequests WHERE Day<'"+date.Format("%Y-%m-%d")+"';");\r
\r
+ // delete old board list inserts/requests - we don't need them anymore\r
+ date.SetToGMTime();\r
+ date.Add(0,0,0,-2);\r
+ m_db->Execute("DELETE FROM tblBoardListInserts WHERE Day<'"+date.Format("%Y-%m-%d")+"';");\r
+ m_db->Execute("DELETE FROM tblBoardListRequests WHERE Day<'"+date.Format("%Y-%m-%d")+"';");\r
+\r
// delete old local identity inserts - we don't need them anymore\r
date.SetToGMTime();\r
date.Add(0,0,0,-2);\r
major=1;\r
minor=6;\r
}\r
+ if(major==1 && minor==6)\r
+ {\r
+ ConvertDB0106To0107();\r
+ major=1;\r
+ minor=7;\r
+ }\r
}\r
else\r
{\r
- db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,6);");\r
+ db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,7);");\r
}\r
\r
- db->Execute("UPDATE tblDBVersion SET Major=1, Minor=6;");\r
+ db->Execute("UPDATE tblDBVersion SET Major=1, Minor=7;");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\\r
Option TEXT UNIQUE,\\r
PeerTrustListTrust INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
AddedMethod TEXT,\\r
MessageTrustComment TEXT,\\r
- TrustListTrustComment TEXT\\r
+ TrustListTrustComment TEXT,\\r
+ Hidden BOOL CHECK(Hidden IN('true','false')) DEFAULT 'false'\\r
);");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblIdentityRequests(\\r
BoardName TEXT UNIQUE,\\r
BoardDescription TEXT,\\r
DateAdded DATETIME,\\r
- SaveReceivedMessages BOOL CHECK(SaveReceivedMessages IN('true','false')) DEFAULT 'true'\\r
+ SaveReceivedMessages BOOL CHECK(SaveReceivedMessages IN('true','false')) DEFAULT 'true',\\r
+ AddedMethod TEXT\\r
);");\r
\r
- db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES('fms','Freenet Message System','2007-12-01 12:00:00');");\r
- db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES('freenet','Discussion about Freenet','2007-12-01 12:00:00');");\r
- db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES('public','Public discussion','2007-12-01 12:00:00');");\r
- db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES('test','Test board','2007-12-01 12:00:00');");\r
+ db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('fms','Freenet Message System','2007-12-01 12:00:00','Initial Board');");\r
+ db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('freenet','Discussion about Freenet','2007-12-01 12:00:00','Initialt Board');");\r
+ db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('public','Public discussion','2007-12-01 12:00:00','Initial Board');");\r
+ db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('test','Test board','2007-12-01 12:00:00','Initial Board');");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblMessage(\\r
MessageID INTEGER PRIMARY KEY,\\r
ReplyOrder INTEGER\\r
);");\r
\r
+ db->Execute("CREATE INDEX IF NOT EXISTS idxMessageReplyTo_MessageID ON tblMessageReplyTo (MessageID);");\r
+\r
db->Execute("CREATE TABLE IF NOT EXISTS tblMessageBoard(\\r
MessageID INTEGER,\\r
BoardID INTEGER\\r
);");\r
\r
+ db->Execute("CREATE INDEX IF NOT EXISTS idxMessageBoard_MessageID ON tblMessageBoard (MessageID);");\r
db->Execute("CREATE INDEX IF NOT EXISTS idxMessageBoard_BoardID ON tblMessageBoard (BoardID);");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblMessageListRequests(\\r
\r
date.SetToGMTime();\r
// insert SomeDude's public key\r
- db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,LocalTrustListTrust) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"',50);");\r
+ 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');");\r
// insert Shadow Panther's public key\r
- db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('SSK@~mimyB1kmH4f7Cgsd2wM2Qv2NxrZHRMM6IY8~7EWRVQ,fxTKkR0TYhgMYb-vEGAv55sMOxCGD2xhE4ZxWHxdPz4,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"');");\r
+ 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');");\r
// insert garfield's public key\r
- db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('SSK@T8l1IEGU4-PoASFzgc2GYhIgRzUvZsKdoQWeuLHuTmM,QLxAPfkGis8l5NafNpSCdbxzXhBlu9WL8svcqJw9Mpo,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"');");\r
+ db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('SSK@T8l1IEGU4-PoASFzgc2GYhIgRzUvZsKdoQWeuLHuTmM,QLxAPfkGis8l5NafNpSCdbxzXhBlu9WL8svcqJw9Mpo,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"','Initial Identity');");\r
\r
// TODO remove sometime after 0.1.17\r
FixCapitalBoardNames();\r
db->Execute("UPDATE tblDBVersion SET Major=1, Minor=6;");\r
}\r
\r
+void ConvertDB0106To0107()\r
+{\r
+ // add AddedMethod to tblBoard\r
+ SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+ db->Execute("ALTER TABLE tblBoard ADD COLUMN AddedMethod TEXT;");\r
+ db->Execute("ALTER TABLE tblIdentity ADD COLUMN Hidden BOOL CHECK(Hidden IN('true','false')) DEFAULT 'false';");\r
+ db->Execute("UPDATE tblIdentity SET Hidden='false' WHERE Hidden IS NULL;");\r
+ db->Execute("UPDATE tblDBVersion SET Major=1, Minor=7;");\r
+}\r
+\r
void SetupDefaultOptions()\r
{\r
// 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\r
\r
SQLite3DB::Statement st=db->Prepare("SELECT BoardID,BoardName FROM tblBoard WHERE BoardID NOT IN (SELECT BoardID FROM tblAdministrationBoard);");\r
SQLite3DB::Statement st2=db->Prepare("SELECT BoardID FROM tblBoard WHERE BoardName=?;");\r
- SQLite3DB::Statement del=db->Prepare("DELTE FROM tblBoard WHERE BoardID=?;");\r
+ SQLite3DB::Statement del=db->Prepare("DELETE FROM tblBoard WHERE BoardID=?;");\r
SQLite3DB::Statement upd=db->Prepare("UPDATE tblBoard SET BoardName=? WHERE BoardID=?;");\r
SQLite3DB::Statement upd2=db->Prepare("UPDATE tblMessage SET ReplyBoardID=? WHERE ReplyBoardID=?;");\r
SQLite3DB::Statement upd3=db->Prepare("UPDATE tblMessageBoard SET BoardID=? WHERE BoardID=?;");\r
StringFunctions::LowerCase(boardname,boardname);\r
boarddescription=(*queryvars.find("boarddescription")).second;\r
\r
- SQLite3DB::Statement addst=m_db->Prepare("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES(?,?,?);");\r
+ SQLite3DB::Statement addst=m_db->Prepare("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES(?,?,?,?);");\r
addst.Bind(0,boardname);\r
addst.Bind(1,boarddescription);\r
addst.Bind(2,now.Format("%Y-%m-%d %H:%M:%S"));\r
+ addst.Bind(3,"Added manually");\r
addst.Step();\r
}\r
if((*queryvars.find("formaction")).second=="remove0messages")\r
st.Finalize();\r
\r
\r
- sql="SELECT BoardID,BoardName,BoardDescription,SaveReceivedMessages FROM tblBoard WHERE BoardID NOT IN (SELECT BoardID FROM tblAdministrationBoard)";\r
+ sql="SELECT BoardID,BoardName,BoardDescription,SaveReceivedMessages,AddedMethod FROM tblBoard WHERE BoardID NOT IN (SELECT BoardID FROM tblAdministrationBoard)";\r
if(boardsearch!="")\r
{\r
sql+=" AND (BoardName LIKE '%' || ? || '%' OR BoardDescription LIKE '%' || ? || '%')";\r
content+="<td><form name=\"frmaddboard\" method=\"POST\"><input type=\"hidden\" name=\"formaction\" value=\"addboard\"><input type=\"text\" name=\"boardname\"></td><td><input type=\"text\" name=\"boarddescription\" size=\"40\" maxlength=\"50\"></td><td><input type=\"submit\" value=\"Add Board\"></form></td>";\r
content+="</tr>";\r
\r
- content+="<tr><td colspan=\"3\"><hr><form name=\"frmboards\" method=\"POST\"><input type=\"hidden\" name=\"formaction\" value=\"update\"></td></tr>";\r
+ content+="<tr><td colspan=\"4\"><hr><form name=\"frmboards\" method=\"POST\"><input type=\"hidden\" name=\"formaction\" value=\"update\"></td></tr>";\r
content+="<tr>";\r
- content+="<th>Name</th><th>Description</th><th>Save Received Messages *</th>";\r
+ content+="<th>Name</th><th>Description</th><th>Save Received Messages *</th><th>Added Method</th>";\r
content+="</tr>"; \r
while(st.RowReturned() && rownum<rowsperpage)\r
{\r
std::string boardname="";\r
std::string boarddescription="";\r
std::string savereceivedmessages="";\r
+ std::string addedmethod="";\r
\r
st.ResultText(0,boardidstr);\r
st.ResultText(1,boardname);\r
st.ResultText(2,boarddescription);\r
st.ResultText(3,savereceivedmessages);\r
+ st.ResultText(4,addedmethod);\r
\r
StringFunctions::Convert(rownum,rownumstr);\r
\r
}\r
content+=">";\r
content+="</td>";\r
+ content+="<td class=\"smaller\">"+SanitizeOutput(addedmethod)+"</td>";\r
content+="</tr>\r\n";\r
st.Step();\r
rownum++;\r
}\r
if(startrow+rowsperpage<boardcount)\r
{\r
- while(cols<2)\r
+ while(cols<3)\r
{\r
content+="<td></td>";\r
cols++;\r
}\r
\r
content+="<tr>";\r
- content+="<td colspan=\"3\"><center><input type=\"submit\" value=\"Update\"></center></form></td>";\r
+ content+="<td colspan=\"4\"><center><input type=\"submit\" value=\"Update\"></center></form></td>";\r
content+="</tr>";\r
content+="</table>";\r
content+="<p class=\"paragraph\">";\r
\r
if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="create")\r
{\r
- SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name,PublishTrustList,DateCreated) VALUES(?,'true',?);");\r
+ SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name,PublishTrustList,DateCreated) VALUES(?,'false',?);");\r
std::string name="";\r
DateTime date;\r
date.SetToGMTime();\r
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
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
{\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
\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
std::string addedmethod="";\r
std::string usk="";\r
std::string fcphost="";\r
+ std::string hidden="";\r
\r
if(queryvars.find("identityid")!=queryvars.end() && (*queryvars.find("identityid")).second!="")\r
{\r
del.Step();\r
}\r
\r
+ if(identityid!=0 && queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="hide")\r
+ {\r
+ SQLite3DB::Statement del=m_db->Prepare("UPDATE tblIdentity SET Hidden='true' WHERE IdentityID=?;");\r
+ del.Bind(0,identityid);\r
+ del.Step();\r
+ }\r
+ \r
+ if(identityid!=0 && queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="show")\r
+ {\r
+ SQLite3DB::Statement del=m_db->Prepare("UPDATE tblIdentity SET Hidden='false' WHERE IdentityID=?;");\r
+ del.Bind(0,identityid);\r
+ del.Step();\r
+ }\r
+\r
Option::Instance()->Get("FCPHost",fcphost);\r
\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen,AddedMethod FROM tblIdentity WHERE IdentityID=?;");\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen,AddedMethod,Hidden FROM tblIdentity WHERE IdentityID=?;");\r
st.Bind(0,identityid);\r
st.Step();\r
\r
st.ResultText(2,dateadded);\r
st.ResultText(3,lastseen);\r
st.ResultText(4,addedmethod);\r
+ st.ResultText(5,hidden);\r
\r
usk=publickey;\r
if(usk.find("SSK@")==0)\r
{\r
usk.erase(0,3);\r
- usk="USK"+usk+"/fms/0/";\r
+ usk="USK"+usk+"fms/0/";\r
}\r
\r
content+="<tr><td>Name</td><td>"+SanitizeOutput(name)+"</td></tr>";\r
content+="<tr><td>Date Added</td><td>"+dateadded+"</td></tr>";\r
content+="<tr><td>Last Seen</td><td>"+lastseen+"</td></tr>";\r
content+="<tr><td>Added Method</td><td class=\"smaller\">"+SanitizeOutput(addedmethod)+"</td></tr>";\r
+ content+="<tr><td>Hidden in Main Peer Trust Page</td>";\r
+ content+="<td>"+hidden;\r
+ content+=" <form name=\"frmhidden\" method=\"POST\">";\r
+ content+="<input type=\"hidden\" name=\"identityid\" value=\""+identityidstr+"\">";\r
+ if(hidden=="false")\r
+ {\r
+ content+="<input type=\"hidden\" name=\"formaction\" value=\"hide\">";\r
+ content+="<input type=\"submit\" value=\"Hide\">";\r
+ }\r
+ else\r
+ {\r
+ content+="<input type=\"hidden\" name=\"formaction\" value=\"show\">";\r
+ content+="<input type=\"submit\" value=\"Show\">";\r
+ }\r
+ content+="</form>";\r
+ content+="</td></tr>";\r
}\r
\r
// get message count posted by this identity\r
st.Bind(0,identityid);\r
st.Step();\r
\r
+ content+="<tr><th colspan=\"5\"><hr></th></tr>";\r
content+="<tr><th colspan=\"5\">";\r
content+="Trust of this identity from other identities";\r
content+="</th></tr>";\r
}\r
\r
content+="<h2>Peer Trust</h2>";\r
- 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.";\r
+ 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.";\r
content+="<div style=\"text-align:center;\">";\r
content+="<form name=\"frmsearch\" method=\"POST\" action=\"peertrust.htm\">";\r
content+="<input type=\"text\" name=\"namesearch\" value=\""+SanitizeOutput(namesearch)+"\">";\r
sql="SELECT COUNT(*) FROM tblIdentity";\r
if(namesearch!="")\r
{\r
- sql+=" WHERE Name LIKE '%' || ? || '%'";\r
+ sql+=" WHERE Name LIKE '%' || ? || '%' AND tblIdentity.Hidden='false'";\r
+ }\r
+ else\r
+ {\r
+ sql+=" WHERE tblIdentity.Hidden='false'"; \r
}\r
sql+=";";\r
SQLite3DB::Statement st=m_db->Prepare(sql);\r
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";\r
if(namesearch!="")\r
{\r
- sql+=" WHERE Name LIKE '%' || ? || '%'";\r
+ sql+=" WHERE (Name LIKE '%' || ? || '%' OR PublicKey LIKE '%' || ? || '%') AND tblIdentity.Hidden='false'";\r
+ }\r
+ else\r
+ {\r
+ sql+=" WHERE tblIdentity.Hidden='false'"; \r
}\r
sql+=" GROUP BY tblIdentity.IdentityID";\r
sql+=" ORDER BY";\r
if(namesearch!="")\r
{\r
st.Bind(0,namesearch);\r
+ st.Bind(1,namesearch);\r
}\r
st.Step();\r
\r