version 0.1.13
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Sat, 23 Feb 2008 12:26:00 +0000 (13:26 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Sat, 23 Feb 2008 12:26:00 +0000 (13:26 +0100)
24 files changed:
CMakeLists.txt
include/freenet/messagerequester.h
include/freenet/trustlistxml.h
include/global.h
include/http/pages/boardspage.h [new file with mode: 0644]
include/message.h
src/freenet/boardlistrequester.cpp
src/freenet/introductionpuzzlerequester.cpp
src/freenet/messagelistrequester.cpp
src/freenet/messagerequester.cpp
src/freenet/trustlistinserter.cpp
src/freenet/trustlistrequester.cpp
src/freenet/trustlistxml.cpp
src/global.cpp
src/http/httpthread.cpp
src/http/ipagehandler.cpp
src/http/pages/boardspage.cpp [new file with mode: 0644]
src/http/pages/homepage.cpp
src/http/pages/peertrustpage.cpp
src/logfile.cpp
src/message.cpp
src/nntp/mime/Mime.cpp
src/nntp/nntpconnection.cpp
template.htm

index 455a73d..5f976ac 100644 (file)
@@ -55,6 +55,7 @@ src/http/identityexportxml.cpp
 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
@@ -96,15 +97,31 @@ ADD_DEFINITIONS(-DTIXML_USE_STL)
 \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
index 353de7e..e840635 100644 (file)
@@ -17,6 +17,7 @@ private:
        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
index ad09e60..ac16d1f 100644 (file)
@@ -6,6 +6,7 @@
 \r
 #include <vector>\r
 \r
+// trust of -1 will mean NULL trust\r
 class TrustListXML:public IFMSXMLDocument,public ILogger\r
 {\r
 private:\r
index d9a82e0..3abb065 100644 (file)
@@ -5,11 +5,12 @@
 //#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
diff --git a/include/http/pages/boardspage.h b/include/http/pages/boardspage.h
new file mode 100644 (file)
index 0000000..7f8ae92
--- /dev/null
@@ -0,0 +1,20 @@
+#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
index 74c25d4..c99b96d 100644 (file)
@@ -46,7 +46,7 @@ public:
 \r
        const bool PostedToAdministrationBoard()                { return CheckForAdministrationBoard(m_boards); }\r
 \r
-       void StartFreenetInsert();\r
+       const bool StartFreenetInsert();\r
        void HandleAdministrationMessage();\r
 \r
 private:\r
@@ -56,6 +56,7 @@ private:
        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
index 6b52a46..28ba901 100644 (file)
@@ -173,7 +173,7 @@ void BoardListRequester::PopulateIDList()
        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
index 03d4a41..1a24bd0 100644 (file)
@@ -38,6 +38,7 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message)
        IntroductionPuzzleXML xml;\r
        long identityid;\r
        long index;\r
+       bool validmessage=true;\r
 \r
        now.SetToGMTime();\r
        StringFunctions::Split(message["Identifier"],"|",idparts);\r
@@ -65,17 +66,64 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message)
        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
index c5ef11c..242d292 100644 (file)
@@ -160,7 +160,7 @@ void MessageListRequester::PopulateIDList()
        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
index 54b0d26..ac56c5c 100644 (file)
@@ -81,6 +81,8 @@ const bool MessageRequester::HandleAllData(FCPMessage &message)
        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
@@ -115,6 +117,8 @@ const bool MessageRequester::HandleAllData(FCPMessage &message)
        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
@@ -130,61 +134,111 @@ const bool MessageRequester::HandleAllData(FCPMessage &message)
                        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
@@ -294,7 +348,8 @@ void MessageRequester::PopulateIDList()
 \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
@@ -325,6 +380,28 @@ void MessageRequester::PopulateIDList()
 \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
index 5f2fbb8..2d14f89 100644 (file)
@@ -148,8 +148,22 @@ void TrustListInserter::StartInsert(const long localidentityid, const std::strin
        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
index 3fd5d99..77b03b1 100644 (file)
@@ -96,8 +96,22 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message)
                        //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
index c3e71db..d732105 100644 (file)
@@ -73,8 +73,14 @@ std::string TrustListXML::GetXML()
                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
@@ -122,16 +128,22 @@ const bool TrustListXML::ParseXML(const std::string &xml)
                        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
index 0c6f913..5515e1a 100644 (file)
@@ -52,13 +52,19 @@ void SetupDB()
                        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
@@ -126,10 +132,10 @@ void SetupDB()
                                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
@@ -166,10 +172,11 @@ void SetupDB()
                                );");\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
@@ -265,10 +272,13 @@ void SetupDB()
                                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
@@ -360,7 +370,7 @@ void SetupDB()
 \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
@@ -398,6 +408,35 @@ void ConvertDB0100To0101()
        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
@@ -577,6 +616,12 @@ void SetupDefaultOptions()
        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
index 6ad6ef9..a58044c 100644 (file)
@@ -13,6 +13,7 @@
 #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
@@ -58,6 +59,7 @@ HTTPThread::HTTPThread()
        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
index f4ac20f..3565aab 100644 (file)
@@ -12,7 +12,7 @@ void IPageHandler::CreateArgArray(const std::map<std::string,std::string> &vars,
        {\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
@@ -82,7 +82,7 @@ const bool IPageHandler::Handle(shttpd_arg *arg)
                                        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
diff --git a/src/http/pages/boardspage.cpp b/src/http/pages/boardspage.cpp
new file mode 100644 (file)
index 0000000..8d10aa6
--- /dev/null
@@ -0,0 +1,258 @@
+#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),"&nbsp;"," ")+"\">";\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
index c89d92c..f305f30 100644 (file)
@@ -16,6 +16,9 @@ const std::string HomePage::GeneratePage(const std::string &method, const std::m
 \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
index 667595d..48a19e8 100644 (file)
@@ -91,8 +91,22 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                                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
@@ -144,7 +158,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
        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
@@ -279,7 +293,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                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
index 7e632f9..52d0452 100644 (file)
@@ -75,7 +75,7 @@ void LogFile::WriteDate()
                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
index 41add10..d8adc87 100644 (file)
@@ -140,8 +140,22 @@ void Message::HandleAdministrationMessage()
                                {\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
@@ -222,7 +236,14 @@ void Message::HandleChangeTrust()
                        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
@@ -258,6 +279,15 @@ void Message::Initialize()
        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
@@ -587,7 +617,7 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage)
        return true;\r
 }\r
 \r
-void Message::StartFreenetInsert()\r
+const bool Message::StartFreenetInsert()\r
 {\r
 \r
        MessageXML xml;\r
@@ -618,12 +648,19 @@ void Message::StartFreenetInsert()
        // 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
@@ -638,4 +675,6 @@ void Message::StartFreenetInsert()
 \r
        HandleChangeTrust();\r
 \r
+       return true;\r
+\r
 }\r
index 89de9f1..d925590 100644 (file)
@@ -475,7 +475,7 @@ list<CMimeField>::iterator CMimeHeader::FindField(const char* pszFieldName)
        #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
index 078c1c3..fa35f4f 100644 (file)
@@ -786,9 +786,15 @@ void NNTPConnection::HandlePostedMessage(const std::string &message)
                }\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
index 157b1b2..1320715 100644 (file)
@@ -224,6 +224,7 @@ td          { padding-left:5px; padding-right:5px; }
                        <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