#include "../../../include/http/pages/homepage.h"\r
#include "../../../include/stringfunctions.h"\r
#include "../../../include/global.h"\r
+#include "../../../include/fmsapp.h"\r
+#include "../../../include/option.h"\r
\r
#ifdef XMEM\r
#include <xmem.h>\r
const std::string HomePage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
{\r
\r
- if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="shutdown")\r
+ std::string messagecountstr="";\r
+ std::string filecountstr="";\r
+ std::string fcphost="127.0.0.1";\r
+ std::string fproxyport="8888";\r
+\r
+ Option::Instance()->Get("FCPHost",fcphost);\r
+ Option::Instance()->Get("FProxyPort",fproxyport);\r
+\r
+ if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="shutdown" && ValidateFormPassword(queryvars))\r
{\r
- wantshutdown=true;\r
+ m_log->trace("HomePage::GeneratePage requested shutdown");\r
+ ((FMSApp *)&FMSApp::instance())->Terminate();\r
}\r
\r
std::string content="<h2>Home</h2>";\r
content+="<p class=\"paragraph\">";\r
+ content+="<b>FMS version ";\r
+ content+=FMS_VERSION;\r
+ content+="</b><br>";\r
+\r
+ bool showgenericupdate=true;\r
+ SQLite3DB::Statement st=m_db->Prepare("SELECT Major, Minor, Release, PageKey FROM tblFMSVersion ORDER BY Major DESC, Minor DESC, Release DESC LIMIT 1;");\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ int major=0;\r
+ int minor=0;\r
+ int release=0;\r
+ int currentmajor=0;\r
+ int currentminor=0;\r
+ int currentrelease=0;\r
+ std::string freesite="";\r
+ std::string majorstr="";\r
+ std::string minorstr="";\r
+ std::string releasestr="";\r
+\r
+ StringFunctions::Convert(VERSION_MAJOR,currentmajor);\r
+ StringFunctions::Convert(VERSION_MINOR,currentminor);\r
+ StringFunctions::Convert(VERSION_RELEASE,currentrelease);\r
+\r
+ st.ResultInt(0,major);\r
+ st.ResultInt(1,minor);\r
+ st.ResultInt(2,release);\r
+ st.ResultText(3,freesite);\r
+\r
+ StringFunctions::Convert(major,majorstr);\r
+ StringFunctions::Convert(minor,minorstr);\r
+ StringFunctions::Convert(release,releasestr);\r
+\r
+ 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 "+majorstr+"."+minorstr+"."+releasestr+"</a></b><br>";\r
+ content+="You can see the release info <a href=\"versioninfo.htm?Major="+majorstr+"&Minor="+minorstr+"&Release="+releasestr+"\">here</a><br>";\r
+ showgenericupdate=false;\r
+ }\r
+ else\r
+ {\r
+ content+="<a href=\"versioninfo.htm\">Release info</a><br>";\r
+ }\r
+\r
+ }\r
+\r
+ if(showgenericupdate)\r
+ {\r
+ content+="Check for new versions at the <a href=\"http://"+fcphost+":"+fproxyport+"/"+FMS_FREESITE_USK+"\">FMS Freesite</a><br>";\r
+ }\r
+\r
content+="Use these pages to administer your FMS installation.";\r
content+="</p>";\r
+\r
+ st=m_db->Prepare("SELECT COUNT(*) FROM tblMessageInserts WHERE Inserted='false';");\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ st.ResultText(0,messagecountstr);\r
+ }\r
+ content+="Messages waiting to be inserted:"+messagecountstr+"<br>";\r
+ st=m_db->Prepare("SELECT COUNT(*) FROM tblFileInserts WHERE Key IS NULL;");\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ st.ResultText(0,filecountstr);\r
+ }\r
+ content+="Files waiting to be inserted:"+filecountstr+"<br>";\r
+\r
content+="<p class=\"paragraph\">";\r
content+="<form name=\"frmshutdown\" method=\"POST\">";\r
+ content+=CreateFormPassword();\r
content+="<input type=\"hidden\" name=\"formaction\" value=\"shutdown\">";\r
content+="<input type=\"submit\" value=\"Shutdown FMS\">";\r
content+="</form>";\r
content+="</p>";\r
- return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+\r
+ return StringFunctions::Replace(m_template,"[CONTENT]",content);\r
}\r
\r
const bool HomePage::WillHandleURI(const std::string &uri)\r