php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12158 EVAL code not working correctly if IF block
Submitted: 2001-07-13 20:58 UTC Modified: 2001-07-17 11:53 UTC
From: craig at nerds dot net Assigned:
Status: Closed Package: Strings related
PHP Version: 4.0.6 OS: Win2K
Private report: No CVE-ID: None
 [2001-07-13 20:58 UTC] craig at nerds dot net
<?php

$extensions=array(".htm",".asp");

$x="";
$numargs=count($extensions);
for ($i=0;$i<=$numargs-1;$i++){	
	$x=$x."strstr(\$filename,\"".$extensions[$i]."\")";
	if ($numargs>0 && $i!=$numargs-1){
		$x=$x." || ";
	}		
}
$validExtensions=$x;
echo $validExtensions;

		
$handle=opendir('.');

while (($filename = readdir($handle))!==false) {
if (is_file($filename)){
	$fd = fopen ($filename, "rb");
	$contents = fread ($fd, filesize ($filename));

		if (eval($validExtensions)){
				echo $filename."<br>";
		}

	fclose ($fd);
}

      

}
closedir($handle); 






?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-17 11:53 UTC] stas@php.net
The code you get is:

strstr($filename,".htm") || strstr($filename,".asp")

this is not a valid code block for eval. If you add "return " before it and ";" after it, it should work then. 
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Jan 18 08:01:26 2021 UTC