const bool GetSingleUse() { return m_singleuse; }\r
void SetSingleUse(const bool singleuse) { m_singleuse=singleuse; }\r
\r
+ const int GetFreesiteEdition() { return m_freesiteedition; }\r
+ void SetFreesiteEdition(const int edition) { m_freesiteedition=edition; }\r
+\r
private:\r
void Initialize();\r
\r
bool m_publishtrustlist;\r
bool m_publishboardlist;\r
bool m_singleuse;\r
+ int m_freesiteedition;\r
\r
};\r
\r
#include <vector>\r
#include "pthreadwrapper/thread.h"\r
\r
-#define FMS_VERSION "0.2.9"\r
+#define FMS_VERSION "0.2.10"\r
\r
// opens database and creates tables and initial inserts if necessary\r
void SetupDB();\r
void ConvertDB0104To0105();\r
void ConvertDB0105To0106();\r
void ConvertDB0106To0107();\r
+void ConvertDB0107To0108();\r
// inserts default options into the database\r
void SetupDefaultOptions();\r
// opens logfile and sets it up\r
StringFunctions::Convert(localidentityid,idstring);\r
date.SetToGMTime();\r
\r
- SQLite3DB::Recordset rs=m_db->Query("SELECT Name,PrivateKey,SingleUse,PublishTrustList,PublishBoardList FROM tblLocalIdentity WHERE LocalIdentityID="+idstring+";");\r
+ SQLite3DB::Recordset rs=m_db->Query("SELECT Name,PrivateKey,SingleUse,PublishTrustList,PublishBoardList,PublishFreesite,FreesiteEdition FROM tblLocalIdentity WHERE LocalIdentityID="+idstring+";");\r
\r
if(rs.Empty()==false)\r
{\r
std::string singleuse="false";\r
std::string publishtrustlist="false";\r
std::string publishboardlist="false";\r
+ std::string freesiteedition="";\r
+ int edition=-1;\r
\r
now.SetToGMTime();\r
\r
}\r
publishboardlist=="true" ? idxml.SetPublishBoardList(true) : idxml.SetPublishBoardList(false);\r
\r
+ if(rs.GetField(5) && rs.GetField(6))\r
+ {\r
+ if(std::string(rs.GetField(5))=="true")\r
+ {\r
+ freesiteedition=rs.GetField(6);\r
+ StringFunctions::Convert(freesiteedition,edition);\r
+ idxml.SetFreesiteEdition(edition);\r
+ }\r
+ }\r
+\r
data=idxml.GetXML();\r
StringFunctions::Convert(data.size(),datasizestr);\r
\r
if(xml.ParseXML(std::string(data.begin(),data.end()))==true)\r
{\r
\r
- st=m_db->Prepare("UPDATE tblIdentity SET Name=?, SingleUse=?, LastSeen=?, PublishTrustList=?, PublishBoardList=? WHERE IdentityID=?");\r
+ st=m_db->Prepare("UPDATE tblIdentity SET Name=?, SingleUse=?, LastSeen=?, PublishTrustList=?, PublishBoardList=?, FreesiteEdition=? WHERE IdentityID=?");\r
name=xml.GetName();\r
if(name.size()>40)\r
{\r
{\r
st.Bind(4,"false");\r
}\r
- st.Bind(5,identityid);\r
+ if(xml.GetFreesiteEdition()>=0)\r
+ {\r
+ st.Bind(5,xml.GetFreesiteEdition());\r
+ }\r
+ else\r
+ {\r
+ st.Bind(5);\r
+ }\r
+ st.Bind(6,identityid);\r
st.Step();\r
st.Finalize();\r
\r
\r
tid->LinkEndChild(XMLCreateBooleanElement("PublishBoardList",m_publishboardlist));\r
\r
+ // freesite edition will be -1 if identity isn't publishing a freesite\r
+ if(m_freesiteedition>=0)\r
+ {\r
+ tid->LinkEndChild(XMLCreateTextElement("FreesiteEdition",m_freesiteedition));\r
+ }\r
+\r
td.Accept(&tp);\r
return std::string(tp.CStr());\r
\r
m_publishtrustlist=false;\r
m_publishboardlist=false;\r
m_singleuse=false;\r
+ m_freesiteedition=-1;\r
}\r
\r
const bool IdentityXML::ParseXML(const std::string &xml)\r
\r
m_publishboardlist=XMLGetBooleanElement(hnd.FirstChild("Identity").ToElement(),"PublishBoardList");\r
\r
+ txt=hnd.FirstChild("Identity").FirstChild("FreesiteEdition").FirstChild().ToText();\r
+ if(txt)\r
+ {\r
+ std::string editionstr=txt->ValueStr();\r
+ StringFunctions::Convert(editionstr,m_freesiteedition);\r
+ }\r
+\r
return true;\r
\r
}\r
\r
date.SetToGMTime();\r
date.Add(0,0,0,-20);\r
- SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,tblIdentityTrust.LocalMessageTrust,tblIdentityTrust.LocalTrustListTrust,tblIdentity.IdentityID,tblIdentityTrust.MessageTrustComment,tblIdentityTrust.TrustListTrustComment FROM tblIdentity LEFT JOIN (SELECT IdentityID,LocalMessageTrust,LocalTrustListTrust,MessageTrustComment,TrustListTrustComment FROM tblIdentityTrust WHERE LocalIdentityID=?) AS 'tblIdentityTrust' ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID WHERE PublicKey IS NOT NULL AND LastSeen IS NOT NULL AND LastSeen>=? ORDER BY Name COLLATE NOCASE;");\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,tblIdentityTrust.LocalMessageTrust,tblIdentityTrust.LocalTrustListTrust,tblIdentity.IdentityID,tblIdentityTrust.MessageTrustComment,tblIdentityTrust.TrustListTrustComment,tblIdentity.FreesiteEdition FROM tblIdentity LEFT JOIN (SELECT IdentityID,LocalMessageTrust,LocalTrustListTrust,MessageTrustComment,TrustListTrustComment FROM tblIdentityTrust WHERE LocalIdentityID=?) AS 'tblIdentityTrust' ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID WHERE PublicKey IS NOT NULL AND LastSeen IS NOT NULL AND LastSeen>=? ORDER BY Name COLLATE NOCASE;");\r
st.Bind(0,localidentityid);\r
st.Bind(1,date.Format("%Y-%m-%d %H:%M:%S"));\r
st.Step();\r
std::string trustlisttrust="";\r
std::string publickey="";\r
std::string uskkey="";\r
+ std::string freesiteedition="";\r
\r
st.ResultText(0,idname);\r
st.ResultText(1,publickey);\r
st.ResultText(4,thisid);\r
st.ResultText(5,messagetrustcomment);\r
st.ResultText(6,trustlisttrustcomment);\r
+ st.ResultText(7,freesiteedition);\r
\r
- if(publickey.find("SSK@")==0)\r
+ if(freesiteedition!="")\r
{\r
- uskkey=publickey;\r
- uskkey.erase(0,3);\r
- uskkey="USK"+uskkey;\r
- uskkey+=m_messagebase+"/0/";\r
+ if(publickey.find("SSK@")==0)\r
+ {\r
+ uskkey=publickey;\r
+ uskkey.erase(0,3);\r
+ uskkey="USK"+uskkey;\r
+ uskkey+=m_messagebase+"/"+freesiteedition+"/";\r
+ }\r
}\r
\r
content+="<tr>";\r
- content+="<td><a href=\""+uskkey+"\">"+SanitizeOutput(CreateShortIdentityName(idname,publickey))+"</a></td>";\r
+ if(freesiteedition!="")\r
+ {\r
+ content+="<td><a href=\""+uskkey+"\">"+SanitizeOutput(CreateShortIdentityName(idname,publickey))+"</a></td>";\r
+ }\r
+ else\r
+ {\r
+ content+="<td>"+SanitizeOutput(CreateShortIdentityName(idname,publickey))+"</td>";\r
+ }\r
content+="<td "+GetClassString(messagetrust)+">"+messagetrust+"</td>";\r
content+="<td>"+SanitizeOutput(messagetrustcomment)+"</td>";\r
content+="<td "+GetClassString(trustlisttrust)+">"+trustlisttrust+"</td>";\r
const bool SiteInserter::HandlePutSuccessful(FCPMessage &message)\r
{\r
std::vector<std::string> idparts;\r
+ std::vector<std::string> uriparts;\r
long localidentityid;\r
+ int edition=-1;\r
DateTime now;\r
\r
now.SetToGMTime();\r
StringFunctions::Split(message["Identifier"],"|",idparts);\r
StringFunctions::Convert(idparts[1],localidentityid);\r
\r
- SQLite3DB::Statement st=m_db->Prepare("UPDATE tblLocalIdentity SET LastInsertedFreesite=? WHERE LocalIdentityID=?;");\r
+ // edition is very last part of uri\r
+ StringFunctions::Split(message["URI"],"/",uriparts);\r
+ if(uriparts.size()>0)\r
+ {\r
+ StringFunctions::Convert(uriparts[uriparts.size()-1],edition);\r
+ }\r
+\r
+ SQLite3DB::Statement st=m_db->Prepare("UPDATE tblLocalIdentity SET LastInsertedFreesite=?, FreesiteEdition=? WHERE LocalIdentityID=?;");\r
st.Bind(0,now.Format("%Y-%m-%d %H:%M:%S"));\r
- st.Bind(1,localidentityid);\r
+ st.Bind(1,edition);\r
+ st.Bind(2,localidentityid);\r
st.Step();\r
\r
m_log->WriteLog(LogFile::LOGLEVEL_INFO,"SiteInserter::HandlePutSuccessful successfully inserted Freesite.");\r
major=1;\r
minor=7;\r
}\r
+ if(major==1 && minor==7)\r
+ {\r
+ ConvertDB0107To0108();\r
+ major=1;\r
+ minor=8;\r
+ }\r
}\r
else\r
{\r
- db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,7);");\r
+ db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,8);");\r
}\r
\r
- db->Execute("UPDATE tblDBVersion SET Major=1, Minor=7;");\r
+ db->Execute("UPDATE tblDBVersion SET Major=1, Minor=8;");\r
\r
db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\\r
Option TEXT UNIQUE,\\r
PublishTrustList BOOL CHECK(PublishTrustList IN('true','false')) DEFAULT 'false',\\r
PublishBoardList BOOL CHECK(PublishBoardList IN('true','false')) DEFAULT 'false',\\r
PublishFreesite BOOL CHECK(PublishFreesite IN('true','false')) DEFAULT 'false',\\r
+ FreesiteEdition INTEGER,\\r
InsertingIdentity BOOL CHECK(InsertingIdentity IN('true','false')) DEFAULT 'false',\\r
LastInsertedIdentity DATETIME,\\r
InsertingPuzzle BOOL CHECK(InsertingPuzzle IN('true','false')) DEFAULT 'false',\\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
+ FreesiteEdition INTEGER,\\r
DateAdded DATETIME,\\r
LastSeen DATETIME,\\r
LocalMessageTrust INTEGER CHECK(LocalMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
db->Execute("UPDATE tblDBVersion SET Major=1, Minor=7;");\r
}\r
\r
+void ConvertDB0107To0108()\r
+{\r
+ // add FreesiteEdition to tblLocalIdentity and tblIdentity\r
+ SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+ db->Execute("ALTER TABLE tblLocalIdentity ADD COLUMN FreesiteEdition INTEGER;");\r
+ db->Execute("ALTER TABLE tblIdentity ADD COLUMN FreesiteEdition INTEGER;");\r
+ db->Execute("UPDATE tblDBVersion SET Major=1, Minor=8;");\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 usk="";\r
std::string fcphost="";\r
std::string hidden="";\r
+ int freesiteedition=-1;\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 FROM tblIdentity WHERE IdentityID=?;");\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen,AddedMethod,Hidden,FreesiteEdition FROM tblIdentity WHERE IdentityID=?;");\r
st.Bind(0,identityid);\r
st.Step();\r
\r
st.ResultText(3,lastseen);\r
st.ResultText(4,addedmethod);\r
st.ResultText(5,hidden);\r
+ if(st.ResultNull(6)==false)\r
+ {\r
+ st.ResultInt(6,freesiteedition);\r
+ }\r
\r
usk=publickey;\r
- if(usk.find("SSK@")==0)\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
- usk="USK"+usk+messagebase+"/0/";\r
+ StringFunctions::Convert(freesiteedition,editionstr);\r
+ usk="USK"+usk+messagebase+"/"+editionstr+"/";\r
+ }\r
+ else\r
+ {\r
+ usk="";\r
}\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>Freesite</td><td class=\"smaller\"><a href=\"http://"+fcphost+":8888/"+SanitizeOutput(usk)+"\">"+SanitizeOutput(usk)+"</a></td></tr>";\r
+ if(usk!="")\r
+ {\r
+ content+="<tr><td>Freesite</td><td class=\"smaller\"><a href=\"http://"+fcphost+":8888/"+SanitizeOutput(usk)+"\">"+SanitizeOutput(usk)+"</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
}\r
else\r
{\r
- origmessagetrust=m_minlocalmessagetrust;\r
+ //origmessagetrust=m_minlocalmessagetrust;\r
+ origmessagetrust=50;\r
}\r
if(origmess.ResultNull(3)==false)\r
{\r
}\r
else\r
{\r
- origtrustlisttrust=m_minlocaltrustlisttrust;\r
+ //origtrustlisttrust=m_minlocaltrustlisttrust;\r
+ origtrustlisttrust=50;\r
}\r
\r
origmessagetrust+=changemessagetrust;\r
}\r
else\r
{\r
- localmessagetrust=m_minlocalmessagetrust;\r
+ //localmessagetrust=m_minlocalmessagetrust;\r
+ localmessagetrust=50;\r
}\r
\r
localmessagetrust+=m_changemessagetrustonreply;\r