X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fglobal.cpp;h=d241f069f2ec6bb96f4324735ecdceaf74d9255e;hb=8a0a83a78390f22f99d4487cda2569909dfbc28e;hp=2dbfcdf9a3148f26a3e8a56e13c6fe4ef03e4160;hpb=3dc3ac3cfe10b7196a7977e9c041c29fa141c35e;p=fms.git diff --git a/src/global.cpp b/src/global.cpp index 2dbfcdf..d241f06 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -28,9 +28,6 @@ void SetupDB() db->Open("fms.db3"); db->SetBusyTimeout(10000); // set timeout to 10 seconds db->Execute("VACUUM;"); - - // TODO remove this - temp fix for problem in 0.1.8 - db->Execute("DELETE FROM tblMessageBoard WHERE MessageID NOT IN (SELECT MessageID FROM tblMessage);"); db->Execute("CREATE TABLE IF NOT EXISTS tblDBVersion(\ Major INTEGER,\ @@ -64,13 +61,25 @@ void SetupDB() major=1; minor=4; } + if(major==1 && minor==4) + { + ConvertDB0104To0105(); + major=1; + minor=5; + } + if(major==1 && minor==5) + { + ConvertDB0105To0106(); + major=1; + minor=6; + } } else { - db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,4);"); + db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,6);"); } - db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;"); + db->Execute("UPDATE tblDBVersion SET Major=1, Minor=6;"); db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\ Option TEXT UNIQUE,\ @@ -86,6 +95,7 @@ void SetupDB() SingleUse BOOL CHECK(SingleUse IN('true','false')) DEFAULT 'false',\ PublishTrustList BOOL CHECK(PublishTrustList IN('true','false')) DEFAULT 'false',\ PublishBoardList BOOL CHECK(PublishBoardList IN('true','false')) DEFAULT 'false',\ + PublishFreesite BOOL CHECK(PublishFreesite IN('true','false')) DEFAULT 'false',\ InsertingIdentity BOOL CHECK(InsertingIdentity IN('true','false')) DEFAULT 'false',\ LastInsertedIdentity DATETIME,\ InsertingPuzzle BOOL CHECK(InsertingPuzzle IN('true','false')) DEFAULT 'false',\ @@ -96,6 +106,7 @@ void SetupDB() LastInsertedBoardList DATETIME,\ InsertingMessageList BOOL CHECK(InsertingMessageList IN('true','false')) DEFAULT 'false',\ LastInsertedMessageList DATETIME,\ + LastInsertedFreesite DATETIME,\ DateCreated DATETIME\ );"); @@ -131,18 +142,21 @@ void SetupDB() );"); db->Execute("CREATE TABLE IF NOT EXISTS tblIdentity(\ - IdentityID INTEGER PRIMARY KEY,\ - PublicKey TEXT UNIQUE,\ - Name TEXT,\ - SingleUse BOOL CHECK(SingleUse IN('true','false')) DEFAULT 'false',\ - PublishTrustList BOOL CHECK(PublishTrustList IN('true','false')) DEFAULT 'false',\ - PublishBoardList BOOL CHECK(PublishBoardList IN('true','false')) DEFAULT 'false',\ - DateAdded DATETIME,\ - LastSeen DATETIME,\ - LocalMessageTrust INTEGER CHECK(LocalMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\ - PeerMessageTrust INTEGER CHECK(PeerMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\ - LocalTrustListTrust INTEGER CHECK(LocalTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\ - PeerTrustListTrust INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL\ + IdentityID INTEGER PRIMARY KEY,\ + PublicKey TEXT UNIQUE,\ + Name TEXT,\ + SingleUse BOOL CHECK(SingleUse IN('true','false')) DEFAULT 'false',\ + PublishTrustList BOOL CHECK(PublishTrustList IN('true','false')) DEFAULT 'false',\ + PublishBoardList BOOL CHECK(PublishBoardList IN('true','false')) DEFAULT 'false',\ + DateAdded DATETIME,\ + LastSeen DATETIME,\ + LocalMessageTrust INTEGER CHECK(LocalMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\ + PeerMessageTrust INTEGER CHECK(PeerMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\ + LocalTrustListTrust INTEGER CHECK(LocalTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\ + PeerTrustListTrust INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\ + AddedMethod TEXT,\ + MessageTrustComment TEXT,\ + TrustListTrustComment TEXT\ );"); db->Execute("CREATE TABLE IF NOT EXISTS tblIdentityRequests(\ @@ -172,10 +186,12 @@ void SetupDB() );"); db->Execute("CREATE TABLE IF NOT EXISTS tblPeerTrust(\ - IdentityID INTEGER,\ - TargetIdentityID INTEGER,\ - MessageTrust INTEGER CHECK(MessageTrust BETWEEN 0 AND 100),\ - TrustListTrust INTEGER CHECK(TrustListTrust BETWEEN 0 AND 100)\ + IdentityID INTEGER,\ + TargetIdentityID INTEGER,\ + MessageTrust INTEGER CHECK(MessageTrust BETWEEN 0 AND 100),\ + TrustListTrust INTEGER CHECK(TrustListTrust BETWEEN 0 AND 100),\ + MessageTrustComment TEXT,\ + TrustListTrustComment TEXT\ );"); db->Execute("CREATE TABLE IF NOT EXISTS tblBoard(\ @@ -463,6 +479,28 @@ void ConvertDB0103To0104() db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;"); } +void ConvertDB0104To0105() +{ + // add AddedMethod, MessageTrustComment, TrustListTrustComment to tblIdentity + // add MessageTrustComment,TrustListTrustComment to tblPeerTrust + SQLite3DB::DB *db=SQLite3DB::DB::Instance(); + db->Execute("ALTER TABLE tblIdentity ADD COLUMN AddedMethod TEXT;"); + db->Execute("ALTER TABLE tblIdentity ADD COLUMN MessageTrustComment TEXT;"); + db->Execute("ALTER TABLE tblIdentity ADD COLUMN TrustListTrustComment TEXT;"); + db->Execute("ALTER TABLE tblPeerTrust ADD COLUMN MessageTrustComment TEXT;"); + db->Execute("ALTER TABLE tblPeerTrust ADD COLUMN TrustListTrustComment TEXT;"); + db->Execute("UPDATE tblDBVersion SET Major=1, Minor=5;"); +} + +void ConvertDB0105To0106() +{ + // add Publish Freesite + SQLite3DB::DB *db=SQLite3DB::DB::Instance(); + db->Execute("ALTER TABLE tblLocalIdentity ADD COLUMN PublishFreesite BOOL CHECK(PublishFreesite IN('true','false')) DEFAULT 'false';"); + db->Execute("ALTER TABLE tblLocalIdentity ADD COLUMN LastInsertedFreesite DATETIME;"); + db->Execute("UPDATE tblDBVersion SET Major=1, Minor=6;"); +} + void SetupDefaultOptions() { // 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 @@ -509,7 +547,7 @@ void SetupDefaultOptions() st.Bind(0,"StartHTTP"); st.Bind(1,"true"); - st.Bind(2,"Start HTTP server."); + st.Bind(2,"Start HTTP server. WARNING: If you turn this off, you won't be able to access the administration pages."); st.Step(); st.Reset(); @@ -519,10 +557,16 @@ void SetupDefaultOptions() st.Step(); st.Reset(); + st.Bind(0,"HTTPAccessControl"); + st.Bind(1,"-0.0.0.0/0,+127.0.0.1"); + st.Bind(2,"Comma separated list of addresses and/or subnet masks that are allowed access to the administration pages. Default is localhost only. + allows a host, - denies as host."); + st.Step(); + st.Reset(); + // StartFreenetUpdater st.Bind(0,"StartFreenetUpdater"); st.Bind(1,"true"); - st.Bind(2,"Start Freenet Updater thread."); + st.Bind(2,"Set to true to start the Freenet Updater thread and connect to Freenet. Set to false to prevent communication with Freenet."); st.Step(); st.Reset(); @@ -595,7 +639,7 @@ void SetupDefaultOptions() st.Reset(); st.Bind(0,"MinLocalTrustListTrust"); - st.Bind(1,"51"); + st.Bind(1,"50"); st.Bind(2,"Specifies a local trust list trust level that a peer must have before its trust list will be included in the weighted average. Any peers below this number will be excluded from the results."); st.Step(); st.Reset(); @@ -636,6 +680,12 @@ void SetupDefaultOptions() st.Step(); st.Reset(); + st.Bind(0,"SaveMessagesFromNewBoards"); + st.Bind(1,"true"); + st.Bind(2,"Set to true to automatically save messages posted to new boards. Set to false to ignore messages to new boards."); + st.Step(); + st.Reset(); + st.Bind(0,"ChangeMessageTrustOnReply"); st.Bind(1,"0"); st.Bind(2,"How much the local message trust level of an identity should change when you reply to one of their messages."); @@ -714,72 +764,6 @@ void SigHandler(int signum) exit(0); } -/* -void ShutdownThreads(std::vector &threads) -{ - std::vector::iterator i; - for(i=threads.begin(); i!=threads.end(); i++) - { - (*i)->Cancel(); - } - - for(i=threads.begin(); i!=threads.end(); i++) - { - LogFile::Instance()->WriteLog(LogFile::LOGLEVEL_DEBUG,"ShutdownThreads waiting for thread to exit."); - //(*i)->wait(); - (*i)->Join(); - delete (*i); - } - - threads.clear(); - -} - -void StartThreads(std::vector &threads) -{ - std::string startfreenet; - std::string startnntp; - std::string starthttp; - - if(Option::Instance()->Get("StartFreenetUpdater",startfreenet)==false) - { - startfreenet="true"; - Option::Instance()->Set("StartFreenetUpdater","true"); - } - - if(Option::Instance()->Get("StartNNTP",startnntp)==false) - { - startnntp="true"; - Option::Instance()->Set("StartNNTP","true"); - } - - if(Option::Instance()->Get("StartHTTP",starthttp)==false) - { - starthttp="true"; - Option::Instance()->Set("StartHTTP","true"); - } - - if(startfreenet=="true") - { - PThread::Thread *t=new PThread::Thread(new FreenetMasterThread()); - threads.push_back(t); - } - - if(startnntp=="true") - { - PThread::Thread *t=new PThread::Thread(new NNTPListener()); - threads.push_back(t); - } - - if(starthttp=="true") - { - PThread::Thread *t=new PThread::Thread(new HTTPThread()); - threads.push_back(t); - } - -} -*/ - void FixCapitalBoardNames() { SQLite3DB::DB *db=SQLite3DB::DB::Instance();