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 Option option(m_db);
\r
16 std::string messagecountstr="";
\r
17 std::string filecountstr="";
\r
18 std::string fcphost="127.0.0.1";
\r
19 std::string fproxyport="8888";
\r
21 option.Get("FCPHost",fcphost);
\r
22 option.Get("FProxyPort",fproxyport);
\r
24 if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="shutdown" && ValidateFormPassword(queryvars))
\r
26 m_log->trace("HomePage::GeneratePage requested shutdown");
\r
27 ((FMSApp *)&FMSApp::instance())->Terminate();
\r
30 std::string content="<h2>Home</h2>";
\r
31 content+="<p class=\"paragraph\">";
\r
32 content+="<b>FMS version ";
\r
33 content+=FMS_VERSION;
\r
34 content+="</b><br>";
\r
36 bool showgenericupdate=true;
\r
37 SQLite3DB::Statement st=m_db->Prepare("SELECT Major, Minor, Release, PageKey FROM tblFMSVersion ORDER BY Major DESC, Minor DESC, Release DESC LIMIT 1;");
\r
39 if(st.RowReturned())
\r
46 int currentrelease=0;
\r
47 std::string freesite="";
\r
48 std::string majorstr="";
\r
49 std::string minorstr="";
\r
50 std::string releasestr="";
\r
52 StringFunctions::Convert(VERSION_MAJOR,currentmajor);
\r
53 StringFunctions::Convert(VERSION_MINOR,currentminor);
\r
54 StringFunctions::Convert(VERSION_RELEASE,currentrelease);
\r
56 st.ResultInt(0,major);
\r
57 st.ResultInt(1,minor);
\r
58 st.ResultInt(2,release);
\r
59 st.ResultText(3,freesite);
\r
61 StringFunctions::Convert(major,majorstr);
\r
62 StringFunctions::Convert(minor,minorstr);
\r
63 StringFunctions::Convert(release,releasestr);
\r
65 if(currentmajor<major || (currentmajor==major && currentminor<minor) || (currentmajor==major && currentminor==minor && currentrelease<release))
\r
67 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
68 content+="You can see the release info <a href=\"versioninfo.htm?Major="+majorstr+"&Minor="+minorstr+"&Release="+releasestr+"\">here</a><br>";
\r
69 showgenericupdate=false;
\r
73 content+="<a href=\"versioninfo.htm\">Release info</a><br>";
\r
78 if(showgenericupdate)
\r
80 content+="Check for new versions at the <a href=\"http://"+fcphost+":"+fproxyport+"/"+FMS_FREESITE_USK+"\">FMS Freesite</a><br>";
\r
83 content+="Use these pages to administer your FMS installation.";
\r
86 st=m_db->Prepare("SELECT COUNT(*) FROM tblMessageInserts WHERE Inserted='false';");
\r
88 if(st.RowReturned())
\r
90 st.ResultText(0,messagecountstr);
\r
92 content+="Messages waiting to be inserted:"+messagecountstr;
\r
93 if (messagecountstr!="0") //show link to message page
\r
95 content+=" (<a href=\"showpendingmessage.htm\">show messages</a>)";
\r
98 st=m_db->Prepare("SELECT COUNT(*) FROM tblFileInserts WHERE Key IS NULL;");
\r
100 if(st.RowReturned())
\r
102 st.ResultText(0,filecountstr);
\r
104 content+="Files waiting to be inserted:"+filecountstr+"<br>";
\r
105 content+="<p class=\"paragraph\">";
\r
106 content+="<form name=\"frmshutdown\" method=\"POST\">";
\r
107 content+=CreateFormPassword();
\r
108 content+="<input type=\"hidden\" name=\"formaction\" value=\"shutdown\">";
\r
109 content+="<input type=\"submit\" value=\"Shutdown FMS\">";
\r
110 content+="</form>";
\r
113 return StringFunctions::Replace(m_template,"[CONTENT]",content);
\r
116 const bool HomePage::WillHandleURI(const std::string &uri)
\r