diff --git a/acinclude.m4 b/acinclude.m4 index 3b103591e..387b3338f 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -114,10 +114,12 @@ if test "$TARGET" = "cdk"; then sysconfdir="\${prefix}/etc" localstatedir="\${prefix}/var" libdir="\${prefix}/lib" + mntdir="\${prefix}/mnt" targetdatadir="\${TARGET_PREFIX}/share" targetsysconfdir="\${TARGET_PREFIX}/etc" targetlocalstatedir="\${TARGET_PREFIX}/var" targetlibdir="\${TARGET_PREFIX}/lib" + targetmntdir="\${TARGET_PREFIX}/mnt" fi TUXBOX_APPS_DIRECTORY_ONE(configdir,CONFIGDIR,localstatedir,/var,/tuxbox/config, @@ -152,6 +154,9 @@ TUXBOX_APPS_DIRECTORY_ONE(private_httpddir,PRIVATE_HTTPDDIR,datadir,/share,/tuxb TUXBOX_APPS_DIRECTORY_ONE(public_httpddir,PUBLIC_HTTPDDIR,localstatedir,/var,/httpd, [--with-public_httpddir=PATH ],[where to find the the public httpd files]) + +TUXBOX_APPS_DIRECTORY_ONE(hosted_httpddir,HOSTED_HTTPDDIR,mntdir,/mnt,/hosted, + [--with-hosted_httpddir=PATH ],[where to find the the hosted files]) ]) dnl automake <= 1.6 needs this specifications @@ -160,12 +165,14 @@ AC_SUBST(DATADIR) AC_SUBST(FONTDIR) AC_SUBST(GAMESDIR) AC_SUBST(LIBDIR) +AC_SUBST(MNTDIR) AC_SUBST(PLUGINDIR) AC_SUBST(UCODEDIR) AC_SUBST(THEMESDIR) AC_SUBST(ICONSDIR) AC_SUBST(PRIVATE_HTTPDDIR) AC_SUBST(PUBLIC_HTTPDDIR) +AC_SUBST(HOSTED_HTTPDDIR) dnl end workaround AC_DEFUN([TUXBOX_APPS_ENDIAN],[ diff --git a/src/nhttpd/README b/src/nhttpd/README index ec5e8f38d..b46815ca2 100644 --- a/src/nhttpd/README +++ b/src/nhttpd/README @@ -32,7 +32,7 @@ Tuxbox.LogosURL= WebsiteMain.directory=/share/tuxbox/neutrino/httpd // Main HTML,Javascript, Images Directoty root (e.g. read-only area in mFlash) WebsiteMain.override_directory=/var/httpd // Override directory (writable) for extensions or Updates. Webserver first search here. WebsiteMain.port=80 // Port the webserver is running on -WebsiteMain.hosted_directory=/var/hosted // our own directory hosted by the webserver. Adressable with /hosted/ +WebsiteMain.hosted_directory=/mnt/hosted // our own directory hosted by the webserver. Adressable with /hosted/ configfile.version=4 // Version of this config file mod_auth.authenticate=false // ask for username/password (http digit authentication) mod_auth.no_auth_client= // IP Adress without http authentication diff --git a/src/nhttpd/nhttpd.conf.in b/src/nhttpd/nhttpd.conf.in index a4d74e924..4facd7a42 100644 --- a/src/nhttpd/nhttpd.conf.in +++ b/src/nhttpd/nhttpd.conf.in @@ -4,7 +4,7 @@ Tuxbox.LogosURL=@TARGET_ICONSDIR@/logo WebsiteMain.directory=@TARGET_PRIVATE_HTTPDDIR@ WebsiteMain.override_directory=@TARGET_PUBLIC_HTTPDDIR@ WebsiteMain.port=80 -WebsiteMain.hosted_directory=/var/hosted +WebsiteMain.hosted_directory=@TARGET_HOSTED_HTTPDDIR@ configfile.version=4 mod_auth.authenticate=false mod_auth.no_auth_client= diff --git a/src/nhttpd/web/Y_Blocks.txt b/src/nhttpd/web/Y_Blocks.txt index 32f6504b3..d17ad1693 100644 --- a/src/nhttpd/web/Y_Blocks.txt +++ b/src/nhttpd/web/Y_Blocks.txt @@ -53,7 +53,7 @@ start-block~nhttpd_save_settings {=ini-set:/var/tuxbox/config/nhttpd.conf;WebsiteMain.port;{=port=}~cache=} {=ini-set:/var/tuxbox/config/nhttpd.conf;webserver.threading;{=threading=}~cache=} {=ini-set:/var/tuxbox/config/nhttpd.conf;server.no_keep-alive_ips;{=no_keep_alive_ips=}~cache=} -{=ini-set:/var/tuxbox/config/nhttpd.conf;WebsiteMain.hosted_directory;{=HostedDocRoot=}~cache=} +{=ini-set:/var/tuxbox/config/nhttpd.conf;WebsiteMain.hosted_directory;{=hosted_directory=}~cache=} {=ini-set:/var/tuxbox/config/nhttpd.conf;WebsiteMain.override_directory;{=override_directory=}~cache=} {=ini-set:/var/tuxbox/config/nhttpd.conf;mod_sendfile.mime_types;{=mod_sendfile_mime_types=}~cache=} {=ini-set:/var/tuxbox/config/nhttpd.conf;mod_sendfile.sendAll;{=mod_sendfile_sendAll=}~cache=} diff --git a/src/nhttpd/web/Y_Settings_nhttpd.yhtm b/src/nhttpd/web/Y_Settings_nhttpd.yhtm index 5418e22a4..d3891c79a 100644 --- a/src/nhttpd/web/Y_Settings_nhttpd.yhtm +++ b/src/nhttpd/web/Y_Settings_nhttpd.yhtm @@ -62,7 +62,7 @@ function do_submit() {=L:set.nhttpd.port=} -  {=L:active_after_boot=} +  {=L:set.nhttpd.active_after_boot=} {=if-not-equal:{=global-var-get:boxtype=}~coolstream~ @@ -76,8 +76,15 @@ function do_submit() =} {=L:set.nhttpd.alternate_web_folder=} -  {=L:active_after_boot=} - + +  {=L:set.nhttpd.active_after_boot=} + + + + {=L:set.nhttpd.hosted_folder=} + +  {=L:set.nhttpd.active_after_boot=} + {=L:set.nhttpd.allowed_file_extensions=} diff --git a/src/nhttpd/web/languages/Deutsch b/src/nhttpd/web/languages/Deutsch index 0457b64cf..5afaea92f 100644 --- a/src/nhttpd/web/languages/Deutsch +++ b/src/nhttpd/web/languages/Deutsch @@ -303,6 +303,7 @@ set.nhttpd.active_after_boot=Nach Neustart aktiv set.nhttpd.port=Port set.nhttpd.threading=Threading set.nhttpd.alternate_web_folder=Alternativer Web-Ordner +set.nhttpd.hosted_folder=Eingebundenes Verzeichnis set.nhttpd.allowed_file_extensions=Erlaubte Dateiendungen / MIME set.nhttpd.allow_all_file_extensions=Alle Dateiendungen erlauben set.nhttpd.url_of_logos_desc=URL bzw. Verzeichnis der Logos eingeben diff --git a/src/nhttpd/web/languages/English b/src/nhttpd/web/languages/English index 7e28b9afa..a769bd57b 100644 --- a/src/nhttpd/web/languages/English +++ b/src/nhttpd/web/languages/English @@ -306,6 +306,7 @@ set.nhttpd.active_after_boot=active after boot set.nhttpd.port=Port set.nhttpd.threading=Threading set.nhttpd.alternate_web_folder=Alternate Web-Folder +set.nhttpd.hosted_folder=Mounted directory set.nhttpd.allowed_file_extensions=Allowed File Extensions / MIME set.nhttpd.allow_all_file_extensions=Allow all File Extensions set.nhttpd.url_of_logos_desc=Enter URL or directory of Logos diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 675d6a04e..663e919b0 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -109,7 +109,8 @@ #define YWEB_CONFIGFILE HTTPD_CONFIGDIR"/Y-Web.conf" #define PUBLICDOCUMENTROOT PUBLIC_HTTPDDIR #define NEUTRINO_CONFIGFILE CONFIGDIR"/neutrino.conf" -#define HOSTEDDOCUMENTROOT "/mnt/hosted" +#define HOSTEDDOCUMENTROOT HOSTED_HTTPDDIR +#define HOSTEDDOCUMENTURL "/hosted/" #define EXTRASDOCUMENTROOT "/mnt/hosted/extras" #define EXTRASDOCUMENTURL "/hosted/extras" #define ZAPITXMLPATH CONFIGDIR"/zapit" diff --git a/src/nhttpd/yhttpd.cpp b/src/nhttpd/yhttpd.cpp index 6d8125c8d..718728c1c 100644 --- a/src/nhttpd/yhttpd.cpp +++ b/src/nhttpd/yhttpd.cpp @@ -490,7 +490,7 @@ void Cyhttpd::ReadConfig(void) { Config->setString("Language.selected", HTTPD_DEFAULT_LANGUAGE); Config->setString("Language.directory", HTTPD_LANGUAGEDIR); if (Config->getString("WebsiteMain.hosted_directory", "") == "") - Config->setString("WebsiteMain.hosted_directory", "/var/hosted"); + Config->setString("WebsiteMain.hosted_directory", HOSTEDDOCUMENTROOT); Config->saveConfig(HTTPD_CONFIGFILE); } } @@ -527,14 +527,20 @@ void Cyhttpd::ReadConfig(void) { // Check location of logos if (Config->getString("Tuxbox.LogosURL", "") == "") { - if (access(std::string(ConfigList["WebsiteMain.directory"] + "/logos").c_str(), 4) == 0) { - Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.directory"] + "/logos"); - have_config = false; //save config - } - else if (access(std::string(ConfigList["WebsiteMain.override_directory"] ).c_str(), 4) == 0){ + if (access(std::string(ConfigList["WebsiteMain.override_directory"] + "/logos").c_str(), 4) == 0) { Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.override_directory"] + "/logos"); have_config = false; //save config } + else if (access(std::string(ConfigList["WebsiteMain.directory"] + "/logos").c_str(), 4) == 0){ + Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.directory"] + "/logos"); + have_config = false; //save config + } +#ifdef Y_CONFIG_USE_HOSTEDWEB + else if (access(std::string(ConfigList["WebsiteMain.hosted_directory"] + "/logos").c_str(), 4) == 0){ + Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.hosted_directory"] + "/logos"); + have_config = false; //save config + } +#endif //Y_CONFIG_USE_HOSTEDWEB } ConfigList["Tuxbox.LogosURL"] = Config->getString("Tuxbox.LogosURL", ""); diff --git a/src/nhttpd/yhttpd_core/yresponse.cpp b/src/nhttpd/yhttpd_core/yresponse.cpp index 96ed8f510..74af5515a 100644 --- a/src/nhttpd/yhttpd_core/yresponse.cpp +++ b/src/nhttpd/yhttpd_core/yresponse.cpp @@ -64,14 +64,6 @@ bool CWebserverResponse::SendResponse() { // Checking and Preperation: Auth, static, cache, ... //-------------------------------------------------------------- - // move to mod_sendfile ??? -#ifdef Y_CONFIG_USE_HOSTEDWEB - // for hosted webs: rewrite URL - std::string _hosted="/hosted/"; - if((Connection->Request.UrlData["path"]).compare(0,_hosted.length(),"/hosted/") == 0) // hosted Web ? - Connection->Request.UrlData["path"]=Cyhttpd::ConfigList["WebsiteMain.hosted_directory"] - +(Connection->Request.UrlData["path"]).substr(_hosted.length()-1); -#endif //Y_CONFIG_USE_HOSTEDWEB do { if (Connection->RequestCanceled) return false; diff --git a/src/nhttpd/yhttpd_mods/mod_sendfile.cpp b/src/nhttpd/yhttpd_mods/mod_sendfile.cpp index ce3a2551f..81f3cabb6 100644 --- a/src/nhttpd/yhttpd_mods/mod_sendfile.cpp +++ b/src/nhttpd/yhttpd_mods/mod_sendfile.cpp @@ -65,6 +65,14 @@ THandleStatus CmodSendfile::Hook_PrepareResponse(CyhookHandler *hh) { hh->status = HANDLED_NONE; log_level_printf(4, "mod_sendfile prepare hook start url:%s\n", hh->UrlData["fullurl"].c_str()); + +#ifdef Y_CONFIG_USE_HOSTEDWEB + // for hosted webs: rewrite URL + std::string _hosted=HOSTEDDOCUMENTURL; + if((hh->UrlData["path"]).compare(0,_hosted.length(),HOSTEDDOCUMENTURL) == 0) // hosted Web ? + hh->UrlData["path"]=hh->WebserverConfigList["WebsiteMain.hosted_directory"]+(hh->UrlData["path"]).substr(_hosted.length()-1); +#endif //Y_CONFIG_USE_HOSTEDWEB + std::string mime = sendfileTypes[hh->UrlData["fileext"]]; if (((mime != "") || (hh->WebserverConfigList["mod_sendfile.sendAll"] == "true")) && !(hh->UrlData["fileext"] == "yhtm" || hh->UrlData["fileext"] == "yjs" || hh->UrlData["fileext"] == "ysh")) { diff --git a/src/nhttpd/yhttpd_mods/mod_yparser.cpp b/src/nhttpd/yhttpd_mods/mod_yparser.cpp index b7995dc23..e6859fb25 100644 --- a/src/nhttpd/yhttpd_mods/mod_yparser.cpp +++ b/src/nhttpd/yhttpd_mods/mod_yparser.cpp @@ -271,10 +271,18 @@ std::string CyParser::cgi_file_parsing(CyhookHandler *hh, bool found = false; std::string htmlfullfilename, yresult, html_template; + bool isHosted = false; +#ifdef Y_CONFIG_USE_HOSTEDWEB + // for hosted webs: search in hosted_directory only + std::string _hosted=hh->WebserverConfigList["WebsiteMain.hosted_directory"]; + if((hh->UrlData["path"]).compare(0,_hosted.length(),hh->WebserverConfigList["WebsiteMain.hosted_directory"]) == 0) // hosted Web ? + isHosted = true; +#endif //Y_CONFIG_USE_HOSTEDWEB + char cwd[255]; getcwd(cwd, 254); - for (unsigned int i = 0; i < HTML_DIR_COUNT && !found; i++) { - htmlfullfilename = HTML_DIRS[i] + "/" + htmlfilename; + for (unsigned int i = 0; i < (isHosted ? 1 : HTML_DIR_COUNT) && !found; i++) { + htmlfullfilename = (isHosted ? "" : HTML_DIRS[i]) + "/" + htmlfilename; std::fstream fin(htmlfullfilename.c_str(), std::fstream::in); if (fin.good()) { found = true; @@ -292,11 +300,11 @@ std::string CyParser::cgi_file_parsing(CyhookHandler *hh, } chdir(cwd); if (!found) { - printf("[CyParser] Y-cgi:template %s not found in\n", - htmlfilename.c_str()); - for (unsigned int i = 0; i < HTML_DIR_COUNT; i++) { - printf("%s\n", HTML_DIRS[i].c_str()); - } + printf("[CyParser] Y-cgi:template %s not found %s\n", htmlfilename.c_str(), isHosted ? "" : "in"); + if (!isHosted) + for (unsigned int i = 0; i < HTML_DIR_COUNT; i++) { + printf("%s\n", HTML_DIRS[i].c_str()); + } } return yresult; }