- 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

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