version 0.2.14
[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 \r
5 #ifdef XMEM\r
6         #include <xmem.h>\r
7 #endif\r
8 \r
9 const std::string HomePage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
10 {\r
11 \r
12         std::string messagecountstr="";\r
13         std::string filecountstr="";\r
14 \r
15         if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="shutdown")\r
16         {\r
17                 wantshutdown=true;\r
18         }\r
19 \r
20         std::string content="<h2>Home</h2>";\r
21         content+="<p class=\"paragraph\">";\r
22         content+="<b>FMS version ";\r
23         content+=FMS_VERSION;\r
24         content+="</b><br>";\r
25         content+="Use these pages to administer your FMS installation.";\r
26         content+="</p>";\r
27 \r
28         SQLite3DB::Statement st=m_db->Prepare("SELECT COUNT(*) FROM tblMessageInserts WHERE Inserted='false';");\r
29         st.Step();\r
30         if(st.RowReturned())\r
31         {\r
32                 st.ResultText(0,messagecountstr);\r
33         }\r
34         content+="Messages waiting to be inserted:"+messagecountstr+"<br>";\r
35         st=m_db->Prepare("SELECT COUNT(*) FROM tblFileInserts WHERE Key IS NULL;");\r
36         st.Step();\r
37         if(st.RowReturned())\r
38         {\r
39                 st.ResultText(0,filecountstr);\r
40         }\r
41         content+="Files waiting to be inserted:"+filecountstr+"<br>";\r
42 \r
43         content+="<p class=\"paragraph\">";\r
44         content+="<form name=\"frmshutdown\" method=\"POST\">";\r
45         content+="<input type=\"hidden\" name=\"formaction\" value=\"shutdown\">";\r
46         content+="<input type=\"submit\" value=\"Shutdown FMS\">";\r
47         content+="</form>";\r
48         content+="</p>";\r
49 \r
50         return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
51 }\r
52 \r
53 const bool HomePage::WillHandleURI(const std::string &uri)\r
54 {\r
55         return true;\r
56 }\r