本文整理汇总了PHP中CUtils::getSize方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtils::getSize方法的具体用法?PHP CUtils::getSize怎么用?PHP CUtils::getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtils
的用法示例。
在下文中一共展示了CUtils::getSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMainBodyTable
protected function getMainBodyTable()
{
$ret = $this->getTopTableHeader();
$dirname = $GLOBALS['PRJ_DIR'] . '/admin/backup/';
//var_dump($dirname);
$dir = @opendir($dirname);
$files = array();
while ($file = @readdir($dir)) {
$fullname = $dirname . $file;
if ($file == "." || $file == ".." || @is_dir($fullname)) {
continue;
} else {
if (@file_exists($fullname)) {
$files[] = array('name' => $fullname, 'name2' => $file, 'type' => 0, 'ext' => substr($file, strrpos($file, ".")), 'stat' => stat($fullname));
}
}
}
@closedir($dir);
foreach ($files as $current) {
//var_dump($current['ext']);
if ($current['ext'] == '.gz') {
$ret .= '<tr>';
$tmp_ret = '';
$link = str_replace($GLOBALS['PRJ_DIR'], '', $current['name']);
$ret .= '<td>' . $current['name2'] . '</td>';
$ret .= '<td>' . str_replace($_SERVER['DOCUMENT_ROOT'], '', $current['name']) . '</td>';
$ret .= '<td>' . CUtils::getSize($current['stat'][7]) . '</td>';
$ret .= '<td>' . date('d.m.Y H:i:s', $current['stat'][9]) . '</td>';
$ret .= $this->getUpdateDelete($link) . '</tr>' . "\n";
}
}
$ret .= $this->getTopTableFooter();
return $ret;
}
示例2: getFileSize
public static function getFileSize($ref, $precision = 2)
{
$ret = '';
if (@file_exists($GLOBALS['PRJ_DIR'] . $ref)) {
$ret = CUtils::getSize(max(filesize($GLOBALS['PRJ_DIR'] . $ref), 0), $precision);
}
return $ret;
}
示例3: makeArchive
function makeArchive($fD)
{
$my_time = time();
$my_key = CUtils::genKey(8);
$objResponse = new xajaxResponse();
$objResponse->assign("archive_info", 'innerHTML', '');
$filename = 'admin/backup/' . date('YmdHi', $my_time) . '_' . $my_key . '.tar.gz';
$filename_sql = 'admin/backup/' . date('YmdHi', $my_time) . '_' . $my_key . '.sql';
$filename_sql2 = 'admin/backup/' . date('YmdHi', $my_time) . '_' . $my_key . '_after_connect.sql';
$f = fopen($GLOBALS['PRJ_DIR'] . '/' . $filename_sql2, "a");
fwrite($f, "/*!41000 SET NAMES 'cp1251' */;");
fclose($f);
set_time_limit(0);
$GLOBALS['db']->backupDB($filename_sql);
inc_lib('tools/CArchive.php');
$test = new gzip_file($filename);
$test->set_options(array('basedir' => $GLOBALS['PRJ_DIR'] . '/', 'overwrite' => 1, 'level' => 5));
$test->add_files(array("*.*"));
//$test->exclude_files(array("admin/lib/templates_c/*.php", "*.gz"));
$cfiles = 0;
$sfiles = 0;
foreach ($test->files as $key => $current) {
if (stristr($current['name'], '.tar.gz')) {
unset($test->files[$key]);
} else {
$sfiles += $current['stat'][7];
$cfiles++;
}
}
$test->create_archive();
$text = '';
$text .= 'Количество файлов: ' . $cfiles;
$text .= '<br>';
$text .= 'Размер неупакованых файлов: ' . CUtils::getSize($sfiles, 2);
$text .= '<br>';
$text .= 'Размер архива: ' . CUtils::getFileSize('/' . $filename, 2);
//$text = 'test';
@unlink($GLOBALS['PRJ_DIR'] . '/' . $filename_sql);
@unlink($GLOBALS['PRJ_DIR'] . '/' . $filename_sql2);
$objResponse->assign("archive_info", 'innerHTML', $text);
$objResponse->script("hideDiv('waiting');window.location.reload()");
return $objResponse;
}