]> granicus.if.org Git - php/commitdiff
Added MINFO() to Apache 2, which displays the Apache version & all of the
authorIlia Alshanetsky <iliaa@php.net>
Fri, 27 Dec 2002 22:02:17 +0000 (22:02 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 27 Dec 2002 22:02:17 +0000 (22:02 +0000)
loaded Apache modules.
Added apache_get_version() & apache_get_modules() functions.

sapi/apache2filter/php_functions.c

index 4985127d1b134865bf001a136cd8a4c2d3f6c355..4959fb91c719ad53a62f108056eee70afb176eeb 100644 (file)
@@ -19,6 +19,8 @@
 /* $Id$ */
 
 #include "php.h"
+#include "ext/standard/php_smart_str.h"
+#include "ext/standard/info.h"
 #include "SAPI.h"
 
 #include "apr_strings.h"
@@ -37,6 +39,8 @@
 
 #include "php_apache.h"
 
+extern module **ap_loaded_modules;
+
 static request_rec *php_apache_lookup_uri(char *filename TSRMLS_DC)
 {
        php_struct *ctx;
@@ -286,8 +290,57 @@ PHP_FUNCTION(apache_getenv)
 }
 /* }}} */
 
+static char *php_apache_get_version()
+{
+       return (char *) ap_get_server_version();
+}
+
+/* {{{ proto string apache_get_version(void)
+   Fetch Apache version */
+PHP_FUNCTION(apache_get_version)
+{
+       char *apv = php_apache_get_version();
+
+       if (apv && *apv) {
+               RETURN_STRING(apv, 1);
+       } else {
+               RETURN_FALSE;
+       }
+}
+/* }}} */
+
+/* {{{ proto array apache_get_modules(void)
+   Get a list of loaded Apache modules */
+PHP_FUNCTION(apache_get_modules)
+{
+       int n;
+       
+       array_init(return_value);
+       
+       for (n = 0; ap_loaded_modules[n]; ++n) {
+               add_next_index_string(return_value, (char *) ap_loaded_modules[n]->name, 1);
+       }
+}
+/* }}} */
+
 PHP_MINFO_FUNCTION(apache)
 {
+       char *apv = php_apache_get_version();
+       smart_str tmp1 = {0};
+       int n;
+       
+       for (n = 0; ap_loaded_modules[n]; ++n) {
+               smart_str_appends(&tmp1, ap_loaded_modules[n]->name);
+               smart_str_appendc(&tmp1, ' ');
+       }
+            
+       php_info_print_table_start();
+       if (apv && *apv) {
+               php_info_print_table_row(2, "Apache Version", apv);
+       }
+       php_info_print_table_row(2, "Loaded Apache Modules", tmp1.c);
+       smart_str_free(&tmp1);
+       php_info_print_table_end();
 }
 
 static function_entry apache_functions[] = {
@@ -298,6 +351,8 @@ static function_entry apache_functions[] = {
        PHP_FE(apache_setenv, NULL)
        PHP_FE(apache_getenv, NULL)
        PHP_FE(apache_note, NULL)
+       PHP_FE(apache_get_version, NULL)
+       PHP_FE(apache_get_modules, NULL)
        PHP_FALIAS(getallheaders, apache_request_headers, NULL)
        {NULL, NULL, NULL}
 };