Re: fatal input in flex scanner

From: Date: Sat, 25 Aug 2001 01:24:34 +0000
Subject: Re: fatal input in flex scanner
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-64382@lists.php.net to get a copy of this message
> function group_include($directory) > { > $handle=opendir("$directory"); > while ($file = readdir($handle)) > { //load files in $directory into array > if ($file != ".." && $file != ".") > { > $files_to_include[count($files_to_include)] = $file; The count(...) is pretty silly here. Get rid of it. PHP will do what you want. > } > } > > //clean up and sort > closedir($handle); > if (is_array($files_to_include)) > { > while (list ($key, $val) = each ($files_to_include)) > { > include "$directory/$val"; > } > } > } Why create an array and then walk through it? Why not just include() as you go?... Also, this is pretty dangerous... A hacker only needs to manage to upload one file to your web-directory, and they've taken over your machine. Don't do this. > //include common and page specific modules > > $common_include_dir="modules/common"; > $page_include_dir="modules/page"; > > group_include($common_include_dir); > group_include($page_include_dir); > The list of files simply can't be that large. Why not just have a file in modules/common that includes all the other files in modules/common, and then edit that as you add files to modules/common, and then you can just include that one file. -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#64382) next »