private:\r
struct trust\r
{\r
- trust(const std::string &identity, const long messagetrust, const long trustlisttrust):m_identity(identity),m_messagetrust(messagetrust),m_trustlisttrust(trustlisttrust) {}\r
+ trust(const std::string &identity, const long messagetrust, const long trustlisttrust, const std::string &messagetrustcomment, const std::string &trustlisttrustcomment):m_identity(identity),m_messagetrust(messagetrust),m_trustlisttrust(trustlisttrust),m_messagetrustcomment(messagetrustcomment),m_trustlisttrustcomment(trustlisttrustcomment) {}\r
std::string m_identity;\r
long m_messagetrust;\r
long m_trustlisttrust;\r
+ std::string m_messagetrustcomment;\r
+ std::string m_trustlisttrustcomment;\r
};\r
public:\r
TrustListXML();\r
\r
void ClearTrust() { m_trust.clear(); }\r
\r
- void AddTrust(const std::string &identity, const long messagetrust, const long trustlisttrust);\r
+ void AddTrust(const std::string &identity, const long messagetrust, const long trustlisttrust, const std::string &messagetrustcomment, const std::string &trustlisttrustcomment);\r
\r
const std::vector<trust>::size_type TrustCount() { return m_trust.size(); }\r
std::string GetIdentity(const long index);\r
long GetMessageTrust(const long index);\r
long GetTrustListTrust(const long index);\r
+ std::string GetMessageTrustComment(const long index);\r
+ std::string GetTrustListTrustComment(const long index);\r
\r
private:\r
void Initialize();\r
//#include <zthread/Thread.h>\r
#include "pthreadwrapper/thread.h"\r
\r
-#define FMS_VERSION "0.2.1"\r
+#define FMS_VERSION "0.2.2"\r
\r
// opens database and creates tables and initial inserts if necessary\r
void SetupDB();\r
void ConvertDB0100To0101();\r
void ConvertDB0101To0103();\r
void ConvertDB0103To0104();\r
+void ConvertDB0104To0105();\r
// inserts default options into the database\r
void SetupDefaultOptions();\r
// opens logfile and sets it up\r
-----\r
Trust is the most important element of FMS. It determines which identities you\r
will download messages from and thus your overall experience. Do not give\r
-trust to arbitrary identities. Pick whom you trust wisely. There settings for\r
+trust to arbitrary identities. Pick whom you trust wisely. The settings for\r
minimum trust before downloading messages and trust lists can be changed on the\r
web interface.\r
\r
BMP bmp;\r
int bmpwidth=100;\r
int bmpheight=50;\r
+ RGBApixel lettercols[5];\r
std::string puzzlestring;\r
std::string tempfilename=GenerateRandomString(10);\r
tempfilename+=".bmp";\r
bmp.SetSize(bmpwidth,bmpheight);\r
\r
// first draw some random lines around the bitmap\r
- int numlines=(rand()%20)+10;\r
+ int numlines=(rand()%10)+10;\r
for(int i=0; i<numlines; i++)\r
{\r
RGBApixel pixel;\r
DrawAALine(bmp,x1,y1,x2,y2,pixel);\r
}\r
\r
- // print puzzle onto bitmap\r
+ // draw some random arcs\r
+ int numarcs=(rand()%10)+10;\r
+ for(int i=0; i<numarcs; i++)\r
+ {\r
+ RGBApixel pixel;\r
+ int x1=rand()%bmpwidth;\r
+ int y1=rand()%bmpwidth;\r
+ int radius=rand()%(bmpheight/2);\r
+ double startangle=(double)(rand()%360)*(3.14159/180);\r
+ double endangle=(double)(rand()%360)*(3.14159/180);\r
+ pixel.Red=100+(rand()%150);\r
+ pixel.Green=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
+ DrawAALine(bmp,rand()%bmpwidth,rand()%bmpheight,rand()%bmpwidth,rand()%bmpheight,lettercols[i]);\r
+ }\r
+\r
+ // print puzzle onto bitmap\r
+ for(int i=0; i<5; i++)\r
+ {\r
+ PrintLetter(bmp,puzzlestring[i],5+(i*20)+(rand()%11)-5,10+(rand()%10),20,lettercols[i]);\r
+ }\r
+\r
+ /* TOO dificult to solve with this\r
+ // skew image left/right\r
+ double skew=0;\r
+ for(int yy=0; yy<bmpheight; yy++)\r
+ {\r
RGBApixel pixel;\r
- pixel.Red=(rand()%200);\r
- pixel.Green=(rand()%200);\r
- pixel.Blue=(rand()%200);\r
- PrintLetter(bmp,puzzlestring[i],5+(i*20),10+(rand()%10),20,pixel);\r
+ skew=skew+(double)((rand()%11)-5)/20.0;\r
+ int xx;\r
+ for(xx=0; xx<skew; xx++)\r
+ {\r
+ pixel.Red=255;\r
+ pixel.Green=255;\r
+ pixel.Blue=255;\r
+ bmp.SetPixel(xx,yy,pixel);\r
+ }\r
+ if(skew<0)\r
+ {\r
+ for(xx=0; xx<bmpwidth+skew; xx++)\r
+ {\r
+ pixel=bmp.GetPixel(xx-skew,yy);\r
+ bmp.SetPixel(xx,yy,pixel);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ for(xx=bmpwidth-1; xx>skew; xx--)\r
+ {\r
+ pixel=bmp.GetPixel(xx-skew,yy);\r
+ bmp.SetPixel(xx,yy,pixel);\r
+ }\r
+ }\r
+ for(xx=bmpwidth+skew; xx<bmpwidth; xx++)\r
+ {\r
+ pixel.Red=255;\r
+ pixel.Green=255;\r
+ pixel.Blue=255;\r
+ bmp.SetPixel(xx,yy,pixel);\r
+ }\r
+ }\r
+ */\r
+\r
+ // generate noise for each pixel\r
+ for(int yy=0; yy<bmpheight; yy++)\r
+ {\r
+ for(int xx=0; xx<bmpwidth; xx++)\r
+ {\r
+ RGBApixel pixel=bmp.GetPixel(xx,yy);\r
+ int tempred=pixel.Red+(rand()%21)-10;\r
+ int tempgreen=pixel.Green+(rand()%21)-10;\r
+ int tempblue=pixel.Blue+(rand()%21)-10;\r
+\r
+ tempred < 0 ? tempred=0 : false;\r
+ tempred > 255 ? tempred=255 : false;\r
+ tempgreen < 0 ? tempgreen=0 : false;\r
+ tempgreen > 255 ? tempgreen=255 : false;\r
+ tempblue < 0 ? tempblue=0 : false;\r
+ tempblue > 255 ? tempblue=255 : false;\r
+\r
+ pixel.Red=tempred;\r
+ pixel.Green=tempgreen;\r
+ pixel.Blue=tempblue;\r
+\r
+ bmp.SetPixel(xx,yy,pixel);\r
+ }\r
}\r
\r
bmp.WriteToFile(tempfilename.c_str());\r
// we don't already know about this id - add it\r
st.Finalize();\r
date.SetToGMTime();\r
- st=m_db->Prepare("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES(?,?);");\r
+ st=m_db->Prepare("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES(?,?,?);");\r
st.Bind(0,xml.GetIdentity());\r
st.Bind(1,date.Format("%Y-%m-%d %H:%M:%S"));\r
+ st.Bind(2,"solved captcha");\r
st.Step();\r
}\r
st.Finalize();\r
int id;\r
\r
date.SetToGMTime();\r
- date.Add(0,0,-1);\r
+ date.SetHour(0);\r
+ date.SetMinute(0);\r
+ date.SetSecond(0);\r
\r
- // select identities we want to query (haven't seen in last hour) - 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 IS NULL OR LastSeen<='"+date.Format("%Y-%m-%d %H:%M:%S")+"') ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
+ // select identities we want to query (haven't seen yet 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 IS NULL OR LastSeen<'"+date.Format("%Y-%m-%d %H:%M:%S")+"') ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
st.Step();\r
\r
m_ids.clear();\r
int index;\r
std::string indexstr;\r
std::string localidentityidstr;\r
+ std::string messagetrustcomment="";\r
+ std::string trustlisttrustcomment="";\r
\r
now.SetToGMTime();\r
date.SetToGMTime();\r
\r
// build the xml file - we only want to add identities that we recently saw, otherwise we could be inserting a ton of identities\r
date.Add(0,0,0,-20); // identities seen in last 20 days\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, LocalMessageTrust, LocalTrustListTrust FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LastSeen>=?;");\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, LocalMessageTrust, LocalTrustListTrust, MessageTrustComment, TrustListTrustComment FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LastSeen>=?;");\r
st.Bind(0,date.Format("%Y-%m-%d"));\r
st.Step();\r
while(st.RowReturned())\r
{\r
trustlisttrust=-1;\r
}\r
- xml.AddTrust(publickey,messagetrust,trustlisttrust);\r
+ st.ResultText(3,messagetrustcomment);\r
+ st.ResultText(4,trustlisttrustcomment);\r
+ xml.AddTrust(publickey,messagetrust,trustlisttrust,messagetrustcomment,trustlisttrustcomment);\r
st.Step();\r
}\r
\r
// parse file into xml and update the database\r
if(xml.ParseXML(std::string(data.begin(),data.end()))==true)\r
{\r
+ // find the identity name and public key of the identity publishing the trust list\r
+ std::string publisherid="";\r
+ st=m_db->Prepare("SELECT Name,PublicKey FROM tblIdentity WHERE IdentityID=?;");\r
+ st.Bind(0,identityid);\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ std::string publishername="";\r
+ std::string publisherpublickey="";\r
+ st.ResultText(0,publishername);\r
+ st.ResultText(1,publisherpublickey);\r
+ publisherid=publishername;\r
+ if(publisherpublickey.size()>4)\r
+ {\r
+ publisherid+=publisherpublickey.substr(3,44);\r
+ }\r
+ }\r
+ st.Finalize();\r
\r
// drop all existing peer trust from this identity - we will rebuild it when we go through each trust in the xml file\r
st=m_db->Prepare("DELETE FROM tblPeerTrust WHERE IdentityID=?;");\r
st.Finalize();\r
\r
st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey=?;");\r
- trustst=m_db->Prepare("INSERT INTO tblPeerTrust(IdentityID,TargetIdentityID,MessageTrust,TrustListTrust) VALUES(?,?,?,?);");\r
+ trustst=m_db->Prepare("INSERT INTO tblPeerTrust(IdentityID,TargetIdentityID,MessageTrust,TrustListTrust,MessageTrustComment,TrustListTrustComment) VALUES(?,?,?,?,?,?);");\r
+ \r
+ SQLite3DB::Statement idinsert=m_db->Prepare("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES(?,?,?);");\r
+ \r
// loop through all trust entries in xml and add to database if we don't already know them\r
for(long i=0; i<xml.TrustCount(); i++)\r
{\r
int id;\r
std::string identity;\r
+ std::string messagetrustcomment="";\r
+ std::string trustlisttrustcomment="";\r
identity=xml.GetIdentity(i);\r
\r
st.Bind(0,identity);\r
st.Step();\r
if(st.RowReturned()==false)\r
{\r
- m_db->ExecuteInsert("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('"+identity+"','"+now.Format("%Y-%m-%d %H:%M:%S")+"');",(long &)id);\r
+ idinsert.Bind(0,identity);\r
+ idinsert.Bind(1,now.Format("%Y-%m-%d %H:%M:%S"));\r
+ idinsert.Bind(2,"trust list of "+publisherid);\r
+ idinsert.Step(true);\r
+ id=idinsert.GetLastInsertRowID();\r
+ idinsert.Reset();\r
+ // m_db->ExecuteInsert("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('"+identity+"','"+now.Format("%Y-%m-%d %H:%M:%S")+"');",(long &)id);\r
}\r
else\r
{\r
{\r
trustst.Bind(3,xml.GetTrustListTrust(i));\r
}\r
+ messagetrustcomment=xml.GetMessageTrustComment(i);\r
+ trustlisttrustcomment=xml.GetTrustListTrustComment(i);\r
+ // limit comments to 50 characters each\r
+ if(messagetrustcomment.size()>50)\r
+ {\r
+ messagetrustcomment.erase(50);\r
+ }\r
+ if(trustlisttrustcomment.size()>50)\r
+ {\r
+ trustlisttrustcomment.erase(50);\r
+ }\r
+ trustst.Bind(4,messagetrustcomment);\r
+ trustst.Bind(5,trustlisttrustcomment);\r
trustst.Step();\r
trustst.Reset();\r
\r
Initialize();\r
}\r
\r
-void TrustListXML::AddTrust(const std::string &identity, const long messagetrust, const long trustlisttrust)\r
+void TrustListXML::AddTrust(const std::string &identity, const long messagetrust, const long trustlisttrust, const std::string &messagetrustcomment, const std::string &trustlisttrustcomment)\r
{\r
- m_trust.push_back(trust(identity,messagetrust,trustlisttrust));\r
+ m_trust.push_back(trust(identity,messagetrust,trustlisttrust,messagetrustcomment,trustlisttrustcomment));\r
}\r
\r
std::string TrustListXML::GetIdentity(const long index)\r
} \r
}\r
\r
+std::string TrustListXML::GetMessageTrustComment(const long index)\r
+{\r
+ if(index>=0 && index<m_trust.size())\r
+ {\r
+ return m_trust[index].m_messagetrustcomment;\r
+ }\r
+ else\r
+ {\r
+ return "";\r
+ } \r
+}\r
+\r
long TrustListXML::GetTrustListTrust(const long index)\r
{\r
if(index>=0 && index<m_trust.size())\r
}\r
}\r
\r
+std::string TrustListXML::GetTrustListTrustComment(const long index)\r
+{\r
+ if(index>=0 && index<m_trust.size())\r
+ {\r
+ return m_trust[index].m_trustlisttrustcomment;\r
+ }\r
+ else\r
+ {\r
+ return "";\r
+ }\r
+}\r
+\r
std::string TrustListXML::GetXML()\r
{\r
TiXmlDocument td;\r
{\r
tr->LinkEndChild(XMLCreateTextElement("TrustListTrustLevel",trustlisttrust));\r
}\r
+ if((*i).m_messagetrustcomment!="")\r
+ {\r
+ tr->LinkEndChild(XMLCreateCDATAElement("MessageTrustComment",(*i).m_messagetrustcomment));\r
+ }\r
+ if((*i).m_trustlisttrustcomment!="")\r
+ {\r
+ tr->LinkEndChild(XMLCreateCDATAElement("TrustListTrustComment",(*i).m_trustlisttrustcomment));\r
+ }\r
}\r
\r
td.Accept(&tp);\r
std::string identity;\r
std::string messagetruststr;\r
std::string trustlisttruststr;\r
+ std::string messagetrustcomment="";\r
+ std::string trustlisttrustcomment="";\r
long messagetrust;\r
long trustlisttrust;\r
TiXmlText *txt;\r
StringFunctions::Convert(trustlisttruststr,trustlisttrust);\r
}\r
}\r
+ txt=hnd2.FirstChild("MessageTrustComment").FirstChild().ToText();\r
+ if(txt)\r
+ {\r
+ messagetrustcomment=txt->ValueStr();\r
+ }\r
+ txt=hnd2.FirstChild("TrustListTrustComment").FirstChild().ToText();\r
+ if(txt)\r
+ {\r
+ trustlisttrustcomment=txt->ValueStr();\r
+ }\r
\r
if(identity!="" && messagetrust>=-1 && messagetrust<=100 && trustlisttrust>=-1 && trustlisttrust<=100)\r
{\r
if(std::find(m_foundkeys.begin(),m_foundkeys.end(),identity)==m_foundkeys.end())\r
{\r
m_foundkeys.push_back(identity);\r
- m_trust.push_back(trust(identity,messagetrust,trustlisttrust));\r
+ m_trust.push_back(trust(identity,messagetrust,trustlisttrust,messagetrustcomment,trustlisttrustcomment));\r
}\r
}\r
else\r
db->Open("fms.db3");\r
db->SetBusyTimeout(10000); // set timeout to 10 seconds\r
db->Execute("VACUUM;");\r
- \r
- // TODO remove this - temp fix for problem in 0.1.8\r
- db->Execute("DELETE FROM tblMessageBoard WHERE MessageID NOT IN (SELECT MessageID FROM tblMessage);");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblDBVersion(\\r
Major INTEGER,\\r
major=1;\r
minor=4;\r
}\r
+ if(major==1 && minor==4)\r
+ {\r
+ ConvertDB0104To0105();\r
+ major=1;\r
+ minor=5;\r
+ }\r
}\r
else\r
{\r
- db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,4);");\r
+ db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,5);");\r
}\r
\r
db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;");\r
);");\r
\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
+ 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
+ AddedMethod TEXT,\\r
+ MessageTrustComment TEXT,\\r
+ TrustListTrustComment TEXT\\r
);");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblIdentityRequests(\\r
);");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblPeerTrust(\\r
- IdentityID INTEGER,\\r
- TargetIdentityID INTEGER,\\r
- MessageTrust INTEGER CHECK(MessageTrust BETWEEN 0 AND 100),\\r
- TrustListTrust INTEGER CHECK(TrustListTrust BETWEEN 0 AND 100)\\r
+ IdentityID INTEGER,\\r
+ TargetIdentityID INTEGER,\\r
+ MessageTrust INTEGER CHECK(MessageTrust BETWEEN 0 AND 100),\\r
+ TrustListTrust INTEGER CHECK(TrustListTrust BETWEEN 0 AND 100),\\r
+ MessageTrustComment TEXT,\\r
+ TrustListTrustComment TEXT\\r
);");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblBoard(\\r
db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;");\r
}\r
\r
+void ConvertDB0104To0105()\r
+{\r
+ // add AddedMethod, MessageTrustComment, TrustListTrustComment to tblIdentity\r
+ // add MessageTrustComment,TrustListTrustComment to tblPeerTrust\r
+ SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+ db->Execute("ALTER TABLE tblIdentity ADD COLUMN AddedMethod TEXT;");\r
+ db->Execute("ALTER TABLE tblIdentity ADD COLUMN MessageTrustComment TEXT;");\r
+ db->Execute("ALTER TABLE tblIdentity ADD COLUMN TrustListTrustComment TEXT;");\r
+ db->Execute("ALTER TABLE tblPeerTrust ADD COLUMN MessageTrustComment TEXT;");\r
+ db->Execute("ALTER TABLE tblPeerTrust ADD COLUMN TrustListTrustComment TEXT;");\r
+ db->Execute("UPDATE tblDBVersion SET Major=1, Minor=5;");\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
std::string keypart="";\r
std::string lastseen="";\r
std::string dateadded="";\r
+ std::string addedmethod="";\r
\r
if(queryvars.find("identityid")!=queryvars.end() && (*queryvars.find("identityid")).second!="")\r
{\r
del.Step();\r
}\r
\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen FROM tblIdentity WHERE IdentityID=?;");\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen,AddedMethod FROM tblIdentity WHERE IdentityID=?;");\r
st.Bind(0,identityid);\r
st.Step();\r
\r
st.ResultText(1,publickey);\r
st.ResultText(2,dateadded);\r
st.ResultText(3,lastseen);\r
+ st.ResultText(4,addedmethod);\r
\r
content+="<tr><td>Name</td><td>"+SanitizeOutput(name)+"</td></tr>";\r
content+="<tr><td>Public Key</td><td class=\"smaller\">"+SanitizeOutput(publickey)+"</td></tr>";\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
}\r
\r
// get message count posted by this identity\r
content+="</table>";\r
\r
\r
- st=m_db->Prepare("SELECT Name,PublicKey,MessageTrust,TrustListTrust,tblIdentity.IdentityID FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.TargetIdentityID=tblIdentity.IdentityID WHERE tblPeerTrust.IdentityID=? ORDER BY Name COLLATE NOCASE;");\r
+ st=m_db->Prepare("SELECT Name,PublicKey,MessageTrust,TrustListTrust,tblIdentity.IdentityID,tblPeerTrust.MessageTrustComment,tblPeerTrust.TrustListTrustComment FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.TargetIdentityID=tblIdentity.IdentityID WHERE tblPeerTrust.IdentityID=? ORDER BY Name COLLATE NOCASE;");\r
st.Bind(0,identityid);\r
st.Step();\r
\r
content+="<tr><th colspan=\"3\">";\r
content+="Trust List of this identity";\r
content+="</th></tr>";\r
- content+="<tr><td></td><th>Message Trust</th><th>Trust List Trust</th></tr>";\r
+ content+="<tr><td></td><th>Message Trust</th><th>Message Comment</th><th>Trust List Trust</th><th>Trust Comment</th></tr>";\r
while(st.RowReturned())\r
{\r
std::string thisid="";\r
+ std::string messagetrustcomment="";\r
+ std::string trustlisttrustcomment="";\r
\r
st.ResultText(0,name);\r
st.ResultText(1,publickey);\r
st.ResultText(2,messagetrust);\r
st.ResultText(3,trustlisttrust);\r
st.ResultText(4,thisid);\r
+ st.ResultText(5,messagetrustcomment);\r
+ st.ResultText(6,trustlisttrustcomment);\r
\r
if(publickey.size()>8)\r
{\r
content+="<tr>";\r
content+="<td><a href=\"peerdetails.htm?identityid="+thisid+"\">"+SanitizeOutput(name+keypart)+"...</a></td>";\r
content+="<td "+GetClassString(messagetrust)+">"+messagetrust+"</td>";\r
+ content+="<td>"+SanitizeOutput(messagetrustcomment)+"</td>";\r
content+="<td "+GetClassString(trustlisttrust)+">"+trustlisttrust+"</td>";\r
+ content+="<td>"+SanitizeOutput(trustlisttrustcomment)+"</td>";\r
content+="</tr>\r\n";\r
\r
st.Step();\r
}\r
\r
- st=m_db->Prepare("SELECT Name,PublicKey,MessageTrust,TrustListTrust,tblIdentity.IdentityID FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.IdentityID=tblIdentity.IdentityID WHERE tblPeerTrust.TargetIdentityID=? ORDER BY Name COLLATE NOCASE;");\r
+ st=m_db->Prepare("SELECT Name,PublicKey,MessageTrust,TrustListTrust,tblIdentity.IdentityID,tblPeerTrust.MessageTrustComment,tblPeerTrust.TrustListTrustComment FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.IdentityID=tblIdentity.IdentityID WHERE tblPeerTrust.TargetIdentityID=? ORDER BY Name COLLATE NOCASE;");\r
st.Bind(0,identityid);\r
st.Step();\r
\r
content+="<tr><th colspan=\"3\">";\r
content+="Trust of this identity from other identities";\r
content+="</th></tr>";\r
- content+="<tr><td></td><th>Message Trust</th><th>Trust List Trust</th></tr>";\r
+ content+="<tr><td></td><th>Message Trust</th><th>Message Comment</th><th>Trust List Trust</th><th>Trust Comment</th></tr>";\r
while(st.RowReturned())\r
{\r
std::string thisid="";\r
+ std::string messagetrustcomment="";\r
+ std::string trustlisttrustcomment="";\r
\r
st.ResultText(0,name);\r
st.ResultText(1,publickey);\r
st.ResultText(2,messagetrust);\r
st.ResultText(3,trustlisttrust);\r
st.ResultText(4,thisid);\r
+ st.ResultText(5,messagetrustcomment);\r
+ st.ResultText(6,trustlisttrustcomment);\r
\r
if(publickey.size()>8)\r
{\r
content+="<tr>";\r
content+="<td><a href=\"peerdetails.htm?identityid="+thisid+"\">"+SanitizeOutput(name+keypart)+"...</a></td>";\r
content+="<td "+GetClassString(messagetrust)+">"+messagetrust+"</td>";\r
+ content+="<td>"+SanitizeOutput(messagetrustcomment)+"</td>";\r
content+="<td "+GetClassString(trustlisttrust)+">"+trustlisttrust+"</td>";\r
+ content+="<td>"+SanitizeOutput(trustlisttrustcomment)+"</td>";\r
content+="</tr>";\r
\r
st.Step();\r
std::vector<std::string> lmt;\r
std::vector<std::string> oldltlt;\r
std::vector<std::string> ltlt;\r
+ std::vector<std::string> oldmtc;\r
+ std::vector<std::string> mtc;\r
+ std::vector<std::string> oldtltc;\r
+ std::vector<std::string> tltc;\r
int localmessagetrust=0;\r
int localtrustlisttrust=0;\r
int identityid;\r
CreateArgArray(queryvars,"localmessagetrust",lmt);\r
CreateArgArray(queryvars,"oldlocaltrustlisttrust",oldltlt);\r
CreateArgArray(queryvars,"localtrustlisttrust",ltlt);\r
+ CreateArgArray(queryvars,"oldmessagetrustcomment",oldmtc);\r
+ CreateArgArray(queryvars,"messagetrustcomment",mtc);\r
+ CreateArgArray(queryvars,"oldtrustlisttrustcomment",oldtltc);\r
+ CreateArgArray(queryvars,"trustlisttrustcomment",tltc);\r
\r
- SQLite3DB::Statement update=m_db->Prepare("UPDATE tblIdentity SET LocalMessageTrust=?, LocalTrustListTrust=? WHERE IdentityID=?;");\r
+ SQLite3DB::Statement update=m_db->Prepare("UPDATE tblIdentity SET LocalMessageTrust=?, LocalTrustListTrust=?, MessageTrustComment=?, TrustListTrustComment=? WHERE IdentityID=?;");\r
\r
for(int i=0; i<identityids.size(); i++)\r
{\r
- if(oldlmt[i]!=lmt[i] || oldltlt[i]!=ltlt[i])\r
+ if(oldlmt[i]!=lmt[i] || oldltlt[i]!=ltlt[i] || oldmtc[i]!=mtc[i] || oldtltc[i]!=tltc[i])\r
{\r
StringFunctions::Convert(lmt[i],localmessagetrust);\r
StringFunctions::Convert(ltlt[i],localtrustlisttrust);\r
{\r
update.Bind(1);\r
}\r
- update.Bind(2,identityid);\r
+ update.Bind(2,mtc[i]);\r
+ update.Bind(3,tltc[i]);\r
+ update.Bind(4,identityid);\r
update.Step();\r
update.Reset();\r
}\r
content+="<table>";\r
content+="<tr><th><a href=\"peertrust.htm?"+BuildQueryString(startrow,namesearch,"Name",ReverseSort("Name",sortby,sortorder))+"\">Name</a></th>";\r
content+="<th><a href=\"peertrust.htm?"+BuildQueryString(startrow,namesearch,"LocalMessageTrust",ReverseSort("LocalMessageTrust",sortby,sortorder))+"\">Local Message Trust</a></th>";\r
+ content+="<th>Message Comment</th>";\r
content+="<th><a href=\"peertrust.htm?"+BuildQueryString(startrow,namesearch,"PeerMessageTrust",ReverseSort("PeerMessageTrust",sortby,sortorder))+"\">Peer Message Trust</a></th>";\r
content+="<th><a href=\"peertrust.htm?"+BuildQueryString(startrow,namesearch,"LocalTrustListTrust",ReverseSort("LocalTrustListTrust",sortby,sortorder))+"\">Local Trust List Trust</a></th>";\r
+ content+="<th>Trust Comment</th>";\r
content+="<th><a href=\"peertrust.htm?"+BuildQueryString(startrow,namesearch,"PeerTrustListTrust",ReverseSort("PeerTrustListTrust",sortby,sortorder))+"\">Peer Trust List Trust</a></th></tr>";\r
\r
// get count of identities we are showing\r
st.ResultInt(0,identitycount);\r
st.Finalize();\r
\r
- sql="SELECT IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey FROM tblIdentity";\r
+ sql="SELECT IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey,MessageTrustComment,TrustListTrustComment FROM tblIdentity";\r
if(namesearch!="")\r
{\r
sql+=" WHERE Name LIKE '%' || ? || '%'";\r
std::string peertrustlisttrust;\r
std::string publickey;\r
std::string keypart="";\r
+ std::string messagetrustcomment="";\r
+ std::string trustlisttrustcomment="";\r
\r
StringFunctions::Convert(count,countstr);\r
\r
st.ResultText(4,localtrustlisttrust);\r
st.ResultText(5,peertrustlisttrust);\r
st.ResultText(6,publickey);\r
+ st.ResultText(7,messagetrustcomment);\r
+ st.ResultText(8,trustlisttrustcomment);\r
\r
if(publickey.size()>8)\r
{\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 "+GetClassString(localmessagetrust)+">";\r
+ content+="<input type=\"hidden\" name=\"oldmessagetrustcomment["+countstr+"]\" value=\""+SanitizeOutput(messagetrustcomment)+"\">";\r
+ content+="<input type=\"text\" name=\"messagetrustcomment["+countstr+"]\" value=\""+SanitizeOutput(messagetrustcomment)+"\" maxlength=\"50\">";\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 "+GetClassString(localtrustlisttrust)+">";\r
+ content+="<input type=\"hidden\" name=\"oldtrustlisttrustcomment["+countstr+"]\" value=\""+SanitizeOutput(trustlisttrustcomment)+"\">";\r
+ content+="<input type=\"text\" name=\"trustlisttrustcomment["+countstr+"]\" value=\""+SanitizeOutput(trustlisttrustcomment)+"\" maxlength=\"50\">";\r
+ content+="</td>";\r
content+="<td "+GetClassString(peertrustlisttrust)+">";\r
content+=peertrustlisttrust+"</td>";\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?"+BuildQueryString(startrow-rowsperpage,namesearch,sortby,sortorder)+"\"><-- Previous Page</a></td>";\r
- cols+=2;\r
+ content+="<td colspan=\"3\" align=\"left\"><a href=\"peertrust.htm?"+BuildQueryString(startrow-rowsperpage,namesearch,sortby,sortorder)+"\"><-- Previous Page</a></td>";\r
+ cols+=3;\r
}\r
if(startrow+rowsperpage<identitycount)\r
{\r
- while(cols<3)\r
+ while(cols<4)\r
{\r
content+="<td></td>";\r
cols++;\r
}\r
- content+="<td colspan=\"2\" align=\"right\"><a href=\"peertrust.htm?"+BuildQueryString(startrow+rowsperpage,namesearch,sortby,sortorder)+"\">Next Page --></a></td>";\r
+ content+="<td colspan=\"3\" align=\"right\"><a href=\"peertrust.htm?"+BuildQueryString(startrow+rowsperpage,namesearch,sortby,sortorder)+"\">Next Page --></a></td>";\r
}\r
content+="</tr>";\r
}\r
\r
int main(int argc, char *argv[])\r
{\r
+\r
bool daemon=false;\r
\r
#ifdef XMEM\r