/** * Returns size of a directory, with all file & subdirectory * sizes added up * @param string dir path * @return int */ function dirSize($dirName = '.') { $dir = dir($dirName); $size = 0; while ($file = $dir->read()) { if ($file != '.' && $file != '..') { if (is_dir("{$dirName}{$file}")) { $size += Files::dirSize($dirName . '/' . $file); } else { $size += filesize($dirName . '/' . $file); } } } $dir->close(); return $size; }
<td colspan="5"><input type="text" id="f_alt" class="largelWidth" value="" /></td> </tr> <?php } if ($insertMode == 'link' || $IMConfig['images_enable_title']) { ?> <tr> <td style="text-align: right;"><label for="f_title">Title (tooltip)</label></td> <td colspan="5"><input type="text" id="f_title" class="largelWidth" value="" /></td> </tr> <?php } ?> <tr> <?php if (!empty($IMConfig['max_foldersize_mb']) && Files::dirSize($manager->getImagesDir()) > $IMConfig['max_foldersize_mb'] * 1048576) { ?> <td colspan="6" style="text-align: right;">Maximum folder size limit reached. Upload disabled.</td> <?php } else { if ($IMConfig['allow_upload']) { ?> <td style="text-align: right;"><label for="upload">Upload</label></td> <td colspan="5"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max = ($insertMode == 'image' ? $IMConfig['max_filesize_kb_image'] : $IMConfig['max_filesize_kb_link']) * 1024; ?> " /> <input type="file" name="upload" id="upload" /></td>
function getDiskInfo() { if (empty($this->config['max_foldersize_mb'])) { return ''; } $tmpFreeSize = $this->config['max_foldersize_mb'] * 1048576 - Files::dirSize($this->getImagesDir()); if (!is_numeric($tmpFreeSize) || $tmpFreeSize < 0) { $tmpFreeSize = 0; } return 'Total Size : $max_foldersize_mb=' . $this->config['max_foldersize_mb'] . '$ MB, Free Space: $free_space=' . Files::formatSize($tmpFreeSize) . '$'; }