static int lsapi_activate_user_ini_basic_checks(_lsapi_activate_user_ini_ctx *ctx, void* next) { int rc = SUCCESS; fn_activate_user_ini_chain_t *fn_next = next; if (!PG(user_ini_filename) || !*PG(user_ini_filename)) { return SUCCESS; } /* PATH_TRANSLATED should be defined at this stage */ ctx->path = SG(request_info).path_translated; if (!ctx->path || !*ctx->path) { return FAILURE; } ctx->doc_root = sapi_lsapi_getenv("DOCUMENT_ROOT", 0); DEBUG_MESSAGE("doc_root: %s", ctx->doc_root); if (*fn_next) { rc = (*fn_next)(ctx, fn_next + 1); } return rc; }
static int sapi_lsapi_activate() { char *path, *server_name; size_t path_len, server_name_len; /* PATH_TRANSLATED should be defined at this stage but better safe than sorry :) */ if (!SG(request_info).path_translated) { return FAILURE; } if (php_ini_has_per_host_config()) { server_name = sapi_lsapi_getenv("SERVER_NAME", 0); /* SERVER_NAME should also be defined at this stage..but better check it anyway */ if (server_name) { server_name_len = strlen(server_name); server_name = estrndup(server_name, server_name_len); zend_str_tolower(server_name, server_name_len); php_ini_activate_per_host_config(server_name, server_name_len); efree(server_name); } } if (php_ini_has_per_dir_config()) { /* Prepare search path */ path_len = strlen(SG(request_info).path_translated); /* Make sure we have trailing slash! */ if (!IS_SLASH(SG(request_info).path_translated[path_len])) { path = emalloc(path_len + 2); memcpy(path, SG(request_info).path_translated, path_len + 1); path_len = zend_dirname(path, path_len); path[path_len++] = DEFAULT_SLASH; } else { path = estrndup(SG(request_info).path_translated, path_len); path_len = zend_dirname(path, path_len); } path[path_len] = 0; /* Activate per-dir-system-configuration defined in php.ini and stored into configuration_hash during startup */ php_ini_activate_per_dir_config(path, path_len); /* Note: for global settings sake we check from root to path */ efree(path); } if (parse_user_ini && lsapi_activate_user_ini() == FAILURE) { return FAILURE; } return SUCCESS; }