|
|
PHP block
Posted under General by Steen Brølling on Saturday March 17 2001 @ 06:09AM EST
|
I'm trying to include some PHP in my blocks, but it seems that it parses some PHP and doesn't parse other PHP parts...
|
Related Link
|
|
|
Brian Milby writes on Saturday March 17 2001 @ 08:44PM EST: [ reply | parent ]
This came up before and I said that it was too hard. After looking around, I think that I've found a way to implement this fairly easily. You will need to edit include/layout.inc.php to make the following changes:
Near the end of each function in that file, you will find $tmp = "print... and a couple of lines later eval($tmp) [lines 55 and 57 are the first instance]. Use the following instead:
eval("\$tmp = \"" . $template . "\";");
eval("?<" . $tmp);
I would strongly advise against making this change to the F_drawComment function because it would create a huge security hole.
I would also caution you in that I have not tested this extensively except to make sure that it does work for simple cases.
|
|
|
Steen Brølling writes on Sunday March 18 2001 @ 11:33PM EST: [ reply | parent ]
Well I've tried it, and can't get it to work. I get errors all over the page.
Seems like every simple PHP string gives an error.
|
|
|
|
Brian Milby writes on Tuesday March 20 2001 @ 09:40AM EST: [ reply | parent ]
What level of HTML are you allowing? You really need to have it down to 0 (don't touch) because you may get unexpected results. Also, the php must be inserted just like in a normal document - <? ...code...; ?>
|
|
|
|
Brian Milby writes on Tuesday March 20 2001 @ 09:42AM EST: [ reply | parent ]
Hey, I made a huge typo... eval("?>" . $tmp);
Sorry!
|
|
|
|
Brian Milby writes on Tuesday March 20 2001 @ 09:51AM EST: [ reply | parent ]
Take a look here for the example: http://linux.nscs.com/phpweblog/stories.php?story=01/03/20/9816540
I won't guarantee that it will be there long, but at least for the next few days.
|
|
|
|
Brian Milby writes on Tuesday March 20 2001 @ 09:55AM EST: [ reply | parent ]
Here's the complete replacement:
eval("\$tmp = \"" . $template . "\";");eval("?>" . $tmp);
|
|
|
jason writes on Sunday March 18 2001 @ 12:02AM EST: [ reply | parent ]
Another solution, which might actually be a bug preventing you from doing this, is to remove the javascript check for URL when you add a new page/block. Without that, if I can remember correctly, you should be able to put the full local path to a php script to include. I honestly can't remember if this works, and am not around a machine right now where I can check.
|
|
kevin writes on Friday March 23 2001 @ 05:21PM EST: [ reply | parent ]
I'm setting up a new log at the moment, and I've had no trouble worth a mention when using php blocks (mostly fetching selections from T_Links). And it's my first go at php and mysql... I just include B_etcetera.inc.php. What am I doing "wrong"? Parselevel luck?
|
|
|
|
|