Home
'); // Avoid write javascript in the files $link = str_replace($no_symbol, "", $link); $name = str_replace($no_symbol, "", $name); // Get the last occurrence of '.' and the remaining text $lastDotIndex = strrpos($link, "."); if ($lastDotIndex) { $filetype = substr($link, $lastDotIndex + 1); } else { $filetype = "others"; } $filetype = str_replace('.', "", $filetype); $filetype = strtolower($filetype); if(!file_exists("categories")){ mkdir("categories"); } if(!file_exists("categories/$category")){ mkdir("categories/$category"); } if (isset($_POST['submit'])) { if(!file_exists("categories/$category/$name")){ $file = fopen("categories/$category/$name", "w"); fwrite($file, $link); fclose($file); $result = "
Sent with success!"; } else { $result = "
File already exists!"; } } $start = $_GET['start']; if (!$start){$start = 0;} $search = $_POST['search']; if ($search == ""){$search = $_GET['search'];} // Avoid accessing the above directories $search = str_replace('.', "", $search); $c = 0; $limit = 20; $ini = $start * $limit; $end = $ini + $limit; $entry = 0; if ($search == ""){$search = ' ';} $search = strtolower($search); echo "
$result "; if ($search != "" ){ $dir = 'categories'; // Open the directory if ($handle = opendir($dir)) { // Loop through each subdirectory while (false !== ($subdir = readdir($handle))) { if ($subdir != "." && $subdir != ".." && is_dir($dir.'/'.$subdir)) { // Open the subdirectory if ($subhandle = opendir($dir.'/'.$subdir)) { // Loop through each file in the subdirectory while (false !== ($file = readdir($subhandle))) { $filename_written = $file; // Find the occurrence in lower or uppercase $file_l = strtolower($file); //if ($subdir == $search){echo 'ok';} // Check if the filename contains the string // If there is a category with the searched name all the files within that category will be displayed if (strpos($file_l, $search) !== false || $subdir == $search) { // Pagination if($entry >= $ini and $entry < $end){ if ($file == "." || $file == ".."){continue;} // Display the filename //echo $dir.'/'.$subdir.'/'.$file . "
"; $td_color = $entry % 2 == 0 ? '#EEE' : '#FFF'; $file_path = $dir.'/'.$subdir.'/'.$file; $filesize = filesize($file_path); // Checks if is a binary file or text content if($filesize > 500){ $contents = $file_path; } else { $contents = file_get_contents($file_path); } $lastDotIndex = strrpos($contents, "."); if ($lastDotIndex) { $filetype = substr($contents, $lastDotIndex + 1); } $filetype = strtolower($filetype); // Don't show characters or variables after the file extension $filetype = substr($filetype, 0, 3); echo ""; // Show case be a picture extension if($filetype == "png" || $filetype == "jpg" || $filetype == "jpeg" || $filetype == "gif"){ echo ""; } // Show a thumbnail case exists if(file_exists('thumbs/' . $subdir . '/' . $filename_written . '.jpg')){ echo ""; } $search_break++; } $entry++; // Skip the files of the directory when reached the total results if($search_break == $end){break;} } } if($search_break == $end){break;} // Close the subdirectory closedir($subhandle); } } } // Close the directory closedir($handle); } if ($entry == 0){ echo "
Not found."; } } echo "
$filename_written$subdir$filetypeComment
"; if (!$search && !$start && !$result){ echo "Hello!"; } echo "

"; if ($entry){ for ($i = $start; $i < $start + 20; $i++) { echo "$i "; } } echo "
"; ?>