Could not connect to FTP host")); $ftp_login = @ftp_login($ftp_stream, $ftp_username, $ftp_password) or die(display_error_message("Could not login to FTP host.")); } //If listing mode is FTP, open connection stream -done //Check if directory exists $folder_exists = 1; if($listing_mode == 0 && !is_dir($dir_to_browse)) //HTTP $folder_exists = 0; if($listing_mode == 1 && !is_dir("ftp://$ftp_username:$ftp_password@$ftp_host/$dir_to_browse")) //FTP $folder_exists = 0; if($folder_exists == 0) { 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 is valid -done //This is a VERY important security feature. It prevents people from browsing directories above $dir_to_browse and the excluded folders. Edit this part at your own risk if(count(explode("../",$folder)) > 1 || in_array(basename($folder), $exclude)) { echo display_error_message("Access Denied."); exit; } if(strlen($folder) == 2 && $folder == "..") { echo display_error_message("Access Denied."); exit; } //Seurity feature -done //Breadcrumbs $this_file_name = substr(strrchr($_SERVER['PHP_SELF'], "/"),1); $folders_in_URL = explode("/",rawurldecode($folder)); foreach($folders_in_URL as $key => $val) { $_temp = $_temp."/".$val; $folders_in_URL_array[$key] = $_temp; if($key == 0) { $_temp = $folders_in_URL[0]; $folders_in_URL_array[0] = $folders_in_URL[0]; } } $nav_links = "home/"; for($i=0;$i$folders_in_URL[$i]/"; else $nav_links = $nav_links."$folders_in_URL[$i]"; } echo "Index of: ".$nav_links."

"; //Breadcrumbs -done //Change excluded extensions to lower case if $case_sensative_ext is disabled foreach($exclude_ext as $key => $val) { $exclude_ext[$key] = strtolower($val); } //Initialize arrays $folders_array = array(); $folders_size_array = array(); $folders_cdate_array = array(); $folders_link_array = array(); $files_array = array(); $files_size_array = array(); $files_cdate_array = array(); $files_link_array = array(); //initialize arrays -done //Get directory content seperatiung files and folders into 2 arrays and filtering them to remove those exlcluded if($listing_mode == 0) //HTTP { $dir_content = get_dir_content($dir_to_browse); $folders_total_size = 0; $files_total_size = 0; foreach($dir_content as $key => $val) { if(!in_array($val, $exclude)) { $path = $dir_to_browse.$val; if(is_dir($path)) { $folders_array[] = $val; if($show_folder_size_http == 1) { $folder_size = folder_size($path); $folders_size_array[] = letter_size($folder_size); } $folders_total_size += $folder_size; if($folder == "") $folders_link_array[] = $val; else $folders_link_array[] = $folder."/".$val; $folders_cdate_array[] = date("d F Y", filectime($path)); } else { $this_file_size = filesize($this_file_name); if($path != $this_file_name && $this_file_size != filesize($path)) { $file_ext = strrchr($val, "."); if($case_sensative_ext == 0) $file_ext = strtolower($file_ext); if(!in_array($file_ext, $exclude_ext)) { $files_array[] = $val; $file_size = filesize($path); $files_size_array[] = letter_size($file_size); $files_total_size += $file_size; $files_link_array[] = $path; $files_cdate_array[] = date("d F Y", filectime($path)); } } } } } } elseif($listing_mode == 1) //FTP { $dir_content = ftp_rawlist($ftp_stream, $dir_to_browse); $folders_total_size = 0; $files_total_size = 0; foreach($dir_content as $key => $val) { $current = parse_rawurl($val); if(!in_array($current[8], $exclude)) { if(substr($current[0], 0, 1) == "d") { $folders_array[] = $current[8]; if($show_folder_size_ftp == 1) { $folder_size = folder_size($dir_to_browse.$current[8]); $folders_size_array[] = letter_size($folder_size); } $folders_total_size += $folder_size; if($folder == "") $folders_link_array[] = $current[8]; else $folders_link_array[] = $folder."/".$current[8]; $folders_cdate_array[] = $current[6]." ".$current[5]." ".$current[7]; } else { $this_file_size = filesize($this_file_name); if($path != $this_file_name && $this_file_size != $current[4]) { $file_ext = strrchr($current[8], "."); if($case_sensative_ext == 0) $file_ext = strtolower($file_ext); if(!in_array($file_ext, $exclude_ext)) { $files_array[] = $current[8]; $file_size = $current[4]; $files_size_array[] = letter_size($file_size); $files_total_size += $file_size; $files_link_array[] = 'dirLIST_files/ftp_download.php?ftpf='.base64_encode($dir_to_browse.$current[8]); $files_cdate_array[] = $current[6]." ".$current[5]." ".$current[7]; } } } } } } //Sort the folders and files array alpahbatically if(!empty($folders_array)) natcasesort($folders_array); if(!empty($files_array)) natcasesort($files_array); //Sort the folders and files array alpahbatically -done if(!empty($folders_array) || !empty($files_array)) { //Palce the content into a table if($legend == 1) echo "
KEY Folder
 
File
 
|
 

"; if($statistics == 1) { echo' Show/hide statistics
'; } echo"
"; foreach($folders_array as $key => $val) { echo""; } $count = 0; foreach($files_array as $key => $val) { if($count%2 == 0) $color = $color_1; else $color = $color_2; echo""; $count++; } echo "
Daily Transaction Report Size Date uploaded
$val $folders_size_array[$key] $folders_cdate_array[$key]
$val $files_size_array[$key] $files_cdate_array[$key]
"; //Palce the content into a table -done } //Output if the directory is empty if(empty($folders_array) && empty($files_array)) echo display_error_message("No files or folders in this directory: $folder"); //Output if the directory is empty -done //Display load time if($load_time == 1) { $endtime = explode(" ",microtime()); echo "
This page loaded in ".sprintf("%.3f", $endtime[1] + $endtime[0] - $starttime)." seconds"; } //Display load time -done ?>