本文整理汇总了PHP中get_dirsize函数的典型用法代码示例。如果您正苦于以下问题:PHP get_dirsize函数的具体用法?PHP get_dirsize怎么用?PHP get_dirsize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_dirsize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_dirsize
function get_dirsize($dirname)
{
$dirsize = 0;
if ($dir = opendir($dirname)) {
while ($file = readdir($dir)) {
if ($file == "." || $file == "..") {
} elseif (is_dir($dirname . '/' . $file)) {
$dirsize = $dirsize + get_dirsize($dirname . "/" . $file);
} else {
$dirsize = $dirsize + filesize($dirname . "/" . $file);
}
}
closedir($dir);
}
return $dirsize;
}
示例2: evc_fetch_remote_file
function evc_fetch_remote_file($args)
{
if (!empty($args)) {
extract($args);
}
//$post_date = date('Y-m-d H:i:s');
$upload = wp_upload_dir();
$upload = wp_upload_bits($file_name, 0, '');
if ($upload['error']) {
return new WP_Error('upload_dir_error', $upload['error']);
}
$headers = wp_get_http($url, $upload['file']);
if (!$headers) {
@unlink($upload['file']);
return new WP_Error('import_file_error', __('Remote server did not respond', 'evc'));
}
if ($headers['response'] != '200') {
@unlink($upload['file']);
return new WP_Error('import_file_error', sprintf(__('Remote server says: %1$d %2$s', 'evc'), $headers['response'], get_status_header_desc($headers['response'])));
} elseif (isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length']) {
@unlink($upload['file']);
return new WP_Error('import_file_error', __('Remote file is incorrect size', 'evc'));
}
$max_size = (int) get_site_option('fileupload_maxk') * 1024;
// fileupload_maxk for wpmu compatibility
$file_size = filesize($upload['file']);
if (!empty($max_size) && $file_size > $max_size) {
@unlink($upload['file']);
return new WP_Error('import_file_error', sprintf(__('Remote file is %1$d KB but limit is %2$d', 'evc'), $file_size / 1024, $max_size / 1024));
}
// This check is for wpmu compatibility
if (function_exists('get_space_allowed')) {
$space_allowed = 1048576 * get_space_allowed();
$space_used = get_dirsize(BLOGUPLOADDIR);
$space_left = $space_allowed - $space_used;
if ($space_left < 0) {
@unlink($upload['file']);
return new WP_Error('not_enough_diskspace', sprintf(__('You have %1$d KB diskspace used but %2$d allowed.', 'evc'), $space_used / 1024, $space_allowed / 1024));
}
}
$upload['content-type'] = $headers['content-type'];
return $upload;
}
示例3: wpmu_checkAvailableSpace
function wpmu_checkAvailableSpace()
{
$spaceAllowed = get_space_allowed();
$dirName = trailingslashit(BLOGUPLOADDIR);
if (!(is_dir($dirName) && is_readable($dirName))) {
return;
}
$dir = dir($dirName);
$size = 0;
while ($file = $dir->read()) {
if ($file != '.' && $file != '..') {
if (is_dir($dirName . $file)) {
$size += get_dirsize($dirName . $file);
} else {
$size += filesize($dirName . $file);
}
}
}
$dir->close();
$size = $size / 1024 / 1024;
if ($spaceAllowed - $size <= 0) {
define('DISABLE_UPLOADS', true);
define('DISABLE_UPLOADS_MESSAGE', __('Sorry, you must delete files before you can upload any more.'));
}
}
示例4: et_handle_upload_prefilter
function et_handle_upload_prefilter($file)
{
if (!is_multisite()) {
return $file;
}
if (get_site_option('upload_space_check_disabled')) {
return $file;
}
if ($file['error'] != '0') {
// there's already an error
return $file;
}
if (defined('WP_IMPORTING')) {
return $file;
}
$space_allowed = 1048576 * get_space_allowed();
$space_used = get_dirsize(BLOGUPLOADDIR);
$space_left = $space_allowed - $space_used;
$file_size = filesize($file['tmp_name']);
if ($space_left < $file_size) {
$file['error'] = sprintf(__('Not enough space to upload. %1$s KB needed.', ET_DOMAIN), number_format(($file_size - $space_left) / 1024));
}
if ($file_size > 1024 * get_site_option('fileupload_maxk', 1500)) {
$file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.', ET_DOMAIN), get_site_option('fileupload_maxk', 1500));
}
if (function_exists('upload_is_user_over_quota') && upload_is_user_over_quota(false)) {
$file['error'] = __('You have used your space quota. Please delete files before uploading.', ET_DOMAIN);
}
// if ( $file['error'] != '0' && !isset($_POST['html-upload']) )
// wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
return $file;
}
示例5: rigr_fetch_remote_file
function rigr_fetch_remote_file($post, $url)
{
$url2 = str_replace('&', '&', str_replace('https://', 'http://', $url));
preg_match('/[a-z0-9;=_%\\Q?&.-+[]\\E]+\\.(jpg|jpeg|gif|png|rar|zip|mp3|mp4|flv|pdf|swf)/i', $url2, $pu);
$file_name = str_replace('%25', '-', $pu[0]);
$file_name = preg_replace('/[;=%\\Q?&-+\\E]+/i', '-', $file_name);
$file_name = strlen($file_name) > 255 ? substr($file_name, 180) : $file_name;
$upload = wp_upload_bits($file_name, 0, '', $post['post_date']);
if ($upload['error']) {
echo $upload['error'];
return new WP_Error('upload_dir_error', $upload['error']);
}
$headers = wp_get_http($url2, $upload['file']);
if (!$headers) {
@unlink($upload['file']);
return new WP_Error('import_file_error', __('<p class="help"><img src="images/no.png"> <span style="color: #ff0000;">Remote server did not respond</span></p>', 'rigr'));
}
if ($headers['response'] != '200') {
@unlink($upload['file']);
return new WP_Error('import_file_error', sprintf(__('Remote server says: %1$d %2$s', 'rigr'), $headers['response'], get_status_header_desc($headers['response'])));
} elseif (isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length']) {
@unlink($upload['file']);
return new WP_Error('import_file_error', __('<p class="help"><img src="images/no.png"> <span style="color: #ff0000;">Remote file can not be downloaded</span></p>', 'rigr'));
}
$min_size = max((double) $_POST['rigr_min_size'], 0) * 1024;
$max_size = max((int) $_POST['rigr_max_size'], (int) get_site_option('fileupload_maxk')) * 1024;
/* -- fileupload_maxk for wpmu compatibility -- */
$file_size = filesize($upload['file']);
if (!empty($max_size) && $file_size > $max_size) {
@unlink($upload['file']);
return new WP_Error('import_file_error', sprintf(__('Remote file is %1$d KB but limit is %2$d', 'rigr'), $file_size / 1024, $max_size / 1024));
} elseif (!empty($min_size) && $file_size < $min_size) {
@unlink($upload['file']);
return new WP_Error('import_file_error', sprintf(__('Remote file size is less then %1$d KB', 'rigr'), $min_size / 1024));
}
/* -- This check is for wpmu compatibility -- */
if (function_exists('get_space_allowed')) {
$space_allowed = 1048576 * get_space_allowed();
$space_used = get_dirsize(BLOGUPLOADDIR);
$space_left = $space_allowed - $space_used;
if ($space_left < 0) {
@unlink($upload['file']);
return new WP_Error('not_enough_diskspace', sprintf(__('You have %1$d KB diskspace used but %2$d allowed.', 'rigr'), $space_used / 1024, $space_allowed / 1024));
}
}
$upload['content-type'] = $headers['content-type'];
return $upload;
}
示例6: details
function details()
{
// take default seetings
$settings = array('remain' => array('color_text' => 'white', 'color_bar' => '#0D324F', 'color_bg' => '#a0a0a0', 'decimals' => 2, 'unit' => 'm', 'display' => true, 'graph' => false), 'used' => array('color_text' => 'white', 'color_bar' => '#0D324F', 'color_bg' => '#a0a0a0', 'decimals' => 2, 'unit' => 'm', 'display' => true, 'graph' => true));
$quota = ngg_SpaceManager::getQuota() * 1024 * 1024;
$used = get_dirsize(constant("ABSPATH") . constant("UPLOADS"));
// $used = get_dirsize( ABSPATH."wp-content/blogs.dir/".$blog_id."/files" );
if ($used > $quota) {
$percentused = '100';
} else {
$percentused = $used / $quota * 100;
}
$remaining = $quota - $used;
$percentremain = 100 - $percentused;
$out = "";
$out .= '<div id="spaceused"> <h3>' . __('Storage Space', 'nggallery') . '</h3>';
if ($settings['used']['display']) {
$out .= __('Upload Space Used:', 'nggallery') . "\n";
$out .= ngg_SpaceManager::buildGraph($settings['used'], $used, $quota, $percentused);
$out .= "<br />";
}
if ($settings['remain']['display']) {
$out .= __('Upload Space Remaining:', 'nggallery') . "\n";
$out .= ngg_SpaceManager::buildGraph($settings['remain'], $remaining, $quota, $percentremain);
}
$out .= "</div>";
echo $out;
}
示例7: wp_dashboard_quota
function wp_dashboard_quota()
{
if (!is_multisite() || !current_user_can('upload_files') || get_site_option('upload_space_check_disabled')) {
return true;
}
$quota = get_space_allowed();
$used = get_dirsize(BLOGUPLOADDIR) / 1024 / 1024;
if ($used > $quota) {
$percentused = '100';
} else {
$percentused = $used / $quota * 100;
}
$used_color = $percentused >= 70 ? ' spam' : '';
$used = round($used, 2);
$percentused = number_format($percentused);
?>
<p class="sub musub"><?php
_e('Storage Space');
?>
</p>
<div class="table table_content musubtable">
<table>
<tr class="first">
<td class="first b b-posts"><?php
printf(__('<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>'), esc_url(admin_url('upload.php')), $quota);
?>
</td>
<td class="t posts"><?php
_e('Space Allowed');
?>
</td>
</tr>
</table>
</div>
<div class="table table_discussion musubtable">
<table>
<tr class="first">
<td class="b b-comments"><?php
printf(__('<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>'), esc_url(admin_url('upload.php')), $used, $percentused);
?>
</td>
<td class="last t comments<?php
echo $used_color;
?>
"><?php
_e('Space Used');
?>
</td>
</tr>
</table>
</div>
<br class="clear" />
<?php
}
示例8: get_space_used
/**
* Returns the space used by the current blog.
*
* @since 3.5.0
*
* @return int Used space in megabytes
*/
function get_space_used()
{
/**
* Filter the amount of storage space used by the current site.
*
* @since 3.5.0
*
* @param int|bool $space_used The amount of used space, in megabytes. Default false.
*/
$space_used = apply_filters('pre_get_space_used', false);
if (false === $space_used) {
$upload_dir = wp_upload_dir();
$space_used = get_dirsize($upload_dir['basedir']) / 1024 / 1024;
}
return $space_used;
}
示例9: wpmu_checkAvailableSpace
function wpmu_checkAvailableSpace()
{
if (get_site_option('upload_space_check_disabled')) {
return true;
}
$spaceAllowed = get_space_allowed();
$dirName = trailingslashit(BLOGUPLOADDIR);
if (!(is_dir($dirName) && is_readable($dirName))) {
return;
}
$dir = dir($dirName);
$size = 0;
while ($file = $dir->read()) {
if ($file != '.' && $file != '..') {
if (is_dir($dirName . $file)) {
$size += get_dirsize($dirName . $file);
} else {
$size += filesize($dirName . $file);
}
}
}
$dir->close();
$size = $size / 1024 / 1024;
if ($spaceAllowed - $size <= 0) {
wp_die(__('Sorry, you must delete files before you can upload any more.'));
}
}
示例10: cpm_wpmu_get_available_disk_space
/**
* Get the available disk space for this account.
*/
function cpm_wpmu_get_available_disk_space()
{
$space_allowed = 1048576 * get_space_allowed();
$space_used = get_dirsize(constant("ABSPATH") . constant("UPLOADS"));
return $space_allowed - $space_used;
}
示例11: fix_import_form_size
/**
* Get the remaining upload space for this blog.
*
* @since MU
* @uses upload_is_user_over_quota()
* @uses get_space_allowed()
* @uses get_dirsize()
*
* @param int $size
* @return int
*/
function fix_import_form_size( $size ) {
if ( upload_is_user_over_quota( false ) == true )
return 0;
$spaceAllowed = 1024 * 1024 * get_space_allowed();
$dirsize = get_dirsize( BLOGUPLOADDIR );
if ( $size > $spaceAllowed - $dirsize )
return $spaceAllowed - $dirsize; // remaining space
else
return $size; // default
}
示例12: get_space_used
/**
* Returns the space used by the current blog.
*
* @since 3.5.0
*
* @return int Used space in megabytes
*/
function get_space_used()
{
// Allow for an alternative way of tracking storage space used
$space_used = apply_filters('pre_get_space_used', false);
if (false === $space_used) {
$space_used = get_dirsize(BLOGUPLOADDIR) / 1024 / 1024;
}
return $space_used;
}
示例13: _get_space
function _get_space()
{
$space = get_space_allowed();
//echo "space<pre>"; print_r($space); echo "</pre>";
$_used_bytes = apply_filters('embi_upload_storage_used_bytes', get_dirsize(BLOGUPLOADDIR));
$used = apply_filters('embi_upload_storage_used_mb', $_used_bytes / 1024 / 1024);
$available = $space - $used;
$percentused = sprintf("%.2f", $used / $space * 100);
$space = $space > 1000 ? sprintf("%.2f", $space / 1024) . __('GB') : sprintf("%.2f", $space) . __('MB');
$used = $used > 1000 ? sprintf("%.2f", $used / 1024) . __('GB') : sprintf("%.2f", $used) . __('MB');
$available = $available > 1000 ? sprintf("%.2f", $available / 1024) . __('GB') : sprintf("%.2f", $available) . __('MB');
return array('total' => $space, 'used' => $used, 'percent' => $percentused, 'available' => $available);
}
示例14: dashboard_quota
function dashboard_quota()
{
if (get_site_option('upload_space_check_disabled')) {
return;
}
if (!wpmu_enable_function('wpmuQuotaCheck')) {
return;
}
$settings = C_NextGen_Settings::get_instance();
$fs = C_Fs::get_instance();
$dir = $fs->join_paths($fs->get_document_root('content'), $settings->gallerypath);
$quota = get_space_allowed();
$used = get_dirsize($dir) / 1024 / 1024;
if ($used > $quota) {
$percentused = '100';
} else {
$percentused = $used / $quota * 100;
}
$used_color = $percentused < 70 ? $percentused >= 40 ? 'yellow' : 'green' : 'red';
$used = round($used, 2);
$percentused = number_format($percentused);
?>
<p><?php
print __('Storage Space');
?>
</p>
<ul>
<li><?php
printf(__('%1$sMB Allowed', 'nggallery'), $quota);
?>
</li>
<li class="<?php
print $used_color;
?>
"><?php
printf(__('%1$sMB (%2$s%%) Used', 'nggallery'), $used, $percentused);
?>
</li>
</ul>
<?php
}
示例15: ngg_dashboard_quota
function ngg_dashboard_quota()
{
if (get_site_option('upload_space_check_disabled')) {
return;
}
if (!wpmu_enable_function('wpmuQuotaCheck')) {
return;
}
$quota = get_space_allowed();
$used = get_dirsize(BLOGUPLOADDIR) / 1024 / 1024;
if ($used > $quota) {
$percentused = '100';
} else {
$percentused = $used / $quota * 100;
}
$used_color = $percentused < 70 ? $percentused >= 40 ? 'waiting' : 'approved' : 'spam';
$used = round($used, 2);
$percentused = number_format($percentused);
?>
<p class="sub musub" style="position:static" ><?php
_e('Storage Space');
?>
</p>
<div class="table table_content musubtable">
<table>
<tr class="first">
<td class="first b b-posts"><?php
printf(__('<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>'), esc_url(admin_url('admin.php?page=nggallery-manage-gallery')), $quota);
?>
</td>
<td class="t posts"><?php
_e('Space Allowed');
?>
</td>
</tr>
</table>
</div>
<div class="table table_discussion musubtable">
<table>
<tr class="first">
<td class="b b-comments"><?php
printf(__('<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>'), esc_url(admin_url('admin.php?page=nggallery-manage-gallery')), $used, $percentused);
?>
</td>
<td class="last t comments <?php
echo $used_color;
?>
"><?php
_e('Space Used');
?>
</td>
</tr>
</table>
</div>
<br class="clear" />
<?php
}