version 0.3.0
[fms.git] / src / http / pages / homepage.cpp
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
6 \r
7 #ifdef XMEM\r
8         #include <xmem.h>\r
9 #endif\r
10 \r
11 const std::string HomePage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
12 {\r
13 \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
18 \r
19         Option::Instance()->Get("FCPHost",fcphost);\r
20         Option::Instance()->Get("FProxyPort",fproxyport);\r
21 \r
22         if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="shutdown")\r
23         {\r
24                 m_log->trace("HomePage::GeneratePage requested shutdown");\r
25                 ((FMSApp *)&FMSApp::instance())->Terminate();\r
26         }\r
27 \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
33         content+="Check for new versions at the <a href=\"http://"+fcphost+":"+fproxyport+"/USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/58/\">FMS Freesite</a><br>";\r
34         content+="Use these pages to administer your FMS installation.";\r
35         content+="</p>";\r
36 \r
37         SQLite3DB::Statement st=m_db->Prepare("SELECT COUNT(*) FROM tblMessageInserts WHERE Inserted='false';");\r
38         st.Step();\r
39         if(st.RowReturned())\r
40         {\r
41                 st.ResultText(0,messagecountstr);\r
42         }\r
43         content+="Messages waiting to be inserted:"+messagecountstr+"<br>";\r
44         st=m_db->Prepare("SELECT COUNT(*) FROM tblFileInserts WHERE Key IS NULL;");\r
45         st.Step();\r
46         if(st.RowReturned())\r
47         {\r
48                 st.ResultText(0,filecountstr);\r
49         }\r
50         content+="Files waiting to be inserted:"+filecountstr+"<br>";\r
51 \r
52         content+="<p class=\"paragraph\">";\r
53         content+="<form name=\"frmshutdown\" method=\"POST\">";\r
54         content+="<input type=\"hidden\" name=\"formaction\" value=\"shutdown\">";\r
55         content+="<input type=\"submit\" value=\"Shutdown FMS\">";\r
56         content+="</form>";\r
57         content+="</p>";\r
58 \r
59         return StringFunctions::Replace(m_template,"[CONTENT]",content);\r
60 }\r
61 \r
62 const bool HomePage::WillHandleURI(const std::string &uri)\r
63 {\r
64         return true;\r
65 }\r