- yweb: re-introduce 'WebsiteMain.hosted_directory'

* this directory can be used to host some of your cracy stuff.
  yhtm, yjs and ysh will also parsed now. it is reachable with
  <boxip>/hosted/
* if exist a subdir named 'logos' in this directory you can use
  this as an external logo-dir for yweb too
* path can be configured with '--with-hosted_httpddir=PATH'
This commit is contained in:
svenhoefer
2013-06-27 12:20:29 +02:00
parent ac53313da4
commit 9078775a0a
12 changed files with 59 additions and 28 deletions

View File

@@ -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],[

View File

@@ -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 <box ip>/hosted/<your files>
WebsiteMain.hosted_directory=/mnt/hosted // our own directory hosted by the webserver. Adressable with <box ip>/hosted/<your files>
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

View File

@@ -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=

View File

@@ -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=}

View File

@@ -62,7 +62,7 @@ function do_submit()
</tr>
<tr>
<td>{=L:set.nhttpd.port=}</td>
<td><input type="text" name="port" size="20" value="{=ini-get:/var/tuxbox/config/nhttpd.conf;WebsiteMain.port;80~cache=}" title="{=L:port=}"/>&nbsp;{=L:active_after_boot=}
<td><input type="text" name="port" size="20" value="{=ini-get:/var/tuxbox/config/nhttpd.conf;WebsiteMain.port;80~cache=}" title="{=L:set.nhttpd.port=}"/>&nbsp;{=L:set.nhttpd.active_after_boot=}
</td>
</tr>
{=if-not-equal:{=global-var-get:boxtype=}~coolstream~
@@ -76,8 +76,15 @@ function do_submit()
=}
<tr>
<td>{=L:set.nhttpd.alternate_web_folder=}</td>
<td><input type="text" name="override_directory" size="20" value="{=ini-get:/var/tuxbox/config/nhttpd.conf;WebsiteMain.override_directory~cache=}" title="{=L:alternate_web_folder=}"/>&nbsp;{=L:active_after_boot=}
<input type="hidden" name="HostedDocRoot" size="60" value="{=ini-get:/var/tuxbox/config/nhttpd.conf;WebsiteMain.hosted_directory~cache=}" title="Root of hosted Web. Enter mount directory."/></td>
<td>
<input type="text" name="override_directory" size="20" value="{=ini-get:/var/tuxbox/config/nhttpd.conf;WebsiteMain.override_directory~cache=}" title="{=L:set.nhttpd.alternate_web_folder=}"/>&nbsp;{=L:set.nhttpd.active_after_boot=}
</td>
</tr>
<tr>
<td>{=L:set.nhttpd.hosted_folder=}</td>
<td>
<input type="text" name="hosted_directory" size="20" value="{=ini-get:/var/tuxbox/config/nhttpd.conf;WebsiteMain.hosted_directory~cache=}" title="Root of hosted Web. Enter mount directory."/>&nbsp;{=L:set.nhttpd.active_after_boot=}
</td>
</tr>
<tr>
<td>{=L:set.nhttpd.allowed_file_extensions=}</td>

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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", "");

View File

@@ -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;

View File

@@ -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")) {

View File

@@ -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;
}