Back to index

php5  5.3.10
Defines | Functions | Variables
php_functions.c File Reference
#include "php.h"
#include "ext/standard/php_smart_str.h"
#include "ext/standard/info.h"
#include "SAPI.h"
#include "apr_strings.h"
#include "apr_time.h"
#include "ap_config.h"
#include "util_filter.h"
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
#include "php_apache.h"

Go to the source code of this file.

Defines

#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
#define CORE_PRIVATE
#define ADD_LONG(name)   add_property_long(return_value, #name, rr->name)
#define ADD_TIME(name)   add_property_long(return_value, #name, apr_time_sec(rr->name));
#define ADD_STRING(name)   if (rr->name) add_property_string(return_value, #name, (char *) rr->name, 1)

Functions

static request_rec * php_apache_lookup_uri (char *filename TSRMLS_DC)
 PHP_FUNCTION (virtual)
 PHP_FUNCTION (apache_lookup_uri)
 PHP_FUNCTION (apache_request_headers)
 PHP_FUNCTION (apache_response_headers)
 PHP_FUNCTION (apache_note)
 PHP_FUNCTION (apache_setenv)
 PHP_FUNCTION (apache_getenv)
static char * php_apache_get_version ()
 PHP_FUNCTION (apache_get_version)
 PHP_FUNCTION (apache_get_modules)
 PHP_MINFO_FUNCTION (apache)

Variables

static const zend_function_entry apache_functions []
zend_module_entry php_apache_module

Define Documentation

#define ADD_LONG (   name)    add_property_long(return_value, #name, rr->name)

Definition at line 91 of file php_functions.c.

#define ADD_STRING (   name)    if (rr->name) add_property_string(return_value, #name, (char *) rr->name, 1)

Definition at line 95 of file php_functions.c.

#define ADD_TIME (   name)    add_property_long(return_value, #name, apr_time_sec(rr->name));

Definition at line 93 of file php_functions.c.

#define CORE_PRIVATE

Definition at line 29 of file php_functions.c.

Definition at line 22 of file php_functions.c.


Function Documentation

static char* php_apache_get_version ( ) [static]

Definition at line 281 of file php_functions.c.

{
#if MODULE_MAGIC_NUMBER_MAJOR >= 20060905
       return (char *) ap_get_server_banner();
#else
       return (char *) ap_get_server_version();
#endif
}

Here is the caller graph for this function:

static request_rec* php_apache_lookup_uri ( char *filename  TSRMLS_DC) [static]

Definition at line 46 of file php_functions.c.

{
       php_struct *ctx;
       
       if (!filename) {
              return NULL;
       }
       
       ctx = SG(server_context);
       return ap_sub_req_lookup_uri(filename, ctx->f->r, ctx->f->next);
}

Here is the caller graph for this function:

PHP_FUNCTION ( virtual  )

Definition at line 60 of file php_functions.c.

{
       char *filename;
       int filename_len;
       request_rec *rr;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
              return;
       }

       if (!(rr = php_apache_lookup_uri(filename TSRMLS_CC))) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
              RETURN_FALSE;
       }
       
       if (rr->status == HTTP_OK) {
              if (ap_run_sub_req(rr)) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - request execution failed", filename);
                     ap_destroy_sub_req(rr);
                     RETURN_FALSE;
              }
              ap_destroy_sub_req(rr);
              RETURN_TRUE;
       }
       
       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename);
       ap_destroy_sub_req(rr);
       RETURN_FALSE;
}

Here is the call graph for this function:

PHP_FUNCTION ( apache_lookup_uri  )

Definition at line 98 of file php_functions.c.

{
       request_rec *rr;
       char *filename;
       int filename_len;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
              return;
       }

       if (!(rr = php_apache_lookup_uri(filename TSRMLS_CC))) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
              RETURN_FALSE;
       }
       
       if (rr->status == HTTP_OK) {
              object_init(return_value);

              ADD_LONG(status);
              ADD_STRING(the_request);
              ADD_STRING(status_line);
              ADD_STRING(method);
              ADD_TIME(mtime);
              ADD_LONG(clength);
#if MODULE_MAGIC_NUMBER < 20020506
              ADD_STRING(boundary);
#endif
              ADD_STRING(range);
              ADD_LONG(chunked);
              ADD_STRING(content_type);
              ADD_STRING(handler);
              ADD_LONG(no_cache);
              ADD_LONG(no_local_copy);
              ADD_STRING(unparsed_uri);
              ADD_STRING(uri);
              ADD_STRING(filename);
              ADD_STRING(path_info);
              ADD_STRING(args);
              ADD_LONG(allowed);
              ADD_LONG(sent_bodyct);
              ADD_LONG(bytes_sent);
              ADD_LONG(mtime);
              ADD_TIME(request_time);

              ap_destroy_sub_req(rr);
              return;
       }
       
       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename);
       ap_destroy_sub_req(rr);
       RETURN_FALSE;
}

Here is the call graph for this function:

PHP_FUNCTION ( apache_request_headers  )

Definition at line 153 of file php_functions.c.

{
       php_struct *ctx;
       const apr_array_header_t *arr;
       char *key, *val;

       array_init(return_value);
       
       ctx = SG(server_context);
       arr = apr_table_elts(ctx->f->r->headers_in);

       APR_ARRAY_FOREACH_OPEN(arr, key, val)
              if (!val) val = "";
              add_assoc_string(return_value, key, val, 1);
       APR_ARRAY_FOREACH_CLOSE()
}
PHP_FUNCTION ( apache_response_headers  )

Definition at line 173 of file php_functions.c.

{
       php_struct *ctx;
       const apr_array_header_t *arr;
       char *key, *val;

       array_init(return_value);
       
       ctx = SG(server_context);
       arr = apr_table_elts(ctx->f->r->headers_out);

       APR_ARRAY_FOREACH_OPEN(arr, key, val)
              if (!val) val = "";
              add_assoc_string(return_value, key, val, 1);
       APR_ARRAY_FOREACH_CLOSE()
}
PHP_FUNCTION ( apache_note  )

Definition at line 193 of file php_functions.c.

{
       php_struct *ctx;
       char *note_name, *note_val = NULL;
       int note_name_len, note_val_len;
       char *old_note_val=NULL;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
              return;
       }

       ctx = SG(server_context);

       old_note_val = (char *) apr_table_get(ctx->r->notes, note_name);

       if (note_val) {
              apr_table_set(ctx->r->notes, note_name, note_val);
       }

       if (old_note_val) {
              RETURN_STRING(old_note_val, 1);
       }

       RETURN_FALSE;
}

Here is the call graph for this function:

PHP_FUNCTION ( apache_setenv  )

Definition at line 223 of file php_functions.c.

{
       php_struct *ctx;
       char *variable=NULL, *string_val=NULL;
       int variable_len, string_val_len;
       zend_bool walk_to_top = 0;
       int arg_count = ZEND_NUM_ARGS();

       if (zend_parse_parameters(arg_count TSRMLS_CC, "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) {
              return;
       }

       ctx = SG(server_context);

       if (arg_count == 3 && walk_to_top) {
              while(ctx->f->r->prev) {
                     ctx->f->r = ctx->f->r->prev;
              }
       }

       apr_table_set(ctx->r->subprocess_env, variable, string_val);

       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( apache_getenv  )

Definition at line 251 of file php_functions.c.

{
       php_struct *ctx;
       char *variable=NULL;
       int variable_len;
       zend_bool walk_to_top = 0;
       int arg_count = ZEND_NUM_ARGS();
       char *env_val=NULL;

       if (zend_parse_parameters(arg_count TSRMLS_CC, "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) {
              return;
       }

       ctx = SG(server_context);

       if (arg_count == 2 && walk_to_top) {
              while(ctx->f->r->prev) {
                     ctx->f->r = ctx->f->r->prev;
              }
       }

       env_val = (char*) apr_table_get(ctx->r->subprocess_env, variable);
       if (env_val != NULL) {
              RETURN_STRING(env_val, 1);
       }

       RETURN_FALSE;
}

Here is the call graph for this function:

PHP_FUNCTION ( apache_get_version  )

Definition at line 292 of file php_functions.c.

{
       char *apv = php_apache_get_version();

       if (apv && *apv) {
              RETURN_STRING(apv, 1);
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( apache_get_modules  )

Definition at line 306 of file php_functions.c.

{
       int n;
       char *p;
       
       array_init(return_value);
       
       for (n = 0; ap_loaded_modules[n]; ++n) {
              char *s = (char *) ap_loaded_modules[n]->name;
              if ((p = strchr(s, '.'))) {
                     add_next_index_stringl(return_value, s, (p - s), 1);
              } else {
                     add_next_index_string(return_value, s, 1);
              }
       }
}

Here is the call graph for this function:

PHP_MINFO_FUNCTION ( apache  )

Definition at line 324 of file php_functions.c.

{
       char *apv = php_apache_get_version();
       smart_str tmp1 = {0};
       int n;
       char *p;
       
       for (n = 0; ap_loaded_modules[n]; ++n) {
              char *s = (char *) ap_loaded_modules[n]->name;
              if ((p = strchr(s, '.'))) {
                     smart_str_appendl(&tmp1, s, (p - s));
              } else {
                     smart_str_appends(&tmp1, s);
              }
              smart_str_appendc(&tmp1, ' ');
       }
       if ((tmp1.len - 1) >= 0) {
              tmp1.c[tmp1.len - 1] = '\0';
       }
            
       php_info_print_table_start();
       if (apv && *apv) {
              php_info_print_table_row(2, "Apache Version", apv);
       }
       php_info_print_table_row(2, "Loaded Modules", tmp1.c);
       smart_str_free(&tmp1);
       php_info_print_table_end();
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 {









       PHP_FALIAS(getallheaders,          apache_request_headers, arginfo_apache2filter_getallheaders)
       {NULL, NULL, NULL}
}

Definition at line 391 of file php_functions.c.

zend_module_entry php_apache_module
Initial value:

Definition at line 405 of file php_functions.c.