version 0.3.7
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Fri, 11 Jul 2008 17:01:00 +0000 (19:01 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 11 Jul 2008 17:01:00 +0000 (19:01 +0200)
CMakeLists.txt
include/global.h
include/http/pages/versioninfopage.h [new file with mode: 0644]
src/dbmaintenancethread.cpp
src/fmsapp.cpp
src/http/fmshttprequesthandlerfactory.cpp
src/http/pages/homepage.cpp
src/http/pages/versioninfopage.cpp [new file with mode: 0644]
src/optionssetup.cpp

index 1ab671d..db5f4f4 100644 (file)
@@ -96,6 +96,7 @@ src/http/pages/peerdetailspage.cpp
 src/http/pages/peermaintenancepage.cpp\r
 src/http/pages/peertrustpage.cpp\r
 src/http/pages/showcaptchapage.cpp\r
+src/http/pages/versioninfopage.cpp\r
 src/nntp/extensiontrust.cpp\r
 src/nntp/mime\r
 src/nntp/nntpconnection.cpp\r
index 204aa45..34eb58a 100644 (file)
@@ -7,7 +7,7 @@
 \r
 #define VERSION_MAJOR          "0"\r
 #define VERSION_MINOR          "3"\r
-#define VERSION_RELEASE                "6"\r
+#define VERSION_RELEASE                "7"\r
 #define FMS_VERSION                    VERSION_MAJOR"."VERSION_MINOR"."VERSION_RELEASE\r
 \r
 typedef Poco::ScopedLock<Poco::FastMutex> Guard;\r
diff --git a/include/http/pages/versioninfopage.h b/include/http/pages/versioninfopage.h
new file mode 100644 (file)
index 0000000..1d87554
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _versioninfopage_\r
+#define _versioninfopage_\r
+\r
+#include "../ipagehandler.h"\r
+#include "../../idatabase.h"\r
+\r
+class VersionInfoPage:public IPageHandler,public IDatabase\r
+{\r
+public:\r
+       VersionInfoPage(const std::string &templatestr):IPageHandler(templatestr)               {}\r
+\r
+       IPageHandler *New()     { return new VersionInfoPage(m_template); }\r
+\r
+private:\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
+};\r
+\r
+#endif // _versioninfopage_\r
index b613715..bfee4fb 100644 (file)
@@ -20,6 +20,7 @@ DBMaintenanceThread::DBMaintenanceThread()
        m_last1day=Poco::Timestamp();\r
        m_last1day-=Poco::Timespan(0,23,51,0,0);\r
 \r
+       m_deletemessagesolderthan=180;\r
        std::string tempval="180";\r
        Option::Instance()->Get("DeleteMessagesOlderThan",tempval);\r
        StringFunctions::Convert(tempval,m_deletemessagesolderthan);\r
@@ -252,6 +253,7 @@ void DBMaintenanceThread::Do1DayMaintenance()
        // delete old messages\r
        date=Poco::Timestamp();\r
        date-=Poco::Timespan(m_deletemessagesolderthan,0,0,0,0);\r
+       m_log->trace("PeriodicDBMaintenance::Do1DayMaintenance deleting messages prior to "+Poco::DateTimeFormatter::format(date,"%Y-%m-%d"));\r
        st=m_db->Prepare("DELETE FROM tblMessage WHERE MessageDate<?;");\r
        st.Bind(0,Poco::DateTimeFormatter::format(date,"%Y-%m-%d"));\r
        st.Step();\r
index 94443c4..b30c1ba 100644 (file)
@@ -17,6 +17,7 @@
 #include <Poco/FormattingChannel.h>\r
 #include <Poco/PatternFormatter.h>\r
 #include <iostream>\r
+#include <string>\r
 \r
 #ifdef _WIN32\r
        #include <direct.h>\r
@@ -99,7 +100,8 @@ void FMSApp::initialize(Poco::Util::Application &self)
        ServerApplication::initialize(self);\r
 \r
        // set working directory - fall back on application.dir if working directory isn't set\r
-       if(m_workingdirectory=="")\r
+       // if we are runing as a service, then working directory needs to be set to the application directory\r
+       if(m_workingdirectory=="" || config().getBool("application.runAsService",false)==true)\r
        {\r
                m_workingdirectory=config().getString("application.dir");\r
        }\r
index 46f31a2..8d89baa 100644 (file)
@@ -16,6 +16,7 @@
 #include "../../include/http/pages/controlboardpage.h"\r
 #include "../../include/http/pages/peermaintenancepage.h"\r
 #include "../../include/http/pages/peertrustpage.h"\r
+#include "../../include/http/pages/versioninfopage.h"\r
 \r
 FMSHTTPRequestHandlerFactory::FMSHTTPRequestHandlerFactory()\r
 {\r
@@ -52,6 +53,7 @@ FMSHTTPRequestHandlerFactory::FMSHTTPRequestHandlerFactory()
        m_pagehandlers.push_back(new ControlBoardPage(templatestr));\r
        m_pagehandlers.push_back(new PeerMaintenancePage(templatestr));\r
        m_pagehandlers.push_back(new PeerTrustPage(templatestr));\r
+       m_pagehandlers.push_back(new VersionInfoPage(templatestr));\r
        // homepage must be last - catch all page handler\r
        m_pagehandlers.push_back(new HomePage(templatestr));\r
 \r
index a64efd2..2f41fac 100644 (file)
@@ -51,6 +51,7 @@ const std::string HomePage::GeneratePage(const std::string &method, const std::m
                if(currentmajor<major || (currentmajor==major && currentminor<minor) || (currentmajor==major && currentminor==minor && currentrelease<release))\r
                {\r
                        content+="<b>You are running an old version of FMS.  Please update here: <a href=\"http://"+fcphost+":"+fproxyport+"/"+freesite+"\">FMS "+major+"."+minor+"."+release+"</a></b><br>";\r
+                       content+="You can see the release info <a href=\"versioninfo.htm?Major="+major+"&Minor="+minor+"&Release="+release+"\">here</a><br>";\r
                        showgenericupdate=false;\r
                }\r
 \r
@@ -58,7 +59,7 @@ const std::string HomePage::GeneratePage(const std::string &method, const std::m
 \r
        if(showgenericupdate)\r
        {\r
-               content+="Check for new versions at the <a href=\"http://"+fcphost+":"+fproxyport+"/USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/63/\">FMS Freesite</a><br>";\r
+               content+="Check for new versions at the <a href=\"http://"+fcphost+":"+fproxyport+"/USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/66/\">FMS Freesite</a><br>";\r
        }\r
 \r
        content+="Use these pages to administer your FMS installation.";\r
diff --git a/src/http/pages/versioninfopage.cpp b/src/http/pages/versioninfopage.cpp
new file mode 100644 (file)
index 0000000..670e9da
--- /dev/null
@@ -0,0 +1,62 @@
+#include "../../../include/http/pages/versioninfopage.h"\r
+#include "../../../include/global.h"\r
+#include "../../../include/stringfunctions.h"\r
+\r
+#include <string>\r
+\r
+const std::string VersionInfoPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
+{\r
+       std::string content="";\r
+\r
+       std::string major=VERSION_MAJOR;\r
+       std::string minor=VERSION_MINOR;\r
+       std::string release=VERSION_RELEASE;\r
+\r
+       if(queryvars.find("Major")!=queryvars.end())\r
+       {\r
+               major=(*queryvars.find("Major")).second;\r
+       }\r
+       if(queryvars.find("Minor")!=queryvars.end())\r
+       {\r
+               minor=(*queryvars.find("Minor")).second;\r
+       }\r
+       if(queryvars.find("Release")!=queryvars.end())\r
+       {\r
+               release=(*queryvars.find("Release")).second;\r
+       }\r
+\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT Notes, Changes FROM tblFMSVersion WHERE Major=? AND Minor=? AND Release=?;");\r
+       st.Bind(0,major);\r
+       st.Bind(1,minor);\r
+       st.Bind(2,release);\r
+       st.Step();\r
+\r
+       if(st.RowReturned())\r
+       {\r
+               std::string notes="";\r
+               std::string changes="";\r
+\r
+               st.ResultText(0,notes);\r
+               st.ResultText(1,changes);\r
+\r
+               content+="<h2>Release "+major+"."+minor+"."+release+"</h2>";\r
+               content+="<h3>Notes</h3>";\r
+               content+=StringFunctions::Replace(notes,"\n","<br>");\r
+               content+="<h3>Changes</h3>";\r
+               content+=StringFunctions::Replace(changes,"\n","<br>");\r
+       }\r
+\r
+       return StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+}\r
+\r
+const bool VersionInfoPage::WillHandleURI(const std::string &uri)\r
+{\r
+       if(uri.find("versioninfo.")!=std::string::npos)\r
+       {\r
+               return true;\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
index 9395454..7965b16 100644 (file)
@@ -107,7 +107,7 @@ void SetupDefaultOptions()
 \r
        // NNTPBindAddresses\r
        st.Bind(0,"NNTPBindAddresses");\r
-       st.Bind(1,"localhost");\r
+       st.Bind(1,"localhost,127.0.0.1");\r
        st.Step();\r
        st.Reset();\r
        upd.Bind(0,"NNTP Server");\r