Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2009-03-31 04:48:45

0xdeadc0de
New member
Registered: 2009-03-22
Posts: 5

Php embedded inside php problem

It seems when I have some php embedded into a string inside some php it breaks Xinha's script detection
(Rev: 1175 svn)

for example:

<?php
$string = "<?php
echo \"test\";
?>";

eval ("?>".$string."<?");
?>

The eval would be considered by xinha to be regular html, not detecting the "level" it is inside the php - then xinha translates the greater thans to > and the quotes to "


Also, thanks for the response on my other post gogo smile, I figured out it was that fairly quickly, and ended up using embedded tables to make it look the way I wanted
eg: <table><td><form ...><table><td>cell1</td><td>cell 2</td></table></form></td></tr><tr><td><form ...><table><td>.....etc</form></td></table> - but I also now have it so it can be pure css without any tables (I love php! smile )

Btw, I really really like Xinha. Props and cheers!

Last edited by 0xdeadc0de (2009-03-31 04:50:19)

Offline

#2 2009-03-31 05:12:19

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: Php embedded inside php problem

Hi 0xdeadc0de,
if your're talking about the plugin PreserveScripts, it is using RegExps to find blocks of PHP. Obviously not all levels of complexity can be covered by this without designing an equally complex regular expression, but there are always cases that will fall out, like the example you give. Sorry.

Offline

#3 2009-03-31 09:41:38

0xdeadc0de
New member
Registered: 2009-03-22
Posts: 5

Re: Php embedded inside php problem

ahh thank you for the explaination, that does make sense.
I run into lots of troubles with regex's (From not understanding them well neutral ), which is why I personally stick to the alternative of character by character parsing when I make parsers that have to traverse slightly more complex stuff (even though they can be a pain in the arse to get right sometimes).
I'll try taking a whack at it someday when I have free time, if of course nobody minds. I'll have to brush up on JS though.
To give back to Xinha since I'm using it in my latest project would be good .

PS. I like smilies to much.. I need to stop using them all the time!

Last edited by 0xdeadc0de (2009-03-31 09:42:44)

Offline

#4 2009-04-02 18:49:03

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Php embedded inside php problem

I'd work around the issue by using chr(60) for < and chr(62) for >

<?php
$string = chr(60)."?php
echo \"test\";
?".chr(62);

eval (" ?".chr(62).$string.chr(60)."?php ");
?>

James Sleeman

Offline

#5 2009-04-03 04:05:08

0xdeadc0de
New member
Registered: 2009-03-22
Posts: 5

Re: Php embedded inside php problem

Hmm, that gives me an idea, I can put the <?php ?> part inside the api and have it automatically insert into the scripts, although I'm not really crazy for that solution - it already parses and translates those mini-scripts them making then more difficult to debug already.

I don't want to use the chr method because that would reduce readability imo.

I'm using xinha as the default text area editor for a (wiki like) database API, so I don't know what kinds of scripts will be used in it in the end, but I made it "standard" to be able to replace a database field with a custom php script that will be eval'd (hence this bug affecting me).

Offline

Board footer

Powered by FluxBB