mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 07:22:57 +02:00
nhttpd add some new configfile handling
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@543 e54a6e83-5905-42d5-8d5c-058d10e6a962
Origin commit data
------------------
Branch: ni/coolstream
Commit: c091ba4db3
Author: yjogol <yjogol2@online.de>
Date: 2010-04-12 (Mon, 12 Apr 2010)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -30,13 +30,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
typedef std::map<std::string, std::string> ConfigDataMap;
|
||||||
|
|
||||||
class CConfigFile
|
class CConfigFile
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef std::map<std::string, std::string> ConfigDataMap;
|
|
||||||
|
|
||||||
ConfigDataMap configData;
|
ConfigDataMap configData;
|
||||||
char delimiter;
|
char delimiter;
|
||||||
bool saveDefaults;
|
bool saveDefaults;
|
||||||
@@ -106,6 +105,7 @@ class CConfigFile
|
|||||||
bool getUnknownKeyQueryedFlag() const { return unknownKeyQueryedFlag; }
|
bool getUnknownKeyQueryedFlag() const { return unknownKeyQueryedFlag; }
|
||||||
void setUnknownKeyQueryedFlag(const bool val) { unknownKeyQueryedFlag = val; }
|
void setUnknownKeyQueryedFlag(const bool val) { unknownKeyQueryedFlag = val; }
|
||||||
|
|
||||||
|
ConfigDataMap getConfigDataMap(){ return configData; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __configfile_h__ */
|
#endif /* __configfile_h__ */
|
||||||
|
@@ -192,6 +192,8 @@ const CControlAPI::TyCgiCall CControlAPI::yCgiCallList[]=
|
|||||||
// utils
|
// utils
|
||||||
{"build_live_url", &CControlAPI::build_live_url, ""},
|
{"build_live_url", &CControlAPI::build_live_url, ""},
|
||||||
{"get_logo", &CControlAPI::logoCGI, "text/plain"},
|
{"get_logo", &CControlAPI::logoCGI, "text/plain"},
|
||||||
|
// settings
|
||||||
|
{"config", &CControlAPI::ConfigCGI, "text/plain"},
|
||||||
|
|
||||||
};
|
};
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -2224,3 +2226,70 @@ void CControlAPI::logoCGI(CyhookHandler *hh)
|
|||||||
&channel_id);
|
&channel_id);
|
||||||
hh->Write(NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel_id));
|
hh->Write(NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel_id));
|
||||||
}
|
}
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
void CControlAPI::ConfigCGI(CyhookHandler *hh)
|
||||||
|
{
|
||||||
|
bool load = true;
|
||||||
|
CConfigFile *Config = new CConfigFile(',');
|
||||||
|
ConfigDataMap conf;
|
||||||
|
std::string config_filename="";
|
||||||
|
std::string error = "";
|
||||||
|
std::string result = "";
|
||||||
|
|
||||||
|
if (hh->ParamList["action"] == "submit")
|
||||||
|
load = false;
|
||||||
|
|
||||||
|
// Para "config" describes the config type
|
||||||
|
if(hh->ParamList["config"] == "neutrino")
|
||||||
|
config_filename = NEUTRINO_CONFIGFILE;
|
||||||
|
else if(hh->ParamList["config"] == "nhttpd")
|
||||||
|
config_filename = HTTPD_CONFIGFILE;
|
||||||
|
else if(hh->ParamList["config"] == "yweb")
|
||||||
|
config_filename = YWEB_CONFIGFILE;
|
||||||
|
|
||||||
|
if(config_filename != ""){
|
||||||
|
Config->loadConfig(config_filename);
|
||||||
|
|
||||||
|
if(load){
|
||||||
|
conf = Config->getConfigDataMap();
|
||||||
|
ConfigDataMap::iterator it;
|
||||||
|
for(it = conf.begin(); it != conf.end(); it++){
|
||||||
|
std::string key =it->first;
|
||||||
|
replace(key,".","_dot_");
|
||||||
|
replace(key,"-","_bind_");
|
||||||
|
if(!(hh->ParamList["config"] == "nhttpd" && it->first == "mod_auth.password")){
|
||||||
|
// Output as json (default)
|
||||||
|
if (hh->ParamList["format"] == "json" || hh->ParamList["format"] == ""){
|
||||||
|
result += string_printf("%s: '%s',\n", (key).c_str(), (it->second).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (CStringList::iterator it = hh->ParamList.begin(); it
|
||||||
|
!= hh->ParamList.end(); it++)
|
||||||
|
if(it->first != "_dc" && it->first != "action" && it->first != "format" && it->first != "config"){
|
||||||
|
Config->setString(it->first, it->second);
|
||||||
|
}
|
||||||
|
if(config_filename != "")
|
||||||
|
Config->saveConfig(config_filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
error = string_printf("no config defined for: %s", (hh->ParamList["config"]).c_str() );
|
||||||
|
|
||||||
|
if(error == ""){
|
||||||
|
if (hh->ParamList["format"] == "json" || hh->ParamList["format"] == ""){
|
||||||
|
hh->WriteLn("{success: 'true', data:{");
|
||||||
|
hh->WriteLn(result);
|
||||||
|
hh->WriteLn("}}");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (hh->ParamList["format"] == "json" || hh->ParamList["format"] == ""){
|
||||||
|
hh->WriteLn("{success: 'false', error:{");
|
||||||
|
hh->WriteLn(error);
|
||||||
|
hh->WriteLn("}}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete Config;
|
||||||
|
}
|
||||||
|
@@ -98,6 +98,7 @@ private:
|
|||||||
void updateBouquetCGI(CyhookHandler *hh);
|
void updateBouquetCGI(CyhookHandler *hh);
|
||||||
void build_live_url(CyhookHandler *hh);
|
void build_live_url(CyhookHandler *hh);
|
||||||
void logoCGI(CyhookHandler *hh);
|
void logoCGI(CyhookHandler *hh);
|
||||||
|
void ConfigCGI(CyhookHandler *hh);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const unsigned int PLUGIN_DIR_COUNT = 5;
|
static const unsigned int PLUGIN_DIR_COUNT = 5;
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// General central Definitions <configure!>
|
// General central Definitions <configure!>
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#define HTTPD_VERSION "3.3.0" // Webserver version (can be overloaded)
|
#define HTTPD_VERSION "3.3.1" // Webserver version (can be overloaded)
|
||||||
#define YHTTPD_VERSION "1.3.1" // Webserver version (Version of yhttpd-core!)
|
#define YHTTPD_VERSION "1.3.1" // Webserver version (Version of yhttpd-core!)
|
||||||
#define IADDR_LOCAL "127.0.0.1" // local IP
|
#define IADDR_LOCAL "127.0.0.1" // local IP
|
||||||
#define HTTPD_NAME "yhttpd" // Webserver name (can be overloaded)
|
#define HTTPD_NAME "yhttpd" // Webserver name (can be overloaded)
|
||||||
@@ -103,6 +103,7 @@
|
|||||||
|
|
||||||
#define HTTPD_CONFIGDIR "/var/tuxbox/config"
|
#define HTTPD_CONFIGDIR "/var/tuxbox/config"
|
||||||
#define HTTPD_CONFIGFILE HTTPD_CONFIGDIR "/nhttpd.conf"
|
#define HTTPD_CONFIGFILE HTTPD_CONFIGDIR "/nhttpd.conf"
|
||||||
|
#define YWEB_CONFIGFILE HTTPD_CONFIGDIR "/Y-Web.conf"
|
||||||
#define PUBLICDOCUMENTROOT "/var/httpd"
|
#define PUBLICDOCUMENTROOT "/var/httpd"
|
||||||
#define NEUTRINO_CONFIGFILE "/var/tuxbox/config/neutrino.conf"
|
#define NEUTRINO_CONFIGFILE "/var/tuxbox/config/neutrino.conf"
|
||||||
#define HOSTEDDOCUMENTROOT "/mnt/hosted"
|
#define HOSTEDDOCUMENTROOT "/mnt/hosted"
|
||||||
|
Reference in New Issue
Block a user