summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2002-10-04 21:15:59 +0000
committerIlia Alshanetsky <iliaa@php.net>2002-10-04 21:15:59 +0000
commit9f2b70d507cd5e5844274a7146bf4083488fe802 (patch)
tree8d21e97c78e1af6f922dfa6bf37842eda87cbbb5
parentdf837e67c7ee99bb022211c079921f497cacaed0 (diff)
downloadphp-git-9f2b70d507cd5e5844274a7146bf4083488fe802.tar.gz
Added .phps support to Apache 2. It can be enabled by adding
AddType application/x-httpd-php-source .phps to httpd.conf
-rw-r--r--sapi/apache2filter/sapi_apache2.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c
index 33bc5a4242..826ad74716 100644
--- a/sapi/apache2filter/sapi_apache2.c
+++ b/sapi/apache2filter/sapi_apache2.c
@@ -27,6 +27,7 @@
#include "SAPI.h"
#include "ext/standard/php_smart_str.h"
+#include "ext/standard/php_standard.h"
#include "apr_strings.h"
#include "ap_config.h"
@@ -440,12 +441,23 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
php_apache_request_ctor(f, ctx TSRMLS_CC);
apr_file_name_get(&path, ((apr_bucket_file *) b->data)->fd);
- zfd.type = ZEND_HANDLE_FILENAME;
- zfd.filename = (char *) path;
- zfd.free_filename = 0;
- zfd.opened_path = NULL;
-
- php_execute_script(&zfd TSRMLS_CC);
+
+ /* Determine if we need to parse the file or show the source */
+ if (!strncmp(ctx->r->handler, "application/x-httpd-php", sizeof("application/x-httpd-php"))) {
+ zfd.type = ZEND_HANDLE_FILENAME;
+ zfd.filename = (char *) path;
+ zfd.free_filename = 0;
+ zfd.opened_path = NULL;
+
+ php_execute_script(&zfd TSRMLS_CC);
+ } else {
+ zend_syntax_highlighter_ini syntax_highlighter_ini;
+
+ php_get_highlight_struct(&syntax_highlighter_ini);
+
+ highlight_file((char *)path, &syntax_highlighter_ini TSRMLS_CC);
+ }
+
php_apache_request_dtor(f TSRMLS_CC);
ctx->request_processed = 1;
@@ -560,10 +572,13 @@ static void php_add_filter(request_rec *r, ap_filter_t *f)
static void php_insert_filter(request_rec *r)
{
- if (r->content_type &&
- strcmp(r->content_type, "application/x-httpd-php") == 0) {
- php_add_filter(r, r->output_filters);
- php_add_filter(r, r->input_filters);
+ int content_type_len = strlen("application/x-httpd-php");
+
+ if (r->content_type && !strncmp(r->content_type, "application/x-httpd-php", content_type_len-1)) {
+ if (r->content_type[content_type_len] == '\0' || !strncmp(r->content_type+content_type_len, "-source", strlen("-source"))) {
+ php_add_filter(r, r->output_filters);
+ php_add_filter(r, r->input_filters);
+ }
}
}