Text_Wiki
[ class tree: Text_Wiki ] [ index: Text_Wiki ] [ all elements ]

Source for file Include.php

Documentation is available at Include.php

  1. <?php
  2. // $Id: Include.php,v 1.3 2004/09/25 19:05:13 pmjones Exp $
  3.  
  4.  
  5. /**
  6. * This class implements a Text_Wiki_Parse to include the results of a
  7. * script directly into the source at parse-time; thus, the output of the
  8. * script will be parsed by Text_Wiki.  This differs from the 'embed'
  9. * rule, which incorporates the results at render-time, meaning that the
  10. * 'embed' content is not parsed by Text_Wiki.
  11. *
  12. * DANGER!
  13. * This rule is inherently not secure; it allows cross-site scripting to
  14. * occur if the embedded output has <script> or other similar tags.  Be
  15. * careful.
  16. *
  17. @author Paul M. Jones <pmjones@ciaweb.net>
  18. *
  19. @package Text_Wiki
  20. *
  21. */
  22.  
  23.     
  24.     var $conf = array(
  25.         'base' => '/path/to/scripts/'
  26.     );
  27.     
  28.     var $file = null;
  29.     
  30.     var $output = null;
  31.     
  32.     var $vars = null;
  33.  
  34.     /**
  35.     * 
  36.     * The regular expression used to find source text matching this
  37.     * rule.
  38.     * 
  39.     * @access public
  40.     * 
  41.     * @var string 
  42.     * 
  43.     */
  44.     
  45.     var $regex = '/(\[\[include )(.+?)( .+?)?(\]\])/i';
  46.     
  47.     
  48.     /**
  49.     * 
  50.     * Includes the results of the script directly into the source; the output
  51.     * will subsequently be parsed by the remaining Text_Wiki rules.
  52.     * 
  53.     * @access public
  54.     *
  55.     * @param array &$matches The array of matches from parse().
  56.     *
  57.     * @return The results of the included script.
  58.     *
  59.     */
  60.     
  61.     function process(&$matches)
  62.     {
  63.         // save the file location
  64.         $this->file = $this->getConf('base''./'$matches[2];
  65.  
  66.         // extract attribs as variables in the local space
  67.         $this->vars = $this->getAttrs($matches[3]);
  68.         unset($this->vars['this']);
  69.         extract($this->vars);
  70.  
  71.         // run the script
  72.         ob_start();
  73.         include($this->file);
  74.         $this->output = ob_get_contents();
  75.         ob_end_clean();
  76.     
  77.         // done, place the script output directly in the source
  78.         return $this->output;
  79.     }
  80. }
  81. ?>

Documentation generated on Mon, 11 Mar 2019 13:56:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.