version 0.2.12
[fms.git] / src / http / pages / insertedfilespage.cpp
1 #include "../../../include/http/pages/insertedfilespage.h"\r
2 #include "../../../include/stringfunctions.h"\r
3 #include "../../../include/option.h"\r
4 \r
5 #ifdef XMEM\r
6         #include <xmem.h>\r
7 #endif\r
8 \r
9 const std::string InsertedFilesPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
10 {\r
11         std::string content="<h2>Inserted Files</h2>";\r
12 \r
13         SQLite3DB::Statement st=m_db->Prepare("SELECT Key,FileName,Size FROM tblFileInserts WHERE Key IS NOT NULL ORDER BY FileName");\r
14         st.Step();\r
15 \r
16         std::string node="localhost";\r
17         Option::Instance()->Get("FCPHost",node);\r
18         std::string fproxyport="8888";\r
19         Option::Instance()->Get("FProxyPort",fproxyport);\r
20 \r
21         while(st.RowReturned())\r
22         {\r
23                 std::string key="";\r
24                 std::string filename="";\r
25                 std::string sizestr="";\r
26 \r
27                 st.ResultText(0,key);\r
28                 st.ResultText(1,filename);\r
29                 st.ResultText(2,sizestr);\r
30 \r
31                 content+="<a href=\"http://"+node+":"+fproxyport+"/"+StringFunctions::UriEncode(key)+"\">"+SanitizeOutput(filename)+"</a> - "+sizestr+" bytes";\r
32                 content+="<br>";\r
33 \r
34                 st.Step();\r
35         }\r
36 \r
37         return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
38 }\r
39 \r
40 const bool InsertedFilesPage::WillHandleURI(const std::string &uri)\r
41 {\r
42         if(uri.find("insertedfiles.")!=std::string::npos)\r
43         {\r
44                 return true;\r
45         }\r
46         else\r
47         {\r
48                 return false;\r
49         }\r
50 }\r