|
|
|
@ -206,57 +206,3 @@ function chooseFolderIcon($folderPath) |
|
|
|
|
return 'folder_document.png'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Transform a UNIX time stamp in human readable format date. |
|
|
|
|
* |
|
|
|
|
* @author - Hugues Peeters <peeters@ipm.ucl.ac.be> |
|
|
|
|
* @param int $date - UNIX time stamp |
|
|
|
|
* @return string A human readable representation of the UNIX date |
|
|
|
|
*/ |
|
|
|
|
function format_date($date) |
|
|
|
|
{ |
|
|
|
|
return date('d.m.Y', $date); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Transform the file path to a URL. |
|
|
|
|
* |
|
|
|
|
* @param string $file_path (string) - Relative local path of the file on the hard disk |
|
|
|
|
* @return string Relative url |
|
|
|
|
*/ |
|
|
|
|
function format_url($file_path) |
|
|
|
|
{ |
|
|
|
|
$path_component = explode('/', $file_path); |
|
|
|
|
$path_component = array_map('rawurlencode', $path_component); |
|
|
|
|
|
|
|
|
|
return implode('/', $path_component); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the total size of a directory. |
|
|
|
|
* |
|
|
|
|
* @param string $dir_name (string) - Path of the dir on the hard disk |
|
|
|
|
* @return int Total size in bytes |
|
|
|
|
*/ |
|
|
|
|
function folder_size($dir_name) |
|
|
|
|
{ |
|
|
|
|
$size = 0; |
|
|
|
|
if ($dir_handle = opendir($dir_name)) { |
|
|
|
|
while (($entry = readdir($dir_handle)) !== false) { |
|
|
|
|
if ($entry == '.' || $entry == '..') { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (is_dir($dir_name.'/'.$entry)) { |
|
|
|
|
$size += folder_size($dir_name.'/'.$entry); |
|
|
|
|
} else { |
|
|
|
|
$size += filesize($dir_name.'/'.$entry); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
closedir($dir_handle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $size; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|