3 or ($member_db[1] != 1 and $action == "doimagedelete")){ msg("error", "Access Denied", "You don't have permission to manage images"); } /////////////////////////////////////////// //Configuration $files_per_page = $config_files_per_page; $show_download_size = $config_files_downlowad_size; $show_download_counter = $config_files_downlowad_count; $download_counter_text = $config_download_counter_text; /////////////////////////////////////////// $config_path_file_upload = "./data/files"; //Create upload directory if(!file_exists($config_path_file_upload)) mkdir($config_path_file_upload); //Create data/files.txt if(!file_exists('./data/files.txt')) touch('./data/files.txt'); //Create .htaccess file if(!file_exists($config_path_file_upload.'/.htaccess')){ $ht_file = fopen($config_path_file_upload.'/.htaccess', w); $htaccess = "Order Deny,Allow\nAllow from all"; fwrite($ht_file, $htaccess); fclose($config_path_file_upload.'/.htaccess'); } // ******************************************************************************** // Show Images List // ******************************************************************************** if($action != "doimagedelete") { if($action == "quick") { echo" ".$echo['insertTitle']." "; }else{ echoheader("images",$echo['header']); } // ******************************************************************************** // Upload File(s) // ******************************************************************************** if ($action == 'rename' and $image and $name){ rename($config_path_file_upload.'/'.$image, $config_path_file_upload.'/'.$name); //Rename the file in files.txt $file_db_file = './data/files.txt'; $file_db_content = file($file_db_file); $file_db = fopen($file_db_file, 'w'); foreach($file_db_content as $single_line){ $single_line_arr = explode("|", $single_line); if($single_line_arr[0] == $image){ fwrite($file_db, $name."|".$single_line_arr[1]."|".$single_line_arr[2]."|\n"); } else{ fwrite($file_db, $single_line); } } fclose($file_db); } if ($action == 'reset' and $image and $count){ $file_db_file = './data/files.txt'; $file_db_content = file($file_db_file); $file_db = fopen($file_db_file, 'w'); foreach($file_db_content as $single_line){ $single_line_arr = explode("|", $single_line); if($single_line_arr[0] == $image){ fwrite($file_db, $single_line_arr[0]."|".$single_line_arr[1]."|".$count."|\n"); } else{ fwrite($file_db, $single_line); } } fclose($file_db); } if($subaction == "upload") { for ($i = 0; $i < count($_FILES['image']['name'])-1; $i++) { $image = $_FILES['image']['tmp_name'][$i]; $image_name = $_FILES['image']['name'][$i]; $image_name = str_replace(" ", "_", $image_name); $img_name_arr = explode(".",$image_name); if($image_name == ""){ $img_result .= "
$current_image -> ".$echo['notPicked']."!"; } elseif( !isset($overwrite) and file_exists($config_path_file_upload."/".$image_name)){ $img_result .= "
$image_name -> File already exist!";} else{ @copy($image, $config_path_file_upload."/".$image_name) or $img_result = "".$echo['cannotCopy'].""; if(file_exists($config_path_file_upload."/".$image_name)){ $img_result .= "
$image_name -> ".$echo['uploadOK'].""; //Register this file in files.txt $file_db = fopen('./data/files.txt', 'a'); fwrite($file_db, $image_name."|".formatsize(filesize($config_path_file_upload."/".$image_name))."|0|\n"); fclose($file_db); }//if file is uploaded succesfully } } } ////////////// //Upload Form ////////////// if ($action == "quick") { echo '
'; } else { echo '
'; } echo<<
$addNew

$img_result
HTML; //////////////////////// //Prepare file showing //////////////////////// echo"
".$echo['uploadedFiles']." "; if($action == quick){ echo"";} else { echo"";} echo" ".($action == "quick" ? '' : '').""; $img_dir = opendir($config_path_file_upload); $i = 0; while ($file = readdir($img_dir)) { //Yes we'll store them in array for sorting if ($file != ".htaccess" and $file != ".." and $file != "." and is_file($config_path_file_upload."/".$file)){ $images_in_dir[] = $file; } } if($images_in_dir){ natcasesort($images_in_dir); reset($images_in_dir); foreach ($images_in_dir as $file) { $size_all_images += filesize($config_path_file_upload."/".$file); } //Pagination $files_per_page = ($files_per_page ? $files_per_page : 21); $start_from = ($start_from ? $start_from : ''); $i = $start_from; $j = 0; //End Pagination foreach ($images_in_dir as $file) { //Pagination if ($j < $start_from){ $j++; continue; } //End Pagination $i++; $this_size = filesize($config_path_file_upload."/".$file); $total_size += $this_size; $file_name = substr($file, 0, -(strlen(end(explode(".", $file)))+1)); if( $i%2 != 0 ){ $bg = "bgcolor=#F7F6F4"; } else{ $bg = ""; } //Get downloads for each file $file_db_content = file('./data/files.txt'); foreach($file_db_content as $single_line){ $single_line_arr = explode("|", $single_line); if($single_line_arr[0] == $file){ $downloads = $single_line_arr[2]; } } ///////////// //List files ///////////// ?> > ' : ''); ?> "; else{ echo '
'.$echo["total"].' ' : ''); ?> '); if (count($images_in_dir) > $files_per_page){ echo ($action == "quick" ? '' : ''); } ?> '; if($action != "quick"){ echofooter(); } } // ******************************************************************************** // Delete File // ******************************************************************************** elseif($action == "doimagedelete") { if(!isset($images)){ msg("info",$echo['notPicked'],$echo['notPickedInfo'], "$PHP_SELF?mod=files"); } foreach($images as $image){ unlink($config_path_file_upload."/".$image) or print($echo['cannotDelete']." $file"); $file_db_file = './data/files.txt'; $file_db_content = file($file_db_file); $file_db = fopen($file_db_file, 'w'); foreach($file_db_content as $single_line){ $single_line_arr = explode("|", $single_line); if($single_line_arr[0] != $image){ fwrite($file_db, $single_line); } } fclose($file_db); } msg("info",$echo['deletedHeader'],$echo['deletedOK'], "$PHP_SELF?mod=files"); } ?>
   ".$echo['file']."".$echo['actions']."".$echo['actions']."".$echo['size']."'.$echo["downloaded"].' 
   '.$echo["rename"].''.$echo["reset"].'  '.$downloads; echo ''; } //Pagination if ($i >= $files_per_page + $start_from){ break; } //End Pagination }//End foreach } //End if //Pagination if ($start_from > 0){ $previous = $start_from - $files_per_page; $npp_nav .= '<<'; } if (count($images_in_dir) > $files_per_page){ $npp_nav .= ' [ '; $enpages_count = @ceil(count($images_in_dir) / $files_per_page); $enpages_start_from = 0; $enpages = ''; for ($j = 1; $j <= $enpages_count; $j++){ if ($enpages_start_from != $start_from){ $enpages .= ''.$j.' '; } else { $enpages .= ' '.$j.' '; } $enpages_start_from += $files_per_page; } $npp_nav .= $enpages; $npp_nav .= ' ] '; } if (count($images_in_dir) > $i){ $npp_nav .= '>>'; } //End pagination if($i > 0){ ?>

'.formatsize($total_size).'

'.$echo["total"].' 

'.formatsize($total_size).'
  


'.$echo["totalAll"].'

'.formatsize($size_all_images).'

'.$echo["totalAll"].'

'.formatsize($size_all_images).'