\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
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
//#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
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
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
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
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
\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
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
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
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
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
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
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
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
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
\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
\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
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