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

Source for file Embed.php

Documentation is available at Embed.php

  1. <?php
  2. // $Id: Embed.php,v 1.4 2004/09/25 19:05:13 pmjones Exp $
  3.  
  4.  
  5. /**
  6. * 
  7. * This class implements a Text_Wiki_Parse to embed the contents of a URL
  8. * inside the page at render-time.  Typically used to get script output.
  9. * This differs from the 'include' rule, which incorporates results at
  10. * parse-time; 'embed' output does not get parsed by Text_Wiki, while
  11. * 'include' ouput does.
  12. *
  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.     * 
  37.     * The regular expression used to find source text matching this
  38.     * rule.
  39.     * 
  40.     * @access public
  41.     * 
  42.     * @var string 
  43.     * 
  44.     */
  45.     
  46.     var $regex = '/(\[\[embed )(.+?)( .+?)?(\]\])/i';
  47.     
  48.     
  49.     /**
  50.     * 
  51.     * Generates a token entry for the matched text.  Token options are:
  52.     * 
  53.     * 'text' => The full matched text, not including the <code></code> tags.
  54.     * 
  55.     * @access public
  56.     *
  57.     * @param array &$matches The array of matches from parse().
  58.     *
  59.     * @return A delimited token number to be used as a placeholder in
  60.     *  the source text.
  61.     *
  62.     */
  63.     
  64.     function process(&$matches)
  65.     {    
  66.         // save the file location
  67.         $this->file = $this->getConf('base', './') . $matches[2];
  68.         
  69.         // extract attribs as variables in the local space
  70.         $this->vars = $this->getAttrs($matches[3]);
  71.         unset($this->vars['this']);
  72.         extract($this->vars);
  73.         
  74.         // run the script
  75.         ob_start();
  76.         include($this->file);
  77.         $this->output = ob_get_contents();
  78.         ob_end_clean();
  79.         
  80.         // done, place the script output directly in the source
  81.         return $this->wiki->addToken(
  82.             $this->rule,
  83.             array('text' => $this->output)
  84.         );
  85.     }
  86. }
  87. ?>

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