version 1.1.1.2, 2014/06/15 20:20:06
|
version 1.1.1.3, 2016/11/02 10:35:00
|
Line 1
|
Line 1
|
|
#include "first.h" |
|
|
#include "base.h" |
#include "base.h" |
#include "log.h" |
#include "log.h" |
#include "buffer.h" |
#include "buffer.h" |
Line 51 FREE_FUNC(mod_indexfile_free) {
|
Line 53 FREE_FUNC(mod_indexfile_free) {
|
for (i = 0; i < srv->config_context->used; i++) { |
for (i = 0; i < srv->config_context->used; i++) { |
plugin_config *s = p->config_storage[i]; |
plugin_config *s = p->config_storage[i]; |
|
|
if (!s) continue; | if (NULL == s) continue; |
|
|
array_free(s->indexfiles); |
array_free(s->indexfiles); |
|
|
Line 84 SETDEFAULTS_FUNC(mod_indexfile_set_defaults) {
|
Line 86 SETDEFAULTS_FUNC(mod_indexfile_set_defaults) {
|
p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); |
p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); |
|
|
for (i = 0; i < srv->config_context->used; i++) { |
for (i = 0; i < srv->config_context->used; i++) { |
|
data_config const* config = (data_config const*)srv->config_context->data[i]; |
plugin_config *s; |
plugin_config *s; |
|
|
s = calloc(1, sizeof(plugin_config)); |
s = calloc(1, sizeof(plugin_config)); |
Line 94 SETDEFAULTS_FUNC(mod_indexfile_set_defaults) {
|
Line 97 SETDEFAULTS_FUNC(mod_indexfile_set_defaults) {
|
|
|
p->config_storage[i] = s; |
p->config_storage[i] = s; |
|
|
if (0 != config_insert_values_global(srv, ((data_config *)srv->config_context->data[i])->value, cv)) { | if (0 != config_insert_values_global(srv, config->value, cv, i == 0 ? T_CONFIG_SCOPE_SERVER : T_CONFIG_SCOPE_CONNECTION)) { |
return HANDLER_ERROR; |
return HANDLER_ERROR; |
} |
} |
} |
} |
Line 141 URIHANDLER_FUNC(mod_indexfile_subrequest) {
|
Line 144 URIHANDLER_FUNC(mod_indexfile_subrequest) {
|
|
|
if (con->mode != DIRECT) return HANDLER_GO_ON; |
if (con->mode != DIRECT) return HANDLER_GO_ON; |
|
|
if (con->uri.path->used == 0) return HANDLER_GO_ON; | if (buffer_is_empty(con->uri.path)) return HANDLER_GO_ON; |
if (con->uri.path->ptr[con->uri.path->used - 2] != '/') return HANDLER_GO_ON; | if (con->uri.path->ptr[buffer_string_length(con->uri.path) - 1] != '/') return HANDLER_GO_ON; |
|
|
mod_indexfile_patch_connection(srv, con, p); |
mod_indexfile_patch_connection(srv, con, p); |
|
|
Line 158 URIHANDLER_FUNC(mod_indexfile_subrequest) {
|
Line 161 URIHANDLER_FUNC(mod_indexfile_subrequest) {
|
if (ds->value && ds->value->ptr[0] == '/') { |
if (ds->value && ds->value->ptr[0] == '/') { |
/* if the index-file starts with a prefix as use this file as |
/* if the index-file starts with a prefix as use this file as |
* index-generator */ |
* index-generator */ |
buffer_copy_string_buffer(p->tmp_buf, con->physical.doc_root); | buffer_copy_buffer(p->tmp_buf, con->physical.doc_root); |
} else { |
} else { |
buffer_copy_string_buffer(p->tmp_buf, con->physical.path); | buffer_copy_buffer(p->tmp_buf, con->physical.path); |
} |
} |
buffer_append_string_buffer(p->tmp_buf, ds->value); |
buffer_append_string_buffer(p->tmp_buf, ds->value); |
|
|
Line 190 URIHANDLER_FUNC(mod_indexfile_subrequest) {
|
Line 193 URIHANDLER_FUNC(mod_indexfile_subrequest) {
|
continue; |
continue; |
} |
} |
|
|
/* rewrite uri.path to the real path (/ -> /index.php) */ | if (ds->value && ds->value->ptr[0] == '/') { |
buffer_append_string_buffer(con->uri.path, ds->value); | /* replace uri.path */ |
buffer_copy_string_buffer(con->physical.path, p->tmp_buf); | buffer_copy_buffer(con->uri.path, ds->value); |
|
|
/* fce is already set up a few lines above */ | if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) { |
| ds = data_string_init(); |
| } |
| buffer_copy_string_len(ds->key, CONST_STR_LEN("PATH_TRANSLATED_DIRINDEX")); |
| buffer_copy_buffer(ds->value, con->physical.path); |
| array_insert_unique(con->environment, (data_unset *)ds); |
| } else { |
| /* append to uri.path the relative path to index file (/ -> /index.php) */ |
| buffer_append_string_buffer(con->uri.path, ds->value); |
| } |
| |
| buffer_copy_buffer(con->physical.path, p->tmp_buf); |
|
|
return HANDLER_GO_ON; |
return HANDLER_GO_ON; |
} |
} |