本文整理汇总了PHP中byte_format函数的典型用法代码示例。如果您正苦于以下问题:PHP byte_format函数的具体用法?PHP byte_format怎么用?PHP byte_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了byte_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($action = '')
{
$folders = array('/system/cache/' => FALSE, '/system/cache/templates_c/' => FALSE, '/uploads/' => FALSE, '/uploads/images' => FALSE, '/uploads/files' => FALSE, '/uploads/media' => FALSE, '/captcha/' => FALSE);
foreach ($folders as $k => $v) {
$folders[$k] = is_really_writable(PUBPATH . $k);
}
$this->template->assign('folders', $folders);
if ($this->db->dbdriver == 'mysql') {
$this->load->helper('number');
$sql = "SHOW TABLE STATUS FROM `" . $this->db->database . "`";
$query = $this->db->query($sql)->result_array();
// Get total DB size
$total_size = 0;
$total_rows = 0;
foreach ($query as $k => $v) {
$total_size += $v['Data_length'] + $v['Index_length'];
$total_rows += $v['Rows'];
}
$sql = "SELECT VERSION()";
$query = $this->db->query($sql);
$version = $query->row_array();
$this->template->add_array(array('db_version' => $version['VERSION()'], 'db_size' => byte_format($total_size), 'db_rows' => $total_rows));
}
$this->template->show('sys_info', FALSE);
}
示例2: getFileSize
function getFileSize( $fpath ) {
$k = "";
if( file_exists( $fpath ) ) {
$size = filesize( $fpath );
$k = byte_format($size);
}
return $k;
}
示例3: testElement
public function testElement()
{
$this->assertEquals('456 Bytes', byte_format(456));
$this->assertEquals('4.5 KB', byte_format(4567));
$this->assertEquals('44.6 KB', byte_format(45678));
$this->assertEquals('447.8 KB', byte_format(456789));
$this->assertEquals('3.3 MB', byte_format(3456789));
$this->assertEquals('1.8 GB', byte_format(12345678912345));
$this->assertEquals('11,228.3 TB', byte_format(123456789123456789));
$this->assertEquals('44.61 KB', byte_format(45678, 2));
}
示例4: index
function index()
{
// $this->output->cache(1440); // 캐시 되고 있는동안 common 작동 안함
// 계정의 사용량을 구함
$account_space = `du -sb`;
$account_space = substr($account_space, 0, strlen($account_space) - 3);
// DATA 폴더의 용량을 구함
$data_path = DATA_PATH;
$data_space = `du -sb {$data_path}`;
$data_space = substr($data_space, 0, strlen($data_space) - 8);
// GD 버젼
$gd_support = extension_loaded('gd');
if ($gd_support) {
$gd_info = gd_info();
$gd_version = $gd_info['GD Version'];
} else {
$gd_version = 'GD가 설치되지 않음';
}
// MySQL 버전
$query = $this->db->query('select version() as ver');
$row = $query->row_array();
$db_version = $row['ver'];
/*
// http://kr2.php.net/manual/kr/function.mysql-stat.php
$mysql_stat = explode(' ', mysql_stat());
$a = explode(':', $mysql_stat[0]);
$db_date = $a[0] . ': ';
$days = floor($a[1]/86400);
if ($days)
$db_date .= $days . '일 ';
$hours = (floor($a[1]/3600)%24);
if ($hours)
$db_date .= $hours . '시간 ';
$min = (floor($a[1]/60)%60);
if ($min)
$db_date .= $min . '분';
$t = explode(':', $mysql_stat[2]);
$db_status = $mysql_stat[1].'<br/>';
$db_status .= $t[0].': '.number_format($t[1]).'<br/>';
$db_status .= $mysql_stat[3].'<br/>';
$db_status .= $mysql_stat[4].'<br/>';
$db_status .= $mysql_stat[5].'<br/>';
$db_status .= $mysql_stat[6].'<br/>';
$db_status .= $mysql_stat[7].'<br/>';
*/
$head = array('title' => '관리자 페이지');
$data = array('os_version' => php_uname('r'), 'ip_addr' => gethostbyname(trim(`hostname`)), 'account_space' => byte_format($account_space), 'data_space' => byte_format($data_space), 'code_space' => byte_format($account_space - $data_space), 'php_version' => phpversion(), 'zend_version' => zend_version(), 'gd_version' => $gd_version, 'max_filesize' => get_cfg_var('upload_max_filesize'), 'db_version' => $db_version, 'db_date' => '', 'db_status' => '');
widget::run('head', $head);
$this->load->view(ADM_F . '/main', $data);
widget::run('tail');
}
示例5: index
public function index()
{
$this->load->model($this->model_path);
$this->load->library(array('MK_Switch', 'MK_Tagger', 'MK_Category', 'Form_validation'));
$this->load->helper('number');
$path = $this->input->get('path');
if ($path != '') {
$path = $path . '/';
$path = str_replace('//', '/', $path);
} else {
$path = '';
}
$string1 = realpath($this->base . $path);
$string2 = realpath($this->base);
if (strstr($string1, $string2) == false) {
exit;
}
// Get popedom array
$authority = $this->mk_users->get_popedom($this->menu_uuid, $this->menu_authorize_query);
if (!$authority['list']) {
//** MK-ERROR-UNAUTHORIZED **/
show_error($this->lang_common['error_unauthorized_page'], 500);
exit;
}
//load language file
$lang_current = $this->mk_integrate->get_lang($this->lang_path);
if ($this->base . $path == $this->base) {
$name = array_slice(scandir($this->base . $path), 2);
} else {
$name = array_slice(scandir($this->base . $path), 1);
}
$full_path = $this->base . $path;
$info = array();
foreach ($name as $rows) {
$full = $this->base . $path . $rows;
$time = fileatime($full);
$info[$rows][0] = $rows;
$info[$rows][1] = date('Y-m-d H:i:s', $time);
$info[$rows][2] = byte_format(filesize($full));
unset($full);
}
$data['page_path'] = $this->page_path;
$data['lang_common'] = $this->lang_common;
$data['lang_current'] = $lang_current;
$data['menu_uuid'] = $this->menu_uuid;
$data['authority'] = $authority;
$data['file'] = $info;
$data['full_path'] = $full_path;
$data['base'] = $this->base;
$this->load->view("{$this->views_path}/file", $data);
unset($data);
}
示例6: get_byte_abbr
public function get_byte_abbr($bytes, $precision = 2, $key = FALSE)
{
$this->load->helper('number');
if ($key == FALSE) {
$num = byte_format($bytes, $precision);
$num = explode(" ", $num);
$num = $num[0];
} else {
$num = byte_format($bytes, $precision);
$num = $num;
}
return $num;
}
示例7: index
public function index()
{
$this->load->helper('number');
$this->user->restrict('Admin.Maintenance.Access');
if ($this->input->post('migrate') and $this->_migrate() === TRUE) {
redirect('maintenance');
}
if ($this->Maintenance_model->checkTables($this->input->post('tables'))) {
$this->session->set_flashdata('tables', $this->input->post('tables'));
redirect('maintenance/backup');
}
$this->template->setTitle($this->lang->line('text_title'));
$this->template->setHeading($this->lang->line('text_heading'));
$this->template->setButton($this->lang->line('button_backup'), array('class' => 'btn btn-primary', 'onclick' => '$(\'#tables-form\').submit();'));
$this->template->setButton($this->lang->line('button_migrate'), array('class' => 'btn btn-success', 'onclick' => '$(\'#migrate-form\').submit();'));
$data['backup_tables'] = FALSE;
$data['db_tables'] = array();
$db_tables = $this->Maintenance_model->getdbTables();
foreach ($db_tables as $db_table) {
$data['db_tables'][] = array('name' => $db_table['table_name'], 'records' => $db_table['table_rows'], 'data_length' => byte_format($db_table['data_length']), 'index_length' => byte_format($db_table['index_length']), 'data_free' => byte_format($db_table['data_free']), 'engine' => $db_table['engine'], 'browse' => site_url('maintenance/browse_table/' . $db_table['table_name']));
}
$data['backup_files'] = array();
$backup_files = glob(ROOTPATH . 'assets/downloads/*.sql');
if (count($backup_files) > 0) {
foreach ($backup_files as $backup_file) {
$basename = basename($backup_file);
$data['backup_files'][] = array('filename' => $basename, 'size' => filesize($backup_file), 'download' => site_url('maintenance/backup?download=' . $basename), 'restore' => site_url('maintenance/backup?restore=' . $basename), 'delete' => site_url('maintenance/backup?delete=' . $basename));
}
}
$this->load->library('migration');
$data['installed_version'] = $this->migration->get_version();
$data['latest_version'] = $this->migration->get_latest_version();
$data['migration_files'] = array();
if ($migration_files = $this->migration->find_migrations()) {
foreach ($migration_files as $version => $migration_file) {
$migration_file = basename($migration_file);
$version = $this->migration->get_migration_number(basename($migration_file));
$data['migration_files'][$version] = $migration_file;
}
}
$this->template->setPartials(array('header', 'footer'));
$this->template->render('maintenance', $data);
}
示例8: manage
/**
* Manage Index
*/
function manage()
{
role_or_die('streams', 'admin_streams');
$this->_gather_stream_data();
// Get DB table name
$this->data->table_name = $this->data->stream->stream_prefix . $this->data->stream->stream_slug;
// Get the table data
$info = $this->db->query("SHOW TABLE STATUS LIKE '{$this->db->dbprefix($this->data->table_name)}'")->row();
// Get the size of the table
$this->load->helper('number');
$this->data->total_size = byte_format($info->Data_length);
// Last updated time
$this->data->last_updated = !$info->Update_time ? $info->Create_time : $info->Update_time;
// Get the number of rows (the table status data on this can't be trusted)
$this->data->total_rows = $this->db->count_all($this->data->table_name);
// Get the number of fields
$f_obj = $this->db->select('id')->where('stream_id', $this->data->stream->id)->get(ASSIGN_TABLE);
$this->data->num_of_fields = $f_obj->num_rows();
$this->template->build('admin/streams/manage', $this->data);
}
示例9: statistics
public function statistics()
{
$statistics = array();
/*
* 重要: 为了防止与应用别名重名,“服务器信息”、“用户信息”、“开发团队”作为key前面有空格
*/
// 服务器信息
$site_version = model('Xdata')->get('siteopt:site_system_version');
$serverInfo['核心版本'] = 'ThinkSNS ' . $site_version;
$serverInfo['服务器系统及PHP版本'] = PHP_OS . ' / PHP v' . PHP_VERSION;
$serverInfo['服务器软件'] = $_SERVER['SERVER_SOFTWARE'];
$serverInfo['最大上传许可'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : '<font color="red">no</font>';
$mysqlinfo = M('')->query("SELECT VERSION() as version");
$serverInfo['MySQL版本'] = $mysqlinfo[0]['version'];
$t = M('')->query("SHOW TABLE STATUS LIKE '" . C('DB_PREFIX') . "%'");
foreach ($t as $k) {
$dbsize += $k['Data_length'] + $k['Index_length'];
}
$serverInfo['数据库大小'] = byte_format($dbsize);
$statistics[' 服务器信息'] = $serverInfo;
unset($serverInfo);
// 用户信息
$user['当前在线'] = getOnlineUserCount();
$user['全部用户'] = M('user')->count();
$user['有效用户'] = M('user')->where('`is_active` = 1 AND `is_init` = 1')->count();
$statistics[' 用户信息'] = $user;
unset($user);
// 应用统计
$applist = array();
$res = model('App')->where('`statistics_entry`<>""')->field('app_name,app_alias,statistics_entry')->order('display_order ASC')->findAll();
foreach ($res as $v) {
$d = explode('/', $v['statistics_entry']);
$d[1] = empty($d[1]) ? 'index' : $d[1];
$statistics[$v['app_alias']] = D($d[0], $v['app_name'])->{$d}[1]();
}
// 开发团队
$statistics[' 开发团队'] = array('版权所有' => '<a href="http://www.zhishisoft.com" target="_blank">智士软件(北京)有限公司</a>', 'UI设计' => '<a href="http://weibo.com/wasdifferent" target="_blank">申川</a>、<a href="http://weibo.com/u/2134567607" target="_blank">马丽稳</a>', '项目经理' => '<a href="http://weibo.com/sunan" target="_blank">廖素南</a>', '前端设计' => '<a href="http://weibo.com/u/2025142915" target="_blank">牛文涛</a>、<a href="http://weibo.com/u/1087964144" target="_blank">樊翠娥</a>', '开发团队' => '<a href="http://weibo.com/sampeng" target="_blank">彭灵俊</a>、<a href="http://weibo.com/thinksns" target="_blank">刘晓庆</a>、<a href="http://weibo.com/cchhuuaann" target="_blank">陈伟川</a>、<a href="http://weibo.com/satan0714" target="_blank">王祚</a>、<a href="http://weibo.com/nonant" target="_blank">冷浩然</a>、<a href="http://weibo.com/mylovehere" target="_blank">韦新红</a>');
$this->assign('statistics', $statistics);
$this->display();
}
示例10: index
public function index()
{
$this->Purview_model->checkPurview($this->tablefunc);
$folder = $this->input->post('folder');
if (!$folder) {
$folder = $this->defaultfolder;
}
$listarr = directory_map($folder, 1);
$folderlist = array();
$phplist = array();
$csslist = array();
$jslist = array();
foreach ($listarr as $list) {
$thispath = $folder . '/' . $list;
$newlist = get_file_info($thispath);
$newlist['permissions'] = octal_permissions(fileperms($thispath));
$newlist['name'] = $list;
if (is_dir($thispath)) {
$folderlist[] = $newlist;
} else {
$newlist['size'] = byte_format($newlist['size']);
$ext = get_suffix($thispath);
switch ($ext) {
case 'php':
$phplist[] = $newlist;
break;
case 'css':
$csslist[] = $newlist;
break;
case 'js':
$jslist[] = $newlist;
break;
default:
break;
}
}
}
$res = array('tpl' => 'list', 'tablefunc' => $this->tablefunc, 'folderlist' => $folderlist, 'phplist' => $phplist, 'csslist' => $csslist, 'jslist' => $jslist, 'defaultfolder' => $this->defaultfolder, 'folder' => $folder);
$this->load->view($this->tablefunc, $res);
}
示例11: index
public function index()
{
$exts = array('html', 'css', 'js');
$type = $_GET['type'] ? $_GET['type'] : 'html';
if ($type == 'html') {
$path = $this->filepath;
} else {
$path = $this->publicpath . $type . '/';
}
$files = dir_list($path, $type);
foreach ($files as $key => $file) {
$filename = basename($file);
$templates[$key]['value'] = substr($filename, 0, strrpos($filename, '.'));
$templates[$key]['filename'] = $filename;
$templates[$key]['filepath'] = $file;
$templates[$key]['filesize'] = byte_format(filesize($file));
$templates[$key]['filemtime'] = filemtime($file);
$templates[$key]['ext'] = strtolower(substr($filename, strrpos($filename, '.') - strlen($filename)));
}
$this->assign('templates', $templates);
$this->display();
}
示例12: statistics
public function statistics()
{
$statistics = array();
/** 为了防止与应用别名重名,“服务器信息”、“用户信息”、“开发团队”作为key前面有空格 **/
// 服务器信息
$serverInfo['核心版本'] = 'ThinkSNS 2.0';
$serverInfo['服务器系统及PHP版本'] = PHP_OS . ' / PHP v' . PHP_VERSION;
$serverInfo['服务器软件'] = $_SERVER['SERVER_SOFTWARE'];
$serverInfo['最大上传许可'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : '<font color="red">no</font>';
$mysqlinfo = M('')->query("SELECT VERSION() as version");
$serverInfo['MySQL版本'] = $mysqlinfo[0]['version'];
$t = M('')->query("SHOW TABLE STATUS LIKE '" . C('DB_PREFIX') . "%'");
foreach ($t as $k) {
$dbsize += $k['Data_length'] + $k['Index_length'];
}
$serverInfo['数据库大小'] = byte_format($dbsize);
$statistics[' 服务器信息'] = $serverInfo;
unset($serverInfo);
// 用户信息
$user['当前在线'] = getOnlineUserCount();
$user['注册用户'] = M('user')->where('`is_active` = 1 AND `is_init` = 1')->count();
$statistics[' 用户信息'] = $user;
unset($user);
// 应用统计
$applist = array();
$res = model('App')->where('`statistics_entry`<>""')->field('app_name,app_alias,statistics_entry')->order('display_order ASC')->findAll();
foreach ($res as $v) {
$d = explode('/', $v['statistics_entry']);
$d[1] = empty($d[1]) ? 'index' : $d[1];
$statistics[$v['app_alias']] = D($d[0], $v['app_name'])->{$d}[1]();
}
// 开发团队
$statistics[' 开发团队'] = array('版权所有' => '<a href="http://www.zhishisoft.com" target="_blank">智士软件(北京)有限公司</a>', '项目经理' => '冯涛', '美工设计' => '赵杰', '开发团队' => '冷浩然、杨德升、刘晓庆、王祚、彭灵俊、韦心红、陈伟川');
$this->assign('statistics', $statistics);
$this->display();
}
示例13: get_unused_files
/**
* Returns array of unused media files
* (on the disk)
*
* @return array
*/
public function get_unused_files()
{
self::$ci->load->helper('number');
$directory = new RecursiveDirectoryIterator(FCPATH . Settings::get('files_path'), FilesystemIterator::SKIP_DOTS);
$fc_length = strlen(FCPATH);
$unused_size = $total_size = $nb_total = 0;
$tb_str = Settings::get('files_path') . '/.thumbs';
$tb_length = strlen($tb_str);
$files = $paths = array();
$media_paths = array();
$medias = $this->get_all();
foreach ($medias as $media) {
$media_paths[] = $media['path'];
}
foreach (new RecursiveIteratorIterator($directory) as $filename => $current) {
$path = substr($filename, $fc_length);
if (substr($path, 0, $tb_length) != $tb_str) {
$nb_total += 1;
$size = $current->getSize();
$total_size += $size;
if (!in_array($path, $media_paths)) {
$files[] = array('path' => $path, 'size' => byte_format($size, 1));
$unused_size += $size;
}
}
}
// Check for articles content
foreach ($files as $key => $file) {
$sql = "select id_article from article_lang where content like '%" . $file['path'] . "%'";
$query = $this->{$this->db_group}->query($sql);
if ($query->num_rows() > 0 || in_array(basename($file['path']), self::$_UNUSED_IGNORED_FILES)) {
unset($files[$key]);
$nb_total -= 1;
$unused_size -= filesize(DOCPATH . $file['path']);
}
}
$return = array('nb_total' => $nb_total, 'size_total' => byte_format($total_size, 2), 'files' => $files, 'size' => byte_format($unused_size, 2));
return $return;
}
示例14: foreach
<?php
if (isset($r['files'])) {
?>
<div class=-files>
<?php
foreach ($r['files'] as $vs) {
$F = dbFile($vs['file_id']);
?>
<a style="display:block" target=_blank href="<?php
echo $F->url() . '/' . $F->name();
?>
"><?php
echo $F->vs['name'];
?>
(<?php
echo byte_format($F->size());
?>
)</a>
<?php
echo cutSearch1($F->vs['text'], $search, 1);
?>
<?php
}
?>
</div>
<?php
}
?>
</div>
<?php
示例15: max
echo $node->disk_used;
?>
" aria-valuemin="0" aria-valuemax="<?php
echo $node->disk_total;
?>
" style="width: <?php
echo max($node->disk_used / $node->disk_total * 100, 1);
?>
%"></div>
</div>
</td>
<td class="hidden-xs">In: <?php
echo byte_format($node->bytes_in / 5);
?>
/s<br />Out: <?php
echo byte_format($node->bytes_out / 5);
?>
/s </td>
<td class="hidden-xs"><?php
echo elapsed_time($node->uptime);
?>
</td>
</tr>
<?php
}
?>
</table>
</div>
</div>
<?php