[ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php 2 // $Id: Embed.php,v 1.1 2005/01/31 15:46:52 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 class Text_Wiki_Parse_Embed extends Text_Wiki_Parse { 24 25 var $conf = array( 26 'base' => '/path/to/scripts/' 27 ); 28 29 var $file = null; 30 31 var $output = null; 32 33 var $vars = null; 34 35 36 /** 37 * 38 * The regular expression used to find source text matching this 39 * rule. 40 * 41 * @access public 42 * 43 * @var string 44 * 45 */ 46 47 var $regex = '/(\[\[embed )(.+?)( .+?)?(\]\])/i'; 48 49 50 /** 51 * 52 * Generates a token entry for the matched text. Token options are: 53 * 54 * 'text' => The full matched text, not including the <code></code> tags. 55 * 56 * @access public 57 * 58 * @param array &$matches The array of matches from parse(). 59 * 60 * @return A delimited token number to be used as a placeholder in 61 * the source text. 62 * 63 */ 64 65 function process(&$matches) 66 { 67 // save the file location 68 $this->file = $this->getConf('base', './') . $matches[2]; 69 70 // extract attribs as variables in the local space 71 $this->vars = $this->getAttrs($matches[3]); 72 unset($this->vars['this']); 73 extract($this->vars); 74 75 // run the script 76 ob_start(); 77 include($this->file); 78 $this->output = ob_get_contents(); 79 ob_end_clean(); 80 81 // done, place the script output directly in the source 82 return $this->wiki->addToken( 83 $this->rule, 84 array('text' => $this->output) 85 ); 86 } 87 } 88 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |