X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Foptionspage.cpp;h=5c61e16b5fdf2d6616b8e6b89fa0ca53b34283e5;hb=fcb124f8d6d3f5678e82049fb8e5e23c8cfaec6d;hp=774373812334fb655c33b380aab69133bb5f3d20;hpb=14fff12d9df0ee30e2df4bf9d22c2e83065816df;p=fms.git diff --git a/src/http/pages/optionspage.cpp b/src/http/pages/optionspage.cpp index 7743738..5c61e16 100644 --- a/src/http/pages/optionspage.cpp +++ b/src/http/pages/optionspage.cpp @@ -5,13 +5,43 @@ #include #endif +const std::string OptionsPage::CreateDropDown(const std::string &name, const std::vector &items, const std::string &selecteditem) +{ + std::string rval=""; + + rval+=""; + content+=CreateFormPassword(); content+=""; - if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="save") + if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="save" && ValidateFormPassword(queryvars)) { SQLite3DB::Statement update=m_db->Prepare("UPDATE tblOption SET OptionValue=? WHERE Option=?;"); std::vector options; @@ -31,29 +61,52 @@ const std::string OptionsPage::GeneratePage(const std::string &method, const std update.Reset(); } } + } - SQLite3DB::Statement st=m_db->Prepare("SELECT Option,OptionValue,OptionDescription FROM tblOption;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT Option,OptionValue,OptionDescription,Section,ValidValues FROM tblOption ORDER BY SortOrder;"); st.Step(); int count=0; std::string countstr; + std::string lastsection=""; while(st.RowReturned()) { std::string option; std::string value; std::string description; + std::string section; + std::string validvalues; + std::vector validvaluevec; st.ResultText(0,option); st.ResultText(1,value); st.ResultText(2,description); + st.ResultText(3,section); + if(st.ResultNull(4)==false) + { + st.ResultText(4,validvalues); + StringFunctions::Split(validvalues,"|",validvaluevec); + } + + if(section!=lastsection) + { + content+=""; + content+=""; + content+=""; + lastsection=section; + } StringFunctions::Convert(count,countstr); content+=""; content+=""; content+=""; } @@ -67,11 +120,11 @@ const std::string OptionsPage::GeneratePage(const std::string &method, const std st.Step(); count++; } - + content+=""; content+=""; content+="
OptionValueDescription

"+section+"

"+option+""; - if(value!="true" && value!="false") + if(validvaluevec.size()>0) + { + content+=CreateDropDown("value["+countstr+"]",validvaluevec,value); + } + else if(value!="true" && value!="false") { content+="
"; - return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content); + return StringFunctions::Replace(m_template,"[CONTENT]",content); } const bool OptionsPage::WillHandleURI(const std::string &uri)