Index: trunk/extensions/UploadLocal/UploadLocalDirectory.php |
— | — | @@ -133,8 +133,7 @@ |
134 | 134 | } |
135 | 135 | |
136 | 136 | function getFilenamesOfFilesInDirectory($directory) { |
137 | | - if (!is_dir($directory)) return array(); |
138 | | - if ($directory[strlen($directory)-1] !== '/') $directory .= '/'; |
| 137 | + if (! is_dir($directory) || ! is_readable($directory)) return array(); |
139 | 138 | $dh = opendir($directory); |
140 | 139 | $filenames = array(); |
141 | 140 | # Make sure the handle opens correctly |
— | — | @@ -144,13 +143,14 @@ |
145 | 144 | while (($file = readdir($dh)) !== false) { |
146 | 145 | if ($file == '.' || $file == '..') continue; |
147 | 146 | // check if it's a directory |
148 | | - if (is_dir($directory . $file)) continue; |
| 147 | + if (is_dir($directory . '/' . $file)) continue; |
149 | 148 | // check if it's a hidden file - regexp: /\.[^.]+/ |
150 | 149 | if ($file[0] == '.' && strpos($file,'.',1) === false) { |
151 | 150 | continue; |
152 | 151 | } |
153 | 152 | $filenames[] = $file; |
154 | 153 | } |
| 154 | + sort($filenames); |
155 | 155 | closedir($dh); |
156 | 156 | return $filenames; |
157 | 157 | } |