= 1099511627776) { $devolver = round($bytes / 1024 / 1024 / 1024 / 1024, 2); $tam_humano = "TB"; } elseif ($bytes >= 1073741824) { $devolver = round($bytes / 1024 / 1024 / 1024, 2); $tam_humano = "GB"; } elseif ($bytes >= 1048576) { $devolver = round($bytes / 1024 / 1024, 2); $tam_humano = "MB"; } elseif ($bytes >= 1024) { $devolver = round($bytes / 1024, 2); $tam_humano = "KB"; } else { $devolver = $bytes; $tam_humano = "Byte"; } if ($devolver == 1) { $devolver .= " " . $tam_humano; } else { $devolver .= " " . $tam_humano . "s"; } return $devolver; } function tipo($fichero) { if(is_dir($fichero)) return '<dir>'; else { $ext = substr($fichero,(strrpos ($fichero, ".")+1)); if ($ext != '') return strtolower($ext); else return '<...>'; } } function fecha($fichero) { if(is_dir($fichero)) return '<dir>'; else { return date('Y-d-m', filemtime($fichero)); } } function mostrar($fichero) { $extensiones_a_mostrar = array("flv", "mp4", "webm", "avi", "m4a"); return in_array(tipo($fichero), $extensiones_a_mostrar); } if(isset($dir)) @chdir($dir); $archivos = glob("*"); //Listamos los archivos if (count($archivos) > 0) // Si hay algun archivo, listamos { usort($archivos, function($a, $b) { return filemtime($b) - filemtime($a); }); foreach($archivos as $x) { if (is_dir($x)){ $archivo = htmlspecialchars($x); $archivo = str_replace("#","%23",$archivo); $archivo = str_replace("~","%7e",$archivo); echo "\t" . '' . "\n"; echo "\t" . "\t" . '' . "\n"; echo "\t" . "\t" . '' . "\n"; echo "\t" . "\t" . '' . "\n"; echo "\t" . "\t" . '' . "\n"; //Esto casca con almohadillas echo "\t" . '' . "\n"; } else { if (mostrar($x)) { $archivo = htmlspecialchars($x); $archivo = str_replace("#","%23",$archivo); $archivo = str_replace("~","%7e",$archivo); echo "\t" . '' . "\n"; echo "\t" . "\t" . '' . "\n"; echo "\t" . "\t" . '' . "\n"; echo "\t" . "\t" . '' . "\n"; echo "\t" . "\t" . '' . "\n"; //Esto casca con almohadillas echo "\t" . '' . "\n"; } } } } // TODO Si no hay, meter algo en un else. ?>
Nombre Tamaño Extensión Descripción

' . $x . '-' . fecha($x) . '' . shell_exec('file ./' . escapeshellarg($x) . '| cut -d: -f2') . '
' . $x . '' . getfilesize(filesize($x)) . '' . fecha($x) . '' . shell_exec('file ./' . escapeshellarg($x) . '| cut -d: -f2') . '