function my_filesize($file) {
// First check if the file exists.
if(!is_file($file)) exit("File does not exist!");
// Setup some common file size measurements.
$kb = 1024; // Kilobyte
$mb = 1024 * $kb; // Megabyte
$gb = 1024 * $mb; // Gigabyte
$tb = 1024 * $gb; // Terabyte
// Get the file size in bytes.
$size = filesize($file);
/* If it's less than a kb we just return the size, otherwise we keep going until
the size is in the appropriate measurement range. */
if($size < $kb) {
return $size." B";
}
else if($size < $mb) {
return round($size/$kb,0)." KB";
}
else if($size < $gb) {
return round($size/$mb,2)." MB";
}
else if($size < $tb) {
return round($size/$gb,2)." GB";
}
else {
return round($size/$tb,2)." TB";
}
}
$absolutepath = strrev(strstr(strrev($_SERVER['PATH_TRANSLATED']),"/"));
$query = $_SERVER['QUERY_STRING'];
if ($query != "mp3" AND $query != "ogg") {
print "choose your format:
mp3 or ogg
";
} else {
print "prechange ".$query."s: ";
$directory = $absolutepath."../".$query."/";
$handle = opendir($directory);
while ( $file = readdir($handle) ) {
$ft = (filetype ($directory.$file));
// if (is_file($file)) {
if ($file != "." && $file != ".." && $file != "index.php" && $ft != "dir") {
$files[] = $file;
$tempfinfo = my_filesize($directory.$file);
$fileinfo[] = $tempfinfo;
$mtime[] = filemtime($directory.$file);
}
}
closedir($handle);
// sort array $files
//sort ($mtime);
//reset ($mtime);
while (list ($key, $val) = each ($mtime)) {
ob_start();
print_r($fileinfo[$key]);
$info = ob_get_contents();
ob_end_clean();
print "".$files[$key] . " [". $info ."] ";
}
}
?>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
All synthesis by Loosebot at beebleblab mobile studio.
This work is licensed under the Creative Commons
Attribution License. To view a copy of this license,
visit http://creativecommons.org/licenses/by/1.0
or send a letter to Creative Commons,
559 Nathan Abbott Way, Stanford, California 94305, USA.
|
|