note 81510 deleted from function.glob by sobak

From: Date: Thu, 01 Dec 2016 06:29:50 +0000
Subject: note 81510 deleted from function.glob by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207798@lists.php.net to get a copy of this message
Note Submitter: bisqwit at iki dot fi ---- Pomle.com wrote: > Here's a function that behaves as a recursive glob(). It does > rely on shell command find, but works like a charm. > function glob_rec($pattern, $path) { > return explode("\n", shell_exec("find $path -name $pattern")); > } Do note that this command has a security hole. If the $path or $pattern given includes special characters, for example a command substitution such as "rm index.php", the shell will process it and execute that command. You can fix the problem by either escaping the characters properly (use shell_escape) or by writing a function that actually calls glob(), or opendir()/readdir()/closedir(), recursively.

« previous php.notes (#207798) next »