void Initialize();\r
const bool HandlePutSuccessful(FCPMessage &message);\r
const bool HandlePutFailed(FCPMessage &message);\r
- void StartInsert(const long &localidentityid);\r
+ const bool StartInsert(const long &localidentityid);\r
void CheckForNeededInsert();\r
};\r
\r
std::string GetIdentityName(const long identityid);\r
\r
bool m_savemessagesfromnewboards;\r
+ bool m_localtrustoverrides;\r
\r
};\r
\r
void Initialize();\r
const bool HandlePutSuccessful(FCPMessage &message);\r
const bool HandlePutFailed(FCPMessage &message);\r
- void StartInsert(const long &fileinsertid);\r
+ const bool StartInsert(const long &fileinsertid);\r
void CheckForNeededInsert();\r
\r
};\r
virtual void Initialize()=0; // initialize m_fcpuniquename\r
virtual const bool HandlePutSuccessful(FCPMessage &message)=0;\r
virtual const bool HandlePutFailed(FCPMessage &message)=0;\r
- virtual void StartInsert(const IDTYPE &id)=0;\r
+ virtual const bool StartInsert(const IDTYPE &id)=0;\r
virtual void CheckForNeededInsert()=0;\r
virtual void RemoveFromInsertList(const IDTYPE id);\r
\r
void Initialize();\r
const bool HandlePutSuccessful(FCPMessage &message);\r
const bool HandlePutFailed(FCPMessage &message);\r
- void StartInsert(const std::string &messageuuid);\r
+ const bool StartInsert(const std::string &messageuuid);\r
void CheckForNeededInsert();\r
\r
};\r
void Initialize();\r
const bool HandlePutSuccessful(FCPMessage &message);\r
const bool HandlePutFailed(FCPMessage &message);\r
- void StartInsert(const long &localidentityid);\r
+ const bool StartInsert(const long &localidentityid);\r
void CheckForNeededInsert();\r
\r
long m_daysbackward;\r
+ std::map<long,std::string> m_lastinsertedxml; // last xml document inserted for each local identity\r
\r
};\r
\r
const bool HandleAllData(FCPMessage &message);\r
const bool HandleGetFailed(FCPMessage &message);\r
\r
+ bool m_localtrustoverrides;\r
+\r
};\r
\r
#endif // _messagelistrequester_\r
long m_maxpeermessages;\r
long m_maxboardspermessage;\r
bool m_savemessagesfromnewboards;\r
+ bool m_localtrustoverrides;\r
\r
};\r
\r
void Initialize();\r
const bool HandlePutSuccessful(FCPMessage &message);\r
const bool HandlePutFailed(FCPMessage &message);\r
- void StartInsert(const long &localidentityid);\r
+ const bool StartInsert(const long &localidentityid);\r
void CheckForNeededInsert();\r
const std::string SanitizeOutput(const std::string &input);\r
void GeneratePages(const long localidentityid, std::string &uskkey, std::map<std::string,std::string> &pages);\r
#include <vector>\r
#include "pthreadwrapper/thread.h"\r
\r
-#define FMS_VERSION "0.2.14"\r
+#define FMS_VERSION "0.2.15"\r
\r
// opens database and creates tables and initial inserts if necessary\r
void SetupDB();\r
{\r
m_fromcharset="";\r
m_tocharset="";\r
+ return false;\r
}\r
}\r
\r
m_fcpuniquename="BoardListInserter";\r
}\r
\r
-void BoardListInserter::StartInsert(const long &localidentityid)\r
+const bool BoardListInserter::StartInsert(const long &localidentityid)\r
{\r
DateTime daysback;\r
DateTime now;\r
\r
m_inserting.push_back(localidentityid);\r
\r
+ return true;\r
+\r
}\r
m_savemessagesfromnewboards=false;\r
}\r
\r
+ Option::Instance()->Get("LocalTrustOverridesPeerTrust",tempval);\r
+ if(tempval=="true")\r
+ {\r
+ m_localtrustoverrides=true;\r
+ }\r
+ else\r
+ {\r
+ m_localtrustoverrides=false;\r
+ }\r
+\r
}\r
\r
void BoardListRequester::PopulateIDList()\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 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
+ SQLite3DB::Statement st;\r
+\r
+ if(m_localtrustoverrides==false)\r
+ {\r
+ 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
+ }\r
+ else\r
+ {\r
+ 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') OR (LocalMessageTrust IS NULL AND (PeerMessageTrust IS NULL OR PeerMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerMessageTrust')))) AND PublishBoardList='true' ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
+ }\r
st.Step();\r
\r
m_ids.clear();\r
double endangle=(double)(rand()%360)*(3.14159/180);\r
pixel.Red=100+(rand()%150);\r
pixel.Green=100+(rand()%150);\r
+ pixel.Blue=100+(rand()%150);\r
DrawArc(bmp,x1,y1,radius,startangle,endangle,pixel);\r
}\r
\r
for(int i=0; i<5; i++)\r
{\r
// keep the colors dark\r
- lettercols[i].Red=(rand()%200);\r
- lettercols[i].Green=(rand()%200);\r
- lettercols[i].Blue=(rand()%200);\r
- // draw a line with the letter col\r
+ lettercols[i].Red=(rand()%150);\r
+ lettercols[i].Green=(rand()%150);\r
+ lettercols[i].Blue=(rand()%150);\r
+ // draw a line with the letter color\r
DrawAALine(bmp,rand()%bmpwidth,rand()%bmpheight,rand()%bmpwidth,rand()%bmpheight,lettercols[i]);\r
}\r
\r
m_fcpuniquename="FileInserter";\r
}\r
\r
-void FileInserter::StartInsert(const long &fileinsertid)\r
+const bool FileInserter::StartInsert(const long &fileinsertid)\r
{\r
FCPMessage message;\r
std::string fileinsertidstr="";\r
m_fcp->SendRaw(&data[0],data.size());\r
\r
m_inserting.push_back(fileinsertid);\r
+\r
+ return true;\r
}\r
m_fcpuniquename="MessageInserter";\r
}\r
\r
-void MessageInserter::StartInsert(const std::string &messageuuid)\r
+const bool MessageInserter::StartInsert(const std::string &messageuuid)\r
{\r
MessageXML xmlfile;\r
DateTime now;\r
m_inserting.push_back(messageuuid);\r
\r
m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageInserter::StartInsert started message insert "+message["URI"]);\r
+ \r
+ return true;\r
+ }\r
+ else\r
+ {\r
+ return false;\r
}\r
\r
}\r
std::string sql;\r
DateTime now;\r
DateTime previous;\r
+ bool startedinsert=false;\r
\r
now.SetToGMTime();\r
previous.SetToGMTime();\r
st.Bind(1,(now-(1.0/48.0)).Format("%Y-%m-%d %H:%M:%S"));\r
st.Step();\r
\r
- if(st.RowReturned())\r
+ while(st.RowReturned() && startedinsert==false)\r
{\r
int localidentityid;\r
st.ResultInt(0,localidentityid);\r
- StartInsert(localidentityid);\r
+ startedinsert=StartInsert(localidentityid);\r
+ st.Step();\r
}\r
}\r
\r
StringFunctions::Convert(tempval,m_daysbackward);\r
}\r
\r
-void MessageListInserter::StartInsert(const long &localidentityid)\r
+const bool MessageListInserter::StartInsert(const long &localidentityid)\r
{\r
FCPMessage message;\r
DateTime date;\r
\r
// actually insert message\r
xmlstr=mlxml.GetXML();\r
- StringFunctions::Convert(xmlstr.size(),xmlsizestr);\r
\r
- message.SetName("ClientPut");\r
- message["URI"]=privatekey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|MessageList|"+indexstr+".xml";\r
- message["Identifier"]=m_fcpuniquename+"|"+localidentityidstr+"|"+indexstr+"|"+message["URI"];\r
- message["UploadFrom"]="direct";\r
- message["DataLength"]=xmlsizestr;\r
- m_fcp->SendMessage(message);\r
- m_fcp->SendRaw(xmlstr.c_str(),xmlstr.size());\r
+ // only insert if the last message this identity inserted is different than this message\r
+ if(m_lastinsertedxml[localidentityid]!=xmlstr)\r
+ {\r
+ StringFunctions::Convert(xmlstr.size(),xmlsizestr);\r
+\r
+ message.SetName("ClientPut");\r
+ message["URI"]=privatekey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|MessageList|"+indexstr+".xml";\r
+ message["Identifier"]=m_fcpuniquename+"|"+localidentityidstr+"|"+indexstr+"|"+message["URI"];\r
+ message["UploadFrom"]="direct";\r
+ message["DataLength"]=xmlsizestr;\r
+ m_fcp->SendMessage(message);\r
+ m_fcp->SendRaw(xmlstr.c_str(),xmlstr.size());\r
+\r
+ m_inserting.push_back(localidentityid);\r
\r
- m_inserting.push_back(localidentityid);\r
+ m_lastinsertedxml[localidentityid]=xmlstr;\r
+ return true;\r
+ }\r
+ else\r
+ {\r
+ return false;\r
+ }\r
\r
}\r
{\r
m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"Option MaxMessageListRequests is currently set at "+tempval+". This value might be incorrectly configured.");\r
}\r
+\r
+ Option::Instance()->Get("LocalTrustOverridesPeerTrust",tempval);\r
+ if(tempval=="true")\r
+ {\r
+ m_localtrustoverrides=true;\r
+ }\r
+ else\r
+ {\r
+ m_localtrustoverrides=false;\r
+ }\r
+\r
}\r
\r
void MessageListRequester::PopulateIDList()\r
\r
date.SetToGMTime();\r
\r
+ SQLite3DB::Statement st;\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 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
+ if(m_localtrustoverrides==false)\r
+ {\r
+ 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
+ }\r
+ else\r
+ {\r
+ 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') OR (LocalMessageTrust IS NULL AND (PeerMessageTrust IS NULL OR PeerMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerMessageTrust')))) ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
+ }\r
st.Step();\r
\r
m_ids.clear();\r
{\r
m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"Option MaxBoardsPerMessage is currently set at "+tempval+". This value might be incorrectly configured.");\r
}\r
+\r
Option::Instance()->Get("SaveMessagesFromNewBoards",tempval);\r
if(tempval=="true")\r
{\r
{\r
m_savemessagesfromnewboards=false;\r
}\r
+\r
+ Option::Instance()->Get("LocalTrustOverridesPeerTrust",tempval);\r
+ if(tempval=="true")\r
+ {\r
+ m_localtrustoverrides=true;\r
+ }\r
+ else\r
+ {\r
+ m_localtrustoverrides=false;\r
+ }\r
+\r
}\r
\r
void MessageRequester::PopulateIDList()\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 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+="WHERE FromMessageList='true' AND Found='false' AND Day>='"+date.Format("%Y-%m-%d")+"' ";\r
+ if(m_localtrustoverrides==false)\r
+ {\r
+ sql+="AND (tblIdentity.LocalMessageTrust IS NULL OR tblIdentity.LocalMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalMessageTrust')) ";\r
+ sql+="AND (tblIdentity.PeerMessageTrust IS NULL OR tblIdentity.PeerMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerMessageTrust')) ";\r
+ }\r
+ else\r
+ {\r
+ sql+="AND (tblIdentity.LocalMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalMessageTrust') OR (tblIdentity.LocalMessageTrust IS NULL AND (tblIdentity.PeerMessageTrust IS NULL OR tblIdentity.PeerMessageTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerMessageTrust')))) ";\r
+ }\r
sql+="AND tblIdentity.Name <> '' ";\r
sql+=";";\r
\r
content+="</div>";\r
content+="<div class=\"postbody\">";\r
content+=SanitizeOutput(post);\r
+ //post=SanitizeOutput(post);\r
+ //StringFunctions::Replace(post,"\r\n","<br>");\r
+ //content+=post;\r
content+="</div>";\r
content+="</div>";\r
\r
return output;\r
}\r
\r
-void SiteInserter::StartInsert(const long &localidentityid)\r
+const bool SiteInserter::StartInsert(const long &localidentityid)\r
{\r
FCPMessage message;\r
std::string localidentityidstr="";\r
\r
m_inserting.push_back(localidentityid);\r
\r
+ return true;\r
+\r
}\r
);");\r
\r
db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('fms','Freenet Message System','2007-12-01 12:00:00','Initial Board');");\r
- db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('freenet','Discussion about Freenet','2007-12-01 12:00:00','Initialt Board');");\r
+ db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('freenet','Discussion about Freenet','2007-12-01 12:00:00','Initial Board');");\r
db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('public','Public discussion','2007-12-01 12:00:00','Initial Board');");\r
db->Execute("INSERT INTO tblBoard(BoardName,BoardDescription,DateAdded,AddedMethod) VALUES('test','Test board','2007-12-01 12:00:00','Initial Board');");\r
\r
st.Step();\r
st.Reset();\r
\r
+ st.Bind(0,"LocalTrustOverridesPeerTrust");\r
+ st.Bind(1,"false");\r
+ st.Bind(2,"Set to true if you want your local trust levels to override the peer levels when determining which identities you will poll.");\r
+ st.Step();\r
+ st.Reset();\r
+\r
st.Bind(0,"MessageDownloadMaxDaysBackward");\r
st.Bind(1,"5");\r
st.Bind(2,"The maximum number of days backward that messages will be downloaded from each identity");\r
content+="<td><input type=\"submit\" value=\"Update\"></form></td>";\r
content+="<td><form name=\"frmdel\""+countstr+"\" method=\"POST\"><input type=\"hidden\" name=\"formaction\" value=\"delete\"><input type=\"hidden\" name=\"chkidentityid["+countstr+"]\" value=\""+id+"\"><input type=\"submit\" value=\"Delete\"></form></td>";\r
content+="</tr>";\r
+ content+="<tr><td></td><td colspan=\"7\" class=\"smaller\">"+publickey+"</td></tr>";\r
st.Step();\r
count++;\r
}\r
std::string fcphost="";\r
std::string hidden="";\r
int freesiteedition=-1;\r
+ std::string publishtrustlist="";\r
+ std::string messagebase="";\r
\r
std::string fproxyport="8888";\r
Option::Instance()->Get("FProxyPort",fproxyport);\r
+ Option::Instance()->Get("MessageBase",messagebase);\r
\r
if(queryvars.find("identityid")!=queryvars.end() && (*queryvars.find("identityid")).second!="")\r
{\r
\r
Option::Instance()->Get("FCPHost",fcphost);\r
\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen,AddedMethod,Hidden,FreesiteEdition FROM tblIdentity WHERE IdentityID=?;");\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen,AddedMethod,Hidden,FreesiteEdition,PublishTrustList FROM tblIdentity WHERE IdentityID=?;");\r
st.Bind(0,identityid);\r
st.Step();\r
\r
{\r
st.ResultInt(6,freesiteedition);\r
}\r
+ st.ResultText(7,publishtrustlist);\r
\r
usk=publickey;\r
if(freesiteedition>=0 && usk.find("SSK@")==0)\r
{\r
- std::string messagebase="";\r
std::string editionstr="";\r
- Option::Instance()->Get("MessageBase",messagebase);\r
usk.erase(0,3);\r
StringFunctions::Convert(freesiteedition,editionstr);\r
usk="USK"+usk+messagebase+"/"+editionstr+"/";\r
{\r
content+="<tr><td>Freesite</td><td class=\"smaller\"><a href=\"http://"+fcphost+":"+fproxyport+"/"+SanitizeOutput(usk)+"\">"+SanitizeOutput(usk)+"</a></td></tr>";\r
}\r
+ if(publishtrustlist=="true")\r
+ {\r
+ std::string lastseendate=lastseen;\r
+ if(lastseendate.size()>=10)\r
+ {\r
+ lastseendate=lastseendate.substr(0,10);\r
+ }\r
+ content+="<tr><td>Trust List XML</td><td class=\"smaller\"><a href=\"http://"+fcphost+":"+fproxyport+"/"+SanitizeOutput(publickey)+messagebase+"|"+lastseendate+"|TrustList|0.xml\">Trust List</a></td></tr>";\r
+ }\r
content+="<tr><td>Date Added</td><td>"+dateadded+"</td></tr>";\r
content+="<tr><td>Last Seen</td><td>"+lastseen+"</td></tr>";\r
content+="<tr><td>Added Method</td><td class=\"smaller\">"+SanitizeOutput(addedmethod)+"</td></tr>";\r