Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 2.5.4, 2.6.1
-
Fix Version/s: None
-
Component/s: Module: Certificate
-
Labels:None
-
Plugin Version:2013102300
-
Affected Branches:MOODLE_25_STABLE, MOODLE_26_STABLE
Description
Hello Mark
The certificate_scan_image_dir function in certificate/lib.php is quite old fashioned and not very robust (it doesn't work with names containing a dot or with uppercase windows extensions for instance).
May I suggest to replace it with something like
/**
|
* Scans directory for valid images
|
*
|
* @param string the path
|
* @return array
|
*/
|
function certificate_scan_image_dir($path) {
|
// Array to store the images
|
$options = array();
|
|
// Start to scan directory
|
if (is_dir($path)) {
|
$iterator = new DirectoryIterator($path);
|
foreach ($iterator as $fileinfo) {
|
$filename = $fileinfo->getFilename();
|
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
if ($fileinfo->isFile() && in_array($extension, array('png', 'jpg', 'jpeg'))) {
|
$options[$filename] = pathinfo($filename, PATHINFO_FILENAME);
|
}
|
}
|
}
|
return $options;
|
}
|