]> granicus.if.org Git - php/commitdiff
MFH: runtime apache version
authorfoobar <sniper@php.net>
Tue, 9 Sep 2003 21:42:57 +0000 (21:42 +0000)
committerfoobar <sniper@php.net>
Tue, 9 Sep 2003 21:42:57 +0000 (21:42 +0000)
sapi/apache/php_apache.c

index 304ee75d055e99e20c0e24f692f14c88ac1add38..81d2822c5a162c1f54ee3d13c81eb92e905e5c90 100644 (file)
@@ -44,6 +44,7 @@ PHP_FUNCTION(apache_note);
 PHP_FUNCTION(apache_lookup_uri);
 PHP_FUNCTION(apache_child_terminate);
 PHP_FUNCTION(apache_setenv);
+PHP_FUNCTION(apache_get_version);
 
 PHP_MINFO_FUNCTION(apache);
 
@@ -55,6 +56,7 @@ function_entry apache_functions[] = {
        PHP_FE(apache_child_terminate,                                  NULL)
        PHP_FE(apache_setenv,                                                   NULL)
        PHP_FE(apache_response_headers,                                 NULL)
+       PHP_FE(apache_get_version,                                              NULL)
        PHP_FALIAS(getallheaders, apache_request_headers, NULL)
        {NULL, NULL, NULL}
 };
@@ -74,7 +76,6 @@ static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRML
        apache_globals->in_request = 0;
 }
 
-
 static PHP_MINIT_FUNCTION(apache)
 {
 #ifdef ZTS
@@ -158,6 +159,7 @@ PHP_FUNCTION(apache_note)
  */
 PHP_MINFO_FUNCTION(apache)
 {
+       char *apv = (char *) ap_get_server_version();
        module *modp = NULL;
        char output_buf[128];
 #if !defined(WIN32) && !defined(WINNT)
@@ -174,7 +176,6 @@ PHP_MINFO_FUNCTION(apache)
 
        serv = ((request_rec *) SG(server_context))->server;
 
-
        php_info_print_table_start();
 
 #ifdef PHP_WIN32
@@ -190,7 +191,9 @@ PHP_MINFO_FUNCTION(apache)
        php_info_print_table_row(2, "APACHE_TARGET", PHP_APACHE_TARGET);
 #endif
 
-       php_info_print_table_row(2, "Apache Version", SERVER_VERSION);
+       if (apv && *apv) {
+               php_info_print_table_row(2, "Apache Version", apv);
+       } 
 
 #ifdef APACHE_RELEASE
        sprintf(output_buf, "%d", APACHE_RELEASE);
@@ -474,6 +477,19 @@ PHP_FUNCTION(apache_lookup_uri)
 }
 /* }}} */
 
+/* {{{ proto string apache_get_version(void)
+   Fetch Apache version */
+PHP_FUNCTION(apache_get_version)
+{       
+       char *apv = (char *) ap_get_server_version();
+
+       if (apv && *apv) {
+               RETURN_STRING(apv, 1);
+       } else {
+               RETURN_FALSE;
+       }
+}
+/* }}} */
 
 #if 0
 This function is most likely a bad idea.  Just playing with it for now.