@@ 336-358 (lines=23) @@ | ||
333 | * |
|
334 | * @return array Filenames in $directory, in the form $directory/filename. |
|
335 | */ |
|
336 | function elgg_get_file_list($directory, $exceptions = array(), $list = array(), |
|
337 | $extensions = null) { |
|
338 | ||
339 | $directory = sanitise_filepath($directory); |
|
340 | if ($handle = opendir($directory)) { |
|
341 | while (($file = readdir($handle)) !== false) { |
|
342 | if (!is_file($directory . $file) || in_array($file, $exceptions)) { |
|
343 | continue; |
|
344 | } |
|
345 | ||
346 | if (is_array($extensions)) { |
|
347 | if (in_array(strrchr($file, '.'), $extensions)) { |
|
348 | $list[] = $directory . $file; |
|
349 | } |
|
350 | } else { |
|
351 | $list[] = $directory . $file; |
|
352 | } |
|
353 | } |
|
354 | closedir($handle); |
|
355 | } |
|
356 | ||
357 | return $list; |
|
358 | } |
|
359 | ||
360 | /** |
|
361 | * Sanitise file paths ensuring that they begin and end with slashes etc. |
@@ 174-196 (lines=23) @@ | ||
171 | * |
|
172 | * @return array Filenames in $directory, in the form $directory/filename. |
|
173 | */ |
|
174 | function elgg_get_file_list($directory, $exceptions = array(), $list = array(), |
|
175 | $extensions = NULL) { |
|
176 | ||
177 | $directory = sanitise_filepath($directory); |
|
178 | if ($handle = opendir($directory)) { |
|
179 | while (($file = readdir($handle)) !== FALSE) { |
|
180 | if (!is_file($directory . $file) || in_array($file, $exceptions)) { |
|
181 | continue; |
|
182 | } |
|
183 | ||
184 | if (is_array($extensions)) { |
|
185 | if (in_array(strrchr($file, '.'), $extensions)) { |
|
186 | $list[] = $directory . $file; |
|
187 | } |
|
188 | } else { |
|
189 | $list[] = $directory . $file; |
|
190 | } |
|
191 | } |
|
192 | closedir($handle); |
|
193 | } |
|
194 | ||
195 | return $list; |
|
196 | } |
|
197 | ||
198 | /** |
|
199 | * Sanitise file paths ensuring that they begin and end with slashes etc. |