本文整理汇总了PHP中convert_size函数的典型用法代码示例。如果您正苦于以下问题:PHP convert_size函数的具体用法?PHP convert_size怎么用?PHP convert_size使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convert_size函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getListFiles
public function _getListFiles()
{
$files = array();
if (is_dir($this->fullpath) && ($handle = opendir($this->fullpath))) {
$i = 0;
// check each files ...
while (false !== ($file = readdir($handle))) {
// do not display . and the root ..
if ($file == '.' || $file == '..') {
continue;
}
$object = new stdClass();
$file_stat = stat($this->fullpath . $file);
// make the link depending on if it's a file or a dir
$object->is_dir = false;
$object->is_file = true;
$object->link = '<a href="' . get_url('sidebarlink/view' . $this->path . $file) . '">' . $file . '</a>';
$object->name = $file;
// humain size
$object->size = convert_size($file_stat['size']);
// permission
list($object->perms, $object->chmod) = $this->_getPermissions($this->fullpath . $file);
// date modification
$object->mtime = date('D, j M, Y', $file_stat['mtime']);
$files[$object->name] = $object;
$i++;
}
// while
closedir($handle);
}
uksort($files, 'strnatcmp');
return $files;
}
示例2: get
public static function get($name, $decimals = 4)
{
if ($name === true) {
$times = array();
foreach (array_keys(self::$marks) as $name) {
$times[$name] = self::get($name, $decimals);
}
return $times;
}
if (!isset(self::$marks[$name])) {
return false;
}
if (self::$marks[$name]['stop'] === false) {
self::stop($name);
}
return array('time' => number_format(self::$marks[$name]['stop'] - self::$marks[$name]['start'], $decimals), 'memory' => convert_size(self::$marks[$name]['memory_stop'] - self::$marks[$name]['memory_start']));
}
示例3: check_server_config
function check_server_config()
{
$upload_max_filesize = ini_get("upload_max_filesize");
$post_max_size = ini_get("post_max_size");
$max_execution_time = ini_get("max_execution_time");
$max_input_time = ini_get("max_input_time");
$all_good = true;
if (convert_size($upload_max_filesize) < 2000000000) {
$display .= "<div style='line-height: 14px;'><span class=\"red\">upload_max_filesize = {$upload_max_filesize}</span> <-- Determines the max size of the files that a user can upload in EZmanager. We recommend <b>2G</b><br/><br/></div>";
$all_good = $all_good & false;
} else {
$display .= "<div class=\"green\">upload_max_filesize = {$upload_max_filesize}</div>";
$all_good = $all_good & true;
}
if (convert_size($post_max_size) < 2000000000) {
$display .= "<div style='line-height: 14px;'><span class=\"red\">post_max_size = {$post_max_size}</span> <-- Determines the max size of post data allowed. This should be at least the value of 'upload_max_filesize'. We recommend <b>2G</b><br/><br/></div>";
$all_good = $all_good & false;
} else {
$display .= "<div class=\"green\">post_max_size = {$post_max_size}</div>";
$all_good = $all_good & true;
}
if ((int) $max_execution_time < 300) {
$display .= "<div style='line-height: 14px;'><span class=\"red\">max_execution_time = {$max_execution_time}</span> <-- Determines the maximum time in seconds a script is allowed to run before it is terminated by the parser. We recommend <b>300</b><br/><br/></div>";
$all_good = $all_good & false;
} else {
$display .= "<div class=\"green\">max_execution_time = {$max_execution_time} </div>";
$all_good = $all_good & true;
}
if ((int) $max_input_time < 300) {
$display .= "<div style='line-height: 14px;'><span class=\"red\">max_input_time = {$max_input_time}</span> <-- Determines the maximum time in seconds a script is allowed to parse input data, like POST and GET. We recommend <b>300</b><br/><br/></div>";
$all_good = $all_good & false;
} else {
$display .= "<div class=\"green\">max_input_time = {$max_input_time} </div>";
$all_good = $all_good & true;
}
if (!$all_good) {
print "<!DOCTYPE html>\n <html><head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n <title>Check PHP modules</title>\n <link href=\"css/style.css\" rel=\"stylesheet\">\n </head>\n <body>";
template_display("div_header.php");
print "<div id='login_form'>" . $display;
print "</div><div style='width: 400px; margin: auto;'><br/>Edit the '<b>" . php_ini_loaded_file() . "</b>' file to match your own needs.\n <br/><br/>If you want to continue anyway, click on the following button.\n <br/><br/><br/><a class='button' style='float: right;' href='install.php?skip_srv=true'>Continue</a></div>";
template_display("div_footer.php");
print "</body></html>";
die;
}
}
示例4: build_row
function build_row()
{
$args = func_get_args();
$array[0] = $args[1][8];
if ($args[1][2] != "" && $args[0]["owner"]) {
$array[1] = $args[1][2] . ":" . $args[1][3];
} else {
$array[1] = " ";
}
if ($args[1][5] != "" && $args[0]["date"]) {
$array[2] = $args[1][5] . " " . $args[1][6];
} else {
$array[2] = " ";
}
if ($args[1][7] != "" && $args[0]["date"]) {
$array[3] = $args[1][7];
} else {
$array[3] = " ";
}
if ($args[1][4] != "" && $args[0]["size"]) {
$array[4] = convert_size($args[1][4]);
} else {
$array[4] = " ";
}
if ($args[1][0] != "" && $args[0]["perm"]) {
$array[5] = build_perm($args[1][8], $args[1][0]);
} else {
$array[5] = " ";
}
$array[6] = $args[2];
$array[7] = get_type($args[2], $args[1][8]);
if (func_num_args() == "4") {
$array[8] = $args[3];
} else {
$array[8] = $args[1][8];
}
return $array;
}
示例5: foreach
$fields['Fitness Rating1'] = "Arduous";
$fields['Fitness Rating2'] = $fields['Fitness Rating1'];
$row_count = 1;
foreach ($incident_array as $row) {
$result = mydb::cxn()->query("\tSELECT role,qt,shifts\n\t\t\t\t\t\tFROM incident_roster\n\t\t\t\t\t\tWHERE idx like '" . $row['idx'] . "' and crewmember_id like '" . $crewmember_id . "'");
$row2 = $result->fetch_assoc();
$row['fuel_models'] = str_replace(array('1', '2', '3', '4', '5'), array("G", "B", "T", "S", " "), $row['fuel_models']);
// Convert Siskiyou fuel
$fields["Job Code" . $row_count] = strtoupper($row2['role']) . "(" . strtoupper($row2['qt']) . ")";
$fields["Type of Incident" . $row_count] = strtoupper($row['event_type']);
$fields["Date" . $row_count] = date("m/d/Y", $row['date']);
$fields["State" . $row_count] = strtoupper(substr($row['number'], 0, 2));
$fields["Operational Periods" . $row_count] = $row2['shifts'];
$fields["Management Type" . $row_count] = $row['type'];
$fields["Fuel Type" . $row_count] = $row['fuel_models'];
$fields["Fire Size" . $row_count] = convert_size($row['size']);
$fields["Incident Name" . $row_count] = strtoupper($row['name']);
$fields["Incident Order #" . $row_count] = strtoupper($row['number']);
$row_count++;
}
//END foreach($incident_array as $row)
mergePDF($template, $fields, $_SESSION['incident_year'] . "-IQCS-Update_" . $firstname . "_" . $lastname . ".pdf");
//print_r($fields);
function convert_size($acres)
{
if ($acres <= 0.25) {
$letter = "A";
} elseif ($acres > 0.25 && $acres < 10) {
$letter = "B";
} elseif ($acres >= 10 && $acres < 100) {
$letter = "C";
示例6: memory_usage
function memory_usage()
{
return convert_size(memory_get_usage());
}
示例7: _listFiles
private function _listFiles()
{
if (is_dir($this->fullpath)) {
$files = array();
$root = new DirectoryIterator($this->fullpath);
foreach ($root as $cur) {
if ($cur->isDot() || $cur->isLink()) {
continue;
}
$name = $cur->getFilename();
if (Plugin::getSetting('show_hidden', 'file_manager') == '0' && $name[0] === '.') {
continue;
}
if (Plugin::getSetting('show_backups', 'file_manager') == '0' && $name[strlen($name) - 1] === '~') {
continue;
}
$object = new stdClass();
$object->name = $cur->getFilename();
$object->is_dir = $cur->isDir();
$object->is_file = $cur->isFile();
$object->size = convert_size($cur->getSize());
$object->mtime = date('D, j M, Y', $cur->getMTime());
list($object->perms, $object->chmod) = $this->_getPermissions($cur->getPerms());
// Find the file type
$object->type = $this->_getFileType($cur);
// make the link depending on if it's a file or a dir
if ($cur->isDir()) {
$object->link = '<a href="' . get_url('plugin/file_manager/browse/' . $this->path . $object->name) . '">' . $object->name . '</a>';
} else {
$object->link = '<a href="' . get_url('plugin/file_manager/view/' . $this->path . $object->name . (endsWith($object->name, URL_SUFFIX) ? '?has_url_suffix=1' : '')) . '">' . $object->name . '</a>';
}
$files[$object->name] = $object;
}
// note - uses anonymous function so PHP 5.3+ required
uasort($files, function ($a, $b) {
if ($a->is_dir && !$b->is_dir) {
return 0;
} elseif ($b->is_dir && !$a->is_dir) {
return 1;
} else {
return strnatcmp($a->name, $b->name);
}
});
return $files;
}
return array();
}
示例8: _listFiles
private function _listFiles()
{
if (is_dir($this->fullpath)) {
$files = array();
$root = new DirectoryIterator($this->fullpath);
foreach ($root as $cur) {
if ($cur->isDot() || $cur->isLink()) {
continue;
}
$name = $cur->getFilename();
if (Plugin::getSetting('show_hidden', 'file_manager') == '0' && $name[0] === '.') {
continue;
}
if (Plugin::getSetting('show_backups', 'file_manager') == '0' && $name[strlen($name) - 1] === '~') {
continue;
}
$object = new stdClass();
$object->name = $cur->getFilename();
$object->is_dir = $cur->isDir();
$object->is_file = $cur->isFile();
$object->size = convert_size($cur->getSize());
$object->mtime = date('D, j M, Y', $cur->getMTime());
list($object->perms, $object->chmod) = $this->_getPermissions($cur->getPerms());
// Find the file type
$object->type = $this->_getFileType($cur);
// make the link depending on if it's a file or a dir
if ($cur->isDir()) {
$object->link = '<a href="' . get_url('plugin/file_manager/browse/' . $this->path . $object->name) . '">' . $object->name . '</a>';
} else {
$object->link = '<a href="' . get_url('plugin/file_manager/view/' . $this->path . $object->name) . '">' . $object->name . '</a>';
}
$files[$object->name] = $object;
}
uksort($files, 'strnatcmp');
return $files;
}
return array();
}
示例9: convert_size
<?php
//目录操作
$base_dir = "D:/www/";
echo $base_dir . "<hr/>";
echo '磁盘空间剩余: ' . convert_size(disk_free_space($base_dir)) . '<br />';
echo '目录路径: ' . dirname($base_dir) . '<br />';
echo '文件名名称: ' . basename($base_dir) . '<br />';
echo '<hr />';
$fso = @opendir($base_dir);
//打开目录 失败返回false
if ($fso) {
while ($flist = readdir($fso)) {
echo $flist . ' - ' . filetype($flist) . '<br />';
}
closedir($fso);
}
//------------------------------
$file = 'dirlist.php';
if (is_readable($file) == false) {
die('文件不存在或者无法读取');
} else {
echo '存在';
}
//--------------------------------
//创建文件夹
if (isset($_REQUEST['dir'])) {
$new_dir = $base_dir . trim($_REQUEST['dir']);
if (!file_exists($new_dir)) {
mkdir($new_dir, 0777);
//rmdir() 删除目录
示例10: ini_get
<?php
echo "<a href='?f={$file}' class='right'> <b>Apagar Arquivo Log</b> </a>";
?>
<br clear="all" />
<br clear="all" />
<br clear="all" />
<br clear="all" />
<h1>Dados do Servidor</h1>
<div class="log dados_servidor">
<div class="left"><b>Memória Limite:</b><span> <?php
echo ini_get('memory_limit');
?>
</span></div>
<div class="left"><b>Memória Usada :</b><span> <?php
echo convert_size(memory_get_peak_usage(true));
?>
</span></div>
<?php
function get_memory()
{
foreach (file('/proc/meminfo') as $ri) {
$m[strtok($ri, ':')] = strtok('');
}
return 100 - round(($m['MemFree'] + $m['Buffers'] + $m['Cached']) / $m['MemTotal'] * 100);
}
//echo get_memory();
?>
</div>