src/http/ipagehandler.cpp\r
src/http/pages/addpeerpage.cpp\r
src/http/pages/announceidentitypage.cpp\r
+src/http/pages/boardspage.cpp\r
src/http/pages/controlboardpage.cpp\r
src/http/pages/createidentitypage.cpp\r
src/http/pages/execquerypage.cpp\r
\r
ADD_EXECUTABLE(fms ${FMS_SRC} ${FMS_PLATFORM_SRC})\r
\r
-# For SQLite3 and shttpd\r
+# link dl - For SQLite3 and shttpd - not for FreeBSD\r
IF(CMAKE_COMPILER_IS_GNUCC)\r
- TARGET_LINK_LIBRARIES(fms dl)\r
+ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
+ ELSEIF(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
\r
+# add -lcompat only for FreeBSD\r
+IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
+ IF(CMAKE_COMPILER_IS_GNUCXX)\r
+ ADD_DEFINITIONS(-lcompat)\r
+ ENDIF(CMAKE_COMPILER_IS_GNUCXX)\r
+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
+\r
+# link ws2_32 for Windows\r
IF(WIN32)\r
TARGET_LINK_LIBRARIES(fms ws2_32)\r
ENDIF(WIN32)\r
\r
+# add -lxnet and -lsocket on solaris\r
+IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
+ ADD_DEFINITIONS(-lxnet -lsocket)\r
+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
+\r
FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 sqlite3_s)\r
FIND_LIBRARY(TINYXML_LIBRARY NAMES tinyxml tinyxml_s)\r
FIND_LIBRARY(PTHREADS_LIBRARY NAMES pthread pthreads pthreadvc2)\r
const bool HandleGetFailed(FCPMessage &message);\r
\r
const long GetBoardID(const std::string &boardname);\r
+ const bool SaveToBoard(const std::string &boardname);\r
const std::string GetIdentityName(const long identityid);\r
\r
long m_maxdaysbackward;\r
\r
#include <vector>\r
\r
+// trust of -1 will mean NULL trust\r
class TrustListXML:public IFMSXMLDocument,public ILogger\r
{\r
private:\r
//#include <zthread/Thread.h>\r
#include "pthreadwrapper/thread.h"\r
\r
-#define FMS_VERSION "0.1.12"\r
+#define FMS_VERSION "0.1.13"\r
\r
// opens database and creates tables and initial inserts if necessary\r
void SetupDB();\r
void ConvertDB0100To0101();\r
+void ConvertDB0101To0103();\r
// inserts default options into the database\r
void SetupDefaultOptions();\r
// opens logfile and sets it up\r
--- /dev/null
+#ifndef _boardspage_\r
+#define _boardspage_\r
+\r
+#include "../ipagehandler.h"\r
+#include "../../idatabase.h"\r
+\r
+class BoardsPage:public IPageHandler,public IDatabase\r
+{\r
+public:\r
+ BoardsPage(const std::string &templatestr):IPageHandler(templatestr) {}\r
+ \r
+private:\r
+ const bool WillHandleURI(const std::string &uri);\r
+ const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars);\r
+ \r
+ const std::string BuildQueryString(const long startrow, const std::string &boardsearch);\r
+\r
+};\r
+\r
+#endif // _boardspage_\r
\r
const bool PostedToAdministrationBoard() { return CheckForAdministrationBoard(m_boards); }\r
\r
- void StartFreenetInsert();\r
+ const bool StartFreenetInsert();\r
void HandleAdministrationMessage();\r
\r
private:\r
void HandleChangeTrust();\r
\r
long m_messageid;\r
+ bool m_addnewpostfromidentities;\r
std::string m_messageuuid;\r
std::string m_subject;\r
std::string m_body;\r
DateTime today;\r
today.SetToGMTime();\r
\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+today.Format("%Y-%m-%d")+"' AND LocalMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalMessageTrust') AND PublishBoardList='true' ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+today.Format("%Y-%m-%d")+"' AND (LocalMessageTrust IS NULL OR LocalMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalMessageTrust')) AND (PeerMessageTrust IS NULL OR PeerMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerMessageTrust')) AND PublishBoardList='true' ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
st.Step();\r
\r
m_ids.clear();\r
IntroductionPuzzleXML xml;\r
long identityid;\r
long index;\r
+ bool validmessage=true;\r
\r
now.SetToGMTime();\r
StringFunctions::Split(message["Identifier"],"|",idparts);\r
if(xml.ParseXML(std::string(data.begin(),data.end()))==true)\r
{\r
\r
- // TODO - check if last part of UUID matches public key of identity who inserted it\r
+ // check if last part of UUID matches first part of public key of identity who inserted it\r
+ st=m_db->Prepare("SELECT PublicKey FROM tblIdentity WHERE IdentityID=?;");\r
+ st.Bind(0,identityid);\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ std::vector<std::string> uuidparts;\r
+ std::vector<std::string> keyparts;\r
+ std::string keypart="";\r
+ std::string publickey="";\r
+\r
+ st.ResultText(0,publickey);\r
+\r
+ StringFunctions::SplitMultiple(publickey,"@,",keyparts);\r
+ StringFunctions::SplitMultiple(xml.GetUUID(),"@",uuidparts);\r
+\r
+ if(uuidparts.size()>1 && keyparts.size()>1)\r
+ {\r
+ keypart=StringFunctions::Replace(StringFunctions::Replace(keyparts[1],"-",""),"~","");\r
+ if(keypart!=uuidparts[1])\r
+ {\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData UUID in IntroductionPuzzle doesn't match public key of identity : "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData Error with identity's public key or UUID : "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
+\r
+ }\r
+ else\r
+ {\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData Error couldn't find identity : "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
\r
st=m_db->Prepare("INSERT INTO tblIntroductionPuzzleRequests(IdentityID,Day,RequestIndex,Found,UUID,Type,MimeType,PuzzleData) VALUES(?,?,?,?,?,?,?,?);");\r
st.Bind(0,identityid);\r
st.Bind(1,idparts[4]);\r
st.Bind(2,index);\r
- st.Bind(3,"true");\r
- st.Bind(4,xml.GetUUID());\r
- st.Bind(5,xml.GetType());\r
- st.Bind(6,xml.GetMimeType());\r
- st.Bind(7,xml.GetPuzzleData());\r
+ if(validmessage)\r
+ {\r
+ st.Bind(3,"true");\r
+ st.Bind(4,xml.GetUUID());\r
+ st.Bind(5,xml.GetType());\r
+ st.Bind(6,xml.GetMimeType());\r
+ st.Bind(7,xml.GetPuzzleData());\r
+ }\r
+ else\r
+ {\r
+ st.Bind(3,"false");\r
+ st.Bind(4);\r
+ st.Bind(5);\r
+ st.Bind(6);\r
+ st.Bind(7);\r
+ }\r
st.Step();\r
st.Finalize();\r
\r
date.SetToGMTime();\r
\r
// select identities we want to query (we've seen them today) - sort by their trust level (descending) with secondary sort on how long ago we saw them (ascending)\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+date.Format("%Y-%m-%d")+"' AND LocalMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalMessageTrust') ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+date.Format("%Y-%m-%d")+"' AND (LocalMessageTrust IS NULL OR LocalMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalMessageTrust')) AND (PeerMessageTrust IS NULL OR PeerMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerMessageTrust')) ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
st.Step();\r
\r
m_ids.clear();\r
long identityid;\r
long index;\r
bool inserted=false;\r
+ bool validmessage=true;\r
+ long savetoboardcount=0;\r
\r
StringFunctions::Split(message["Identifier"],"|",idparts);\r
StringFunctions::Convert(message["DataLength"],datalength);\r
if(xml.ParseXML(std::string(data.begin(),data.end()))==true)\r
{\r
std::vector<std::string> boards=xml.GetBoards();\r
+ std::map<long,std::string> replyto=xml.GetInReplyTo();\r
+\r
if(boards.size()>m_maxboardspermessage)\r
{\r
boards.resize(m_maxboardspermessage);\r
m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"MessageRequester::HandleAllData Message XML did not contain a reply board! "+message["Identifier"]);\r
return true;\r
}\r
- \r
- // make sure the reply board is on the board list - if not, replace the last element of boardswith the reply board\r
+\r
+ // make sure the reply board is on the board list we are saving - if not, replace the last element of boards with the reply board\r
if(xml.GetReplyBoard()!="" && std::find(boards.begin(),boards.end(),xml.GetReplyBoard())==boards.end() && boards.size()>0)\r
{\r
boards[boards.size()-1]=xml.GetReplyBoard();\r
}\r
\r
- // TODO make sure domain of message id match 43 characters of public key of identity (remove - and ~) - if not, discard message\r
+ // make sure domain of message id match 43 characters of public key of identity (remove - and ~) - if not, discard message\r
// implement after 0.1.12 is released\r
-\r
- st=m_db->Prepare("INSERT INTO tblMessage(IdentityID,FromName,MessageDate,MessageTime,Subject,MessageUUID,ReplyBoardID,Body) VALUES(?,?,?,?,?,?,?,?);");\r
+ st=m_db->Prepare("SELECT PublicKey FROM tblIdentity WHERE IdentityID=?;");\r
st.Bind(0,identityid);\r
- st.Bind(1,GetIdentityName(identityid));\r
- st.Bind(2,xml.GetDate());\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(7,xml.GetBody());\r
- inserted=st.Step(true);\r
- int messageid=st.GetLastInsertRowID();\r
-\r
- if(inserted==true)\r
+ st.Step();\r
+ if(st.RowReturned())\r
{\r
+ std::vector<std::string> uuidparts;\r
+ std::vector<std::string> keyparts;\r
+ std::string keypart="";\r
+ std::string publickey="";\r
\r
- st=m_db->Prepare("INSERT INTO tblMessageBoard(MessageID,BoardID) VALUES(?,?);");\r
- for(std::vector<std::string>::iterator i=boards.begin(); i!=boards.end(); i++)\r
+ st.ResultText(0,publickey);\r
+\r
+ StringFunctions::SplitMultiple(publickey,"@,",keyparts);\r
+ StringFunctions::SplitMultiple(xml.GetMessageID(),"@",uuidparts);\r
+\r
+ if(uuidparts.size()>1 && keyparts.size()>1)\r
{\r
- st.Bind(0,messageid);\r
- st.Bind(1,GetBoardID((*i)));\r
- st.Step();\r
- st.Reset();\r
+ keypart=StringFunctions::Replace(StringFunctions::Replace(keyparts[1],"-",""),"~","");\r
+ if(keypart!=uuidparts[1])\r
+ {\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"MessageRequester::HandleAllData MessageID in Message doesn't match public key of identity : "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
}\r
- st.Finalize();\r
-\r
- st=m_db->Prepare("INSERT INTO tblMessageReplyTo(MessageID,ReplyToMessageUUID,ReplyOrder) VALUES(?,?,?);");\r
- std::map<long,std::string> replyto=xml.GetInReplyTo();\r
- for(std::map<long,std::string>::iterator j=replyto.begin(); j!=replyto.end(); j++)\r
+ else\r
{\r
- st.Bind(0,messageid);\r
- st.Bind(1,(*j).second);\r
- st.Bind(2,(*j).first);\r
- st.Step();\r
- st.Reset();\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"MessageRequester::HandleAllData Error with identity's public key or Message ID : "+message["Identifier"]);\r
+ validmessage=false;\r
}\r
- st.Finalize();\r
-\r
- m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageRequester::HandleAllData parsed Message XML file : "+message["Identifier"]);\r
-\r
}\r
- else // couldn't insert - was already in database\r
+ else\r
{\r
- //m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"MessageRequester::HandleAddData could not insert message into database. "+message["Identifier"]);\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"MessageRequester::HandleAllData Error couldn't find identity : "+message["Identifier"]);\r
+ validmessage=false;\r
}\r
\r
+ // make sure we will at least save to 1 board before inserting message\r
+ savetoboardcount=0;\r
+ for(std::vector<std::string>::iterator bi=boards.begin(); bi!=boards.end(); bi++)\r
+ {\r
+ if(SaveToBoard((*bi)))\r
+ {\r
+ savetoboardcount++;\r
+ }\r
+ }\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.Bind(0,identityid);\r
+ st.Bind(1,GetIdentityName(identityid));\r
+ st.Bind(2,xml.GetDate());\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(7,xml.GetBody());\r
+ inserted=st.Step(true);\r
+ int messageid=st.GetLastInsertRowID();\r
+\r
+ if(inserted==true)\r
+ {\r
+\r
+ st=m_db->Prepare("INSERT INTO tblMessageBoard(MessageID,BoardID) VALUES(?,?);");\r
+ for(std::vector<std::string>::iterator i=boards.begin(); i!=boards.end(); i++)\r
+ {\r
+ if(SaveToBoard((*i)))\r
+ {\r
+ st.Bind(0,messageid);\r
+ st.Bind(1,GetBoardID((*i)));\r
+ st.Step();\r
+ st.Reset();\r
+ }\r
+ }\r
+ st.Finalize();\r
+\r
+ st=m_db->Prepare("INSERT INTO tblMessageReplyTo(MessageID,ReplyToMessageUUID,ReplyOrder) VALUES(?,?,?);");\r
+ for(std::map<long,std::string>::iterator j=replyto.begin(); j!=replyto.end(); j++)\r
+ {\r
+ st.Bind(0,messageid);\r
+ st.Bind(1,(*j).second);\r
+ st.Bind(2,(*j).first);\r
+ st.Step();\r
+ st.Reset();\r
+ }\r
+ st.Finalize();\r
+\r
+ m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageRequester::HandleAllData parsed Message XML file : "+message["Identifier"]);\r
+\r
+ }\r
+ else // couldn't insert - was already in database\r
+ {\r
+ //m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"MessageRequester::HandleAddData could not insert message into database. "+message["Identifier"]);\r
+ }\r
+\r
+ } // if validmessage\r
}\r
else\r
{\r
\r
sql="SELECT tblIdentity.IdentityID,Day,RequestIndex ";\r
sql+="FROM tblMessageRequests INNER JOIN tblIdentity ON tblMessageRequests.IdentityID=tblIdentity.IdentityID ";\r
- sql+="WHERE tblIdentity.LocalMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalMessageTrust') AND FromMessageList='true' AND Found='false' AND Day>='"+date.Format("%Y-%m-%d")+"' ";\r
+ sql+="WHERE (tblIdentity.LocalMessageTrust IS NULL OR tblIdentity.LocalMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalMessageTrust')) ";\r
+ sql+="AND FromMessageList='true' AND Found='false' AND Day>='"+date.Format("%Y-%m-%d")+"' ";\r
sql+="AND (tblIdentity.PeerMessageTrust IS NULL OR tblIdentity.PeerMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerMessageTrust')) ";\r
sql+=";";\r
\r
\r
}\r
\r
+const bool MessageRequester::SaveToBoard(const std::string &boardname)\r
+{\r
+ bool save=true;\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT SaveReceivedMessages FROM tblBoard WHERE BoardName=?;");\r
+ st.Bind(0,boardname);\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ std::string val="";\r
+ st.ResultText(0,val);\r
+ if(val=="true")\r
+ {\r
+ save=true;\r
+ }\r
+ else\r
+ {\r
+ save=false;\r
+ }\r
+ }\r
+ return save;\r
+}\r
+\r
void MessageRequester::StartRequest(const std::string &requestid)\r
{\r
FCPMessage message;\r
while(st.RowReturned())\r
{\r
st.ResultText(0,publickey);\r
- st.ResultInt(1,messagetrust);\r
- st.ResultInt(2,trustlisttrust);\r
+ if(st.ResultNull(1)==false)\r
+ {\r
+ st.ResultInt(1,messagetrust);\r
+ }\r
+ else\r
+ {\r
+ messagetrust=-1;\r
+ }\r
+ if(st.ResultNull(2)==false)\r
+ {\r
+ st.ResultInt(2,trustlisttrust);\r
+ }\r
+ else\r
+ {\r
+ trustlisttrust=-1;\r
+ }\r
xml.AddTrust(publickey,messagetrust,trustlisttrust);\r
st.Step();\r
}\r
//insert trust for this identity\r
trustst.Bind(0,identityid);\r
trustst.Bind(1,id);\r
- trustst.Bind(2,xml.GetMessageTrust(i));\r
- trustst.Bind(3,xml.GetTrustListTrust(i));\r
+ if(xml.GetMessageTrust(i)==-1)\r
+ {\r
+ trustst.Bind(2);\r
+ }\r
+ else\r
+ {\r
+ trustst.Bind(2,xml.GetMessageTrust(i));\r
+ }\r
+ if(xml.GetTrustListTrust(i)==-1)\r
+ {\r
+ trustst.Bind(3);\r
+ }\r
+ else\r
+ {\r
+ trustst.Bind(3,xml.GetTrustListTrust(i));\r
+ }\r
trustst.Step();\r
trustst.Reset();\r
\r
TiXmlElement *tr=new TiXmlElement("Trust");\r
tid->LinkEndChild(tr);\r
tr->LinkEndChild(XMLCreateCDATAElement("Identity",(*i).m_identity));\r
- tr->LinkEndChild(XMLCreateTextElement("MessageTrustLevel",messagetrust));\r
- tr->LinkEndChild(XMLCreateTextElement("TrustListTrustLevel",trustlisttrust));\r
+ if((*i).m_messagetrust>=0)\r
+ {\r
+ tr->LinkEndChild(XMLCreateTextElement("MessageTrustLevel",messagetrust));\r
+ }\r
+ if((*i).m_trustlisttrust>=0)\r
+ {\r
+ tr->LinkEndChild(XMLCreateTextElement("TrustListTrustLevel",trustlisttrust));\r
+ }\r
}\r
\r
td.Accept(&tp);\r
if(txt)\r
{\r
messagetruststr=txt->ValueStr();\r
- StringFunctions::Convert(messagetruststr,messagetrust);\r
+ if(messagetruststr!="")\r
+ {\r
+ StringFunctions::Convert(messagetruststr,messagetrust);\r
+ }\r
}\r
txt=hnd2.FirstChild("TrustListTrustLevel").FirstChild().ToText();\r
if(txt)\r
{\r
trustlisttruststr=txt->ValueStr();\r
- StringFunctions::Convert(trustlisttruststr,trustlisttrust);\r
+ if(trustlisttruststr!="")\r
+ {\r
+ StringFunctions::Convert(trustlisttruststr,trustlisttrust);\r
+ }\r
}\r
\r
- if(identity!="" && messagetrust>=0 && messagetrust<=100 && trustlisttrust>=0 && trustlisttrust<=100)\r
+ if(identity!="" && messagetrust>=-1 && messagetrust<=100 && trustlisttrust>=-1 && trustlisttrust<=100)\r
{\r
// check so we don't add the same identity multiple times from a trust list\r
if(std::find(m_foundkeys.begin(),m_foundkeys.end(),identity)==m_foundkeys.end())\r
major=1;\r
minor=1;\r
}\r
+ if(major==1 && (minor==1 || minor==2))\r
+ {\r
+ ConvertDB0101To0103();\r
+ major=1;\r
+ minor=3;\r
+ }\r
}\r
else\r
{\r
db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,1);");\r
}\r
\r
- db->Execute("UPDATE tblDBVersion SET Major=1, Minor=2;");\r
+ db->Execute("UPDATE tblDBVersion SET Major=1, Minor=3;");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\\r
Option TEXT UNIQUE,\\r
PublishBoardList BOOL CHECK(PublishBoardList IN('true','false')) DEFAULT 'false',\\r
DateAdded DATETIME,\\r
LastSeen DATETIME,\\r
- LocalMessageTrust INTEGER CHECK(LocalMessageTrust BETWEEN 0 AND 100) DEFAULT 50,\\r
- PeerMessageTrust INTEGER CHECK(PeerMessageTrust BETWEEN 0 AND 100) DEFAULT 50,\\r
- LocalTrustListTrust INTEGER CHECK(LocalTrustListTrust BETWEEN 0 AND 100) DEFAULT 50,\\r
- PeerTrustListTrust INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT 50\\r
+ LocalMessageTrust INTEGER CHECK(LocalMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
+ PeerMessageTrust INTEGER CHECK(PeerMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
+ LocalTrustListTrust INTEGER CHECK(LocalTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
+ PeerTrustListTrust INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL\\r
);");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblIdentityRequests(\\r
);");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblBoard(\\r
- BoardID INTEGER PRIMARY KEY,\\r
- BoardName TEXT UNIQUE,\\r
- BoardDescription TEXT,\\r
- DateAdded DATETIME\\r
+ BoardID INTEGER PRIMARY KEY,\\r
+ BoardName TEXT UNIQUE,\\r
+ BoardDescription TEXT,\\r
+ DateAdded DATETIME,\\r
+ SaveReceivedMessages BOOL CHECK(SaveReceivedMessages IN('true','false')) DEFAULT 'true'\\r
);");\r
\r
db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) VALUES('fms','Freenet Message System','2007-12-01 12:00:00');");\r
GROUP BY tblBoard.BoardID;");\r
\r
// calculates peer trust\r
+ // do the (MessageTrust+1)*LocalTrustListTrust/(MessageTrust+1)/100.0 - so it MessageTrust or TrustListTrust is NULL, the calc will be NULL and it won't be included at all in the average\r
+ // need the +1 so that when the values are 0 the result is not 0\r
+ db->Execute("DROP VIEW IF EXISTS vwCalculatedPeerTrust;");\r
db->Execute("CREATE VIEW IF NOT EXISTS vwCalculatedPeerTrust AS \\r
SELECT TargetIdentityID, \\r
- ROUND(SUM(MessageTrust*(LocalMessageTrust/100.0))/SUM(LocalMessageTrust/100.0),0) AS 'PeerMessageTrust', \\r
- ROUND(SUM(TrustListTrust*(LocalTrustListTrust/100.0))/SUM(LocalTrustListTrust/100.0),0) AS 'PeerTrustListTrust' \\r
+ ROUND(SUM(MessageTrust*(LocalTrustListTrust/100.0))/SUM(((MessageTrust+1)*LocalTrustListTrust/(MessageTrust+1))/100.0),0) AS 'PeerMessageTrust', \\r
+ ROUND(SUM(TrustListTrust*(LocalTrustListTrust/100.0))/SUM(((TrustListTrust+1)*LocalTrustListTrust/(TrustListTrust+1))/100.0),0) AS 'PeerTrustListTrust' \\r
FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.IdentityID=tblIdentity.IdentityID \\r
WHERE LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust') \\r
AND ( PeerTrustListTrust IS NULL OR PeerTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerTrustListTrust') ) \\r
\r
date.SetToGMTime();\r
// insert SomeDude's public key\r
- db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"');");\r
+ db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,LocalTrustListTrust) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"',51);");\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
// insert garfield's public key\r
db->Execute("UPDATE tblDBVersion SET Major=1, Minor=1;");\r
}\r
\r
+void ConvertDB0101To0103()\r
+{\r
+ // remove default 50 from trust fields and set default to NULL\r
+ SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+ db->Execute("CREATE TEMPORARY TABLE tblIdentityTemp AS SELECT * FROM tblIdentity;");\r
+ db->Execute("DROP TABLE IF EXISTS tblIdentity;");\r
+ db->Execute("CREATE TABLE IF NOT EXISTS tblIdentity(\\r
+ IdentityID INTEGER PRIMARY KEY,\\r
+ PublicKey TEXT UNIQUE,\\r
+ Name TEXT,\\r
+ SingleUse BOOL CHECK(SingleUse IN('true','false')) DEFAULT 'false',\\r
+ PublishTrustList BOOL CHECK(PublishTrustList IN('true','false')) DEFAULT 'false',\\r
+ PublishBoardList BOOL CHECK(PublishBoardList IN('true','false')) DEFAULT 'false',\\r
+ DateAdded DATETIME,\\r
+ LastSeen DATETIME,\\r
+ LocalMessageTrust INTEGER CHECK(LocalMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
+ PeerMessageTrust INTEGER CHECK(PeerMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
+ LocalTrustListTrust INTEGER CHECK(LocalTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
+ PeerTrustListTrust INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL\\r
+ );");\r
+ db->Execute("INSERT INTO tblIdentity SELECT * FROM tblIdentityTemp;");\r
+ db->Execute("DROP TABLE IF EXISTS tblIdentityTemp;");\r
+\r
+ // add SaveReceivedMessages field to tblBoard\r
+ db->Execute("ALTER TABLE tblBoard ADD COLUMN SaveReceivedMessages BOOL CHECK(SaveReceivedMessages IN('true','false')) DEFAULT 'true';");\r
+\r
+ db->Execute("UPDATE tblDBVersion SET Major=1, Minor=3;");\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
st.Step();\r
st.Reset();\r
\r
+ st.Bind(0,"AddNewPostFromIdentities");\r
+ st.Bind(1,"false");\r
+ st.Bind(2,"Set to true to automatically create new identities when you send a message using a new name. If you set this to false, posting messages will fail until you manually create the identity.");\r
+ st.Step();\r
+ st.Reset();\r
+\r
}\r
\r
void SetupLogFile()\r
#include "../../include/http/pages/peerdetailspage.h"\r
#include "../../include/http/pages/peermaintenancepage.h"\r
#include "../../include/http/pages/execquerypage.h"\r
+#include "../../include/http/pages/boardspage.h"\r
\r
#include <iostream>\r
\r
m_pagehandlers.push_back(new PeerDetailsPage(templatestr));\r
m_pagehandlers.push_back(new PeerMaintenancePage(templatestr));\r
m_pagehandlers.push_back(new ExecQueryPage(templatestr));\r
+ m_pagehandlers.push_back(new BoardsPage(templatestr));\r
// homepage must be last - catch all page handler\r
m_pagehandlers.push_back(new HomePage(templatestr));\r
\r
{\r
if((*i).first.find(basename)==0 && (*i).first.find("[")!=std::string::npos && (*i).first.find("]")!=std::string::npos)\r
{\r
- int index;\r
+ int index=0;\r
std::string indexstr;\r
std::string::size_type startpos;\r
std::string::size_type endpos;\r
long len;\r
StringFunctions::Convert(std::string(lenstr),len);\r
mystate->m_indata=new char[len+1];\r
- mystate->m_indata[len]=NULL;\r
+ mystate->m_indata[len]='\0';\r
mystate->m_indatalen=len;\r
mystate->m_indatapos=0;\r
}\r
--- /dev/null
+#include "../../../include/http/pages/boardspage.h"\r
+#include "../../../include/stringfunctions.h"\r
+#include "../../../include/datetime.h"\r
+\r
+#ifdef XMEM\r
+ #include <xmem.h>\r
+#endif\r
+\r
+const std::string BoardsPage::BuildQueryString(const long startrow, const std::string &boardsearch)\r
+{\r
+ std::string returnval="";\r
+ std::string tempval="";\r
+\r
+ if(startrow>=0)\r
+ {\r
+ StringFunctions::Convert(startrow,tempval);\r
+ returnval+="startrow="+tempval;\r
+ }\r
+\r
+ if(boardsearch!="")\r
+ {\r
+ if(returnval!="")\r
+ {\r
+ returnval+="&";\r
+ }\r
+ returnval+="boardsearch="+boardsearch;\r
+ }\r
+\r
+ return returnval;\r
+\r
+}\r
+\r
+const std::string BoardsPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
+{\r
+ int boardcount=0;\r
+ std::string content="";\r
+ int rownum=0;\r
+ int rowsperpage=25;\r
+ std::string rowsperpagestr="25";\r
+ int startrow=0;\r
+ std::string startrowstr="0";\r
+ std::string boardsearch="";\r
+ std::string sql="";\r
+ DateTime now;\r
+ now.SetToGMTime();\r
+\r
+ if(queryvars.find("formaction")!=queryvars.end())\r
+ {\r
+ if((*queryvars.find("formaction")).second=="addboard" && queryvars.find("boardname")!=queryvars.end() && queryvars.find("boarddescription")!=queryvars.end())\r
+ {\r
+ std::string boardname="";\r
+ std::string boarddescription="";\r
+\r
+ boardname=(*queryvars.find("boardname")).second;\r
+ boarddescription=(*queryvars.find("boarddescription")).second;\r
+\r
+ SQLite3DB::Statement addst=m_db->Prepare("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded) 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.Step();\r
+ }\r
+ if((*queryvars.find("formaction")).second=="update")\r
+ {\r
+ int boardid;\r
+ std::vector<std::string> boardids;\r
+ std::vector<std::string> olddescriptions;\r
+ std::vector<std::string> descriptions;\r
+ std::vector<std::string> oldsavemessages;\r
+ std::vector<std::string> savemessages;\r
+\r
+ CreateArgArray(queryvars,"boardid",boardids);\r
+ CreateArgArray(queryvars,"oldboarddescription",olddescriptions);\r
+ CreateArgArray(queryvars,"boarddescription",descriptions);\r
+ CreateArgArray(queryvars,"oldsavereceivedmessages",oldsavemessages);\r
+ CreateArgArray(queryvars,"savereceivedmessages",savemessages);\r
+\r
+ olddescriptions.resize(boardids.size(),"");\r
+ descriptions.resize(boardids.size(),"");\r
+ oldsavemessages.resize(boardids.size(),"");\r
+ savemessages.resize(boardids.size(),"");\r
+\r
+ SQLite3DB::Statement updatest=m_db->Prepare("UPDATE tblBoard SET BoardDescription=?, SaveReceivedMessages=? WHERE BoardID=?;");\r
+ \r
+ for(int i=0; i<boardids.size(); i++)\r
+ {\r
+ if(olddescriptions[i]!=descriptions[i] || oldsavemessages[i]!=savemessages[i])\r
+ {\r
+ updatest.Bind(0,descriptions[i]);\r
+ if(savemessages[i]!="true")\r
+ {\r
+ updatest.Bind(1,"false");\r
+ }\r
+ else\r
+ {\r
+ updatest.Bind(1,"true");\r
+ }\r
+ boardid=0;\r
+ StringFunctions::Convert(boardids[i],boardid);\r
+ updatest.Bind(2,boardid);\r
+ updatest.Step();\r
+ updatest.Reset();\r
+ }\r
+ }\r
+\r
+ }\r
+ }\r
+\r
+ // if startrow is specified\r
+ if(queryvars.find("startrow")!=queryvars.end())\r
+ {\r
+ startrowstr=(*queryvars.find("startrow")).second;\r
+ // convert back and forth, just in case a number wasn't passed in startrow\r
+ StringFunctions::Convert(startrowstr,startrow);\r
+ if(startrow<0)\r
+ {\r
+ startrow=0;\r
+ }\r
+ StringFunctions::Convert(startrow,startrowstr);\r
+ }\r
+\r
+ // if we are searching by name\r
+ if(queryvars.find("boardsearch")!=queryvars.end())\r
+ {\r
+ boardsearch=(*queryvars.find("boardsearch")).second;\r
+ }\r
+\r
+ content+="<h2>Boards</h2>";\r
+\r
+ sql="SELECT COUNT(*) FROM tblBoard WHERE BoardID NOT IN (SELECT BoardID FROM tblAdministrationBoard)";\r
+ if(boardsearch!="")\r
+ {\r
+ sql+=" AND (BoardName LIKE '%' || ? || '%' OR BoardDescription LIKE '%' || ? || '%')";\r
+ }\r
+ sql+=";";\r
+ SQLite3DB::Statement st=m_db->Prepare(sql);\r
+ if(boardsearch!="")\r
+ {\r
+ st.Bind(0,boardsearch);\r
+ st.Bind(1,boardsearch);\r
+ }\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ st.ResultInt(0,boardcount);\r
+ }\r
+ st.Finalize();\r
+\r
+\r
+ sql="SELECT BoardID,BoardName,BoardDescription,SaveReceivedMessages FROM tblBoard WHERE BoardID NOT IN (SELECT BoardID FROM tblAdministrationBoard)";\r
+ if(boardsearch!="")\r
+ {\r
+ sql+=" AND (BoardName LIKE '%' || ? || '%' OR BoardDescription LIKE '%' || ? || '%')";\r
+ }\r
+ sql+=" ORDER BY BoardName COLLATE NOCASE";\r
+ sql+=" LIMIT "+startrowstr+","+rowsperpagestr+";";\r
+\r
+ st=m_db->Prepare(sql);\r
+ if(boardsearch!="")\r
+ {\r
+ st.Bind(0,boardsearch);\r
+ st.Bind(1,boardsearch);\r
+ }\r
+ st.Step();\r
+\r
+ content+="<table>";\r
+\r
+ content+="<tr>";\r
+ content+="<td colspan=\"3\"><center>";\r
+ content+="<form name=\"frmboardsearch\" action=\"boards.htm\" method=\"POST\"><input type=\"text\" name=\"boardsearch\" value=\""+SanitizeOutput(boardsearch)+"\"><input type=\"submit\" value=\"Search\"></form>";\r
+ content+="</center></td>";\r
+ content+="</tr>";\r
+\r
+ content+="<tr>";\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\"></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>";\r
+ content+="<th>Name</th><th>Description</th><th>Save Received Messages</th>";\r
+ content+="</tr>"; \r
+ while(st.RowReturned() && rownum<rowsperpage)\r
+ {\r
+ std::string rownumstr="";\r
+ std::string boardidstr="";\r
+ std::string boardname="";\r
+ std::string boarddescription="";\r
+ std::string savereceivedmessages="";\r
+\r
+ st.ResultText(0,boardidstr);\r
+ st.ResultText(1,boardname);\r
+ st.ResultText(2,boarddescription);\r
+ st.ResultText(3,savereceivedmessages);\r
+\r
+ StringFunctions::Convert(rownum,rownumstr);\r
+\r
+ content+="<tr>";\r
+ content+="<td>"+SanitizeOutput(boardname)+"</td>";\r
+ content+="<td><input type=\"hidden\" name=\"boardid["+rownumstr+"]\" value=\""+boardidstr+"\">";\r
+ content+="<input type=\"hidden\" name=\"oldboarddescription["+rownumstr+"]\" value=\""+StringFunctions::Replace(SanitizeOutput(boarddescription)," "," ")+"\">";\r
+ content+="<input type=\"text\" name=\"boarddescription["+rownumstr+"]\" value=\""+SanitizeOutput(boarddescription)+"\" size=\"40\"></td>";\r
+ content+="<td>";\r
+ content+="<input type=\"hidden\" name=\"oldsavereceivedmessages["+rownumstr+"]\" value=\""+savereceivedmessages+"\">";\r
+ content+="<input type=\"checkbox\" name=\"savereceivedmessages["+rownumstr+"]\" value=\"true\"";\r
+ if(savereceivedmessages=="true")\r
+ {\r
+ content+=" CHECKED";\r
+ }\r
+ content+=">";\r
+ content+="</td>";\r
+ content+="</tr>\r\n";\r
+ st.Step();\r
+ rownum++;\r
+ }\r
+\r
+ if(startrow>0 || startrow+rowsperpage<boardcount)\r
+ {\r
+ std::string tempstr;\r
+ int cols=0;\r
+\r
+ content+="<tr>";\r
+ if(startrow>0)\r
+ {\r
+ StringFunctions::Convert(startrow-rowsperpage,tempstr);\r
+ content+="<td colspan=\"1\" align=\"left\"><a href=\"boards.htm?"+BuildQueryString(startrow-rowsperpage,boardsearch)+"\"><-- Previous Page</a></td>";\r
+ cols+=1;\r
+ }\r
+ if(startrow+rowsperpage<boardcount)\r
+ {\r
+ while(cols<2)\r
+ {\r
+ content+="<td></td>";\r
+ cols++;\r
+ }\r
+ content+="<td colspan=\"1\" align=\"right\"><a href=\"boards.htm?"+BuildQueryString(startrow+rowsperpage,boardsearch)+"\">Next Page --></a></td>";\r
+ }\r
+ content+="</tr>";\r
+ }\r
+\r
+ content+="<tr>";\r
+ content+="<td colspan=\"3\"><center><input type=\"submit\" value=\"Update\"></center></form></td>";\r
+ content+="</tr>";\r
+ content+="</table>";\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
+\r
+const bool BoardsPage::WillHandleURI(const std::string &uri)\r
+{\r
+ if(uri.find("boards.")!=std::string::npos)\r
+ {\r
+ return true;\r
+ }\r
+ else\r
+ {\r
+ return false;\r
+ }\r
+}\r
\r
std::string content="<h2>Home</h2>";\r
content+="<p class=\"paragraph\">";\r
+ content+="<b>FMS version ";\r
+ content+=FMS_VERSION;\r
+ content+="</b><br>";\r
content+="Use these pages to administer your FMS installation.";\r
content+="</p>";\r
content+="<p class=\"paragraph\">";\r
StringFunctions::Convert(ltlt[i],localtrustlisttrust);\r
StringFunctions::Convert(identityids[i],identityid);\r
\r
- update.Bind(0,localmessagetrust);\r
- update.Bind(1,localtrustlisttrust);\r
+ if(lmt[i]!="")\r
+ {\r
+ update.Bind(0,localmessagetrust);\r
+ }\r
+ else\r
+ {\r
+ update.Bind(0);\r
+ }\r
+ if(ltlt[i]!="")\r
+ {\r
+ update.Bind(1,localtrustlisttrust);\r
+ }\r
+ else\r
+ {\r
+ update.Bind(1);\r
+ }\r
update.Bind(2,identityid);\r
update.Step();\r
update.Reset();\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+="<div style=\"text-align:center;\">";\r
content+="<form name=\"frmsearch\" method=\"POST\" action=\"peertrust.htm\">";\r
- content+="<input type=\"text\" name=\"namesearch\">";\r
+ content+="<input type=\"text\" name=\"namesearch\" value=\""+SanitizeOutput(namesearch)+"\">";\r
content+="<input type=\"submit\" value=\"Search\">";\r
content+="</form>";\r
content+="</div>";\r
content+="</tr>";\r
}\r
\r
- content+="<tr><td colspan=\"5\"><input type=\"submit\" value=\"Update Trust\"></td></tr>";\r
+ content+="<tr><td colspan=\"5\"><center><input type=\"submit\" value=\"Update Trust\"></center></td></tr>";\r
content+="</table>";\r
content+="</form>";\r
\r
struct tm *timeinfo=gmtime(&rawtime);\r
\r
strftime(m_datebuffer,99,"%Y-%m-%d %H:%M:%S : ",timeinfo);\r
- m_datebuffer[99]=NULL;\r
+ m_datebuffer[99]='\0';\r
\r
fputs(m_datebuffer,m_fileptr);\r
}\r
{\r
origmess.ResultInt(0,identityid);\r
origmess.ResultText(1,identityname);\r
- origmess.ResultInt(2,origmessagetrust);\r
- origmess.ResultInt(3,origtrustlisttrust);\r
+ if(origmess.ResultNull(2)==false)\r
+ {\r
+ origmess.ResultInt(2,origmessagetrust);\r
+ }\r
+ else\r
+ {\r
+ origmessagetrust=50;\r
+ }\r
+ if(origmess.ResultNull(3)==false)\r
+ {\r
+ origmess.ResultInt(3,origtrustlisttrust);\r
+ }\r
+ else\r
+ {\r
+ origtrustlisttrust=50;\r
+ }\r
\r
origmessagetrust+=changemessagetrust;\r
origtrustlisttrust+=changetrustlisttrust;\r
int localmessagetrust=0;\r
\r
st.ResultInt(0,identityid);\r
- st.ResultInt(1,localmessagetrust);\r
+ if(st.ResultNull(1)==false)\r
+ {\r
+ st.ResultInt(1,localmessagetrust);\r
+ }\r
+ else\r
+ {\r
+ localmessagetrust=50;\r
+ }\r
\r
localmessagetrust+=m_changemessagetrustonreply;\r
if(localmessagetrust<0)\r
m_changemessagetrustonreply=0;\r
Option::Instance()->Get("ChangeMessageTrustOnReply",tempval);\r
StringFunctions::Convert(tempval,m_changemessagetrustonreply);\r
+ Option::Instance()->Get("AddNewPostFromIdentities",tempval);\r
+ if(tempval=="true")\r
+ {\r
+ m_addnewpostfromidentities=true;\r
+ }\r
+ else\r
+ {\r
+ m_addnewpostfromidentities=false;\r
+ }\r
}\r
\r
const bool Message::Load(const long messageid, const long boardid)\r
return true;\r
}\r
\r
-void Message::StartFreenetInsert()\r
+const bool Message::StartFreenetInsert()\r
{\r
\r
MessageXML xml;\r
// couldn't find identity with this name - insert a new identity\r
if(!st.RowReturned())\r
{\r
- DateTime now;\r
- now.SetToGMTime();\r
- st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name) VALUES(?);");\r
- st.Bind(0,m_fromname);\r
- st.Step(true);\r
- localidentityid=st.GetLastInsertRowID();\r
+ if(m_addnewpostfromidentities==true)\r
+ {\r
+ DateTime now;\r
+ now.SetToGMTime();\r
+ st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name) VALUES(?);");\r
+ st.Bind(0,m_fromname);\r
+ st.Step(true);\r
+ localidentityid=st.GetLastInsertRowID();\r
+ }\r
+ else\r
+ {\r
+ return false;\r
+ }\r
}\r
else\r
{\r
\r
HandleChangeTrust();\r
\r
+ return true;\r
+\r
}\r
#include <io.h>\r
#else\r
#if !defined(__APPLE__) && !defined(__DARWIN__)\r
- #ifndef __FreeBSD__\r
+ #if !defined(__FreeBSD__) && !defined(solaris) && !defined(__sun)\r
#include <sys/io.h>\r
#else\r
#include <stdio.h>\r
}\r
else\r
{\r
- mess.StartFreenetInsert();\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
}\r
- SendBufferedLine("240 Article received OK");\r
}\r
else\r
{\r
<li><a href="addpeer.htm">Add Peer</a></li>\r
<li><a href="peermaintenance.htm">Peer Maintenance</a></li>\r
<li><a href="peertrust.htm">Peer Trust</a></li>\r
+ <li><a href="boards.htm">Boards</a></li>\r
<li><a href="controlboard.htm">Control Boards</a></li>\r
</ul>\r
</div>\r