hi!
i'm trying to prevent my fck editor from removing php code from the pages it has to edit.
actually, i have removed the comment breaks in config.js at the line
FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ;
but it still seems ineffective: in the resulting edited files any code is removed
i'm using php version of fck 2.4
any suggestion?
i'm trying to prevent my fck editor from removing php code from the pages it has to edit.
actually, i have removed the comment breaks in config.js at the line
FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ;
but it still seems ineffective: in the resulting edited files any code is removed
i'm using php version of fck 2.4
any suggestion?
RE: protect php code - uncommenting doesnt wo
What i have done is pre-process the code that is going to be edited inside FCKeditor and replace the php tags <?php ?> with comment tags <!-- ... -->, afterward i replace the comment tags with php tags again. Only drawback of this is that you can't use regular comment tags anywhere in your code.
Here's my functions that i use:
function stripphptags($string) {
$string = preg_replace("/<\?php/", "<!--", $string);
$string = preg_replace("/\?>/", "-->", $string);
return($string);
}
function addphptags($string) {
$string = preg_replace("/<!--/", "<?php", $string); $string = preg_replace("/-->/", "?>", $string);
return($string);
}
Re: protect php code - uncommenting doesnt work
I have the same problem to add php code in my article. Why does it work on the demo http://www.fckeditor.net/demo ?
I have uncommenting the line
FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ; // PHP style server side code
but it has no effect.
please help me.
Regards,
Benoit
Re: protect php code - uncommenting doesnt work
So what I did is create a tag ( {PHP} and {/PHP} ). I added the following to the config file (fckconfig.js):
This allows the users to view their pages and see the source code, but when the page is published these {PHP} {/PHP} tags are converted to <?php and ?> (using my php function). So far I have not encountered any problems with my code being replaced or issues from users entering incorrect php code which would cause fatal errors on their edit page and prevent them from correcting the code.
I would suggest something along these lines instead of entering <?php ?> directly in to your source - then again depending on your application this may not fit your situation or be needed.
Re: protect php code - uncommenting doesnt work
Benoit
Re: protect php code - uncommenting doesnt work
but when in the source file view I add this code
It automatically translate to this:
What is the problem ?
Regards,