• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP format_bytes函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中format_bytes函数的典型用法代码示例。如果您正苦于以下问题:PHP format_bytes函数的具体用法?PHP format_bytes怎么用?PHP format_bytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了format_bytes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: print_states

function print_states($tracker)
{
    global $rulescnt;
    $rulesid = "";
    $bytes = 0;
    $states = 0;
    $packets = 0;
    $evaluations = 0;
    $stcreations = 0;
    $rules = get_pf_rules($rulescnt, $tracker);
    if (is_array($rules)) {
        foreach ($rules as $rule) {
            $bytes += $rule['bytes'];
            $states += $rule['states'];
            $packets += $rule['packets'];
            $evaluations += $rule['evaluations'];
            $stcreations += $rule['state creations'];
            if (strlen($rulesid) > 0) {
                $rulesid .= ",";
            }
            $rulesid .= "{$rule['id']}";
        }
    }
    printf("<a href=\"diag_dump_states.php?ruleid=%s\" data-toggle=\"popover\" data-trigger=\"hover focus\" title=\"%s\" ", $rulesid, gettext("States details"));
    printf("data-content=\"evaluations: %s<br>packets: %s<br>bytes: %s<br>states: %s<br>state creations: %s\" data-html=\"true\">", format_number($evaluations), format_number($packets), format_bytes($bytes), format_number($states), format_number($stcreations));
    printf("%d/%s</a><br>", format_number($states), format_bytes($bytes));
}
开发者ID:NewEraCracker,项目名称:pfsense,代码行数:27,代码来源:firewall_rules.php


示例2: artc

 public function artc()
 {
     $id = I('id');
     $info = D('Article')->get_info($id);
     if (!$info) {
         $this->error('非法ID!', U('Index/index'), false, true);
     }
     $info['description'] = stripcslashes($info['description']);
     preg_match_all("/(?<=\\[attach\\])([\\d]*)(?=\\[\\/attach\\])/", $info['description'], $arr);
     preg_match_all("/(?<=\\[qnattach\\])([\\d]*)(?=\\[\\/qnattach\\])/", $info['description'], $qnarr);
     foreach ($arr[0] as $key => $vo) {
         $replace = '<a href="' . U('File/download', array('id' => think_encrypt($vo))) . '" target="_blank" >' . getattachname($vo) . '</a><span class="attachspan">(下载次数:' . getattachdnum($vo) . '次;大小:' . format_bytes(getattachsize($vo)) . ')</span>';
         $info['description'] = str_replace('[attach]' . $vo . '[/attach]', $replace, $info['description']);
     }
     foreach ($qnarr[0] as $key1 => $vo1) {
         $replace1 = '<a href="' . U('File/download', array('qn' => 1, 'id' => think_encrypt($vo1))) . '" target="_blank" >' . getqnattachname($vo1) . '</a><span class="attachspan">(下载次数:' . getqnattachdnum($vo1) . '次;大小:' . format_bytes(getqnattachsize($vo1)) . ')</span>';
         $info['description'] = str_replace('[qnattach]' . $vo1 . '[/qnattach]', $replace1, $info['description']);
     }
     if ($info['status'] != 1 && $info['uid'] != $_SESSION['cs_home']['user_auth']['uid']) {
         $this->error('你无权查看该内容!', '', false, true);
     }
     $focus['rowid'] = $info['id'];
     $focus['type'] = 1;
     if ($sccount = M('focus')->where($focus)->count() != $info['sccount']) {
         D('Article')->where(array('id' => $id))->setField('sccount', $sccount);
     }
     D('Article')->where(array('id' => $id))->setInc('view', 1);
     if (!empty($info['tag'])) {
         $tags = explode(',', $info['tag']);
         $info['linktag'] = '';
         foreach ($tags as $key1 => $vo1) {
             $maptag['title'] = $vo1;
             $maptag['type'] = 1;
             $tagid = M('tags')->where($maptag)->getField('id');
             $url = CSU('/tagart/' . $tagid, 'Index/tagart', array('id' => $tagid));
             $info['linktag'] .= '<a style="margin-left:5px;" href="' . $url . '">[' . $vo1 . ']</a>';
             $info['tagarr'][$key1] = '<a class="tag" href="' . $url . '">' . $vo1 . '</a>';
         }
     }
     $shareurl = 'http://' . $_SERVER['HTTP_HOST'] . CSU('/artc/' . $info['id'], 'Index/artc', array('id' => $info['id']));
     $sharedes = '原文链接:' . $shareurl;
     $sharetitle = $info['title'] . '-' . C('WEB_SITE_TITLE');
     $authorinfo = query_user(array('space_url', 'signature', 'avatar64', 'nickname'), $info['uid']);
     $map['id'] = is_login();
     $map['rowid'] = $info['id'];
     $map['type'] = 1;
     if (M('Focus')->where($map)->count() > 0) {
         $hassc = true;
     }
     $this->assign('shareurl', $shareurl);
     $this->assign('hassc', $hassc);
     $this->assign('sharedes', $sharedes);
     $this->assign('sharetitle', $sharetitle);
     $this->assign('authorinfo', $authorinfo);
     $this->assign('info', $info);
     $this->assign('webdescription', $info['title']);
     $this->assign('webkeyword', $info['title']);
     $this->assign('webtitle', $info['title']);
     $this->display();
 }
开发者ID:Willshon,项目名称:OLCS,代码行数:60,代码来源:IndexController.class.php


示例3: Movie_thumbnail

function Movie_thumbnail($filelist, $gallery, $dirkey, $filekey, $basedir)
{
    $filename = $filelist[$filekey];
    $file = "{$basedir}/{$filename}";
    $mimetype = mime_content_type($file);
    $filesize = filesize($file);
    $nicefilesize = format_bytes($filesize);
    $caption = get_caption($file);
    if (!isset($caption) || $caption == "") {
        $caption = $filename;
    }
    $imagetag = " MOVIE:  {$filename} <br/>";
    $filesize_display = " File Size: {$nicefilesize} <br/>";
    #<a href='?action=send_file&gallery=$gallery&dirkey=$dirkey&filekey=$filekey'>
    print <<<HTMLEND

    <div class=thumbnail >
\t\t<div class=movie >
\t\t{$imagetag}
\t\t{$filesize_display}
\t\t<a href='send_file.php?mode=attach&gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}'>
\t\tDownload
\t\t</a>
\t\t|
\t\t<a href='gallery.php?action=display_image&gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}' type='{$mimetype}' >
\t\tView in browser
\t\t</a>

    
    \t</div>
    </div>
   
HTMLEND;
}
开发者ID:robincj,项目名称:gallery,代码行数:34,代码来源:generate_gallery.php


示例4: scandir_tree

/**
 * 扫描目录所有文件,并生成treegrid数据
 * @param string $path     目录
 * @param string $filter   过滤文件名
 * @param number $i        辅助用,这个不用传参
 * @return array
 */
function scandir_tree($path, $filter = SITE_DIR, &$i = 1)
{
    $result = array();
    $path = realpath($path);
    $path = str_replace(array('/', '\\'), DS, $path);
    $filter = str_replace(array('/', '\\'), DS, $filter);
    $list = glob($path . DS . '*');
    foreach ($list as $key => $filename) {
        $result[$key]['id'] = $i;
        $result[$key]['name'] = str_replace($filter, '', $filename);
        $i++;
        if (is_dir($filename)) {
            $result[$key]['type'] = 'dir';
            $result[$key]['size'] = '-';
            $result[$key]['mtime'] = '-';
            $result[$key]['state'] = 'closed';
            $result[$key]['children'] = scandir_tree($filename, $filter, $i);
            //easyui当children为空时会出现问题,因此在这里过滤
            if (empty($result[$key]['children'])) {
                $result[$key]['iconCls'] = 'tree-folder';
                unset($result[$key]['state']);
                unset($result[$key]['children']);
            }
        } else {
            $result[$key]['type'] = 'file';
            $result[$key]['size'] = format_bytes(filesize($filename), ' ');
            $result[$key]['mtime'] = date('Y-m-d H:i:s', filemtime($filename));
        }
    }
    return $result;
}
开发者ID:huangxulei,项目名称:app,代码行数:38,代码来源:function.php


示例5: _after_find

 protected function _after_find(&$result, $options)
 {
     $result['update_time_text'] = date('Y-m-d H:i:s', $result['update_time']);
     $result['document_title'] = M('Doc0s1')->getFieldById($result['record_id'], 'title');
     //$result['document_title'] = M('Document')->getFieldById($result['record_id'], 'title');
     $result['size'] = format_bytes($result['size']);
 }
开发者ID:terrydeng,项目名称:beimeibang1205,代码行数:7,代码来源:AttachmentModel.class.php


示例6: lists

 public function lists()
 {
     $type = I('get.type', 'Picture');
     $type = ucfirst($type);
     $title = I('get.title');
     if (empty($this->_path[$type])) {
         $this->error($type . '请选择正确的资源类型');
     }
     $files_list = array();
     //获取该目录下所有文件
     $fileslist = Amango_Scanfiles('./Uploads/' . $type . '/');
     $files_list = explode(',', $fileslist);
     $current_path = $this->_path[$type][1];
     //获取路径
     if (in_array($title, $files_list)) {
         $current_path = $current_path . $title . '/';
         $parent_ext = './' . $title . '/';
     } else {
         $parent_ext = './';
     }
     $file_list = array();
     //遍历目录下文件 取得文件信息
     $totalkbs = 0;
     if ($handle = opendir($current_path)) {
         $i = 0;
         while (false !== ($filename = readdir($handle))) {
             if ($filename[0] == '.') {
                 continue;
             }
             $file = $current_path . $filename;
             if (!is_dir($file)) {
                 $file_ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
                 if (!in_array($file_ext, $this->deny_ext_arr)) {
                     $nowsize = filesize($file);
                     $filesize = $filesize + $nowsize;
                     $file_list[$parent_ext][$i]['is_dir'] = false;
                     $file_list[$parent_ext][$i]['has_file'] = false;
                     $file_list[$parent_ext][$i]['filesize'] = format_bytes($nowsize);
                     $file_list[$parent_ext][$i]['dir_path'] = '';
                     $file_list[$parent_ext][$i]['filetype'] = $file_ext;
                     $file_list[$parent_ext][$i]['filename'] = $filename;
                     //文件名,包含扩展名
                     $file_list[$parent_ext][$i]['datetime'] = date('Y-m-d H:i:s', filectime($file));
                     //文件最后修改时间
                 }
             }
             $i++;
         }
         closedir($handle);
     }
     $this->assign('filesize', format_bytes($filesize));
     $this->assign('filenums', count($file_list[$parent_ext]));
     $this->assign('type', $type);
     $this->assign('nowdir', $title);
     $this->assign('sub_dirs', $files_list);
     $this->assign('subfileslist', $file_list[$parent_ext]);
     $this->assign('catename', $this->_path[$type][0]);
     $this->display();
 }
开发者ID:Luckyseal,项目名称:amango,代码行数:59,代码来源:FileController.class.php


示例7: import_list

    /**
     * 数据库备份/还原列表
     */
    public function import_list($type = null)
    {
        if (IS_POST) {
            $path = C('DATA_BACKUP_PATH');
            if (!is_dir($path)) {
                mkdir($path, 0755, true);
            }
            $path = realpath($path);
            $flag = \FilesystemIterator::KEY_AS_FILENAME;
            $glob = new \FilesystemIterator($path, $flag);
            $list = array();
            foreach ($glob as $name => $file) {
                if (preg_match('/^\\d{8,8}-\\d{6,6}-\\d+\\.sql(?:\\.gz)?$/', $name)) {
                    $name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d');
                    $date = "{$name[0]}-{$name[1]}-{$name[2]}";
                    $time = "{$name[3]}:{$name[4]}:{$name[5]}";
                    $part = $name[6];
                    if (isset($list["{$date} {$time}"])) {
                        $info = $list["{$date} {$time}"];
                        $info['part'] = max($info['part'], $part);
                        $info['size'] = $info['size'] + $file->getSize();
                    } else {
                        $info['part'] = $part;
                        $info['size'] = $file->getSize();
                    }
                    $extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
                    $info['compress'] = $extension === 'SQL' ? '-' : $extension;
                    $info['time'] = strtotime("{$date} {$time}");
                    $list["{$date} {$time}"] = $info;
                }
            }
            foreach ($list as $list_key => $list_one) {
                $_list_one['id'] = date('Ymd-His', $list_one['time']);
                $_list_one['part'] = $list_one['part'];
                $_list_one['size'] = format_bytes($list_one['size']);
                $_list_one['compress'] = $list_one['compress'];
                $_list_one['time'] = $list_key;
                $_list_one['operate'] = '
					<a href="#" onclick="Ajax_DatabaseImport(\'' . U('import', array('time' => $list_one['time'])) . '\',\'DatabaseImport_Data_List\');">还原</a>
					<a href="#" onclick="Datagrid_Ajax(\'' . U('del', array('time' => $list_one['time'])) . '\',\'DatabaseImport_Data_List\');">删除</a>
				';
                $_list[] = $_list_one;
            }
            $total = count($_list);
            if ($total == 0) {
                $_list = '';
            }
            $data = array('total' => $total, 'rows' => $_list);
            $this->ajaxReturn($data);
        } else {
            $operate = '
			<a class="easyui-linkbutton" href="JavaScript:void(0);" data-options="iconCls:\'iconfont icon-refresh\',plain:true" onclick="Data_Reload(\'DatabaseImport_Data_List\');">刷新还原列表</a>
			';
            $this->assign('operate', $operate);
            $this->display();
        }
    }
开发者ID:cwcw,项目名称:cms,代码行数:60,代码来源:DatabaseController.class.php


示例8: getUsedDiskSpace

	/**
	 * Returns disk space data
	 *
	 * @return	array
	 */
    public function getUsedDiskSpace()
    {
        $disk_space['b_free'] = disk_free_space('/');
        $disk_space['b_total'] = disk_total_space('/');
        $disk_space['free'] = format_bytes($disk_space['b_free']);
        $disk_space['total'] = format_bytes($disk_space['b_total']);
        $disk_space['used'] = format_bytes($disk_space['b_total'] - $disk_space['b_free']);
        $disk_space['per_used'] =   100 - (int) ($disk_space['b_free'] / $disk_space['b_total'] * 100);

        return $disk_space;
    }
开发者ID:helinp,项目名称:MediaGrade,代码行数:16,代码来源:System_model.php


示例9: step1

 public function step1()
 {
     $items = array(array('os' => array('操作系统', 1, null, PHP_OS), 'php' => array('PHP版本', 0, '5.3', PHP_VERSION), 'upload' => array('附件上传', 1, null, function_exists('ini_get') ? ini_get('upload_max_filesize') : '未知'), 'disk' => array('磁盘空间', 1, null, function_exists('disk_free_space') ? format_bytes(disk_free_space(realpath(SITE_DIR))) : '未知')), array('pdo' => array('pdo', 0, null, '不支持', 'class_exists'), 'pdo_mysql' => array('pdo_mysql', 0, null, '不支持', 'extension_loaded'), 'json' => array('json', 0, null, '不支持', 'extension_loaded'), 'curl_init' => array('curl', 0, null, '不支持', 'function_exists'), 'gd' => array('gd', 0, null, '不支持', 'extension_loaded'), 'Imagick' => array('imagick', 0, null, '建议开启(可选)', 'class_exists'), 'Gmagick' => array('gmagick', 0, null, '建议开启(可选)', 'class_exists')), array(array(str_replace(SITE_DIR, '.', CONF_PATH . 'config.php'), 0, null, '不可写', CONF_PATH . 'config.php'), array(str_replace(SITE_DIR, '.', RUNTIME_PATH), 0, null, '不可写', RUNTIME_PATH), array(UPLOAD_PATH, 0, null, '不可写', UPLOAD_PATH)));
     if (APP_MODE == 'sae') {
         unset($items[2]);
     }
     $status = true;
     foreach ($items as $k => &$item) {
         foreach ($item as $k2 => &$info) {
             if ($info[1]) {
                 continue;
             }
             switch ($k) {
                 case 0:
                     //运行环境
                     if ($k2 == 'php') {
                         if ($info[3] >= $info[2]) {
                             $info[1] = 1;
                         } else {
                             $status = false;
                         }
                     }
                     break;
                 case 1:
                     //扩展支持
                     if ($info[4]($k2)) {
                         $info[1] = 1;
                         $info[3] = '支持';
                     } else {
                         if (in_array($k2, array('Imagick', 'Gmagick'))) {
                             break;
                         }
                         $status = false;
                     }
                     break;
                 case 2:
                     //权限检测
                     if (is_writable($info[4])) {
                         $info[1] = 1;
                         $info[3] = '可写';
                     } else {
                         $status = false;
                     }
                     break;
             }
         }
     }
     if ($status) {
         session('install_step', 2);
     }
     $this->assign('item', array($status, $items));
     $this->display();
 }
开发者ID:easytp,项目名称:easytp,代码行数:53,代码来源:IndexController.class.php


示例10: filelist_rubbish

 public function filelist_rubbish()
 {
     $File = M('File');
     $where['status'] = 0;
     $count = $File->where($where)->count();
     $Page = new \Think\Page($count, 24);
     $show = $Page->show();
     $filelist = $File->where($where)->field(true)->order('addtime desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
     foreach ($filelist as $key => &$val) {
         $val['size'] = format_bytes($val['size']);
     }
     $this->assign('filelist', $filelist);
     $this->assign('pages', $show);
     $this->display();
 }
开发者ID:licaikai,项目名称:baby,代码行数:15,代码来源:FileController.class.php


示例11: hasErrors

 public function hasErrors()
 {
     // check file size
     if ($this->maxFileSize && $_FILES[$this->altName()]['size'] > $this->maxFileSize) {
         $this->errors[] = t('The file size exceeds max of ' . format_bytes($this->maxFileSize));
     }
     // file extensions allowed validator
     if ($this->allowedExtensions) {
         $extValidator = new \Meta\Validation\FileExtension(array('allowedExtensions' => $this->allowedExtensions, 'value' => $this->getValue()));
         if (!$extValidator->execute()) {
             $this->errors[] = $extValidator->error();
         }
     }
     return count($this->errors) > 0;
 }
开发者ID:moiseh,项目名称:codegen,代码行数:15,代码来源:File.php


示例12: importlist

 /**
  * 数据库还原列表
  */
 public function importlist()
 {
     if (IS_POST) {
         $path = C('DATA_BACKUP_PATH');
         if (!is_dir($path)) {
             mkdir($path, 0755, true);
         }
         $path = realpath($path);
         $flag = \FilesystemIterator::KEY_AS_FILENAME;
         $glob = new \FilesystemIterator($path, $flag);
         $list = array();
         foreach ($glob as $name => $file) {
             if (preg_match('/^\\d{8,8}-\\d{6,6}-\\d+\\.sql(?:\\.gz)?$/', $name)) {
                 $name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d');
                 $date = "{$name[0]}-{$name[1]}-{$name[2]}";
                 $time = "{$name[3]}:{$name[4]}:{$name[5]}";
                 $part = $name[6];
                 if (isset($list["{$date} {$time}"])) {
                     $info = $list["{$date} {$time}"];
                     $info['part'] = max($info['part'], $part);
                     $info['size'] = $info['size'] + $file->getSize();
                 } else {
                     $info['part'] = $part;
                     $info['size'] = $file->getSize();
                 }
                 $extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
                 $info['compress'] = $extension === 'SQL' ? '-' : $extension;
                 $info['time'] = strtotime("{$date} {$time}");
                 $list["{$date} {$time}"] = $info;
             }
         }
         $temp = array();
         foreach ($list as $key => $value) {
             $list[$key]['name'] = date('Ymd-His', strtotime($key));
             $list[$key]['datetime'] = date('Y-m-d H:i:s', strtotime($key));
             $list[$key]['size'] = format_bytes($list[$key]['size']);
             $temp[] = $list[$key];
         }
         $list = $temp;
         $this->ajaxReturn($list);
     } else {
         $currentpos = D('Menu')->currentPos(I('get.menuid'));
         //栏目位置
         $treegrid = array('options' => array('title' => $currentpos, 'url' => U('Database/importlist', array('grid' => 'treegrid')), 'idField' => 'time', 'treefield' => 'time'), 'fields' => array('备份名称' => array('field' => 'name', 'width' => 80), '卷数' => array('field' => 'part', 'width' => 50), '压缩' => array('field' => 'compress', 'width' => 50), '数据大小' => array('field' => 'size', 'width' => 50, 'formatter' => 'function(size){return "<font color=green>"+size+"</font>";}'), '备份时间' => array('field' => 'datetime', 'width' => 80, 'formatter' => 'function(datetime){return "<font color=red>"+datetime+"</font>";}'), '管理操作' => array('field' => 'time', 'width' => 80, 'formatter' => 'databaseImportModule.operate')));
         $this->assign('treegrid', $treegrid);
         $this->display("import");
     }
 }
开发者ID:tiger2soft,项目名称:app,代码行数:51,代码来源:DatabaseController.class.php


示例13: build_folder_structure

/**
 *  Recursively construct the proper HTML
 *  for representing a folder full of items
 *
 *  @param array $dirs       array of directory objects to process
 *  @param array $path_array path components in array form
 *  @param array $item_info  metadata about each item
 *
 *  @return void
 *
 *  @author Ken Auberry <[email protected]>
 */
function build_folder_structure(&$dirs, $path_array, $item_info)
{
    if (count($path_array) > 1) {
        if (!isset($dirs['folders'][$path_array[0]])) {
            $dirs['folders'][$path_array[0]] = array();
        }
        build_folder_structure($dirs['folders'][$path_array[0]], array_splice($path_array, 1), $item_info);
    } else {
        $size_string = format_bytes($item_info['size']);
        $item_id = $item_info['item_id'];
        $url = base_url() . "myemsl/itemauth/{$item_id}";
        $item_info['url'] = $url;
        $item_info_json = json_encode($item_info);
        $dirs['files'][$item_id] = "<a class='item_link' id='item_{$item_id}' href='#'>{$path_array[0]}</a> <span class='fineprint'>[size: {$size_string}]</span><span class='item_data_json' id='item_id_{$item_id}' style='display:none;'>{$item_info_json}</span>";
    }
}
开发者ID:EMSL-MSC,项目名称:pacifica-reporting,代码行数:28,代码来源:item_helper.php


示例14: drive_details

function drive_details($drive)
{
    if (isset($drive["fsSize"])) {
        $pdsize = $drive["fsSize"] * 1024;
        $pfree = $drive["fsFree"] * 1024;
        $pused = $pdsize - $pfree;
        $pused_size = $pused / $pdsize * 100;
        $output['used'] = format_bytes($pused, true, '', '');
        $output['free'] = format_bytes($pfree, true, '', '');
        $output['percent'] = $pused_size;
    }
    $output['id'] = $drive["id"] . " (" . $drive["device"] . ")";
    $output['temp'] = $drive['temp'];
    $output['size'] = format_bytes($drive["size"] * 1024);
    $output['errors'] = $drive['numErrors'];
    return $output;
}
开发者ID:bigjme93,项目名称:Aesir,代码行数:17,代码来源:utility_helper.php


示例15: file_list_upload

/**
 * 上传目录列表
 * @param string $path 目录名
 * @return array
 */
function file_list_upload($path)
{
    $config = C('TMPL_PARSE_STRING');
    switch (strtoupper(C('FILE_UPLOAD_TYPE'))) {
        case 'SAE':
            $path = str_replace(DS, '/', rtrim($path, DS));
            $arr = explode('/', ltrim($path, './'));
            $domain = array_shift($arr);
            $filePath = implode('/', $arr);
            $s = new SaeStorage();
            $list = $s->getListByPath($domain, $filePath);
            $res = array();
            while (isset($list['dirNum']) && $list['dirNum']) {
                $list['dirNum']--;
                array_push($res, array('type' => 'dir', 'name' => $list['dirs'][$list['dirNum']]['name'], 'path' => ltrim($list['dirs'][$list['dirNum']]['fullName'], 'upload/'), 'size' => '-', 'mtime' => '-', 'url' => '#'));
            }
            while (isset($list['fileNum']) && $list['fileNum']) {
                $list['fileNum']--;
                array_push($res, array('type' => 'file', 'name' => $list['files'][$list['fileNum']]['Name'], 'path' => ltrim($list['files'][$list['fileNum']]['fullName'], 'upload/'), 'size' => format_bytes($list['files'][$list['fileNum']]['length'], ' '), 'mtime' => date('Y-m-d H:i:s', $list['files'][$list['fileNum']]['uploadTime']), 'url' => ltrim($list['files'][$list['fileNum']]['fullName'], 'upload/')));
            }
            return $res;
            break;
        case 'FTP':
            $storage = new \Common\Plugin\Ftp();
            $list = $storage->ls($path);
            foreach ($list as &$item) {
                $item['path'] = ltrim($item['path'], UPLOAD_PATH);
                $item['url'] = str_replace('\\', '/', $item['path']);
            }
            return $list;
            break;
        default:
            $path = realpath($path);
            $path = str_replace(array('/', '\\'), DS, $path);
            $list = glob($path . DS . '*');
            $res = array();
            foreach ($list as $key => $filename) {
                array_push($res, array('type' => is_dir($filename) ? 'dir' : 'file', 'name' => basename($filename), 'path' => ltrim(str_replace(realpath(UPLOAD_PATH), '', $filename), DS), 'size' => format_bytes(filesize($filename), ' '), 'mtime' => date('Y-m-d H:i:s', filemtime($filename)), 'url' => ltrim(str_replace(array(realpath(UPLOAD_PATH), '\\'), array('', '/'), $filename), '/')));
            }
            return $res;
    }
}
开发者ID:tiger2soft,项目名称:app,代码行数:47,代码来源:function.php


示例16: testFormatBytes

 public function testFormatBytes()
 {
     $this->assertSame('10 B', format_bytes(10));
     $this->assertSame('100 B', format_bytes(100));
     $this->assertSame('1,0 kB', format_bytes(1000));
     $this->assertSame('1,0 kB', format_bytes(1024));
     $this->assertSame('1,0 kB', format_bytes(1025));
     $this->assertSame('1 kB', format_bytes(1025, 0));
     $this->assertSame('15 kB', format_bytes(15245, 0));
     $this->assertSame('15 kB', format_bytes(15645, 0));
     $this->assertSame('15,3 kB', format_bytes(15645));
     $this->assertSame('15,6 kB', format_bytes(15945));
     $this->assertSame('16 kB', format_bytes(15945, 0));
     $this->assertSame('15 MB', format_bytes(15945987, 0));
     $this->assertSame('15,2 MB', format_bytes(15945987));
     $this->assertSame('2 GB', format_bytes(2000000000, 0));
     $this->assertSame('3 TB', format_bytes(3000000000000, 0));
     $this->assertSame('1 TB', format_bytes(1000000000000, 0));
     $this->assertSame('1 PB', format_bytes(1000000000000000, 0));
     $this->assertSame('8 PB', format_bytes(9000000000000000, 0));
 }
开发者ID:matriphe,项目名称:format,代码行数:21,代码来源:FormatHelperTest.php


示例17: get_backups

 public function get_backups()
 {
     $bdir = $this->_get_backup_dir();
     if (!file_exists($bdir)) {
         $this->_backup_summary['info'] = "No backups";
         return $this->_backup_summary;
     }
     $files = scandir($bdir);
     if (count($files) < 1) {
         $this->_backup_summary['info'] = "No backups";
         return null;
     }
     $bupfiles = preg_grep("/^backup\\-*/", $files);
     if (count($bupfiles) < 1) {
         $this->_backup_summary['info'] = "No backups";
         return null;
     }
     $total_size = 0;
     $bburl = $this->site->siteurl . $this->_get_backup_dir();
     foreach ($bupfiles as $b) {
         $this->_backup_summary['count']++;
         $size = filesize($bdir . $b);
         $total_size += $size;
         $m = $this->_bb_regex($b);
         $d = $m['date'];
         $t = $m['type'];
         if ($t == 'full' && $d > $this->_backup_summary['lastfull']) {
             $this->_backup_summary['lastfull'] = $d;
             $this->_backup_summary['fullurl'] = $bburl . $b;
         } else {
             if ($t == 'db' && $d > $this->_backup_summary['lastdb']) {
                 $this->_backup_summary['lastdb'] = $d;
                 $this->_backup_summary['dburl'] = $bburl . $b;
             }
         }
         $this->_backups[$b] = array('size' => $size, 'date' => $d, 'type' => $t, 'url' => $bburl . $b, 'dir' => $bdir . $b);
     }
     $this->_backup_summary['totalsize'] = format_bytes($total_size);
     return $this->_backups;
 }
开发者ID:rustyeddy,项目名称:sandbox,代码行数:40,代码来源:backupbuddy.php


示例18: check_config

/**
 * check_config
 * This checks the script configuration... Like upload limit, thumbs, etc. 
 */
function check_config()
{
    global $config, $install_errors;
    if (!defined('HTTP_HOST')) {
        $install_errors[] = 'Can\'t resolve <code>HTTP_HOST</code>. Please check at the bottom of <code>config.php</code>';
    }
    // Upload limit vs php.ini value -> http://php.net/manual/ini.php
    $ini_upload_bytes = return_bytes(trim(ini_get('upload_max_filesize')) . 'B');
    $max_size_bytes = return_bytes($config['max_filesize']);
    if (!is_numeric($max_size_bytes)) {
        $install_errors[] = 'Invalid numeric value in <code>$config[\'max_filesize\']</code>';
    } else {
        if ($ini_upload_bytes < $max_size_bytes) {
            $install_errors[] = 'Max. image size (' . $config['max_filesize'] . ') is greater than the value in <code>php.ini</code> (' . format_bytes($ini_upload_bytes) . ')';
        }
    }
    if (!is_int($config['thumb_width'])) {
        $install_errors[] = 'Invalid thumb size width in <code>$config[\'thumb_width\']</code>';
    }
    if (!is_int($config['thumb_height'])) {
        $install_errors[] = 'Invalid thumb size height in <code>$config[\'thumb_height\']</code>';
    }
    if (!is_int($config['min_resize_size']) || $config['min_resize_size'] < 0) {
        $install_errors[] = 'Invalid minimum resize size in <code>$config[\'min_resize_size\']</code>';
    }
    if (!is_int($config['max_resize_size']) || $config['max_resize_size'] < 0) {
        $install_errors[] = 'Invalid maximum resize size in <code>$config[\'max_resize_size\']</code>';
    }
    if (is_int($config['min_resize_size']) && is_int($config['max_resize_size']) && $config['min_resize_size'] > $config['max_resize_size']) {
        $install_errors[] = 'Minimum resize size can\'t be larger than maximum resize size. Please check <code>$config[\'min_resize_size\']</code> and <code>$config[\'max_resize_size\']</code>';
    }
    if (!conditional_config('multiupload')) {
        $config['multiupload_limit'] = 1;
    } else {
        if ($config['multiupload_limit'] <= 0 || $config['multiupload_limit'] == '') {
            $config['multiupload_limit'] = 0;
        }
    }
    if (!check_value(chevereto_config('file_naming')) || !in_array(chevereto_config('file_naming'), array('original', 'random', 'mixed'))) {
        $config['file_naming'] = 'original';
    }
    if (!is_numeric($config['multiupload_limit']) && !is_bool($config['multiupload_limit'])) {
        $install_errors[] = 'Invalid multiupload limit value in <code>$config[\'multiupload_limit\']</code>';
    }
    if ($config['multiupload_limit'] > 100) {
        $install_errors[] = 'Multiupload limit value can\'t be higher than 100 in <code>$config[\'multiupload_limit\']</code>';
    }
    if ($config['short_url_service'] == 'bitly') {
        $bitly_status = fetch_url('http://api.bit.ly/v3/validate?x_login=' . $config['short_url_user'] . '&x_apiKey=' . $config['short_url_keypass'] . '&apiKey=' . $config['short_url_keypass'] . '&login=' . $config['short_url_user'] . '&format=json');
        $bitly_json = json_decode($bitly_status);
        if ($bitly_json->data->valid !== 1) {
            $install_errors[] = 'The <a href="http://bit.ly/" target="_blank">bit.ly</a> user/api is invalid. bitly server says <code>' . $bitly_json->status_txt . '</code>. Please double check your data.';
        }
    }
    // Facebook comments
    if (use_facebook_comments() && !check_value($config['facebook_app_id'])) {
        $install_errors[] = 'You are are trying to use Facebook comments but <code>$config[\'facebook_app_id\']</code> is not setted.';
    }
    // Virtual folders
    foreach (array('virtual_folder_image', 'virtual_folder_uploaded') as $value) {
        if (!check_value($config[$value])) {
            $install_errors[] = '<code>$config[\'' . $value . '\']</code> is not setted.';
        }
    }
    // Passwords
    if ($config['user_password'] == $config['admin_password']) {
        $install_errors[] = 'Admin and user passwords must be different. Please check <code>$config[\'admin_password\']</code> and <code>$config[\'user_password\']</code>';
    }
    // Flood report email?
    if (check_value($config['flood_report_email']) && !check_email_address($config['flood_report_email'])) {
        $install_errors[] = 'It appears that <code>$config[\'flood_report_email\']</code> has a invalid email address';
    }
    // Watermark
    if (conditional_config('watermark_enable')) {
        define('__CHV_WATERMARK_FILE__', __CHV_ROOT_DIR__ . ltrim($config['watermark_image'], '/'));
        if (!is_int($config['watermark_margin'])) {
            $install_errors[] = 'Watermark margin must be integer in <code>$config[\'watermark_margin\']</code>';
        }
        if (!is_int($config['watermark_opacity'])) {
            $install_errors[] = 'Watermark opacity must be integer in <code>$config[\'watermark_opacity\']</code>';
        }
        if ($config['watermark_opacity'] > 100 or $config['watermark_opacity'] < 0) {
            $install_errors[] = 'Watermark opacity value out of limis (' . $config['watermark_opacity'] . '). <code>$config[\'watermark_opacity\']</code> must be in the range 0 to 100';
        }
        // Watermark position
        if (!check_value($config['watermark_position'])) {
            $config['watermark_position'] = 'center center';
        }
        $watermark_position = explode(' ', strtolower($config['watermark_position']));
        if (!isset($watermark_position[1])) {
            $watermark_position[1] = 'center';
        }
        if (preg_match('/^left|center|right$/', $watermark_position[0])) {
            $config['watermark_x_position'] = $watermark_position[0];
        } else {
            $install_errors[] = 'Invalid watermark horizontal position in <code>$config[\'watermark_position\']</code>';
//.........这里部分代码省略.........
开发者ID:JJaicmkmy,项目名称:Chevereto,代码行数:101,代码来源:functions.php


示例19: htmlspecialchars

								<td width="78%" class="listr">
									<?php 
        echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
        echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
        ?>
								</td>
							</tr>
							<tr>
								<td width="22%" class="vncellt"><?php 
        echo gettext("In/out packets (block)");
        ?>
</td>
								<td width="78%" class="listr">
									<?php 
        echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
        echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
        ?>
								</td>
							</tr>
                                <?php 
        if (isset($ifinfo['inerrs'])) {
            ?>
							<tr>
								<td width="22%" class="vncellt"><?php 
            echo gettext("In/out errors");
            ?>
</td>
								<td width="78%" class="listr">
									<?php 
            echo htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);
            ?>
开发者ID:hlcherub,项目名称:core,代码行数:31,代码来源:status_interfaces.php


示例20: htmlspecialchars

/"><?php 
    echo $item["id"];
    ?>
</a></td>
					<td class="wrap"><?php 
    echo htmlspecialchars($item["filename"]);
    ?>
</td>
					<td><?php 
    echo $item["mimetype"];
    ?>
</td>
					<td class="nowrap" data-sort-value="<?php 
    echo $item["date"];
    ?>
"><?php 
    echo date("r", $item["date"]);
    ?>
</td>
					<td><?php 
    echo format_bytes($item["filesize"]);
    ?>
</td>
				&l 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP format_bytes_billing函数代码示例发布时间:2022-05-15
下一篇:
PHP format_bi函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap