[pmwiki-devel] include php file in wiki page

Martin Fick mogulguy at yahoo.com
Wed Nov 15 13:02:13 CST 2006


--- "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