version 0.2.13
[fms.git] / src / http / pages / insertedfilespage.cpp
index c9d4684..1fab7cd 100644 (file)
@@ -10,25 +10,40 @@ 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
        std::string node="localhost";\r
        Option::Instance()->Get("FCPHost",node);\r
        std::string fproxyport="8888";\r
        Option::Instance()->Get("FProxyPort",fproxyport);\r
 \r
+\r
+       if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="removefile" && queryvars.find("fileid")!=queryvars.end())\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+="<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