New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

Problem with XML tags and short_open_tag=On in php.ini

Got problems with Bubba? Then this forum is for you.
Locked
bubbathehut
Posts: 2
Joined: 20 Apr 2007, 09:48

Problem with XML tags and short_open_tag=On in php.ini

Post by bubbathehut »

Hi,

I have some applications that I use to make web pages that creates xml tags of the form

Code: Select all

<?xml version="1.0"?>
or similar.

Since

Code: Select all

short_open_tag=on
in /etc/php4/apache2/php.ini this tag is interpreted as PHP and an error message is shown when I access these pages.

Code: Select all

Parse error: parse error, unexpected T_STRING in /var/www/html/something/index_2.html on line 1
When I tried to set

Code: Select all

short_open_tag=Off
the web admin pages does not work since some of the included tags are only <? and not <?php. Thus I cannot use this setting and without it I cannot use my normal web pages. There are quite a few to migrate from my old Ubuntu server.

Is there any hope that the Bubba PHP code in the next release will only include full PHP tags? :wink:
Anyone has a tip on how I can solve this without having to edit all my existing pages? I know how to do this but it is a lot of pages to edit...
Is there anything I have missed?

/BubbatheHut
tor
Posts: 703
Joined: 06 Dec 2006, 12:24
Contact:

Post by tor »

Hi bubbathehut,

This is a problem we faced our selfs when writing parts of the upload functionality, look at /usr/share/web-admin/ulprogress.php.

The way we solve it is by outputting the header with a print or echo:

Code: Select all

header("content-Type: application/xml");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

print"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n\n";
And to clean up our php is on the todo-list. Actually bubbalibre has done a lot of that in his "tiny hack" and we are looking in to a smart way to integrate at least parts of that.

/Tor
Co-founder OpenProducts and Ex Excito Developer
bubbathehut
Posts: 2
Joined: 20 Apr 2007, 09:48

Post by bubbathehut »

Hi Tor and others,

If anyone else runs into this problem I thought I'd share my solution. At least it seems to work so far. On the PHP homepage I found a few lines which I modified a bit and ran in the web-admin directory (after backup of course).

Code: Select all

find -name '*.php' | xargs perl -pi -e 's/<\?= ?(.*?) ?\?>/<?php echo($1); ?>/g'
find -name '*.php' | xargs perl -pi -e 's/<\?/<?php /g'
find -name '*.php' | xargs perl -pi -e 's/<\?php php/<?php/g'
As I said, this seems to work with short_open_tag = Off but I'm not prepared to bet my life on it since I haven't read through all the code. ;-)
Without short open tags I can run all my other files with the xml tag without problem.

/BubbatheHut
Locked