version 0.1.8
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Sun, 3 Feb 2008 19:04:00 +0000 (20:04 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Sun, 3 Feb 2008 19:04:00 +0000 (20:04 +0100)
CMakeLists.txt
include/global.h
include/http/pages/peertrustpage.h
src/freenet/messagerequester.cpp
src/http/ipagehandler.cpp
src/http/pages/peertrustpage.cpp
src/message.cpp
src/stringfunctions.cpp
template.htm

index 3a14d8f..8c79cce 100644 (file)
@@ -72,13 +72,19 @@ src/xyssl/sha1.c
 \r
 ADD_DEFINITIONS(-DTIXML_USE_STL)\r
 \r
-IF(CMAKE_COMPILER_IS_GNUCXX)\r
-       #ADD_DEFINITIONS(-fpermissive)\r
-       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")\r
-ENDIF(CMAKE_COMPILER_IS_GNUCXX)\r
+# was for ZThreads\r
+#IF(CMAKE_COMPILER_IS_GNUCXX)\r
+#      #ADD_DEFINITIONS(-fpermissive)\r
+#      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")\r
+#ENDIF(CMAKE_COMPILER_IS_GNUCXX)\r
 \r
 ADD_EXECUTABLE(fms ${FMS_SRC})\r
 \r
+# For SQLite3 and shttpd\r
+IF(CMAKE_COMPILER_IS_GNUCC)\r
+       TARGET_LINK_LIBRARIES(fms dl)\r
+ENDIF(CMAKE_COMPILER_IS_GNUCC)\r
+\r
 IF(WIN32)\r
        TARGET_LINK_LIBRARIES(fms ws2_32)\r
 ENDIF(WIN32)\r
@@ -95,9 +101,6 @@ ELSE(SQLITE3_LIBRARY)
        ADD_LIBRARY(sqlite3 libs/sqlite3/sqlite3.c)\r
        TARGET_LINK_LIBRARIES(fms sqlite3)\r
        INCLUDE_DIRECTORIES(libs/sqlite3)\r
-       IF(CMAKE_COMPILER_IS_GNUCC)\r
-               TARGET_LINK_LIBRARIES(fms dl)\r
-       ENDIF(CMAKE_COMPILER_IS_GNUCC)\r
 ENDIF(SQLITE3_LIBRARY)\r
 \r
 IF(TINYXML_LIBRARY)\r
index ba2e84f..889530d 100644 (file)
@@ -5,7 +5,7 @@
 //#include <zthread/Thread.h>\r
 #include "pthreadwrapper/thread.h"\r
 \r
-#define FMS_VERSION    "0.1.7"\r
+#define FMS_VERSION    "0.1.8"\r
 \r
 // opens database and creates tables and initial inserts if necessary\r
 void SetupDB();\r
index b9a5f4e..eb780e0 100644 (file)
@@ -13,6 +13,8 @@ private:
        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 GetClassString(const std::string &trustlevel);\r
+\r
 };\r
 \r
 #endif // _peertrustpage_\r
index c2e3a21..c9908a5 100644 (file)
@@ -253,6 +253,8 @@ void MessageRequester::PopulateIDList()
        SQLite3DB::Statement st=m_db->Prepare(sql);\r
        st.Step();\r
 \r
+       m_ids.clear();\r
+\r
        while(st.RowReturned())\r
        {\r
                st.ResultText(0,val1);\r
index fc77815..d90a927 100644 (file)
@@ -99,9 +99,13 @@ const bool IPageHandler::Handle(shttpd_arg *arg)
                                StringFunctions::Split((*argi),"=",parts);\r
                                if(parts.size()>0)\r
                                {\r
+                                       // replace + with space before UriDecoding\r
+                                       parts[0]=StringFunctions::Replace(parts[0],"+"," ");\r
                                        args[StringFunctions::UriDecode(parts[0])];\r
                                        if(parts.size()>1)\r
                                        {\r
+                                               // replace + with space before UriDecoding\r
+                                               parts[1]=StringFunctions::Replace(parts[1],"+"," ");\r
                                                args[StringFunctions::UriDecode(parts[0])]=StringFunctions::UriDecode(parts[1]);\r
                                        }\r
                                }\r
index a9ac96f..4a451ed 100644 (file)
@@ -10,6 +10,13 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
        int count=0;\r
        std::string countstr;\r
        std::string content="";\r
+       int identitycount=0;            // total number of ids we know\r
+       int rowsperpage=25;                     // how many ids to show per page\r
+       std::string rowsperpagestr;\r
+       int startrow=0;\r
+       std::string startrowstr="0";\r
+\r
+       StringFunctions::Convert(rowsperpage,rowsperpagestr);\r
 \r
        if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="update")\r
        {\r
@@ -48,14 +55,33 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
 \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
        content+="<h2>Peer Trust</h2>";\r
        content+="Message Trust is how much you trust the identity to post good messages. Trust List Trust is how much weight you want the trust list of that identity to have when calculating the total. The local trust levels are set by you, and the peer trust levels are calculated by a weighted average using other identities trust lists.";\r
        content+="<form name=\"frmtrust\" method=\"POST\">";\r
        content+="<input type=\"hidden\" name=\"formaction\" value=\"update\">";\r
+       content+="<input type=\"hidden\" name=\"startrow\" value=\""+startrowstr+"\">";\r
        content+="<table>";\r
        content+="<tr><th>Name</th><th>Local Message Trust</th><th>Peer Message Trust</th><th>Local Trust List Trust</th><th>Peer Trust List Trust</th></tr>";\r
        \r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey FROM tblIdentity ORDER BY Name;");\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT COUNT(*) FROM tblIdentity;");\r
+       st.Step();\r
+       st.ResultInt(0,identitycount);\r
+       st.Finalize();\r
+\r
+       st=m_db->Prepare("SELECT IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey FROM tblIdentity ORDER BY Name COLLATE NOCASE LIMIT "+startrowstr+","+rowsperpagestr+";");\r
        st.Step();\r
 \r
        while(st.RowReturned())\r
@@ -90,18 +116,46 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                        content+="[Unknown Name]";\r
                }\r
                content+="</td>";\r
-               content+="<td>";\r
+               content+="<td "+GetClassString(localmessagetrust)+">";\r
                content+="<input type=\"hidden\" name=\"oldlocalmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\">";\r
                content+="<input type=\"text\" name=\"localmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\" size=\"2\" maxlength=\"3\"></td>";\r
-               content+="<td>"+peermessagetrust+"</td>";\r
-               content+="<td>";\r
+               content+="<td "+GetClassString(peermessagetrust)+">";\r
+               content+=peermessagetrust+"</td>";\r
+               content+="<td "+GetClassString(localtrustlisttrust)+">";\r
                content+="<input type=\"hidden\" name=\"oldlocaltrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\">";\r
                content+="<input type=\"text\" name=\"localtrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\" size=\"2\" maxlength=\"3\"></td>";\r
-               content+="<td>"+peertrustlisttrust+"</td>";\r
+               content+="<td "+GetClassString(peertrustlisttrust)+">";\r
+               content+=peertrustlisttrust+"</td>";\r
                content+="</tr>";\r
                st.Step();\r
                count++;\r
        }\r
+       \r
+       if(startrow>0 || startrow+rowsperpage<identitycount)\r
+       {\r
+               int tempint;\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=\"2\" align=\"left\"><a href=\"peertrust.htm?startrow="+tempstr+"\"><-- Previous Page</a></td>";\r
+                       cols+=2;\r
+               }\r
+               if(startrow+rowsperpage<identitycount)\r
+               {\r
+                       StringFunctions::Convert(startrow+rowsperpage,tempstr);\r
+                       while(cols<3)\r
+                       {\r
+                               content+="<td></td>";\r
+                               cols++;\r
+                       }\r
+                       content+="<td colspan=\"2\" align=\"right\"><a href=\"peertrust.htm?startrow="+tempstr+"\">Next Page --></a></td>";\r
+               }\r
+               content+="</tr>";\r
+       }\r
 \r
        content+="<tr><td colspan=\"5\"><input type=\"submit\" value=\"Update Trust\"></td></tr>";\r
        content+="</table>";\r
@@ -110,6 +164,25 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
        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 std::string PeerTrustPage::GetClassString(const std::string &trustlevel)\r
+{\r
+       int tempint=0;\r
+       std::string tempstr;\r
+\r
+       StringFunctions::Convert(trustlevel,tempint);\r
+       tempint/=10;\r
+       StringFunctions::Convert(tempint,tempstr);\r
+\r
+       if(trustlevel!="")\r
+       {\r
+               return "class=\"trust"+tempstr+"\"";\r
+       }\r
+       else\r
+       {\r
+               return "";\r
+       }\r
+}\r
+\r
 const bool PeerTrustPage::WillHandleURI(const std::string &uri)\r
 {\r
        if(uri.find("peertrust.")!=std::string::npos)\r
index dee644d..2cfb588 100644 (file)
@@ -121,6 +121,9 @@ const bool Message::Load(const long messageid, const long boardid)
                st.ResultText(7,m_fromname);\r
                st.Finalize();\r
 \r
+               // strip off any \r\n in subject\r
+               m_subject=StringFunctions::Replace(m_subject,"\r\n","");\r
+\r
                // get board list\r
                st=m_db->Prepare("SELECT tblBoard.BoardName FROM tblBoard INNER JOIN tblMessageBoard ON tblBoard.BoardID=tblMessageBoard.BoardID WHERE tblMessageBoard.MessageID=?;");\r
                st.Bind(0,messageid);\r
@@ -255,6 +258,8 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage)
        if(mime.GetFieldValue("From"))\r
        {\r
                m_fromname=mime.GetFieldValue("From");\r
+               // remove any path folding\r
+               m_fromname=StringFunctions::Replace(m_fromname,"\r\n","");\r
                // strip off everything between () and <> and any whitespace\r
                std::string::size_type startpos=m_fromname.find("(");\r
                std::string::size_type endpos;\r
@@ -297,6 +302,8 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage)
        if(mime.GetFieldValue("Newsgroups"))\r
        {\r
                std::string temp=mime.GetFieldValue("Newsgroups");\r
+               // remove any path folding\r
+               temp=StringFunctions::Replace(temp,"\r\n","");\r
                std::vector<std::string> parts;\r
                StringFunctions::SplitMultiple(temp,", \t",parts);\r
                for(std::vector<std::string>::iterator i=parts.begin(); i!=parts.end(); i++)\r
@@ -314,6 +321,8 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage)
        if(mime.GetFieldValue("Followup-To"))\r
        {\r
                m_replyboardname=mime.GetFieldValue("Followup-To");\r
+               // remove any path folding\r
+               m_replyboardname=StringFunctions::Replace(m_replyboardname,"\r\n","");\r
        }\r
        else\r
        {\r
@@ -326,6 +335,8 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage)
        if(mime.GetFieldValue("Subject"))\r
        {\r
                m_subject=mime.GetFieldValue("Subject");\r
+               // remove any path folding\r
+               m_subject=StringFunctions::Replace(m_subject,"\r\n","");\r
        }\r
        else\r
        {\r
@@ -335,6 +346,8 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage)
        if(mime.GetFieldValue("References"))\r
        {\r
                std::string temp=mime.GetFieldValue("References");\r
+               // remove any path folding\r
+               temp=StringFunctions::Replace(temp,"\r\n","");\r
                std::vector<std::string> parts;\r
                int count=0;\r
                StringFunctions::SplitMultiple(temp,", \t",parts);\r
index 36a3707..bed3622 100644 (file)
@@ -26,8 +26,8 @@ std::string Replace(const std::string &input, const std::string &find, const std
 \r
 void Split(const std::string &str, const std::string &delim, std::vector<std::string> &output)\r
 {\r
-    unsigned int offset = 0;\r
-    unsigned int delimIndex = 0;\r
+       std::string::size_type offset = 0;\r
+       std::string::size_type delimIndex = 0;\r
     \r
     delimIndex = str.find(delim, offset);\r
 \r
@@ -43,8 +43,8 @@ void Split(const std::string &str, const std::string &delim, std::vector<std::st
 \r
 void SplitMultiple(const std::string &str, const std::string &delim, std::vector<std::string> &output)\r
 {\r
-    unsigned int offset = 0;\r
-    unsigned int delimIndex = 0;\r
+       std::string::size_type offset = 0;\r
+       std::string::size_type delimIndex = 0;\r
     \r
     delimIndex = str.find_first_of(delim, offset);\r
 \r
index 7c4782e..387f576 100644 (file)
@@ -182,6 +182,21 @@ h1, h2, h3, h4, h5, h6 {
                                        margin-bottom:.5em;\r
                                }\r
 </style>\r
+<style type="text/css">\r
+               \r
+.trust0        {background-color:#ff5961;}\r
+.trust1 {background-color:#ff7a67;}\r
+.trust2 {background-color:#ff9b6c;}\r
+.trust3 {background-color:#ffbb72;}\r
+.trust4 {background-color:#ffdc77;}\r
+.trust5 {background-color:#fffd7d;}\r
+.trust6 {background-color:#e2fd83;}\r
+.trust7 {background-color:#c5fe8a;}\r
+.trust8 {background-color:#a7fe90;}\r
+.trust9 {background-color:#8aff97;}\r
+.trust10 {background-color:#6dff9d;}\r
+\r
+</style>\r
 </head>\r
 \r
 <body>\r