X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fhomepage.cpp;h=a64efd2fb8cafab4f0563bccbaf39d82909e96c4;hb=023b2219068d481cd6a300982427c99bacd88a12;hp=c89d92c0a85d431b45f96def4c52751f1e61963c;hpb=f60495a029c54358f82956482fe203fe2b7b5b23;p=fms.git diff --git a/src/http/pages/homepage.cpp b/src/http/pages/homepage.cpp index c89d92c..a64efd2 100644 --- a/src/http/pages/homepage.cpp +++ b/src/http/pages/homepage.cpp @@ -1,6 +1,8 @@ #include "../../../include/http/pages/homepage.h" #include "../../../include/stringfunctions.h" #include "../../../include/global.h" +#include "../../../include/fmsapp.h" +#include "../../../include/option.h" #ifdef XMEM #include @@ -9,22 +11,82 @@ const std::string HomePage::GeneratePage(const std::string &method, const std::map &queryvars) { + std::string messagecountstr=""; + std::string filecountstr=""; + std::string fcphost="127.0.0.1"; + std::string fproxyport="8888"; + + Option::Instance()->Get("FCPHost",fcphost); + Option::Instance()->Get("FProxyPort",fproxyport); + if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="shutdown") { - wantshutdown=true; + m_log->trace("HomePage::GeneratePage requested shutdown"); + ((FMSApp *)&FMSApp::instance())->Terminate(); } std::string content="

Home

"; content+="

"; + content+="FMS version "; + content+=FMS_VERSION; + content+="
"; + + bool showgenericupdate=true; + SQLite3DB::Statement st=m_db->Prepare("SELECT Major, Minor, Release, PageKey FROM tblFMSVersion ORDER BY Major DESC, Minor DESC, Release DESC LIMIT 1;"); + st.Step(); + if(st.RowReturned()) + { + std::string currentmajor=VERSION_MAJOR; + std::string currentminor=VERSION_MINOR; + std::string currentrelease=VERSION_RELEASE; + std::string major=""; + std::string minor=""; + std::string release=""; + std::string freesite=""; + st.ResultText(0,major); + st.ResultText(1,minor); + st.ResultText(2,release); + st.ResultText(3,freesite); + + if(currentmajorFMS "+major+"."+minor+"."+release+"
"; + showgenericupdate=false; + } + + } + + if(showgenericupdate) + { + content+="Check for new versions at the FMS Freesite
"; + } + content+="Use these pages to administer your FMS installation."; content+="

"; + + st=m_db->Prepare("SELECT COUNT(*) FROM tblMessageInserts WHERE Inserted='false';"); + st.Step(); + if(st.RowReturned()) + { + st.ResultText(0,messagecountstr); + } + content+="Messages waiting to be inserted:"+messagecountstr+"
"; + st=m_db->Prepare("SELECT COUNT(*) FROM tblFileInserts WHERE Key IS NULL;"); + st.Step(); + if(st.RowReturned()) + { + st.ResultText(0,filecountstr); + } + content+="Files waiting to be inserted:"+filecountstr+"
"; + content+="

"; content+="

"; content+=""; content+=""; content+="
"; content+="

"; - return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content); + + return StringFunctions::Replace(m_template,"[CONTENT]",content); } const bool HomePage::WillHandleURI(const std::string &uri)