version 0.3.29
[fms.git] / src / http / pages / insertedfilespage.cpp
index c9d4684..dbd27b0 100644 (file)
@@ -10,31 +10,47 @@ const std::string InsertedFilesPage::GeneratePage(const std::string &method, con
 {\r
        std::string content="<h2>Inserted Files</h2>";\r
 \r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT Key,FileName,Size FROM tblFileInserts WHERE Key IS NOT NULL ORDER BY FileName");\r
-       st.Step();\r
-\r
+       Option option(m_db);\r
        std::string node="localhost";\r
-       Option::Instance()->Get("FCPHost",node);\r
+       option.Get("FCPHost",node);\r
        std::string fproxyport="8888";\r
-       Option::Instance()->Get("FProxyPort",fproxyport);\r
+       option.Get("FProxyPort",fproxyport);\r
+\r
+       if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="removefile" && queryvars.find("fileid")!=queryvars.end() && ValidateFormPassword(queryvars))\r
+       {\r
+               SQLite3DB::Statement del=m_db->Prepare("DELETE FROM tblFileInserts WHERE FileInsertID=?;");\r
+               del.Bind(0,(*queryvars.find("fileid")).second);\r
+               del.Step();\r
+       }\r
+\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT Key,FileName,Size,FileInsertID FROM tblFileInserts WHERE Key IS NOT NULL ORDER BY FileName");\r
+       st.Step();\r
 \r
        while(st.RowReturned())\r
        {\r
                std::string key="";\r
                std::string filename="";\r
                std::string sizestr="";\r
+               std::string insertidstr="";\r
 \r
                st.ResultText(0,key);\r
                st.ResultText(1,filename);\r
                st.ResultText(2,sizestr);\r
+               st.ResultText(3,insertidstr);\r
 \r
                content+="<a href=\"http://"+node+":"+fproxyport+"/"+StringFunctions::UriEncode(key)+"\">"+SanitizeOutput(filename)+"</a> - "+sizestr+" bytes";\r
+               content+="<form name=\"frmRemove"+insertidstr+"\" method=\"POST\">";\r
+               content+=CreateFormPassword();\r
+               content+="<input type=\"hidden\" name=\"formaction\" value=\"removefile\">";\r
+               content+="<input type=\"hidden\" name=\"fileid\" value=\""+insertidstr+"\">";\r
+               content+="<input type=\"submit\" value=\"Remove\">";\r
+               content+="</form>";\r
                content+="<br>";\r
 \r
                st.Step();\r
        }\r
 \r
-       return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+       return StringFunctions::Replace(m_template,"[CONTENT]",content);\r
 }\r
 \r
 const bool InsertedFilesPage::WillHandleURI(const std::string &uri)\r