本文整理汇总了PHP中format_filesize函数的典型用法代码示例。如果您正苦于以下问题:PHP format_filesize函数的具体用法?PHP format_filesize怎么用?PHP format_filesize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format_filesize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get($params)
{
$shopId = $this->__checkAuth($params);
$filter['disabled'] = 0;
$filter['target_id'] = $shopId;
$filter['target_type'] = 'shop';
if ($params['img_type'] != 'all') {
$filter['img_type'] = $params['img_type'] != 'other' ? $params['img_type'] : '';
}
if ($params['image_name']) {
$filter['image_name|has'] = $params['image_name'];
}
$total = app::get('image')->model('images')->count($filter);
$result['total'] = $total;
if ($total) {
$page = $this->__page($total, $params['page_no'], $params['page_size']);
$orderBy = $params['orderBy'] ? $params['orderBy'] : 'last_modified desc';
$result['list'] = app::get('image')->model('images')->getList('*', $filter, $page['offset'], $page['limit'], $orderBy);
foreach ($result['list'] as $k => $v) {
$result['list'][$k]['format_size'] = format_filesize($v['size']);
}
} else {
$result['list'] = [];
}
return $result;
}
示例2: test_format_filesize
function test_format_filesize()
{
$this->assertEquals(format_filesize(-25), '-25 b');
$this->assertEquals(format_filesize(25), '25 b');
$this->assertEquals(format_filesize(2500), '2 KB');
$this->assertEquals(format_filesize(2500000), '2.4 MB');
$this->assertEquals(format_filesize(25000000), '23.8 MB');
$this->assertEquals(format_filesize(2500000000), '2.3 GB');
}
示例3: format_files_column_value
protected function format_files_column_value($col, $object, $template_url) {
$html = "";
switch ($col) {
case 'icon': $html .= "<td class='table_row_value'><img src='".array_var($object, 'icon')."' alt='icon'/></td>"; break;
case 'icon_l': $html .= "<td class='table_row_value'><img src='".array_var($object, 'icon_l')."' alt='icon'/></td>"; break;
case 'name': $html .= "<td class='table_row_value'><a href='$template_url'>".array_var($object, 'name')."</a></td>";break;
case 'size': $html .= "<td class='table_row_value'>".format_filesize(array_var($object, 'size'))."</td>"; break;
default : $html .= "<td class='table_row_value'>".array_var($object, $col, '')."</td>"; break;
}
return $html;
}
示例4: index
public function index()
{
requireadmin();
$query = $this->mdb->dashboard();
$items = array();
if ($query->num_rows()) {
$row = $query->row();
$admins = array();
$adminsQ = $this->mdb->get_admins();
foreach ($adminsQ->result() as $adminRow) {
$admins[] = array('id' => $adminRow->id, 'display_name' => $adminRow->display_name);
}
$items = array('projects' => number_format($row->projects), 'users_active' => number_format($row->active_users), 'users_pending' => number_format($row->pending_users), 'users_banned' => number_format($row->banned_users), 'storage_used' => format_filesize($row->storage_used), 'admins' => $admins);
}
generate_json(array('status' => 1, 'items' => $items));
}
示例5: get_ls
/**
* Handle list directory requests (/filemanager/api/ls).
*/
public function get_ls()
{
$file = urldecode(join('/', func_get_args()));
$res = FileManager::dir($file);
if (!$res) {
return $this->error(FileManager::error());
}
foreach ($res['dirs'] as $k => $dir) {
$res['dirs'][$k]['mtime'] = I18n::date_time($dir['mtime']);
}
foreach ($res['files'] as $k => $file) {
$res['files'][$k]['mtime'] = I18n::date_time($file['mtime']);
$res['files'][$k]['fsize'] = format_filesize($file['fsize']);
}
return $res;
}
示例6: get_portable_serverinfo
function get_portable_serverinfo()
{
echo '
<br class="clear" />
<table class="widefat">
<thead>
<tr>
<th>Variable Name</th>
<th>Value</th>
<th>Variable Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>OS</td>
<td>' . PHP_OS . '</td>
<td>Database Data Disk Usage</td>
<td>' . format_filesize(get_mysql_data_usage()) . '</td>
</tr>
<tr class="alternate">
<td>Server</td>
<td>' . $_SERVER['SERVER_SOFTWARE'] . '</td>
<td>Database Index Disk Usage</td>
<td>' . format_filesize(get_mysql_index_usage()) . '</td>
</tr>
<tr>
<td>PHP</td>
<td>v' . PHP_VERSION . '</td>
<td>MYSQL Maximum Packet Size</td>
<td>' . format_filesize(get_mysql_max_allowed_packet()) . '</td>
</tr>
<tr class="alternate">
<td>MYSQL</td>
<td>v' . get_mysql_version() . '</td>
<td>MYSQL Maximum Allowed Connections</td>
<td>' . number_format_i18n(get_mysql_max_allowed_connections()) . '</td>
</tr>
</tbody>
</table>
<br class="clear" />';
}
示例7: get_ls
/**
* Handle list directory requests (/filemanager/api/ls).
*/
public function get_ls()
{
$file = urldecode(join('/', func_get_args()));
if (!self::verify_folder($file, $this->root)) {
return $this->error(i18n_get('Invalid folder name'));
}
$d = dir($this->root . $file);
$out = array('dirs' => array(), 'files' => array());
while (false != ($entry = $d->read())) {
if (preg_match('/^\\./', $entry)) {
continue;
} elseif (@is_dir($this->root . $file . '/' . $entry)) {
$out['dirs'][] = array('name' => $entry, 'path' => ltrim($file . '/' . $entry, '/'), 'mtime' => I18n::date_time(filemtime($this->root . $file . '/' . $entry)));
} else {
$out['files'][] = array('name' => $entry, 'path' => ltrim($file . '/' . $entry, '/'), 'mtime' => I18n::date_time(filemtime($this->root . $file . '/' . $entry)), 'fsize' => format_filesize(filesize($this->root . $file . '/' . $entry)));
}
}
$d->close();
usort($out['dirs'], array('FileManager', 'fsort'));
usort($out['files'], array('FileManager', 'fsort'));
return $out;
}
示例8: implode
$sql = "";
$first_row = true;
}
}
}
$processed_objects[] = $cobj->getId();
// check memory to stop script
if (count($processed_objects) >= OBJECT_COUNT || memory_get_usage(true) > SCRIPT_MEMORY_LIMIT) {
$processed_objects_ids = "(" . implode("),(", $processed_objects) . ")";
DB::execute("INSERT INTO " . TABLE_PREFIX . "processed_objects (object_id) VALUES {$processed_objects_ids} ON DUPLICATE KEY UPDATE object_id=object_id");
$rest = Objects::count("id NOT IN(SELECT object_id FROM " . TABLE_PREFIX . "processed_objects)");
$row = DB::executeOne("SELECT COUNT(object_id) AS 'row_count' FROM " . TABLE_PREFIX . "processed_objects");
$proc_count = $row['row_count'];
$status_message = "Memory limit exceeded (" . format_filesize(memory_get_usage(true)) . "). Script terminated. Processed Objects: {$proc_count}. Total: " . ($proc_count + $rest) . ". Please execute 'Fill searchable objects and sharing table' again.";
$_SESSION['hide_back_button'] = 1;
complete_migration_print("\n" . date("H:i:s") . " - Iteration finished or Memory limit exceeded (" . format_filesize(memory_get_usage(true)) . ") script terminated.\nProcessed Objects: " . count($processed_objects) . ".\nTotal processed objects: {$proc_count}.\n{$rest} objects left.\n{$separator}\n");
$processed_objects = array();
break;
}
$cant++;
} else {
$processed_objects[] = $obj;
}
$cobj = null;
}
// add mails to sharing table for account owners
if ($sql != "") {
$sql .= " ON DUPLICATE KEY UPDATE group_id=group_id;";
DB::execute($sql);
$sql = "";
}
示例9: chdir
<?php
chdir(dirname(__FILE__));
header("Content-type: text/plain");
define("CONSOLE_MODE", true);
include "init.php";
Env::useHelper('format');
define('SCRIPT_MEMORY_LIMIT', 1024 * 1024 * 1024);
// 1 GB
@set_time_limit(0);
ini_set('memory_limit', SCRIPT_MEMORY_LIMIT / (1024 * 1024) + 50 . 'M');
$i = 0;
$objects_ids = Objects::instance()->findAll(array('columns' => array('id'), 'id' => true));
//,'conditions' => 'object_type_id = 6'
echo "\nObjects to process: " . count($objects_ids) . "\n-----------------------------------------------------------------";
foreach ($objects_ids as $object_id) {
$object = Objects::findObject($object_id);
$i++;
if ($object instanceof ContentDataObject) {
$members = $object->getMembers();
DB::execute("DELETE FROM " . TABLE_PREFIX . "object_members WHERE object_id = " . $object->getId() . " AND is_optimization = 1;");
ObjectMembers::addObjectToMembers($object->getId(), $members);
} else {
//
}
if ($i % 100 == 0) {
echo "\n{$i} objects processed. Mem usage: " . format_filesize(memory_get_usage(true));
}
}
示例10: if
if(empty($record['description'])) $record['description'] = JText::_('STATS_LABEL_NODESCRIPTION');
?>
<tr class="row<?php echo $id; ?>">
<td><?php echo $check; ?></td>
<td>
<?php echo $this->escape($record['description']) ?>
</td>
<td>
<?php if( AKEEBA_JVERSION == '16' ): ?>
<?php echo $startTime->format(JText::_('DATE_FORMAT_LC2'), true); ?>
<?php else: ?>
<?php echo $startTime->toFormat(JText::_('DATE_FORMAT_LC2')); ?>
<?php endif; ?>
</td>
<td class="bufa-<?php echo $record['meta']; ?>"><?php echo $status ?></td>
<td><?php echo ($record['meta'] == 'ok') ? format_filesize($record['size']) : ($record['total_size'] > 0 ? "(<i>".format_filesize($record['total_size'])."</i>)" : '—') ?></td>
<td>
<?php echo $filename_col; ?>
<?php if($record['meta'] == 'ok'): ?>
<br/>
<?php
$infoParts = explode("\n", $record['comment']);
$info = json_decode($infoParts[1]);
?>
<?php echo JText::_($info->type) .': '. $info->name ?>
<?php if($info->version): ?>
•
<?php echo JText::_('BUADMIN_LABEL_VERSION')?>: <?php echo $info->version ?>
<?php if($info->date) echo " • "?>
<?php endif?>
<?php if($info->date): ?>
示例11: array
<li>
<?php
$attached_file_options = array();
$attached_file_options[] = '<a href="' . $attached_file->getDetailsUrl() . '">' . lang('file details') . '</a>';
if ($attached_files_object->canDetachFile(logged_user(), $attached_file)) {
$attached_file_options[] = '<a href="' . $attached_files_object->getDetachFileUrl($attached_file) . '" onclick="return confirm(\'' . lang('confirm detach file') . '\')">' . lang('detach file') . '</a>';
}
?>
<a href="<?php
echo $attached_file->getDownloadUrl();
?>
"><span><?php
echo clean($attached_file->getFilename());
?>
</span> (<?php
echo format_filesize($attached_file->getFilesize());
?>
)</a> | <?php
echo implode(' | ', $attached_file_options);
?>
</li>
<?php
}
// foreach
?>
</ul>
<?php
if ($attached_files_object->canAttachFile(logged_user(), $attached_files_object->getProject())) {
?>
<p><a href="<?php
echo $attached_files_object->getAttachFilesUrl();
示例12: SaveMail
function SaveMail(&$content, MailAccount $account, $uidl, $state = 0, $imap_folder_name = '')
{
if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
self::log_connection_status();
Logger::log("UID: {$uidl}");
}
if (!mysql_ping(DB::connection()->getLink())) {
DB::connection()->reconnect();
Logger::log("*** Connection Lost -> Reconnected ***");
}
if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
Logger::log("mem 1) " . format_filesize(memory_get_usage()));
}
if (strpos($content, '+OK ') > 0) {
$content = substr($content, strpos($content, '+OK '));
}
if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
Logger::log("mem 2) " . format_filesize(memory_get_usage()));
}
self::parseMail($content, $decoded, $parsedMail, $warnings);
if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
Logger::log("mem 3) " . format_filesize(memory_get_usage()));
}
$encoding = array_var($parsedMail, 'Encoding', 'UTF-8');
$enc_conv = EncodingConverter::instance();
$to_addresses = self::getAddresses(array_var($parsedMail, "To"));
$from = self::getAddresses(array_var($parsedMail, "From"));
$message_id = self::getHeaderValueFromContent($content, "Message-ID");
$in_reply_to_id = self::getHeaderValueFromContent($content, "In-Reply-To");
if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
Logger::log("mem 4) " . format_filesize(memory_get_usage()));
}
$uid = trim($uidl);
if (str_starts_with($uid, '<') && str_ends_with($uid, '>')) {
$uid = utf8_substr($uid, 1, utf8_strlen($uid, $encoding) - 2, $encoding);
}
if ($uid == '') {
$uid = trim($message_id);
if ($uid == '') {
$uid = array_var($parsedMail, 'Subject', 'MISSING UID');
}
if (str_starts_with($uid, '<') && str_ends_with($uid, '>')) {
$uid = utf8_substr($uid, 1, utf8_strlen($uid, $encoding) - 2, $encoding);
}
if (MailContents::mailRecordExists($account->getId(), $uid, $imap_folder_name == '' ? null : $imap_folder_name)) {
return;
}
}
if (!$from) {
$parsedMail["From"] = self::getFromAddressFromContent($content);
$from = array_var($parsedMail["From"][0], 'address', '');
if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
Logger::log("mem 4.1) " . format_filesize(memory_get_usage()));
}
}
if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
Logger::log("mem 5) " . format_filesize(memory_get_usage()));
}
if (defined('EMAIL_MESSAGEID_CONTROL') && EMAIL_MESSAGEID_CONTROL) {
if (trim($message_id) != "") {
$id_condition = " AND `message_id`='" . trim($message_id) . "'";
} else {
$id_condition = " AND `subject`='" . trim(array_var($parsedMail, 'Subject')) . "' AND `from`='{$from}'";
if (array_var($parsedMail, 'Date')) {
$sent_date_dt = new DateTimeValue(strtotime(array_var($parsedMail, 'Date')));
$sent_date_str = $sent_date_dt->toMySQL();
$id_condition .= " AND `sent_date`='" . $sent_date_str . "'";
}
}
$same = MailContents::findOne(array('conditions' => "`account_id`=" . $account->getId() . $id_condition, 'include_trashed' => true));
if ($same instanceof MailContent) {
return;
}
}
if ($state == 0) {
if ($from == $account->getEmailAddress()) {
if (strpos($to_addresses, $from) !== FALSE) {
$state = 5;
} else {
$state = 1;
}
//Show only in sent folder
}
}
if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
Logger::log("mem 6) " . format_filesize(memory_get_usage()));
self::log_connection_status();
}
$from_spam_junk_folder = strpos(strtolower($imap_folder_name), 'spam') !== FALSE || strpos(strtolower($imap_folder_name), 'junk') !== FALSE || strpos(strtolower($imap_folder_name), 'trash') !== FALSE;
$user_id = logged_user() instanceof User ? logged_user()->getId() : $account->getUserId();
if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
self::log_connection_status();
}
$max_spam_level = user_config_option('max_spam_level', null, $user_id);
if ($max_spam_level < 0) {
$max_spam_level = 0;
}
$mail_spam_level = strlen(trim(array_var($decoded[0]['Headers'], 'x-spam-level:', '')));
// if max_spam_level >= 10 then nothing goes to junk folder
$spam_in_subject = false;
//.........这里部分代码省略.........
示例13: implode
$sql = "";
$first_row = true;
}
}
}
$processed_objects[] = $cobj->getId();
// check memory to stop script
if (memory_get_usage(true) > SCRIPT_MEMORY_LIMIT) {
$processed_objects_ids = "(" . implode("),(", $processed_objects) . ")";
DB::execute("INSERT INTO " . TABLE_PREFIX . "processed_objects (object_id) VALUES {$processed_objects_ids} ON DUPLICATE KEY UPDATE object_id=object_id");
$rest = Objects::count("id NOT IN(SELECT object_id FROM " . TABLE_PREFIX . "processed_objects)");
$row = DB::executeOne("SELECT COUNT(object_id) AS 'row_count' FROM " . TABLE_PREFIX . "processed_objects");
$proc_count = $row['row_count'];
$status_message = "Memory limit exceeded (" . format_filesize(memory_get_usage(true)) . "). Script terminated. Processed Objects: {$proc_count}. Total: " . ($proc_count + $rest) . ". Please execute 'Fill searchable objects and sharing table' again.";
$_SESSION['hide_back_button'] = 1;
complete_migration_print("\n" . date("H:i:s") . " - Memory limit exceeded (" . format_filesize(memory_get_usage(true)) . ") script terminated. Processed Objects: " . count($processed_objects) . ". Total: {$proc_count}.");
$processed_objects = array();
break;
}
$cant++;
}
$cobj = null;
}
// add mails to sharing table for account owners
if ($sql != "") {
$sql .= " ON DUPLICATE KEY UPDATE group_id=group_id;";
DB::execute($sql);
$sql = "";
}
if (count($processed_objects) > 0) {
$processed_objects_ids = "(" . implode("),(", $processed_objects) . ")";
示例14: product_signature
/**
* Returns product signature (name and version). If user is not logged in and
* is not member of owner company he will see only product name
*
* @param void
* @return string
*/
function product_signature() {
if (function_exists('logged_user') && (logged_user() instanceof User) && logged_user()->isMemberOfOwnerCompany()) {
$result = lang('footer powered', 'http://www.projectpier.org/', clean(product_name()) . ' ' . product_version());
if (Env::isDebugging()) {
ob_start();
benchmark_timer_display(false);
$result .= '. ' . ob_get_clean();
if (function_exists('memory_get_usage')) {
$result .= '. ' . format_filesize(memory_get_usage());
} // if
} // if
return $result;
} else {
return lang('footer powered', 'http://www.ProjectPier.org/', clean(product_name()));
} // if
} // product_signature
示例15: checkbox_field
<?php
if($file->getType() == ProjectFiles::TYPE_DOCUMENT){
if (!isset($checkin)) {?>
<div class="header">
<?php echo checkbox_field('file[update_file]', array_var($file_data, 'update_file'), array('class' => 'checkbox', 'id' => $genid . 'fileFormUpdateFile', 'tabindex' => '60', 'onclick' => 'App.modules.addFileForm.updateFileClick(\'' . $genid .'\')')) ?>
<?php echo label_tag(lang('update file'), $genid .'fileFormUpdateFile', false, array('class' => 'checkbox'), '') ?>
</div>
<div id="<?php echo $genid ?>updateFileDescription">
<p><?php echo lang('replace file description') ?></p>
</div>
<?php } // if ?>
<div id="<?php echo $genid ?>updateFileForm" style="<?php echo isset($checkin) ? '': 'display:none' ?>">
<p>
<strong><?php echo lang('existing file') ?>:</strong>
<a target="_blank" href="<?php echo $file->getDownloadUrl() ?>" id="extension_old"><?php echo clean($file->getFilename()) ?></a>
| <?php echo format_filesize($file->getFilesize()) ?>
</p>
<p id="warning_extension_file"></p>
<div id="<?php echo $genid ?>selectFileControlDiv">
<?php echo label_tag(lang('new file'), $genid.'fileFormFile', true) ?>
<?php
Hook::fire('render_upload_control', array(
"genid" => $genid,
"attributes" => array(
"id" => $genid . "fileFormFile",
"tabindex" => "65",
"size" => 88,
"style" => 'width:530px',
)
), $ret);
?>