Talking to Server Side Includes

From: Date: Sun, 23 Jan 2000 12:42:49 +0000
Subject: Talking to Server Side Includes
Groups: php.dev 
Request: Send a blank email to php-dev+get-14856@lists.php.net to get a copy of this message
Hi, I am using php together with ServerSideIncludes (mod_include) to build up a Website. php offers a way to include other Documents in the output of the php script by calling virtual(). The SSI I use define the Page Framework and general appearance. To modify this html Pages kann Set some Variables used by the include, e.g. the Page Title kann be changed by Setting the Variable TITLE unsing the SSI #set command. Virtual() includes the SSI but there is no way to set Variables for use in the Include. I have taken a look at mod_include an found out that it uses the subprocess_env table to store the Variable. But there is still no php function to insert Values in this Table. I have modified functions/apache.c by appendig a funktion apache_subprocess_env() which is mainly a copy of the existing apache_note() function changing only the Table to work on. The apache_subprocess_env enables php to set Variables used by mod_include. I've included the patch in this Mail. Gerhard Schmidt -------------------------------------------------------------------------- Gerhard Schmidt | Nick : estartu IRC : Estartu | Fischbachweg 3 | | PGP Public Key 86856 Hiltenfingen | estartu@augusta.de | auf Anfrage/ Tel: 08232 77 36 4 | | on request Fax: 08232 77 36 3 | |

--- php-3.0.12.orig/functions/apache.c Wed Jun 16 13:34:17 1999 +++ php-3.0.12/functions/apache.c Tue Jan 4 11:33:06 2000 @@ -56,12 +56,14 @@ void php3_apachelog(INTERNAL_FUNCTION_PARAMETERS); void php3_info_apache(void); void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS); +void php3_apache_subprocess_env(INTERNAL_FUNCTION_PARAMETERS); void php3_apache_lookup_uri(INTERNAL_FUNCTION_PARAMETERS); function_entry apache_functions[] = { {"virtual", php3_virtual, NULL}, {"getallheaders", php3_getallheaders, NULL}, {"apache_note", php3_apache_note,NULL}, + {"apache_subprocess_env", php3_apache_subprocess_env,NULL}, {"apache_lookup_uri", php3_apache_lookup_uri,NULL}, {NULL, NULL, NULL} }; @@ -99,6 +101,37 @@ } } /* }}} */ + +/* {{{ proto string apache_subprocess_env(string note_name [, string note_value]) + Get and set Apache request notes */ +void php3_apache_subprocess_env(INTERNAL_FUNCTION_PARAMETERS) +{ + pval *arg_name,*arg_val; + char *note_val; + int arg_count = ARG_COUNT(ht); +TLS_VARS; + + if (arg_count<1 || arg_count>2 || + getParameters(ht,arg_count,&arg_name,&arg_val) == FAILURE ) { + WRONG_PARAM_COUNT; + } + + convert_to_string(arg_name); + note_val = (char *) table_get(GLOBAL(php3_rqst)->subprocess_env,arg_name->value.str.val); + + if (arg_count == 2) { + convert_to_string(arg_val); + table_set(GLOBAL(php3_rqst)->subprocess_env,arg_name->value.str.val,arg_val->value.str.val); + } + + if (note_val) { + RETURN_STRING(note_val,1); + } else { + RETURN_FALSE; + } +} +/* }}} */ + void php3_info_apache(void) { module *modp = NULL; Attachment: [application/pgp-signature]
« previous php.dev (#14856) next »