>

Could not connect to FTP host")); @ftp_login($ftp_stream, $ftp_username, $ftp_password) or die(display_error_message("Could not login to FTP host")); } //Open FTP connection -done $folder_exists = true; //Check if directory exists if($listing_mode == 0) $folder_exists = (!is_dir($dir_to_browse)) ? false : true; //HTTP elseif($listing_mode == 1 && PHP_VERSION >= 5) $folder_exists = (!is_dir('ftp://'.$ftp_username.':'.$ftp_password.'@'.$ftp_host.$dir_to_browse)) ? false : true; //FTP if($folder_exists == false) { echo display_error_message("Error: Folder specified does not exist. This could be because you manually entered the folder name in the URL or you don't have permission to access this folder"); exit; } //Chcek if directory exists -done //This is a VERY important security feature. It prevents people from browsing directories above $dir_to_browse and any excluded folders. Edit this part at your own risk if(count(explode("../",$folder)) > 1 || in_array(basename($url_folder), $exclude)) { echo display_error_message("Access Denied"); exit; } if(strlen($url_folder) == 2 && $url_folder == "..") { echo display_error_message("Access Denied"); exit; } //Seurity feature -done //Calculate table dimensions $table_width = 50+$width_of_files_column+$width_of_sizes_column+$width_of_dates_column; //Breadcrumbs and admin logout link echo '

'; if($_SESSION['logged_in']) echo ''; elseif($admin_login_link == 1) echo ''; echo '
'; $this_file_name = basename($_SERVER['PHP_SELF']); $this_file_size = filesize($this_file_name); echo $local_text['index_of'].': home/'; if(!empty($url_folder)) { $folders_in_url = explode("/", $url_folder); $folders_in_url_count = count($folders_in_url); for($i=0;$i<$folders_in_url_count;$i++) { $temp = ""; for($j=0;$j<$i+1;$j++) { $temp .= "/".$folders_in_url[$j]; } $temp = substr($temp, 1); echo ''.$folders_in_url[$i].'/'; } } echo 'Admin Logout
'.$local_text['check_for_update'].'
Admin Login

'; //Breadcrumbs -done //Any upload error is displayed here switch(base64_decode($_GET['err'])) { case "upload_banned": echo display_error_message("Upload failed, banned file type")."
";break; case "upload_error": echo display_error_message("Upload failed, an unknown error occured")."
";break; case "size": echo display_error_message("File size exceeded limit. Max allowed is ".max_upload_size()."B")."
";break; case "nofile": echo display_error_message("Please select a file to upload!")."
";break; } //Any upload error is displayed here -done //Change excluded extensions to lowercase if $case_sensative_ext is disabled if($case_sensative_ext == 0) foreach($exclude_ext as $key => $val) $exclude_ext[$key] = strtolower($val); //Initialize arrays $folders = array(); $files = array(); //initialize arrays -done //Get directory content seperatiung files and folders into 2 arrays and filtering them to remove those exlcluded $dir_content = get_dir_content($dir_to_browse); $folders['name'] = $dir_content['folders']['name']; $folders['date'] = $dir_content['folders']['date']; $folders['link'] = $dir_content['folders']['link']; $files['name'] = $dir_content['files']['name']; $files['size'] = $dir_content['files']['size']; $files['date'] = $dir_content['files']['date']; $files['link'] = $dir_content['files']['link']; $images_detected = $dir_content['images_detected']; $media_detected = $dir_content['media_detected']; //The folder size calculation has not been placed inside the get_dir_content function so as not to affect it's speed. This is important becasue folder_size calls upon get_dir_content if($view_mode == 1) { if($show_folder_size_http == 1 && $listing_mode == 0) foreach($folders['name'] as $key => $val) $folders['size'][$key] = folder_size($dir_to_browse.$folders['name'][$key]); elseif($show_folder_size_ftp == 1 && $listing_mode == 1) foreach($folders['name'] as $key => $val) $folders['size'][$key] = folder_size($dir_to_browse.$folders['name'][$key]); else $folders['size'][$key] = array(); } //Get directory content -done //Sort the folders and files array //User sorted if(isset($_SESSION['sort'])) { $sort_by = $_SESSION['sort']['by']; $sort_order = $_SESSION['sort']['order']; } if(!empty($folders['name'])) { if($sort_by == 0) { natcasesort($folders['name']); $folders_sorted = $folders['name']; } elseif($sort_by == 1 && $listing_mode == 0 && $show_folder_size_http == 1)//Sort by size for HTTP listing { asort($folders['size'], SORT_NUMERIC); $folders_sorted = $folders['size']; } elseif($sort_by == 1 && $listing_mode == 1 && $show_folder_size_ftp == 1)//Sort by size for FTP listing { asort($folders['size'], SORT_NUMERIC); $folders_sorted = $folders['size']; } else $folders_sorted = sort_by_date($folders['date']); if($sort_order == 1) $folders_sorted = array_reverse($folders_sorted, TRUE); } else $folders_sorted = array();//if there are no folders in the current directory if(!empty($files['name'])) { if($sort_by == 0) { natcasesort($files['name']);//natcasesort preserves the array keys $files_sorted = $files['name']; } elseif($sort_by == 1) { asort($files['size'], SORT_NUMERIC); $files_sorted = $files['size']; } else $files_sorted = sort_by_date($files['date'], $sort_order); if($sort_order == 1) $files_sorted = array_reverse($files_sorted, TRUE); } else $files_sorted = array();//if there are no files in the current directory //Sort the folders and files array -done //Icons if($view_mode == 0) { $files_icons_array = icons($files['name'], $view_mode); $folder_icon = ($view_mode == 0) ? '':' '; } elseif($view_mode == 1 && $file_icons) { $files_icons_array = icons($files['name'], $view_mode); $folder_icon = ($view_mode == 0) ? '':' '; } //Icons -done //Hide file extensions if enabled $files['name_with_ext'] = $files['name']; if($hide_file_ext == 1) { foreach($files['name'] as $key => $val) { $files['name'][$key] = remove_ext($val); } } //Hide file extensions if enabled -done if(!empty($folders['name']) || !empty($files['name'])) { ?>
    |  
'; if($statistics == 1) { ?>
           
$val)//This part is for the folders { $cells_thumbs[] = ''."\n"; $cell_name = ''; $cell_name .= ''; if($_SESSION['logged_in']) $cell_name .= '
'; $cell_name .= ''.chunk_split($folders['name'][$key], 15, "
").'
'; if($_SESSION['logged_in']) $cell_name .= '
'; $cells_names[] = $cell_name.''."\n"; $folders_counter++; } foreach($files_sorted as $key => $val)//This part is for the files { $file_class = ($files_counter%2 == 0) ? "file_bg1" : "file_bg2"; $file_link = ($limit_download_speed == 1 || $listing_mode == 1) ? 'dirLIST_files/download.php?file='.base64_encode($files['link'][$key]):$files['link'][$key]; if(in_array(strtolower(strrchr($files['name'][$key], '.')), $thumb_types) && $display_image_thumbs == 1) { //signifies it's an image and a thumbnail is to be displayed $cells_thumbs[] = ''."\n"; $img_thumbs_counter++; } else { $cells_thumbs[] = ''."\n"; } $cell_name = ''; $cell_name .= ''; if($_SESSION['logged_in']) $cell_name .= '
'; $cell_name .= ''.chunk_split($files['name'][$key], 15, "
").'
'; if($_SESSION['logged_in']) $cell_name .= '
'; $cells_names[] = $cell_name.''."\n"; $files_counter++; } echo ''; $items = 0; $total_items = count($cells_names); $number_of_rows = ceil($total_items/5); for($i=0;$i<$number_of_rows;$i++) { echo ''; for($j=(5*$i);$j<(5*($i+1));$j++) { echo (!empty($cells_thumbs[$j])) ? $cells_thumbs[$j] : ''; } echo ''; for($j=(5*$i);$j<(5*($i+1));$j++) echo (!empty($cells_names[$j])) ? $cells_names[$j] : ''; echo ''; } echo '
'; } else //list mode { echo ''; $count = 0; foreach($folders_sorted as $key => $val) { echo ''; echo ''; $count++; } $count = 0; foreach($files_sorted as $key => $val) { if($count%2 == 0) $file_class = "file_bg1"; else $file_class = "file_bg2"; echo ''; echo ''; $count++; echo ''; } echo '
'; echo '
'; if($file_icons == 1) echo ''; echo ' '.$folders['name'][$key].'
'; if($_SESSION['logged_in']) echo '
'; echo '
'; if($listing_mode == 0 && $show_folder_size_http == 1) echo letter_size($folders['size'][$key]); elseif($listing_mode == 1 && $show_folder_size_ftp == 1) echo letter_size($folders['size'][$key]); else echo '-'; echo ' '.$folders['date'][$key].'
'; echo '
'; if($file_icons == 1) echo ''; $file_link = ($limit_download_speed == 1 || $listing_mode == 1) ? 'dirLIST_files/download.php?file='.base64_encode($files['link'][$key]) :$files['link'][$key]; echo ' '.$files['name'][$key].'
'; if($_SESSION['logged_in']) echo '
'; echo '
'.letter_size($files['size'][$key]).' '.$files['date'][$key].'
'; } //Palce the content into a table -done } //Output if the directory is empty if(empty($folders['name']) && empty($files['name'])) echo display_error_message('No files or folders in this directory: '.$url_folder.''); //Output if the directory is empty -done //Display load time if($load_time == 1) echo "
".$local_text['this_page_loaded_in']." ".sprintf("%.3f", array_sum(explode(" ",microtime())) - $start_time)." ".$local_text['seconds']; //File uploading if($file_uploads == 1 && $listing_mode == 0) { ?>

: B '.$local_text['banned_files'].': '; foreach($banned_file_types as $val) { $string .= substr($val, 1)." | "; } echo substr($string, 0, -3); echo ''; } ?>

dirLIST - PHP Directory Lister v0.3.0
rename

delete