当前位置: 首页>>代码示例>>PHP>>正文


PHP CUtils::getSize方法代码示例

本文整理汇总了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;
 }
开发者ID:rawork,项目名称:colors-life,代码行数:34,代码来源:proc.s_backup.inc.php

示例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;
 }
开发者ID:rawork,项目名称:colors-life,代码行数:8,代码来源:CUtils.php

示例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;
}
开发者ID:rawork,项目名称:colors-life,代码行数:43,代码来源:procajax.php


注:本文中的CUtils::getSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。