[pmwiki-devel] include php file in wiki page
Harvey, Jesse
Jesse.Harvey at xerox.com
Wed Nov 15 13:18:23 CST 2006
Thanks for the two suggestions guys. Martin, you're suggestion was what
I was looking for. Unfortunately it does not quite work.
I added the following to my config.php
Markup('mywebservice', 'directives',
'/\\(:mywebservice:\\)/e',
'include("/home/lla/public_html/pmwiki/ismdfield/tokens/tokens.php")';
And then edited the wiki page and called the markup:
(:mywebservice:)
Unfortunately it appears as if the php is executed first and is placed
above all wiki html. Is there any way to make the included page show up
in the wiki content area?
Thanks again for your replies!
Jesse Harvey
jesse.harvey at xerox.com
-----Original Message-----
From: Martin Fick [mailto:mogulguy at yahoo.com]
Sent: Wednesday, November 15, 2006 2:02 PM
To: Harvey, Jesse; pmwiki-devel at pmichaud.com
Subject: Re: [pmwiki-devel] include php file in wiki page
--- "Harvey, Jesse" <Jesse.Harvey at xerox.com> wrote:
> I would like to
> be able to include a php file inside of a wiki page.
> There are many
> recipes out there now that use iframes and objects
> but I have been
> unable to find one with markup that will allow me to
> do a 'php type
> include' that will actually execute the php file.
From:
http://www.pmwiki.org/wiki/PmWiki/CustomMarkup
the custom markup syntax is:
Markup($name, $when, $pattern, $replace);
So, you might want to define a markup that looks
something like:
(:phpexec phpfile:)
this can probably be done like this:
Markup('phpexec', 'directives',
'/\\(:phpexec\s+(.*?)\s+:\\)/e', 'include("$1")');
This obvisouly allows any accessible file on the
filessytem to be php included. A common practice to
avoid such gaping security risks is to create an array
of valid files to include and simply check the array
first. Something like:
Markup('phpexec', 'directives',
'/\\(:phpexec\s+(.*?)\s+:\\)/e',
'limited_include("$1")');
function limited_include($file) {
global $PHPFILES;
if ( in_array($file, $PHPFILES) )
return include($file);
}
> The main reason for this is to allow a custom web
> app to work inside of our wiki.
But, of course, with a limited array, there is no
reason not to simply create a specific descriptive
markup for each of your web-services. This will be a
lot more author friendly:
Markup('mywebservice', 'directives',
'/\\(:mywebservice:\\)/e',
'include("mywebservice.php")');
-Martin
________________________________________________________________________
____________
Sponsored Link
Mortgage rates near 39yr lows.
$420k for $1,399/mo. Calculate new payment!
www.LowerMyBills.com/lre
More information about the pmwiki-devel
mailing list