function wpcloud_calc_used_space($user_id) { if (!file_exists(get_directory_from_id($user_id))) { return '0';} $used_MB = 0; $dir = ABSPATH . 'cloud/' . $user_id; if ($handle = opendir($dir)) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { $file = $dir . '/' . $entry; $used_MB = $used_MB + wpcloud_format_size($file, true); } } closedir($handle); return $used_MB; } }
<?php $dir = get_directory_from_id(get_current_user_id()); if (!directory_exist(get_current_user_id())) { echo 'Cloud space not activated yet.<br/><small>Please upload a file to generate your webspace...</small>'; } else { if ($handle = opendir($dir)) { echo '<table style="width:100%"> <table style="width:100%"> <tr> <th>File name</th> <th>Size</th> <th>Last edit</th> <th></th> </tr>'; while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { //Check file extension == $temp = explode(".", $entry); $extension = end($temp); if (!in_array($extension, getAllowedExtensions())) { continue; } // ==== $file = $dir . '/' . $entry; $file_url = get_site_url() . '/cloud/' . get_current_user_id() . '/' . $entry;