Example #1
0
function track_data()
{
    $tracks = CMP3File::get_tracks(TRACKS_LOCATION);
    $data = ["total_tracks" => count($tracks), "tracks_location" => TRACKS_LOCATION, "tracks_size" => format_bytes(folder_size(TRACKS_LOCATION))];
    return $data;
}
Example #2
0
/**
 * Get the total size of a directory.
 *
 * @param  - $dir_name (string) - Path of the dir on the hard disk
 * @return - 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;
}
Example #3
0
$folders['link'] = $dir_content['folders']['link'];
$files['name'] = $dir_content['files']['name'];
$files['size'] = $dir_content['files']['size'];
$files['date'] = $dir_content['files']['date'];
$files['link'] = $dir_content['files']['link'];
$images_detected = $dir_content['images_detected'];
$media_detected = $dir_content['media_detected'];
//The folder size calculation has not been placed inside the get_dir_content function so as not to affect it's speed. This is important becasue folder_size calls upon get_dir_content
if ($view_mode == 1) {
    if ($show_folder_size_http == 1 && $listing_mode == 0) {
        foreach ($folders['name'] as $key => $val) {
            $folders['size'][$key] = folder_size($dir_to_browse . $folders['name'][$key]);
        }
    } elseif ($show_folder_size_ftp == 1 && $listing_mode == 1) {
        foreach ($folders['name'] as $key => $val) {
            $folders['size'][$key] = folder_size($dir_to_browse . $folders['name'][$key]);
        }
    } else {
        $folders['size'][$key] = array();
    }
}
//Get directory content -done
//Sort the folders and files array
//User sorted
if (isset($_SESSION['sort'])) {
    $sort_by = $_SESSION['sort']['by'];
    $sort_order = $_SESSION['sort']['order'];
}
if (!empty($folders['name'])) {
    if ($sort_by == 0) {
        natcasesort($folders['name']);
Example #4
0
function folder_size($path)
{
    $dir_content = get_dir_content($path . '/');
    foreach ($dir_content['files']['size'] as $val) {
        $total_size += $val;
    }
    foreach ($dir_content['folders']['name'] as $val) {
        $total_size += folder_size($path . '/' . $val);
    }
    return $total_size;
}
Example #5
0
 #adding edit icon if needed
 if (is_file($fichier) && _mime_content_type($fichier) == 'text/plain' && $extension != 'js' && $extension != 'php' && $extension != 'sphp') {
     $icone_edit = '<a class="edit" href="index.php?p=editor&overwrite=true&file=' . $id . '&token=' . TOKEN . '" title="' . e('Edit this file', false) . '"><span class="icon-edit" ></span></a>';
 } else {
     $icone_edit = '';
 }
 # create item for file or folder
 $fichier_short = substr($fichier, $upload_path_size);
 if (is_dir($fichier)) {
     # Item is a folder
     $current_tree = tree($fichier, null, false, false, $tree);
     if (only_type($current_tree, '.jpg .jpeg .gif .png') || only_type($current_tree, '.mp3 .ogg') || only_type($fichier, '.jpg .jpeg .gif .png') || only_type($fichier, '.mp3 .ogg')) {
         $icone_visu = '<a class="visu" href="index.php?f=' . $id . '" title="' . e('View this share', false) . '"><span class="icon-eye"></span></a>';
     }
     if ($allow_folder_size_stat) {
         $taille = folder_size($fichier);
     } else {
         $taille = '';
     }
     # no share folder button if there's only one user
     if ($mode == 'links' && count($auto_restrict['users']) > 1) {
         $icone_share = '<a class="usershare" title="' . e('Share this folder with another user', false) . '" href="#usershare" data-id="' . $id . '" data-name="' . $fichier_short . '"><span class="icon-users"></span></a>';
     } else {
         $icone_share = '';
     }
     $array = array('#CLASS' => $class, '#ID' => $id, '#FICHIER' => $fichier_short, '#TOKEN' => TOKEN, '#SIZE' => $taille, '#NAME' => $nom, '#USERSHAREBUTTON' => $icone_share, '#TITLE' => $title, '#ICONE_VISU' => $icone_visu, '#SLASHEDNAME' => addslashes($nom), '#SLASHEDFICHIER' => addslashes($fichier_short));
     $folderlist .= template($mode . '_folder_' . $layout, $array);
     $current_tree = '';
 } elseif (is_file($fichier) && $_SESSION['GD'] && ($extension == 'gif' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'png')) {
     # Item is a picture
     auto_thumb($fichier, 64, 64);
Example #6
0
function folder_size($path)
{
    $total_size = 0;
    $files = scandir($path);
    $cleanPath = rtrim($path, '/') . '/';
    foreach ($files as $t) {
        if ($t != "." && $t != "..") {
            $currentFile = $cleanPath . $t;
            if (is_dir($currentFile)) {
                $size = folder_size($currentFile);
                $total_size += $size;
            } else {
                $size = filesize($currentFile);
                $total_size += $size;
            }
        }
    }
    return $total_size;
}
Example #7
0
    }
} else {
    if (isset($_POST['backup_choose'])) {
        if (!empty($_POST['table'])) {
            $c = backup_tables($_POST['table']);
            if ($c) {
                alert('success', Success_backup_database, true);
            }
        } else {
            alert('error', Please_choose_table, true);
        }
    }
}
$SIZE_LIMIT = siteConfig('disk_space') * 1024 * 1024;
// 5 GB
$disk_used = folder_size("../");
$disk_remaining = $SIZE_LIMIT - $disk_used;
?>
<script type="text/javascript">
$(document).ready(function() {
	$(".restore").click(function(e){
		var filename = $(".filesql").val();
		var extension = filename.replace(/^.*\./, '');
        if (extension == filename) {
            extension = '';
        } else {
            extension = extension.toLowerCase();
        }
		if(extension == 'sql') {	
				$('.sql_error').hide();
		} else {		
Example #8
0
function folder_fit($file = null, $size = null, $profile = null)
{
    if (!$file && !$size || !$profile) {
        return false;
    }
    $is_admin = is_superadmin();
    if (empty($_SESSION['profile_folder_max_size']) && !$is_admin) {
        return false;
    }
    $folder = $_SESSION['upload_root_path'] . $profile;
    $max = $_SESSION['profile_folder_max_size'] * 1048576;
    if (!empty($file)) {
        if (!is_file($file)) {
            return false;
        }
        $size = filesize($file);
    }
    if (folder_size($folder, false) + $size > $max && !$is_admin) {
        return false;
    }
    return true;
}