當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。