"Emri Skedarit", "size" => "Madhësia", "last_changed" => "Ndryshuar", "total_used_space" => "Memorija e përdorur total", "free_space" => "Memorija e lirë", "password" => "Fjalëkalimi", "upload" => "Ngarko skedarë", "failed_upload" => "Ngarkimi i skedarit dështoi!", "failed_move" => "Lëvizja e skedarit në udhëzuesin e saktë deshtoi!", "wrong_password" => "Fjalëkalimi i Gabuar!!", "make_directory" => "New dir", "new_dir_failed" => "Failed to create directory", "chmod_dir_failed" => "Failed to change directory rights", "unable_to_read_dir" => "Unable to read directory", "location" => "Location", "root" => "Root" ); // German $_TRANSLATIONS["de"] = array( "file_name" => "Dateiname", "size" => "Größe", "last_changed" => "Letzte Änderung", "total_used_space" => "Benutzter Speicher", "free_space" => "Freier Speicher", "password" => "Passwort", "upload" => "Upload", "failed_upload" => "Upload ist fehlgeschlagen!", "failed_move" => "Verschieben der Datei ist fehlgeschlagen!", "wrong_password" => "Falsches Passwort", "make_directory" => "Neuer Ordner", "new_dir_failed" => "Erstellen des Ordners fehlgeschlagen", "chmod_dir_failed" => "Veränderung der Zugriffsrechte des Ordners fehlgeschlagen", "unable_to_read_dir" => "Unable to read directory", "location" => "Location", "root" => "Root" ); // Greek $_TRANSLATIONS["el"] = array( "file_name" => "Όνομα αρχείου", "size" => "Μέγεθος", "last_changed" => "Τροποποιημένο", "total_used_space" => "Χρησιμοποιημένος χώρος", "free_space" => "Ελεύθερος χώρος", "password" => "Εισάγεται κωδικό", "upload" => "Φόρτωση", "failed_upload" => "Αποτυχία φόρτωσης αρχείου!", "failed_move" => "Αποτυχία μεταφοράς αρχείου στον κατάλληλο φάκελο!", "wrong_password" => "Λάθος κωδικός", "make_directory" => "Δημιουργία νέου φακέλου", "new_dir_failed" => "Αποτυχία δημιουργίας νέου φακέλου", "chmod_dir_failed" => "Αποτυχία τροποποίησης δικαιωμάτων φακέλου", "unable_to_read_dir" => "Unable to read directory", "location" => "Location", "root" => "Root" ); // English $_TRANSLATIONS["en"] = array( "file_name" => "File name", "size" => "Size", "last_changed" => "Last changed", "total_used_space" => "Total used space", "free_space" => "Free space", "password" => "Password", "upload" => "Upload", "failed_upload" => "Failed to upload the file!", "failed_move" => "Failed to move the file into the right directory!", "wrong_password" => "Wrong password", "make_directory" => "New dir", "new_dir_failed" => "Failed to create directory", "chmod_dir_failed" => "Failed to change directory rights", "unable_to_read_dir" => "Unable to read directory", "location" => "Location", "root" => "Root" ); // Spanish $_TRANSLATIONS["es"] = array( "file_name" => "Nombre de archivo", "size" => "Medida", "last_changed" => "Ultima modificación", "total_used_space" => "Total espacio usado", "free_space" => "Espacio libre", "password" => "Contraseña", "upload" => "Subir el archivo", "failed_upload" => "Error al subir el archivo!", "failed_move" => "Error al mover el archivo al directorio seleccionado!", "wrong_password" => "Contraseña incorrecta", "make_directory" => "New dir", "new_dir_failed" => "Failed to create directory", "chmod_dir_failed" => "Failed to change directory rights", "unable_to_read_dir" => "Unable to read directory", "location" => "Location", "root" => "Root" ); // Estonian $_TRANSLATIONS["et"] = array( "file_name" => "Faili nimi", "size" => "Suurus", "last_changed" => "Viimati muudetud", "total_used_space" => "Kokku kasutatud", "free_space" => "Vaba ruumi", "password" => "Parool", "upload" => "Uploadi", "failed_upload" => "Faili ei õnnestunud serverisse laadida!", "failed_move" => "Faili ei õnnestunud õigesse kausta liigutada!", "wrong_password" => "Vale parool", "make_directory" => "Uus kaust", "new_dir_failed" => "Kausta loomine ebaõnnestus", "chmod_dir_failed" => "Kausta õiguste muutmine ebaõnnestus", "unable_to_read_dir" => "Unable to read directory", "location" => "Asukoht", "root" => "Peakaust" ); // French $_TRANSLATIONS["fr"] = array( "file_name" => "Nom de fichier", "size" => "Taille", "last_changed" => "Ajouté", "total_used_space" => "Espace total utilisé", "free_space" => "Espace libre", "password" => "Mot de passe", "upload" => "Envoyer un fichier", "failed_upload" => "Erreur lors de l'envoie!", "failed_move" => "Erreur lors du changement de dossier!", "wrong_password" => "Mauvais mot de passe", "make_directory" => "New dir", "new_dir_failed" => "Failed to create directory", "chmod_dir_failed" => "Failed to change directory rights", "unable_to_read_dir" => "Unable to read directory", "location" => "Location", "root" => "Root" ); // Italian $_TRANSLATIONS["it"] = array( "file_name" => "Nome file", "size" => "Dimensione", "last_changed" => "Ultima modifica", "total_used_space" => "Totale spazio usato", "free_space" => "Spazio disponibile", "password" => "Parola chiave", "upload" => "Caricamento file", "failed_upload" => "Caricamento del file fallito!", "failed_move" => "Spostamento del file nella cartella fallito!", "wrong_password" => "Password sbagliata", "make_directory" => "Nuova cartella", "new_dir_failed" => "Creazione cartella fallita!", "chmod_dir_failed" => "Modifica dei permessi della cartella fallita!", "unable_to_read_dir" => "Unable to read directory", "location" => "Location", "root" => "Root" ); // Dutch $_TRANSLATIONS["nl"] = array( "file_name" => "Bestandsnaam", "size" => "Omvang", "last_changed" => "Laatst gewijzigd", "total_used_space" => "Totaal gebruikte ruimte", "free_space" => "Beschikbaar", "password" => "Wachtwoord", "upload" => "Upload", "failed_upload" => "Fout bij uploaden van bestand!", "failed_move" => "Fout bij het verplaatsen van tijdelijk uploadbestand!", "wrong_password" => "Fout wachtwoord!", "make_directory" => "Nieuwe folder", "new_dir_failed" => "Fout bij aanmaken folder!", "chmod_dir_failed" => "Rechten konden niet gewijzigd worden!", "unable_to_read_dir" => "Unable to read directory", "location" => "Location", "root" => "Root" ); // Romanian $_TRANSLATIONS["ro"] = array( "file_name" => "Nume fisier", "size" => "Marime", "last_changed" => "Ultima modificare", "total_used_space" => "Spatiu total utilizat", "free_space" => "Spatiu disponibil", "password" => "Parola", "upload" => "Incarcare fisier", "failed_upload" => "Incarcarea fisierului a esuat!", "failed_move" => "Mutarea fisierului in alt director a esuat!", "wrong_password" => "Parola gresita!", "make_directory" => "New dir", "new_dir_failed" => "Failed to create directory", "chmod_dir_failed" => "Failed to change directory rights", "unable_to_read_dir" => "Unable to read directory", "location" => "Location", "root" => "Root" ); // Turkish $_TRANSLATIONS["tr"] = array( "file_name" => "Dosya ismi", "size" => "Boyut", "last_changed" => "gecmis", "total_used_space" => "Toplam dosya boyutu", "free_space" => "Bos alan", "password" => "Sifre", "upload" => "Yükleyen", "failed_upload" => "Hatali dosya yüklemesi!", "failed_move" => "Hatali dosya tasimasi!", "wrong_password" => "Yeniden sifre", "make_directory" => "Yeni dosya", "new_dir_failed" => "Dosya olusturalamadi", "chmod_dir_failed" => "Dosya ayari deqistirelemedi", "unable_to_read_dir" => "Unable to read directory", "location" => "Location", "root" => "Root" ); /***************************************************************************/ /* CSS KUJUNDUSE MUUTMISEKS */ /* */ /* CSS FOR TWEAKING THE DESIGN */ /***************************************************************************/ function css() { ?> name, $b->name); } function cmp_name_asc($b, $a) { return strcasecmp($a->name, $b->name); } function cmp_size_desc($a, $b) { return ($b->size - $a->size); } function cmp_size_asc($a, $b) { return ($a->size - $b->size); } function cmp_mod_desc($a, $b) { return ($a->modTime - $b->modTime); } function cmp_mod_asc($b, $a) { return ($a->modTime - $b->modTime); } // // The class that displays images (icons) // class ImageServer { function showImage() { global $_IMAGES; if(isset($_GET['img'])) { if(strlen($_GET['img']) > 0) { header('Content-type: image/gif'); if(isset($_IMAGES[$_GET['img']])) print base64_decode($_IMAGES[$_GET['img']]); else print base64_decode($_IMAGES["unknown"]); } return true; } return false; } } // // The class for any kind of file managing (new folder, upload, etc). // class FileManager { function checkPassword($inputPassword) { global $_CONFIG; global $_ERROR; global $_LANG; if(strlen($_CONFIG['upload_password']) > 0 && $inputPassword == $_CONFIG['upload_password']) { return true; } else { $_ERROR = $_LANG["wrong_password"]; return false; } } function newFolder($location, $dirname) { global $_ERROR; global $_LANG; if(strlen($dirname) > 0) { $forbidden = array(".", "/", "\\"); for($i = 0; $i < count($forbidden); $i++) $dirname = str_replace($forbidden[$i], "", $dirname); if(!mkdir($location->getDir(true, false, 0).$dirname, 0777)) $_ERROR = $_LANG["new_dir_failed"]; else if(!chmod($location->getDir(true, false, 0).$dirname, 0777)) $error = $_LANG["chmod_dir_failed"]; } } function uploadFile($location, $userfile) { global $_CONFIG; global $_ERROR; global $_LANG; $name = basename($userfile['name']); if(get_magic_quotes_gpc()) $name = stripslashes($name); $upload_dir = $location->getFullPath(); $upload_file = $upload_dir . $name; if(!is_uploaded_file($userfile['tmp_name'])) { $_ERROR = $_LANG["failed_upload"]; } else if(!@move_uploaded_file($userfile['tmp_name'], $upload_file)) { $_ERROR = $_LANG["failed_move"]; } else chmod($upload_file, 0755); } // // The main function, checks if the user wants to perform any supported operations // function run($location) { if(isset($_POST['password']) && $this->checkPassword($_POST['password'])) { if(isset($_POST['userdir']) && strlen($_POST['userdir']) > 0) $this->newFolder($location, $_POST['userdir']); if(isset($_FILES['userfile']['name']) && strlen($_FILES['userfile']['name']) > 0) $this->uploadFile($location, $_FILES['userfile']); } } } // // Dir class holds the information about one directory in the list // class Dir { var $name; var $location; // // Constructor // function Dir($name, $location) { $this->name = htmlspecialchars($name); $this->location = $location; } function getName() { return $this->name; } function getNameEncoded() { return urlencode($this->name); } // // Debugging output // function output() { print("Dir name: ".$this->name."\n"); print("Dir location: ".$this->location->getDir(true, false, 0)."\n"); } } // // File class holds the information about one file in the list // class File { var $name; var $location; var $size; var $extension; var $modTime; // // Constructor // function File($name, $location) { $this->name = htmlspecialchars($name); $this->location = $location; $this->extension = $this->findExtension($this->location->getDir(true, false, 0).$this->getName()); $this->size = $this->findSize($this->location->getDir(true, false, 0).$this->getName()); $this->modTime = filemtime($this->location->getDir(true, false, 0).$this->getName()); } function getName() { return $this->name; } function getNameEncoded() { return urlencode($this->name); } function getSize() { return $this->size; } function getExtension() { return $this->extension; } function getModTime() { return $this->modTime; } // // Determine the size of a file // function findSize($file) { $sizeInBytes = filesize($file); // If filesize() fails (with larger files), try to get the size from unix command line. if (!$sizeInBytes) { $sizeInBytes=exec("ls -l '$file' | awk '{print $5}'"); } return $sizeInBytes; } // // Return file extension (the string after the last dot). // function findExtension($file) { $chunks = explode(".", $file); return $chunks[count($chunks)-1]; } // // Debugging output // function output() { print("File name: ".$this->getName()."\n"); print("File location: ".$this->location->getDir(true, false, 0)."\n"); print("File size: ".$this->size."\n"); print("File extension: ".$this->extension."\n"); print("File modTime: ".$this->modTime."\n"); } } class Location { var $path; // // Split a file path into array elements // function splitPath($dir) { $path1 = preg_split("/[\\\\\/]+/", $dir); $path2 = array(); for($i = 0; $i < count($path1); $i++) { if($path1[$i] == ".." || $path1[$i] == "." || $path1[$i] == "") continue; $path2[] = $path1[$i]; } return $path2; } // // Get the current directory. // Options: Include the prefix ("./"); URL-encode the string; return directory n-levels up // function getDir($prefix, $encoded, $up) { $dir = ""; if($prefix == true) $dir .= "./"; for($i = 0; $i < ((count($this->path) >= $up && $up > 0)?count($this->path)-$up:count($this->path)); $i++) { $dir .= ($encoded?rawurlencode($this->path[$i]):$this->path[$i])."/"; } return $dir; } function getFullPath() { return ($_CONFIG['basedir']?$_CONFIG['basedir']:dirname($_SERVER['SCRIPT_FILENAME']))."/".$this->getDir(true, false, 0); } // // Debugging output // function output() { print_r($this->path); print("Dir with prefix: ".$this->getDir(true, false, 0)."\n"); print("Dir without prefix: ".$this->getDir(false, false, 0)."\n"); print("Upper dir with prefix: ".$this->getDir(true, false, 1)."\n"); print("Upper dir without prefix: ".$this->getDir(false, false, 1)."\n"); } // // Set the current directory // function init() { global $_CONFIG; if(!isset($_GET['dir']) || strlen($_GET['dir']) == 0) { $this->path = $this->splitPath($_CONFIG['starting_dir']); } else { $this->path = $this->splitPath($_GET['dir']); } } } class Encode_Explorer { var $location; var $dirs; var $files; var $sort_by; var $sort_as; // // Determine sorting, calculate space. // function init() { $this->sort_by = ""; $this->sort_as = ""; if(isset($_GET["sort_by"]) && isset($_GET["sort_as"])) { if($_GET["sort_by"] == "name" || $_GET["sort_by"] == "size" || $_GET["sort_by"] == "mod") if($_GET["sort_as"] == "asc" || $_GET["sort_as"] == "desc") { $this->sort_by = $_GET["sort_by"]; $this->sort_as = $_GET["sort_as"]; } } if(strlen($this->sort_by) <= 0 || strlen($this->sort_as) <= 0) { $this->sort_by = "name"; $this->sort_as = "desc"; } $this->calculateSpace(); } // // Read the file list from the directory // function readDir() { global $_CONFIG; global $_ERROR; global $_LANG; // // Reading the data of files and directories // if($open_dir = @opendir($this->location->getFullPath())) { $this->dirs = array(); $this->files = array(); while ($object = readdir($open_dir)) { if($object != "." && $object != "..") { if(is_dir($this->location->getDir(true, false, 0)."/".$object)) { if(!in_array($object, $_CONFIG['hidden_dirs'])) $this->dirs[] = new Dir($object, $this->location); } else if(!in_array($object, $_CONFIG['hidden_files'])) $this->files[] = new File($object, $this->location); } } closedir($open_dir); } else { $_ERROR = $_LANG['unable_to_read_dir']; } } // // A recursive function for calculating the total used space // function sum_dir($start_dir, $ignore_files, $levels = 1) { if ($dir = opendir($start_dir)) { $filesize = 0; while ((($file = readdir($dir)) !== false)) { if (!in_array($file, $ignore_files)) { if ((is_dir($start_dir . '/' . $file)) && ($levels - 1 >= 0)) { $filesize += $this->sum_dir($start_dir . '/' . $file, $ignore_files, $levels-1); } elseif (is_file($start_dir . '/' . $file)) { $filesize += filesize($start_dir . '/' . $file) / 1024; } } } closedir($dir); return $filesize; } } function calculateSpace() { global $_CONFIG; $ignore_files = array('..', '.'); $start_dir = getcwd(); $spaceUsed = $this->sum_dir($start_dir, $ignore_files, $_CONFIG['dir_levels']); $spaceLeft = $_CONFIG['max_space'] - $spaceUsed; $this->spaceUsed = round($spaceUsed/1024, 3); $this->spaceLeft = round($spaceLeft/1024, 3); } function sort() { @usort($this->files, "cmp_".$this->sort_by."_".$this->sort_as); if($this->sort_by == "name" && $this->sort_as == "asc") @usort($this->dirs, "cmp_name_asc"); else @usort($this->dirs, "cmp_name_desc"); } function makeArrow($sort_by) { global $_LANG; if($this->sort_by == $sort_by && $this->sort_as == "asc") { $sort_as = "desc"; $img = "arrow_up"; } else { $sort_as = "asc"; $img = "arrow_down"; } if($sort_by == "name") $text = $_LANG["file_name"]; else if($sort_by == "size") $text = $_LANG["size"]; else if($sort_by == "mod") $text = $_LANG["last_changed"]; return "location->getDir(false, true, 0)."&sort_by=".$sort_by."&sort_as=".$sort_as."\"> $text "; } function makeIcon($l) { $l = strtolower($l); return "?img=".$l; } function formatModTime($time) { return date("d.m.y H:i:s", $time); } function formatSize($size) { $sizes = Array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'); $y = $sizes[0]; for ($i = 1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $y = $sizes[$i]; } return round($size, 2)." ".$y; } // // Debugging output // function output() { print("!!!!!!!!!"); print("Explorer location: ".$this->location->getDir(true, false, 0)."\n"); for($i = 0; $i < count($this->dirs); $i++) $this->dirs[$i]->output(); for($i = 0; $i < count($this->files); $i++) $this->files[$i]->output(); } // // Main function, activating tasks // function run($location) { $this->init(); $this->location = $location; $this->readDir(); $this->sort(); $this->outputHtml(); } // // Printing the actual page // function outputHtml() { global $_ERROR; global $_CONFIG; global $_LANG; ?>
: location->path); $i++) { ?> / location->path[$i]; ?> | |||
makeArrow("name");?> | makeArrow("size"); ?> | makeArrow("mod"); ?> | |
.. | |||
location->getDir(false, true, 0).$dir->getNameEncoded()."\">".$dir->getName().""; ?> | |||
location->getDir(false, true, 0).$file->getName()."\""; if($_CONFIG['open_in_new_window']) print "target=\"_blank\""; print ">".$file->getName().""; ?> | formatSize($file->getSize()); ?> | formatModTime($file->getModTime());?> |