Announcement

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

#1 2006-06-08 15:38:14

feechgeelz
New member
Registered: 2006-06-08
Posts: 3

PHP code getting taken out

I'm using Xinha as an editor for some content and people here aren't totally html smart. So I offer some instructions on what to type to get php to output something. This Text is stored a MySQL DB.

So, if the data out of MySQL DB contains:

<p> This is a test content!
</p>
<p>This is super duper cool.
</p>
<p>Can we do php?
</p>
<p><? echo "yes we can!"; ?>
</p>

And I put that in the textarea to edit, Xinha removes the php code and gives the user:

<p> This is a test content!
</p>
<p>This is super duper cool.
</p>
<p>Can we do php?
</p>
<p>
</p>

Anyway to make Xinha not do this?

Offline

#2 2006-06-10 07:05:32

mharrisonline
Xinha Administrator
From: Denver, Colorado
Registered: 2005-04-11
Posts: 110
Website

Re: PHP code getting taken out

You have to use the GetHtml plugin and only insert PHP with long script notation if you want to use PHP in Xinha. If you are inserting existing content into Xinha that already has <? or <?php notation, you must run your code through a regular expressions before sending it into Xinha to convert it into notation with standard script tags. I use the php below on the page that loads Xinha and it works perfectly.

// prevent browser DOM from changing short PHP notation to comments, etc
$text_box=ereg_replace("<\?php ","<script language=\"PHP\">",$text_box);
$text_box=ereg_replace("<\? ","<script language=\"PHP\">",$text_box);
$text_box=eregi_replace(" \?>","</script>",$text_box);

Be aware that not everything will be safe, especially in full page mode. Anywhere (such as various locations in the head) that Xinha would remove or relocate a javascript, it will also do the same to your PHP. Sometimes you can prevent this from happening by placing the PHP inside an HTML comment, but then anything you echo or include will be inside a comment... so your echo may have to start with a comment close and end with a comment open.

Offline

#3 2007-03-03 00:18:42

Hypercubed
New member
Registered: 2005-11-11
Posts: 8
Website

Re: PHP code getting taken out

You can also now use the specialReplacements feature like this:

xinha_config.specialReplacements = { '<?php' :  '<script language=\"PHP\">', '<?' :  '<script language=\"PHP\">', '?>' : '</script>'  };

Hypercubed
website: [url=http://www.hypercubed.com/]www.hypercubed.com[/url]
blog: [url=http://blog.hypercubed.com/]blog.hypercubed.com[/url]

Offline

Board footer

Powered by FluxBB