note 55480 added to function.eval
| From: | tomekatzdybaldotlapdotpl at osu1 dot php dot net | Date: | Thu, 04 Aug 2005 18:13:12 +0000 |
| Subject: | note 55480 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93084@lists.php.net to get a copy of this message | ||
Following script is loading any site with php-tags:
<?php
function eval_html($eval_str) {
$eval_str = preg_replace("/\?>(.*?)(<\?php|<\?)/si", "echo
\"\1\";", $eval_str);
preg_match("/(<\?php|<\?)(.*?)\?>/si", $eval_str, $raw_php_matches);
$raw_php_str = $raw_php_matches[0];
$raw_php_str = str_replace("<?php", "", $raw_php_str);
$raw_php_str = str_replace("?>", "", $raw_php_str);
ob_start();
eval("$raw_php_str;");
$exec_php_str = ob_get_contents();
ob_end_clean();
$eval_str = preg_replace("/(<\?php|<\?)(.*?)\?>/si", $exec_php_str,
$eval_str, 1);
return $eval_str;
}
?>
You can load sites like that:
<?php
$a = 1;
if($a == 1){
?>
<br />ir?<br />
<?php
}
?>
and also:
<?php
$a = 1;
if($a == 1){
echo "<br />ir?<br />";
}
?>
XHTML-tags can be loaded safetly.
Based on script by michael at smartgrp dot net, one line from script by arnico at c4 dot lv
I hope it will be useful.
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55480
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55480&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55480&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55480&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55480&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55480&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55480&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55480&report=yes
Search -- http://master.php.net/manage/user-notes.php