Re: [PHP] Virtual includes of PHP into SSI pages.

2005-11-16 Thread cron
For this to work you must set html and shml as a php file extension in
apache.

This is because shml includes are made before it reaches apache output, so
if you have file a including file b it the same as having only one file
a with copy and paste of file b with shml file extension and thus this
is never parsed to php.

Hope i´m making any sense here, bad english

Angelo



- Original Message - 
From: Neil Hoggarth [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Monday, November 14, 2005 11:01 AM
Subject: [PHP] Virtual includes of PHP into SSI pages.


 Hi Folks,

 I'm attempting to diagnose an apparent problem with my Apache/PHP
 server setup. The platform is SPARC Solaris 9. I'm running Apache httpd
 2.0.55 and PHP 4.4.1, built from NetBSD pkgsrc.

 I have a user who has .shtml (server side include) pages which include
 PHP fragments using directives like !--#include virtual=/name.php --
 (and yes, I know this is silly, and that obvious thing to do is to use
 PHP for the top level pages rather than SSI; unfortunatly I'm the
 sysadmin providing the service, rather than the person maintaining the
 content).

 I wanted to check to see if anyone knows of any known problems or
 gotchas in this area?

 I'm told that this mechanism was working okay until recently, but it
 broke at some point in the last few months. I've done a number of
 upgrades to both the apache2 and PHP packages over the time period in
 question, in response to security advisories; unfortunately the user
 can't pinpoint exactly when things started to fail.

 I've recreated a very simple test case:

 test.shtml:

html
head
titleTest Page/title
/head
body
pBegin Test/p
!--#include virtual=/foo1.php --
pEnd Test/p
/body
/html

 foo1.php:

pHello From PHP/p

 Fetching test.shtml produces the output:

Begin Test

End Test

 (no sign of the included fragment in the output).

 Editing the test harness to teplacing the include of foo1.php with an
 include of a plain HTML or SHTML file produces the expected output
 (included content appears in the output between the begin and end
 markers).

 Furthermore, if I edit the test harness to include an HTML file and
 *then* the PHP fragment, I get a reproduceable segmentation fault in
 PHP:

 Program received signal SIGSEGV, Segmentation fault.
 0xfecb541c in zend_hash_index_update_or_next_insert (ht=0xfed3c1c4, h=0,
 pData=0xffbfdec8, nDataSize=12,
  pDest=0x0, flag=1) at
 /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_hash.c:390
 390 p = ht-arBuckets[nIndex];
 (gdb) where
 #0  0xfecb541c in zend_hash_index_update_or_next_insert (ht=0xfed3c1c4,
 h=0, pData=0xffbfdec8,
  nDataSize=12, pDest=0x0, flag=1)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_hash.c:390
 #1  0xfecb8cc0 in zend_list_insert (ptr=0x299250, type=2)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_list.c:45
 #2  0xfecb8eb8 in zend_register_resource (rsrc_result=0x0,
rsrc_pointer=0x299250, rsrc_type=2)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_list.c:98
 #3  0xfec693d8 in _php_stream_alloc (ops=0xfed31528, abstract=0x1eb770,
persistent_id=0x0,
  mode=0xfece83f0 rb) at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:281
 #4  0xfec6e0b0 in _php_stream_fopen_from_fd (fd=22, mode=0xfece83f0 rb,
persistent_id=0x0)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2072
 #5  0xfec6de5c in _php_stream_fopen (filename=0x297cb8
/usr/pkg/share/httpd/htdocs/foo1.php,
  mode=0xfece83f0 rb, opened_path=0xffbfeb90, options=165)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2004
 #6  0xfec6d5cc in _php_stream_fopen_with_path (filename=0x297cb8
/usr/pkg/share/httpd/htdocs/foo1.php,
  mode=0xfece83f0 rb, path=0xfece7fc8 .:/usr/pkg/lib/php,
opened_path=0xffbfeb90, options=165)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:1784
 #7  0xfec6efd4 in php_plain_files_stream_opener (wrapper=0xfed31598,
  path=0x297cb8 /usr/pkg/share/httpd/htdocs/foo1.php, mode=0xfece83f0
rb, options=165,
  opened_path=0xffbfeb90, context=0x0)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2489
 #8  0xfec6fb18 in _php_stream_open_wrapper_ex (path=0x297cb8
/usr/pkg/share/httpd/htdocs/foo1.php,
  mode=0xfece83f0 rb, options=173, opened_path=0xffbfeb90,
context=0x0)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2696
 #9  0xfec6ff34 in _php_stream_open_wrapper_as_file_handle (
  path=0x297cb8 /usr/pkg/share/httpd/htdocs/foo1.php, mode=0xfece83f0
rb, options=141, fh=0xffbfeb88)
  at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2823
 #10 0xfec53900 in php_open_wrapper_for_zend (filename=0x297cb8
/usr/pkg/share/httpd/htdocs/foo1.php,
  fh=0xffbfeb88) at
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/main.c:764
 #11

[PHP] Virtual includes of PHP into SSI pages.

2005-11-14 Thread Neil Hoggarth

Hi Folks,

I'm attempting to diagnose an apparent problem with my Apache/PHP 
server setup. The platform is SPARC Solaris 9. I'm running Apache httpd

2.0.55 and PHP 4.4.1, built from NetBSD pkgsrc.

I have a user who has .shtml (server side include) pages which include 
PHP fragments using directives like !--#include virtual=/name.php -- 
(and yes, I know this is silly, and that obvious thing to do is to use 
PHP for the top level pages rather than SSI; unfortunatly I'm the 
sysadmin providing the service, rather than the person maintaining the 
content).


I wanted to check to see if anyone knows of any known problems or 
gotchas in this area?


I'm told that this mechanism was working okay until recently, but it 
broke at some point in the last few months. I've done a number of 
upgrades to both the apache2 and PHP packages over the time period in 
question, in response to security advisories; unfortunately the user 
can't pinpoint exactly when things started to fail.


I've recreated a very simple test case:

test.shtml:

  html
  head
  titleTest Page/title
  /head
  body
  pBegin Test/p
  !--#include virtual=/foo1.php --
  pEnd Test/p
  /body
  /html

foo1.php:

  pHello From PHP/p

Fetching test.shtml produces the output:

  Begin Test

  End Test

(no sign of the included fragment in the output).

Editing the test harness to teplacing the include of foo1.php with an 
include of a plain HTML or SHTML file produces the expected output 
(included content appears in the output between the begin and end 
markers).


Furthermore, if I edit the test harness to include an HTML file and 
*then* the PHP fragment, I get a reproduceable segmentation fault in 
PHP:


Program received signal SIGSEGV, Segmentation fault.
0xfecb541c in zend_hash_index_update_or_next_insert (ht=0xfed3c1c4, h=0, 
pData=0xffbfdec8, nDataSize=12,
pDest=0x0, flag=1) at 
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_hash.c:390

390 p = ht-arBuckets[nIndex];
(gdb) where
#0  0xfecb541c in zend_hash_index_update_or_next_insert (ht=0xfed3c1c4, 
h=0, pData=0xffbfdec8,

nDataSize=12, pDest=0x0, flag=1)
at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_hash.c:390
#1  0xfecb8cc0 in zend_list_insert (ptr=0x299250, type=2)
at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_list.c:45
#2  0xfecb8eb8 in zend_register_resource (rsrc_result=0x0, 
rsrc_pointer=0x299250, rsrc_type=2)
at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend_list.c:98
#3  0xfec693d8 in _php_stream_alloc (ops=0xfed31528, abstract=0x1eb770, 
persistent_id=0x0,
mode=0xfece83f0 rb) at 
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:281
#4  0xfec6e0b0 in _php_stream_fopen_from_fd (fd=22, mode=0xfece83f0 rb, 
persistent_id=0x0)
at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2072
#5  0xfec6de5c in _php_stream_fopen (filename=0x297cb8 
/usr/pkg/share/httpd/htdocs/foo1.php,
mode=0xfece83f0 rb, opened_path=0xffbfeb90, options=165)
at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2004
#6  0xfec6d5cc in _php_stream_fopen_with_path (filename=0x297cb8 
/usr/pkg/share/httpd/htdocs/foo1.php,
mode=0xfece83f0 rb, path=0xfece7fc8 .:/usr/pkg/lib/php, 
opened_path=0xffbfeb90, options=165)
at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:1784
#7  0xfec6efd4 in php_plain_files_stream_opener (wrapper=0xfed31598,
path=0x297cb8 /usr/pkg/share/httpd/htdocs/foo1.php, mode=0xfece83f0 rb, 
options=165,
opened_path=0xffbfeb90, context=0x0)
at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2489
#8  0xfec6fb18 in _php_stream_open_wrapper_ex (path=0x297cb8 
/usr/pkg/share/httpd/htdocs/foo1.php,
mode=0xfece83f0 rb, options=173, opened_path=0xffbfeb90, context=0x0)
at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2696
#9  0xfec6ff34 in _php_stream_open_wrapper_as_file_handle (
path=0x297cb8 /usr/pkg/share/httpd/htdocs/foo1.php, mode=0xfece83f0 rb, 
options=141, fh=0xffbfeb88)
at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/streams.c:2823
#10 0xfec53900 in php_open_wrapper_for_zend (filename=0x297cb8 
/usr/pkg/share/httpd/htdocs/foo1.php,
fh=0xffbfeb88) at 
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/main/main.c:764
#11 0xfec82730 in open_file_for_scanning (file_handle=0xffbfeb88) at 
Zend/zend_language_scanner.c:3022
#12 0xfec82a34 in compile_file (file_handle=0xffbfeb88, type=2) at 
Zend/zend_language_scanner.c:3114
#13 0xfecae520 in zend_execute_scripts (type=2, retval=0x0, file_count=1)
at /export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/Zend/zend.c:934
#14 0xfecd2b74 in php_handler (r=0x297150)
at 
/export/scratch/pkgsrc/www/ap-php/work/php-4.4.1/sapi/apache2handler/sapi_apache2.c:574
#15 0x000e3c28 in ap_run_handler (r=0x297150) at config.c:152
#16 0x000e4848 in ap_invoke_handler (r=0x297150) at config.c:364
#17 0x00114840 in ap_run_sub_req