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. * This class implements a Text_Wiki_Parse to embed the contents of a URL
  7. * inside the page at render-time.  Typically used to get script output.
  8. * This differs from the 'include' rule, which incorporates results at
  9. * parse-time; 'embed' output does not get parsed by Text_Wiki, while
  10. * 'include' ouput does.
  11. *
  12. * This rule is inherently not secure; it allows cross-site scripting to
  13. * occur if the embedded output has <script> or other similar tags.  Be
  14. * careful.
  15. *
  16. @author Paul M. Jones <pmjones@ciaweb.net>
  17. *
  18. @package Text_Wiki
  19. *
  20. */
  21.  
  22.     
  23.     var $conf = array(
  24.         'base' => '/path/to/scripts/'
  25.     );
  26.     
  27.     var $file = null;
  28.  
  29.     var $output = null;
  30.  
  31.     var $vars = null;
  32.  
  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 = '/(\[\[embed )(.+?)( .+?)?(\]\])/i';
  46.     
  47.     
  48.     /**
  49.     * 
  50.     * Generates a token entry for the matched text.  Token options are:
  51.     * 
  52.     * 'text' => The full matched text, not including the <code></code> tags.
  53.     * 
  54.     * @access public
  55.     *
  56.     * @param array &$matches The array of matches from parse().
  57.     *
  58.     * @return delimited token number to be used as a placeholder in
  59.     *  the source text.
  60.     *
  61.     */
  62.     
  63.     function process(&$matches)
  64.     {    
  65.         // save the file location
  66.         $this->file = $this->getConf('base''./'$matches[2];
  67.         
  68.         // extract attribs as variables in the local space
  69.         $this->vars = $this->getAttrs($matches[3]);
  70.         unset($this->vars['this']);
  71.         extract($this->vars);
  72.         
  73.         // run the script
  74.         ob_start();
  75.         include($this->file);
  76.         $this->output = ob_get_contents();
  77.         ob_end_clean();
  78.         
  79.         // done, place the script output directly in the source
  80.         return $this->wiki->addToken(
  81.             $this->rule,
  82.             array('text' => $this->output)
  83.         );
  84.     }
  85. }
  86. ?>

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