1 #include "../../../include/http/pages/homepage.h"
\r
2 #include "../../../include/stringfunctions.h"
\r
3 #include "../../../include/global.h"
\r
4 #include "../../../include/fmsapp.h"
\r
5 #include "../../../include/option.h"
\r
11 const std::string HomePage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)
\r
14 std::string messagecountstr="";
\r
15 std::string filecountstr="";
\r
16 std::string fcphost="127.0.0.1";
\r
17 std::string fproxyport="8888";
\r
19 Option::Instance()->Get("FCPHost",fcphost);
\r
20 Option::Instance()->Get("FProxyPort",fproxyport);
\r
22 if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="shutdown" && ValidateFormPassword(queryvars))
\r
24 m_log->trace("HomePage::GeneratePage requested shutdown");
\r
25 ((FMSApp *)&FMSApp::instance())->Terminate();
\r
28 std::string content="<h2>Home</h2>";
\r
29 content+="<p class=\"paragraph\">";
\r
30 content+="<b>FMS version ";
\r
31 content+=FMS_VERSION;
\r
32 content+="</b><br>";
\r
34 bool showgenericupdate=true;
\r
35 SQLite3DB::Statement st=m_db->Prepare("SELECT Major, Minor, Release, PageKey FROM tblFMSVersion ORDER BY Major DESC, Minor DESC, Release DESC LIMIT 1;");
\r
37 if(st.RowReturned())
\r
44 int currentrelease=0;
\r
45 std::string freesite="";
\r
46 std::string majorstr="";
\r
47 std::string minorstr="";
\r
48 std::string releasestr="";
\r
50 StringFunctions::Convert(VERSION_MAJOR,currentmajor);
\r
51 StringFunctions::Convert(VERSION_MINOR,currentminor);
\r
52 StringFunctions::Convert(VERSION_RELEASE,currentrelease);
\r
54 st.ResultInt(0,major);
\r
55 st.ResultInt(1,minor);
\r
56 st.ResultInt(2,release);
\r
57 st.ResultText(3,freesite);
\r
59 StringFunctions::Convert(major,majorstr);
\r
60 StringFunctions::Convert(minor,minorstr);
\r
61 StringFunctions::Convert(release,releasestr);
\r
63 if(currentmajor<major || (currentmajor==major && currentminor<minor) || (currentmajor==major && currentminor==minor && currentrelease<release))
\r
65 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
66 content+="You can see the release info <a href=\"versioninfo.htm?Major="+majorstr+"&Minor="+minorstr+"&Release="+releasestr+"\">here</a><br>";
\r
67 showgenericupdate=false;
\r
72 if(showgenericupdate)
\r
74 content+="Check for new versions at the <a href=\"http://"+fcphost+":"+fproxyport+"/USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/76/\">FMS Freesite</a><br>";
\r
77 content+="Use these pages to administer your FMS installation.";
\r
80 st=m_db->Prepare("SELECT COUNT(*) FROM tblMessageInserts WHERE Inserted='false';");
\r
82 if(st.RowReturned())
\r
84 st.ResultText(0,messagecountstr);
\r
86 content+="Messages waiting to be inserted:"+messagecountstr+"<br>";
\r
87 st=m_db->Prepare("SELECT COUNT(*) FROM tblFileInserts WHERE Key IS NULL;");
\r
89 if(st.RowReturned())
\r
91 st.ResultText(0,filecountstr);
\r
93 content+="Files waiting to be inserted:"+filecountstr+"<br>";
\r
95 content+="<p class=\"paragraph\">";
\r
96 content+="<form name=\"frmshutdown\" method=\"POST\">";
\r
97 content+=CreateFormPassword();
\r
98 content+="<input type=\"hidden\" name=\"formaction\" value=\"shutdown\">";
\r
99 content+="<input type=\"submit\" value=\"Shutdown FMS\">";
\r
100 content+="</form>";
\r
103 return StringFunctions::Replace(m_template,"[CONTENT]",content);
\r
106 const bool HomePage::WillHandleURI(const std::string &uri)
\r