static void php_ns_sapi_register_variables(zval *track_vars_array) { int i; char buf[NS_BUF_SIZE + 1]; char *tmp; for(i = 0; i < Ns_SetSize(NSG(conn->headers)); i++) { char *key = Ns_SetKey(NSG(conn->headers), i); char *value = Ns_SetValue(NSG(conn->headers), i); char *p; char c; snprintf(buf, NS_BUF_SIZE, "HTTP_%s", key); for(p = buf + 5; (c = *p); p++) { c = toupper(c); if(c < 'A' || c > 'Z') { c = '_'; } *p = c; } ADD_STRINGX(buf, value); } snprintf(buf, NS_BUF_SIZE, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion()); ADD_STRING("SERVER_SOFTWARE"); snprintf(buf, NS_BUF_SIZE, "HTTP/%1.1f", NSG(conn)->request->version); ADD_STRING("SERVER_PROTOCOL"); ADD_STRINGX("REQUEST_METHOD", NSG(conn)->request->method); if(NSG(conn)->request->query) ADD_STRINGX("QUERY_STRING", NSG(conn)->request->query); ADD_STRINGX("SERVER_BUILDDATE", Ns_InfoBuildDate()); ADD_STRINGX("REMOTE_ADDR", Ns_ConnPeer(NSG(conn))); snprintf(buf, NS_BUF_SIZE, "%d", Ns_ConnPeerPort(NSG(conn))); ADD_STRING("REMOTE_PORT"); snprintf(buf, NS_BUF_SIZE, "%d", Ns_ConnPort(NSG(conn))); ADD_STRING("SERVER_PORT"); tmp = Ns_ConnHost(NSG(conn)); if (tmp) ADD_STRINGX("SERVER_NAME", tmp); ADD_STRINGX("PATH_TRANSLATED", SG(request_info).path_translated); ADD_STRINGX("REQUEST_URI", SG(request_info).request_uri); ADD_STRINGX("PHP_SELF", SG(request_info).request_uri); ADD_STRINGX("GATEWAY_INTERFACE", "CGI/1.1"); snprintf(buf, NS_BUF_SIZE, "%d", Ns_InfoBootTime()); ADD_STRING("SERVER_BOOTTIME"); }
static void php_info_aolserver(ZEND_MODULE_INFO_FUNC_ARGS) { char buf[512]; int uptime = Ns_InfoUptime(); int i; php_info_print_table_start(); php_info_print_table_row(2, "SAPI module version", "$Id$"); php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); php_info_print_table_row(2, "Installation path", Ns_InfoHomePath()); php_info_print_table_row(2, "Hostname of server", Ns_InfoHostname()); php_info_print_table_row(2, "Source code label", Ns_InfoLabel()); php_info_print_table_row(2, "Server platform", Ns_InfoPlatform()); snprintf(buf, 511, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion()); php_info_print_table_row(2, "Server version", buf); snprintf(buf, 511, "%d day(s), %02d:%02d:%02d", uptime / 86400, (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60); php_info_print_table_row(2, "Server uptime", buf); php_info_print_table_end(); SECTION("HTTP Headers Information"); php_info_print_table_start(); php_info_print_table_colspan_header(2, "HTTP Request Headers"); php_info_print_table_row(2, "HTTP Request", NSG(conn)->request->line); for (i = 0; i < Ns_SetSize(NSG(conn)->headers); i++) { php_info_print_table_row(2, Ns_SetKey(NSG(conn)->headers, i), Ns_SetValue(NSG(conn)->headers, i)); } php_info_print_table_colspan_header(2, "HTTP Response Headers"); for (i = 0; i < Ns_SetSize(NSG(conn)->outputheaders); i++) { php_info_print_table_row(2, Ns_SetKey(NSG(conn)->outputheaders, i), Ns_SetValue(NSG(conn)->outputheaders, i)); } php_info_print_table_end(); }
/** Standard AOLserver callback. * Initialize jk2, unless already done in another server. Register URI mappping for Tomcat * If multiple virtual servers use this module, calls to Ns_ModuleInit will be made serially * in order of appearance of those servers in nsd.tcl */ int Ns_ModuleInit(char *server, char *module) { jk_env_t *env; /* configuration-related */ char* serverName=NULL; char* confPath; static char cwdBuf[PATH_MAX]; static char* serverRoot = NULL; /* APR-related */ apr_status_t aprrc; char errbuf[512]; apr_pool_t *jk_globalPool = NULL; /* URI registration */ char *hosts[2] = {"*", NULL}; jk_map_t *vhosts; int i, j, k, l, cnt1, cnt2; jk_map_t *uriMap, *webapps, *uriMaps[3]; jk_uriEnv_t *uriEnv, *hostEnv, *appEnv; if (jkInitCount++ == 0) { /* Get Tomcat installation root - this value is same for all virtual servers*/ if (serverRoot == NULL) { confPath = Ns_ConfigGetPath (NULL, module, NULL); serverRoot = (confPath? Ns_ConfigGetValue (confPath, "serverRoot") : NULL); } /* not configured in nsd.tcl? try env. variable */ if (serverRoot == NULL) { serverRoot = getenv ("TOMCAT_HOME"); } /* not in env. variables? get it from CWD */ if (serverRoot == NULL) { serverRoot = getcwd (cwdBuf, sizeof(cwdBuf)); } /* Initialize APR */ if ((aprrc=apr_initialize()) != APR_SUCCESS) { LOG_ERROR2 ("Cannot initialize APR", apr_strerror (aprrc, errbuf, sizeof(errbuf))); return NS_ERROR; } if ((aprrc=apr_pool_create(&jk_globalPool, NULL)) != APR_SUCCESS) { LOG_ERROR2 ("Cannot create global APR pool", apr_strerror (aprrc, errbuf, sizeof(errbuf))); return NS_ERROR; } /* Initialize JNI */ if (workerEnv==NULL && jk2_create_workerEnv(jk_globalPool, serverRoot)==JK_ERR) { return NS_ERROR; } env=workerEnv->globalEnv; env->setAprPool(env, jk_globalPool); /* Initialize JK2 */ if (workerEnv->init(env, workerEnv ) != JK_OK) { LOG_ERROR("Cannot initialize worker environment"); return NS_ERROR; } workerEnv->server_name = apr_pstrcat (jk_globalPool, Ns_InfoServerName(), " ", Ns_InfoServerVersion (), NULL); apr_pool_cleanup_register(jk_globalPool, NULL, jk2_shutdown, apr_pool_cleanup_null); workerEnv->was_initialized = JK_TRUE; if ((aprrc=apr_pool_userdata_set( "INITOK", "Ns_ModuleInit", NULL, jk_globalPool )) != APR_SUCCESS) { LOG_ERROR2 ("Cannot set APR pool user data", apr_strerror (aprrc, errbuf, sizeof(errbuf))); return NS_ERROR; } if (workerEnv->parentInit( env, workerEnv) != JK_OK) { LOG_ERROR ("Cannot initialize global environment"); return NS_ERROR; } /* Obtain TLS slot - it's destructor will detach threads from JVM */ jvmGlobal = workerEnv->vm->jvm; Ns_TlsAlloc (&jkTls, jkTlsDtor); Ns_Log (Notice, "nsjk2: Initialized JK2 environment"); } else { env = workerEnv->globalEnv; } Ns_RegisterShutdown (jk2_shutdown_system, NULL); /* Register URI patterns from workers2.properties with AOLserver * * Worker environment has a list of vhosts, including "*" vhost. * Each vhost has a list of web applications (contexts) associated with it. * Each webapp has a list of exact, prefix, suffix and regexp URI patterns. * * Will register URIs that are either in vhost "*", or one with name matching * this AOLserver virtual server. Will ignore regexp patterns. Will register * exact webapp URIs (context root) as JK2 somehow doesn't include them in URI * maps, even if specified in workers2.properties. * */ /* virtual server name override if specified */ confPath = Ns_ConfigGetPath (server, module, NULL); if (confPath != NULL) serverName = Ns_ConfigGetValue (confPath, "serverName"); if (serverName == NULL) serverName = server; vhosts=workerEnv->uriMap->vhosts; hosts[1]= serverName; for (i=0; i<sizeof(hosts)/sizeof(*hosts); i++) { hostEnv=vhosts->get (env, vhosts, hosts[i]); if (hostEnv==NULL || hostEnv->webapps==NULL) continue; webapps=hostEnv->webapps; cnt1=webapps->size(env, webapps); for (j=0; j<cnt1; j++) { appEnv = webapps->valueAt (env, webapps, j); if (appEnv == NULL) continue; /* register webapp root - registerURI checks if it is "/" */ registerURI (env, appEnv, server, serverName); uriMaps[0] = appEnv->exactMatch; uriMaps[1] = appEnv->prefixMatch; uriMaps[2] = appEnv->suffixMatch; for (k=0; k<sizeof(uriMaps)/sizeof(*uriMaps); k++) { if (uriMaps[k] == NULL) continue; cnt2 = uriMaps[k]->size (env, uriMaps[k]); for (l=0; l<cnt2; l++) { registerURI (env, uriMaps[k]->valueAt (env, uriMaps[k], l), server, serverName); } } } } Ns_Log (Notice, "nsjk2: Initialized on %s", server); return NS_OK; }