/** * list_files function. * * @access public * @return void */ public function list_files() { // Check Nonce check_ajax_referer('list-files', 'security'); // Check user rights if (!current_user_can('manage_downloads')) { return false; } $path = esc_attr(stripslashes($_POST['path'])); if ($path) { // The File Manager $file_manager = new DLM_File_Manager(); // List all files $files = $file_manager->list_files($path); foreach ($files as $found_file) { // Multi-byte-safe pathinfo $file = $file_manager->mb_pathinfo($found_file['path']); if ($found_file['type'] == 'folder') { echo '<li><a href="#" class="folder" data-path="' . trailingslashit($file['dirname']) . $file['basename'] . '">' . $file['basename'] . '</a></li>'; } else { $filename = $file['basename']; $extension = empty($file['extension']) ? '' : $file['extension']; if (substr($filename, 0, 1) == '.') { continue; } // Ignore files starting with . like htaccess if (in_array($extension, array('', 'php', 'html', 'htm', 'tmp'))) { continue; } // Ignored file types echo '<li><a href="#" class="file filetype-' . sanitize_title($extension) . '" data-path="' . trailingslashit($file['dirname']) . $file['basename'] . '">' . $file['basename'] . '</a></li>'; } } } die; }