5 * Includes the contents of another PHP script into the source text.
11 * @author Paul M. Jones <pmjones@php.net>
15 * @version $Id: Include.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $
21 * This class implements a Text_Wiki_Parse to include the results of a
22 * script directly into the source at parse-time; thus, the output of the
23 * script will be parsed by Text_Wiki. This differs from the 'embed'
24 * rule, which incorporates the results at render-time, meaning that the
25 * 'embed' content is not parsed by Text_Wiki.
29 * This rule is inherently not secure; it allows cross-site scripting to
30 * occur if the embedded output has <script> or other similar tags. Be
37 * @author Paul M. Jones <pmjones@php.net>
41 class Text_Wiki_Parse_Include
extends Text_Wiki_Parse
{
44 'base' => '/path/to/scripts/'
55 * The regular expression used to find source text matching this
64 var $regex = '/(\[\[include )(.+?)( .+?)?(\]\])/i';
69 * Includes the results of the script directly into the source; the output
70 * will subsequently be parsed by the remaining Text_Wiki rules.
74 * @param array &$matches The array of matches from parse().
76 * @return The results of the included script.
80 function process(&$matches)
82 // save the file location
83 $this->file
= $this->getConf('base', './') . $matches[2];
85 // extract attribs as variables in the local space
86 $this->vars
= $this->getAttrs($matches[3]);
87 unset($this->vars
['this']);
93 $this->output
= ob_get_contents();
96 // done, place the script output directly in the source