| 
	
 | 
 Posted by Daniel Loose on 08/24/05 22:32 
Just discovered http://de.php.net/eval and on that url especially the 
user contributed function eval_html3(). But can't get it to work. 
 
I made a simple test page: 
http://mueller.zems.tu-berlin.de/~loose/test/test.php 
Perhaps you feel like helping to fix the function. (Or to tell me what 
I have misunderstood.) I just renamed eval_html3 to eval_html and 
replaced <?php by <?. It's now supposed to work but it doesnt. Here 
the test files: 
 
test.php: 
------------ 
$s = eval_html(file_get_contents('.js.php', 0)); 
$t = eval_html(file_get_contents('.css.php', 0)); 
 
function eval_html($string) { 
   $string = '<? ?>'.$string.'<? ?>'; 
   $string = str_replace( '?>', '', str_replace( array( '<?', '<?' ), 
'', preg_replace_callback( "/\?>(.*?)(<\?|<\?)/", "my_eval", $string ) 
) ); 
   return eval($string); 
}		 
function my_eval($arr) { 
   return ('echo stripslashes("'.addslashes($arr[0]).'");'); 
} 
 
..js.php and .css.php:  
------------------------------ 
contain plain js/ css plus one line 
<? $a = 6+7; echo ".testClass { font-size: ".$a."px; }\n\n"; ?> 
or resp.  
<? $a = 4+5; echo 'testVar = '.$a;; ?> 
No errors when called directly. 
 
test.php itself does nothing (blank screen), I only want to get away 
the errors. You may also download this small test if you want to 
figure it out on your own system (See Link) 
 
Thanx a lot! , Daniel 
 
PS Thx to the other poster, will check your idea out soon as possible.
 
  
Navigation:
[Reply to this message] 
 |