# link dl - For SQLite3 and shttpd - not for FreeBSD\r
IF(CMAKE_COMPILER_IS_GNUCC)\r
IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
- ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
+ ELSE(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
TARGET_LINK_LIBRARIES(fms dl)\r
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
ENDIF(CMAKE_COMPILER_IS_GNUCC)\r
# add -lcompat only for FreeBSD\r
IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
IF(CMAKE_COMPILER_IS_GNUCXX)\r
- ADD_DEFINITIONS(-lcompat)\r
+ TARGET_LINK_LIBRARIES(fms compat)\r
ENDIF(CMAKE_COMPILER_IS_GNUCXX)\r
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
\r
\r
# add -lxnet and -lsocket on solaris\r
IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
- ADD_DEFINITIONS(-lxnet -lsocket)\r
+ TARGET_LINK_LIBRARIES(fms xnet)\r
+ TARGET_LINK_LIBRARIES(fms socket)\r
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
\r
FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 sqlite3_s)\r
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
\r
const bool Load(const long boardid);\r
const bool Load(const std::string &boardname);\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
\r
private:\r
+ void SetDateFromString(const std::string &datestring);\r
+\r
long m_boardid;\r
std::string m_boardname;\r
std::string m_boarddescription;\r
long m_lowmessageid; // lowest id of all message currently in this board\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
};\r
\r
#endif // _board_\r
long m_index;\r
std::vector<std::string> m_boards;\r
};\r
+ struct externalmessage\r
+ {\r
+ externalmessage(const std::string &type, const std::string identity, const std::string &date, const long index, const std::vector<std::string> &boards):m_type(type),m_identity(identity),m_date(date),m_index(index),m_boards(boards) {}\r
+ externalmessage(const std::string &type, const std::string messagekey, const std::string &date, const std::vector<std::string> &boards):m_type(type),m_messagekey(messagekey),m_date(date),m_boards(boards) {}\r
+ std::string m_type;\r
+ std::string m_identity;\r
+ std::string m_messagekey;\r
+ long m_index;\r
+ std::string m_date;\r
+ std::vector<std::string> m_boards;\r
+ };\r
public:\r
MessageListXML();\r
\r
\r
void ClearMessages() { m_messages.clear(); }\r
\r
- void AddMessage(const std::string &date, const long index, const std::vector<std::string> boards);\r
+ void AddMessage(const std::string &date, const long index, const std::vector<std::string> &boards);\r
+ void AddExternalMessage(const std::string &identity, const std::string &date, const long index, const std::vector<std::string> &boards);\r
+ void AddExternalMessage(const std::string &messagekey, const std::string &date, const std::vector<std::string> &boards);\r
\r
const std::vector<message>::size_type MessageCount() { return m_messages.size(); }\r
std::string GetDate(const long index);\r
const long GetIndex(const long index);\r
std::vector<std::string> GetBoards(const long index);\r
\r
+ const std::vector<externalmessage>::size_type ExternalMessageCount() { return m_externalmessages.size(); }\r
+ std::string GetExternalType(const long index);\r
+ std::string GetExternalIdentity(const long index);\r
+ std::string GetExternalMessageKey(const long index);\r
+ const long GetExternalIndex(const long index);\r
+ std::string GetExternalDate(const long index);\r
+ std::vector<std::string> GetExternalBoards(const long index);\r
+\r
private:\r
void Initialize();\r
\r
std::vector<message> m_messages;\r
+ std::vector<externalmessage> m_externalmessages;\r
\r
};\r
\r
//#include <zthread/Thread.h>\r
#include "pthreadwrapper/thread.h"\r
\r
-#define FMS_VERSION "0.1.13"\r
+#define FMS_VERSION "0.1.14"\r
\r
// opens database and creates tables and initial inserts if necessary\r
void SetupDB();\r
void ConvertDB0100To0101();\r
void ConvertDB0101To0103();\r
+void ConvertDB0103To0104();\r
// inserts default options into the database\r
void SetupDefaultOptions();\r
// opens logfile and sets it up\r
// checks vector of boards for any special administration boards - if it finds one true is returned, otherwise false\r
const bool CheckForAdministrationBoard(const std::vector<std::string> &boards);\r
void HandleChangeTrust();\r
+ void StripAdministrationBoards(); // removes administration boards from boards vector\r
\r
long m_messageid;\r
bool m_addnewpostfromidentities;\r
void UpperCase(const std::string &str, std::string &output);\r
\r
/**\r
+ \brief Converts a string to lower case\r
+ \param str string to convert to lower case\r
+ \param[out] string converted to lower case\r
+*/\r
+void LowerCase(const std::string &str, std::string &output);\r
+\r
+/**\r
\brief Decodes a URI encoded string\r
\param aSrc string that is URI encoded\r
\return URI decoded input string\r
m_lowmessageid=0;\r
m_highmessageid=0;\r
m_messagecount=0;\r
+ m_savereceivedmessages=true;\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
+{\r
+ m_boardid=boardid;\r
+ m_boardname=boardname;\r
+ m_boarddescription=boarddescription;\r
+ m_lowmessageid=lowmessageid;\r
+ m_highmessageid=highmessageid;\r
+ m_messagecount=messagecount;\r
+ m_savereceivedmessages=savereceivedmessages;\r
+\r
+ SetDateFromString(datecreated);\r
+\r
+}\r
+\r
+\r
const bool Board::Load(const long boardid)\r
{\r
// clear current values\r
m_highmessageid=0;\r
m_messagecount=0;\r
\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT BoardName, BoardDescription, DateAdded FROM tblBoard WHERE BoardID=?;");\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
st.Bind(0,boardid);\r
st.Step();\r
\r
st.ResultText(1,m_boarddescription);\r
st.ResultText(2,tempstr);\r
\r
- // break out date created - date should be in format yyyy-mm-dd HH:MM:SS, so we split on "-", " " (space), and ":"\r
- StringFunctions::SplitMultiple(tempstr,"- :",dateparts);\r
- if(dateparts.size()>0)\r
- {\r
- StringFunctions::Convert(dateparts[0],tempint);\r
- m_datecreated.SetYear(tempint);\r
- }\r
- if(dateparts.size()>1)\r
- {\r
- StringFunctions::Convert(dateparts[1],tempint);\r
- m_datecreated.SetMonth(tempint);\r
- }\r
- if(dateparts.size()>2)\r
- {\r
- StringFunctions::Convert(dateparts[2],tempint);\r
- m_datecreated.SetDay(tempint);\r
- }\r
- if(dateparts.size()>3)\r
- {\r
- StringFunctions::Convert(dateparts[3],tempint);\r
- m_datecreated.SetHour(tempint);\r
- }\r
- if(dateparts.size()>4)\r
- {\r
- StringFunctions::Convert(dateparts[4],tempint);\r
- m_datecreated.SetMinute(tempint);\r
- }\r
- if(dateparts.size()>5)\r
+ SetDateFromString(tempstr);\r
+\r
+ tempint=0;\r
+ st.ResultInt(3,tempint);\r
+ m_highmessageid=tempint;\r
+ tempint=0;\r
+ st.ResultInt(4,tempint);\r
+ m_lowmessageid=tempint;\r
+ tempint=0;\r
+ st.ResultInt(5,tempint);\r
+ m_messagecount=tempint;\r
+ st.ResultText(6,tempstr);\r
+ if(tempstr=="true")\r
{\r
- StringFunctions::Convert(dateparts[5],tempint);\r
- m_datecreated.SetSecond(tempint);\r
+ m_savereceivedmessages=true;\r
}\r
-\r
- // get max and min ids and message count in this board\r
- SQLite3DB::Statement bounds=m_db->Prepare("SELECT HighMessageID, LowMessageID, MessageCount FROM vwBoardStats WHERE BoardID=?;");\r
- bounds.Bind(0,boardid);\r
- bounds.Step();\r
-\r
- if(bounds.RowReturned())\r
+ else\r
{\r
- int tempint;\r
- bounds.ResultInt(0,tempint);\r
- m_highmessageid=tempint;\r
- bounds.ResultInt(1,tempint);\r
- m_lowmessageid=tempint;\r
- bounds.ResultInt(2,tempint);\r
- m_messagecount=tempint;\r
+ m_savereceivedmessages=false;\r
}\r
\r
return true;\r
return false;\r
}\r
}\r
+\r
+void Board::SetDateFromString(const std::string &datestring)\r
+{\r
+ // break out date created - date should be in format yyyy-mm-dd HH:MM:SS, so we split on "-", " " (space), and ":"\r
+ int tempint=0;\r
+ std::vector<std::string> dateparts;\r
+ StringFunctions::SplitMultiple(datestring,"- :",dateparts);\r
+ if(dateparts.size()>0)\r
+ {\r
+ StringFunctions::Convert(dateparts[0],tempint);\r
+ m_datecreated.SetYear(tempint);\r
+ }\r
+ if(dateparts.size()>1)\r
+ {\r
+ StringFunctions::Convert(dateparts[1],tempint);\r
+ m_datecreated.SetMonth(tempint);\r
+ }\r
+ if(dateparts.size()>2)\r
+ {\r
+ StringFunctions::Convert(dateparts[2],tempint);\r
+ m_datecreated.SetDay(tempint);\r
+ }\r
+ if(dateparts.size()>3)\r
+ {\r
+ StringFunctions::Convert(dateparts[3],tempint);\r
+ m_datecreated.SetHour(tempint);\r
+ }\r
+ if(dateparts.size()>4)\r
+ {\r
+ StringFunctions::Convert(dateparts[4],tempint);\r
+ m_datecreated.SetMinute(tempint);\r
+ }\r
+ if(dateparts.size()>5)\r
+ {\r
+ StringFunctions::Convert(dateparts[5],tempint);\r
+ m_datecreated.SetSecond(tempint);\r
+ }\r
+}\r
{\r
clear();\r
\r
- int tempint;\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT BoardID FROM tblBoard ORDER BY BoardName;");\r
+ int boardid=0;\r
+ std::string boardname="";\r
+ std::string boarddescription="";\r
+ std::string dateadded="";\r
+ std::string savereceivedstr="";\r
+ bool savereceived=false;\r
+ int highmessageid=0;\r
+ int lowmessageid=0;\r
+ int messagecount=0;\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
st.Step();\r
\r
while(st.RowReturned())\r
{\r
- st.ResultInt(0,tempint);\r
- push_back(Board(tempint));\r
+ st.ResultInt(0,boardid);\r
+ st.ResultText(1,boardname);\r
+ st.ResultText(2,boarddescription);\r
+ st.ResultText(3,dateadded);\r
+ st.ResultInt(4,highmessageid);\r
+ st.ResultInt(5,lowmessageid);\r
+ st.ResultInt(6,messagecount);\r
+ st.ResultText(7,savereceivedstr);\r
+\r
+ if(savereceivedstr=="true")\r
+ {\r
+ savereceived=true;\r
+ } \r
+ else\r
+ {\r
+ savereceived=false;\r
+ }\r
+\r
+ push_back(Board(boardid,boardname,boarddescription,dateadded,lowmessageid,highmessageid,messagecount,savereceived));\r
st.Step();\r
}\r
}\r
{\r
if(name!="" && description!="")\r
{\r
- m_boards.push_back(board(name,description));\r
+ std::string lowername=name;\r
+ StringFunctions::Convert(lowername,lowername);\r
+ m_boards.push_back(board(lowername,description));\r
}\r
}\r
\r
if(txt)\r
{\r
name=txt->ValueStr();\r
+ StringFunctions::LowerCase(name,name);\r
}\r
txt=hnd2.FirstChild("Description").FirstChild().ToText();\r
if(txt)\r
}\r
st.Finalize();\r
\r
+\r
+ st=m_db->Prepare("SELECT MessageDate, MessageIndex, PublicKey, MessageID FROM tblMessage INNER JOIN tblIdentity ON tblMessage.IdentityID=tblIdentity.IdentityID WHERE MessageIndex IS NOT NULL ORDER BY MessageDate DESC, MessageTime DESC LIMIT 100;");\r
+ SQLite3DB::Statement st2=m_db->Prepare("SELECT BoardName FROM tblBoard INNER JOIN tblMessageBoard ON tblBoard.BoardID=tblMessageBoard.BoardID WHERE tblMessageBoard.MessageID=?;");\r
+ st.Step();\r
+ while(st.RowReturned())\r
+ {\r
+ std::string day;\r
+ int index;\r
+ std::string publickey;\r
+ std::vector<std::string> boardlist;\r
+ int messageid;\r
+ \r
+ st.ResultText(0,day);\r
+ st.ResultInt(1,index);\r
+ st.ResultText(2,publickey);\r
+ st.ResultInt(3,messageid);\r
+\r
+ st2.Bind(0,messageid);\r
+ st2.Step();\r
+ while(st2.RowReturned())\r
+ {\r
+ std::string boardname="";\r
+ st2.ResultText(0,boardname);\r
+ StringFunctions::LowerCase(boardname,boardname);\r
+ boardlist.push_back(boardname);\r
+ st2.Step();\r
+ }\r
+ st2.Reset();\r
+\r
+ mlxml.AddExternalMessage(publickey,day,index,boardlist);\r
+\r
+ st.Step();\r
+ }\r
+\r
// get last inserted messagelist index for this day\r
index=0;\r
st=m_db->Prepare("SELECT MAX(InsertIndex) FROM tblMessageListInserts WHERE LocalIdentityID=? AND Day=?;");\r
{\r
\r
SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblMessageRequests WHERE IdentityID=? AND Day=? AND RequestIndex=?;");\r
+ SQLite3DB::Statement spk=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey=?;");\r
SQLite3DB::Statement mst=m_db->Prepare("INSERT INTO tblMessageRequests(IdentityID,Day,RequestIndex,FromMessageList) VALUES(?,?,?,'true');");\r
for(long i=0; i<xml.MessageCount(); i++)\r
{\r
}\r
st.Reset();\r
}\r
- mst.Finalize();\r
- st.Finalize();\r
+\r
+ // insert external message indexes\r
+ for(long i=0; i<xml.ExternalMessageCount(); i++)\r
+ {\r
+ spk.Bind(0,xml.GetExternalIdentity(i));\r
+ spk.Step();\r
+ if(spk.RowReturned())\r
+ {\r
+ int thisidentityid=0;\r
+ spk.ResultInt(0,thisidentityid);\r
+ mst.Bind(0,thisidentityid);\r
+ mst.Bind(1,xml.GetExternalDate(i));\r
+ mst.Bind(2,xml.GetExternalIndex(i));\r
+ mst.Step();\r
+ mst.Reset();\r
+ }\r
+ spk.Reset();\r
+ }\r
\r
st=m_db->Prepare("INSERT INTO tblMessageListRequests(IdentityID,Day,RequestIndex,Found) VALUES(?,?,?,'true');");\r
st.Bind(0,identityid);\r
Initialize();\r
}\r
\r
-void MessageListXML::AddMessage(const std::string &date, const long index, const std::vector<std::string> boards)\r
+void MessageListXML::AddMessage(const std::string &date, const long index, const std::vector<std::string> &boards)\r
{\r
m_messages.push_back(message(date,index,boards));\r
}\r
\r
+void MessageListXML::AddExternalMessage(const std::string &identity, const std::string &date, const long index, const std::vector<std::string> &boards)\r
+{\r
+ m_externalmessages.push_back(externalmessage("Keyed",identity,date,index,boards));\r
+}\r
+\r
+void MessageListXML::AddExternalMessage(const std::string &messagekey, const std::string &date, const std::vector<std::string> &boards)\r
+{\r
+ m_externalmessages.push_back(externalmessage("Anonymous",messagekey,date,boards));\r
+}\r
+\r
std::vector<std::string> MessageListXML::GetBoards(const long index)\r
{\r
if(index>=0 && index<m_messages.size())\r
}\r
}\r
\r
+std::vector<std::string> MessageListXML::GetExternalBoards(const long index)\r
+{\r
+ if(index>=0 && index<m_externalmessages.size())\r
+ {\r
+ return m_externalmessages[index].m_boards;\r
+ }\r
+ else\r
+ {\r
+ return std::vector<std::string>();\r
+ }\r
+}\r
+\r
+std::string MessageListXML::GetExternalDate(const long index)\r
+{\r
+ if(index>=0 && index<m_externalmessages.size())\r
+ {\r
+ return m_externalmessages[index].m_date;\r
+ }\r
+ else\r
+ {\r
+ return "";\r
+ }\r
+}\r
+\r
+std::string MessageListXML::GetExternalIdentity(const long index)\r
+{\r
+ if(index>=0 && index<m_externalmessages.size())\r
+ {\r
+ return m_externalmessages[index].m_identity;\r
+ }\r
+ else\r
+ {\r
+ return "";\r
+ }\r
+}\r
+\r
+const long MessageListXML::GetExternalIndex(const long index)\r
+{\r
+ if(index>=0 && index<m_externalmessages.size())\r
+ {\r
+ return m_externalmessages[index].m_index;\r
+ }\r
+ else\r
+ {\r
+ return-1;\r
+ }\r
+}\r
+\r
+std::string MessageListXML::GetExternalMessageKey(const long index)\r
+{\r
+ if(index>=0 && index<m_externalmessages.size())\r
+ {\r
+ return m_externalmessages[index].m_messagekey;\r
+ }\r
+ else\r
+ {\r
+ return "";\r
+ }\r
+}\r
+\r
+std::string MessageListXML::GetExternalType(const long index)\r
+{\r
+ if(index>=0 && index<m_externalmessages.size())\r
+ {\r
+ return m_externalmessages[index].m_type;\r
+ }\r
+ else\r
+ {\r
+ return "";\r
+ }\r
+}\r
+\r
const long MessageListXML::GetIndex(const long index)\r
{\r
if(index>=0 && index<m_messages.size())\r
}\r
}\r
\r
+ for(std::vector<externalmessage>::iterator i=m_externalmessages.begin(); i!=m_externalmessages.end(); i++)\r
+ {\r
+ TiXmlElement *tr=new TiXmlElement("ExternalMessage");\r
+ tid->LinkEndChild(tr);\r
+ tr->LinkEndChild(XMLCreateTextElement("Type",(*i).m_type));\r
+ if((*i).m_type=="Keyed")\r
+ {\r
+ tr->LinkEndChild(XMLCreateCDATAElement("Identity",(*i).m_identity));\r
+ tr->LinkEndChild(XMLCreateTextElement("Index",(*i).m_index));\r
+ }\r
+ else\r
+ {\r
+ tr->LinkEndChild(XMLCreateCDATAElement("MessageKey",(*i).m_messagekey));\r
+ }\r
+ tr->LinkEndChild(XMLCreateTextElement("Date",(*i).m_date));\r
+ TiXmlElement *brds=new TiXmlElement("Boards");\r
+ tr->LinkEndChild(brds);\r
+ for(std::vector<std::string>::iterator j=(*i).m_boards.begin(); j!=(*i).m_boards.end(); j++)\r
+ {\r
+ brds->LinkEndChild(XMLCreateCDATAElement("Board",(*j)));\r
+ }\r
+ }\r
+\r
td.Accept(&tp);\r
return std::string(tp.CStr());\r
}\r
void MessageListXML::Initialize()\r
{\r
m_messages.clear();\r
+ m_externalmessages.clear();\r
}\r
\r
const bool MessageListXML::ParseXML(const std::string &xml)\r
\r
if(validmessage && savetoboardcount>0)\r
{\r
- st=m_db->Prepare("INSERT INTO tblMessage(IdentityID,FromName,MessageDate,MessageTime,Subject,MessageUUID,ReplyBoardID,Body) VALUES(?,?,?,?,?,?,?,?);");\r
+ st=m_db->Prepare("INSERT INTO tblMessage(IdentityID,FromName,MessageDate,MessageTime,Subject,MessageUUID,ReplyBoardID,Body,MessageIndex) VALUES(?,?,?,?,?,?,?,?,?);");\r
st.Bind(0,identityid);\r
st.Bind(1,GetIdentityName(identityid));\r
st.Bind(2,xml.GetDate());\r
st.Bind(5,xml.GetMessageID());\r
st.Bind(6,GetBoardID(xml.GetReplyBoard()));\r
st.Bind(7,xml.GetBody());\r
+ st.Bind(8,index);\r
inserted=st.Step(true);\r
int messageid=st.GetLastInsertRowID();\r
\r
{\r
if(node2->FirstChild())\r
{\r
- m_boards.push_back(node2->FirstChild()->ValueStr());\r
+ std::string boardname=node2->FirstChild()->ValueStr();\r
+ StringFunctions::LowerCase(boardname,boardname);\r
+ m_boards.push_back(boardname);\r
}\r
node2=node2->NextSibling("Board");\r
}\r
st.Step();\r
}\r
\r
+ // delete single use identities that are older than 7 days\r
+ date.SetToGMTime();\r
+ date.Add(0,0,0,-7);\r
+ st=m_db->Prepare("DELETE FROM tblIdentity WHERE SingleUse='true' AND DateAdded<?;");\r
+ st.Bind(0,date.Format("%Y-%m-%d %H:%M:%S"));\r
+ st.Step();\r
+\r
+ // delete local single use identities that are older than 7 days\r
+ date.SetToGMTime();\r
+ date.Add(0,0,0,-7);\r
+ st=m_db->Prepare("DELETE FROM tblLocalIdentity WHERE SingleUse='true' AND DateCreated<?;");\r
+ st.Bind(0,date.Format("%Y-%m-%d %H:%M:%S"));\r
+ st.Step();\r
+\r
}\r
\r
void PeriodicDBMaintenance::Process()\r
major=1;\r
minor=3;\r
}\r
+ if(major==1 && minor==3)\r
+ {\r
+ ConvertDB0103To0104();\r
+ major=1;\r
+ minor=4;\r
+ }\r
}\r
else\r
{\r
- db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,1);");\r
+ db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,4);");\r
}\r
\r
- db->Execute("UPDATE tblDBVersion SET Major=1, Minor=3;");\r
+ db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\\r
Option TEXT UNIQUE,\\r
InsertingBoardList BOOL CHECK(InsertingBoardList IN('true','false')) DEFAULT 'false',\\r
LastInsertedBoardList DATETIME,\\r
InsertingMessageList BOOL CHECK(InsertingMessageList IN('true','false')) DEFAULT 'false',\\r
- LastInsertedMessageList DATETIME\\r
+ LastInsertedMessageList DATETIME,\\r
+ DateCreated DATETIME\\r
);");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblLocalIdentityInserts(\\r
Subject TEXT,\\r
MessageUUID TEXT UNIQUE,\\r
ReplyBoardID INTEGER,\\r
- Body TEXT\\r
+ Body TEXT,\\r
+ MessageIndex INTEGER\\r
);");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblMessageReplyTo(\\r
Found BOOL CHECK(Found IN('true','false')) DEFAULT 'false'\\r
);");\r
\r
+ db->Execute("CREATE UNIQUE INDEX IF NOT EXISTS idxMessageRequest ON tblMessageRequests(IdentityID,Day,RequestIndex);");\r
+\r
db->Execute("CREATE TABLE IF NOT EXISTS tblMessageInserts(\\r
LocalIdentityID INTEGER,\\r
Day DATE,\\r
db->Execute("UPDATE tblDBVersion SET Major=1, Minor=3;");\r
}\r
\r
+void ConvertDB0103To0104()\r
+{\r
+ // add MessageIndex to tblMessage\r
+ DateTime date;\r
+ SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+ db->Execute("ALTER TABLE tblMessage ADD COLUMN MessageIndex INTEGER;");\r
+ db->Execute("CREATE UNIQUE INDEX IF NOT EXISTS idxMessageRequest ON tblMessageRequests(IdentityID,Day,RequestIndex);");\r
+ db->Execute("ALTER TABLE tblLocalIdentity ADD COLUMN DateCreated DATETIME;");\r
+ date.SetToGMTime();\r
+ db->Execute("UPDATE tblLocalIdentity SET DateCreated='"+date.Format("%Y-%m-%d %H:%M:%S")+"' WHERE DateCreated IS NULL;");\r
+ db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;");\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
content+="<tr><td colspan=\"3\"><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>";\r
content+="</tr>"; \r
while(st.RowReturned() && rownum<rowsperpage)\r
{\r
content+="<td colspan=\"3\"><center><input type=\"submit\" value=\"Update\"></center></form></td>";\r
content+="</tr>";\r
content+="</table>";\r
+ content+="<p class=\"paragraph\">";\r
+ content+="* If you uncheck this box, any new messages you download that are posted to this board will be discarded.";\r
+ content+="</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
}\r
#include "../../../include/http/pages/createidentitypage.h"\r
#include "../../../include/stringfunctions.h"\r
+#include "../../../include/datetime.h"\r
\r
#ifdef XMEM\r
#include <xmem.h>\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) VALUES(?,'true');");\r
+ SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name,PublishTrustList,DateCreated) VALUES(?,'true',?);");\r
std::string name="";\r
+ DateTime date;\r
+ date.SetToGMTime();\r
\r
if(queryvars.find("name")!=queryvars.end())\r
{\r
}\r
\r
st.Bind(0,name);\r
+ st.Bind(1,date.Format("%Y-%m-%d %H:%M:%S"));\r
st.Step();\r
\r
content+="<h2>Created Identity</h2>";\r
{\r
std::string content="";\r
int identityid=0;\r
+ std::string identityidstr="";\r
std::string name;\r
std::string publickey;\r
std::string messagetrust;\r
std::string trustlisttrust;\r
std::string keypart="";\r
std::string lastseen="";\r
+ std::string dateadded="";\r
\r
if(queryvars.find("identityid")!=queryvars.end() && (*queryvars.find("identityid")).second!="")\r
{\r
+ identityidstr=(*queryvars.find("identityid")).second;\r
StringFunctions::Convert((*queryvars.find("identityid")).second,identityid);\r
}\r
\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,LastSeen FROM tblIdentity WHERE IdentityID=?;");\r
+ if(identityid!=0 && queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="deletemessages")\r
+ {\r
+ SQLite3DB::Statement del=m_db->Prepare("DELETE FROM tblMessage WHERE IdentityID=?;");\r
+ del.Bind(0,identityid);\r
+ del.Step();\r
+ }\r
+\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen FROM tblIdentity WHERE IdentityID=?;");\r
st.Bind(0,identityid);\r
st.Step();\r
\r
+ content+="<table>";\r
if(st.RowReturned())\r
{\r
st.ResultText(0,name);\r
st.ResultText(1,publickey);\r
- st.ResultText(2,lastseen);\r
+ st.ResultText(2,dateadded);\r
+ st.ResultText(3,lastseen);\r
\r
- content+="<table>";\r
content+="<tr><td>Name</td><td>"+SanitizeOutput(name)+"</td></tr>";\r
- content+="<tr><td>Public Key</td><td>"+SanitizeOutput(publickey)+"</td></tr>";\r
+ content+="<tr><td>Public Key</td><td class=\"smaller\">"+SanitizeOutput(publickey)+"</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+="</table>";\r
}\r
\r
+ // get message count posted by this identity\r
+ st=m_db->Prepare("SELECT COUNT(MessageID) FROM tblMessage WHERE IdentityID=?;");\r
+ st.Bind(0,identityid);\r
+ st.Step();\r
+\r
+ if(st.RowReturned())\r
+ {\r
+ std::string messagecountstr="0";\r
+ st.ResultText(0,messagecountstr);\r
+ content+="<tr>";\r
+ content+="<td>Message Count</td>";\r
+ content+="<td>"+messagecountstr;\r
+ content+=" <form name=\"frmdeletemessages\" method=\"POST\">";\r
+ content+="<input type=\"hidden\" name=\"identityid\" value=\""+identityidstr+"\">";\r
+ content+="<input type=\"hidden\" name=\"formaction\" value=\"deletemessages\">";\r
+ content+="<input type=\"submit\" value=\"Delete Messages\">";\r
+ content+="</form>";\r
+ content+="</td>";\r
+ content+="</tr>";\r
+ }\r
+\r
+ content+="</table>";\r
+\r
+\r
st=m_db->Prepare("SELECT Name,PublicKey,MessageTrust,TrustListTrust,tblIdentity.IdentityID FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.TargetIdentityID=tblIdentity.IdentityID WHERE tblPeerTrust.IdentityID=? ORDER BY Name COLLATE NOCASE;");\r
st.Bind(0,identityid);\r
st.Step();\r
xml.SetDate(m_datetime.Format("%Y-%m-%d"));\r
xml.SetTime(m_datetime.Format("%H:%M:%S"));\r
\r
+ StripAdministrationBoards();\r
for(std::vector<std::string>::iterator i=m_boards.begin(); i!=m_boards.end(); i++)\r
{\r
xml.AddBoard((*i));\r
return true;\r
\r
}\r
+\r
+void Message::StripAdministrationBoards()\r
+{\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT tblBoard.BoardID FROM tblBoard INNER JOIN tblAdministrationBoard ON tblBoard.BoardID=tblAdministrationBoard.BoardID WHERE BoardName=?;");\r
+ for(std::vector<std::string>::iterator i=m_boards.begin(); i!=m_boards.end(); )\r
+ {\r
+ st.Bind(0,(*i));\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ i=m_boards.erase(i);\r
+ }\r
+ else\r
+ {\r
+ i++;\r
+ }\r
+ st.Reset();\r
+ }\r
+}\r
show=uwildmat((*i).GetBoardName().c_str(),arg2.c_str());\r
}\r
\r
- if(show==true)\r
+ if(show==true && (*i).GetSaveReceivedMessages()==true)\r
{\r
tempstr << (*i).GetBoardName() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << (m_status.m_allowpost ? "y" : "n");\r
SendBufferedLine(tempstr.str());\r
show=uwildmat((*i).GetBoardName().c_str(),arg2.c_str());\r
}\r
\r
- if(show==true)\r
+ if(show==true && (*i).GetSaveReceivedMessages()==true)\r
{\r
tempstr << (*i).GetBoardName() << "\t" << (*i).GetBoardDescription();\r
SendBufferedLine(tempstr.str());\r
\r
for(BoardList::iterator i=bl.begin(); i!=bl.end(); i++)\r
{\r
- std::ostringstream tempstr;\r
- tempstr << (*i).GetBoardName() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << m_status.m_allowpost ? "y" : "n";\r
- SendBufferedLine(tempstr.str());\r
+ if((*i).GetSaveReceivedMessages()==true)\r
+ {\r
+ std::ostringstream tempstr;\r
+ tempstr << (*i).GetBoardName() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << m_status.m_allowpost ? "y" : "n";\r
+ SendBufferedLine(tempstr.str());\r
+ }\r
}\r
\r
SendBufferedLine(".");\r
{\r
mess.HandleAdministrationMessage();\r
}\r
+ if(mess.StartFreenetInsert())\r
+ {\r
+ SendBufferedLine("240 Article received OK");\r
+ }\r
else\r
{\r
- if(mess.StartFreenetInsert())\r
- {\r
- SendBufferedLine("240 Article received OK");\r
- }\r
- else\r
- {\r
- SendBufferedLine("441 Posting failed. Make sure the identity you are sending with exists!");\r
- }\r
+ SendBufferedLine("441 Posting failed. Make sure the identity you are sending with exists!");\r
}\r
}\r
else\r
namespace StringFunctions\r
{\r
\r
+void LowerCase(const std::string &str, std::string &output)\r
+{\r
+ output=str;\r
+ std::transform(str.begin(),str.end(),output.begin(),tolower);\r
+}\r
+\r
std::string Replace(const std::string &input, const std::string &find, const std::string &replace)\r
{\r
std::string returnstr=input;\r