本文整理汇总了PHP中admin_tools::FormatBytes方法的典型用法代码示例。如果您正苦于以下问题:PHP admin_tools::FormatBytes方法的具体用法?PHP admin_tools::FormatBytes怎么用?PHP admin_tools::FormatBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类admin_tools
的用法示例。
在下文中一共展示了admin_tools::FormatBytes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ShowFiles
/**
* Show files in the cache
*
*/
function ShowFiles()
{
global $page, $langmessage;
$page->head_js[] = '/include/thirdparty/tablesorter/tablesorter.js';
$page->jQueryCode .= '$("table.tablesorter").tablesorter({cssHeader:"gp_header",cssAsc:"gp_header_asc",cssDesc:"gp_header_desc"});';
if (!$this->all_files) {
return;
}
echo '<p>';
echo common::Link('Admin_Cache', 'Empty Cache', 'cmd=EmptyResourceCache', array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => 'Empty the resource cache?'));
echo '</p>';
echo '<table class="bordered tablesorter full_width">';
echo '<thead>';
echo '<tr><th>';
echo $langmessage['file_name'];
echo '</th><th>';
echo $langmessage['File Size'];
echo '</th><th>';
echo 'Touched';
echo '</th><th>';
echo $langmessage['options'];
echo '</th></tr>';
echo '</thead>';
$total_size = 0;
echo '<tbody>';
foreach ($this->all_files as $file) {
$full = $this->cache_dir . '/' . $file;
echo '<tr><td>';
echo '<a href="?cmd=ViewFile&file=' . rawurlencode($file) . '">';
echo $file;
echo '</a>';
echo '</td><td>';
$size = filesize($full);
echo '<span style="display:none">' . $size . '</span>';
echo admin_tools::FormatBytes($size);
$total_size += $size;
echo '</td><td>';
$elapsed = admin_tools::Elapsed(time() - filemtime($full));
echo sprintf($langmessage['_ago'], $elapsed);
echo '</td><td>';
echo common::Link('Admin_Cache', $langmessage['delete'], 'cmd=DeleteFile&file=' . rawurlencode($file), array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => $langmessage['delete_confirm']));
echo '</tr>';
}
echo '</tbody>';
//totals
echo '<tfoot>';
echo '<tr><td>';
echo number_format(count($this->all_files)) . ' Files';
echo '</td><td>';
echo admin_tools::FormatBytes($total_size);
echo '</td><td>';
echo '</tr>';
echo '</table>';
}
示例2: FileStats
function FileStats($key, $title, $is_special)
{
global $langmessage, $gp_titles;
echo '<a>' . $langmessage['Slug/URL'] . ': ' . htmlspecialchars($title) . '</a>';
echo '<a>' . $langmessage['Content Type'] . ': ' . str_replace(',', ', ', $gp_titles[$key]['type']) . '</a>';
if (!$is_special) {
$file = gpFiles::PageFile($title);
$stats = @stat($file);
if ($stats) {
$mtime = $stats['mtime'];
$size = $stats['size'];
echo '<a>' . $langmessage['File Size'] . ': ' . admin_tools::FormatBytes($size) . '</a>';
echo '<a>' . $langmessage['Modified'] . ': ' . date('M j, Y \\a\\t H:i', $mtime) . '</a>';
}
}
echo '<a>Data Index: ' . $key . '</a>';
}
示例3: BufferOut
//.........这里部分代码省略.........
}
$last_error['file'] = realpath($last_error['file']);
//may be redundant
showError($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line'], false);
//send error to logger
$reload = false;
//disable execution
if (count(self::$catchable)) {
$last_error['time'] = time();
$last_error['request_method'] = $_SERVER['REQUEST_METHOD'];
if (!empty($last_error['file'])) {
$last_error['file_modified'] = filemtime($last_error['file']);
$last_error['file_size'] = filesize($last_error['file']);
}
//error text, check for existing fatal notice
if (count(self::$fatal_notices)) {
$content = end(self::$fatal_notices);
reset(self::$fatal_notices);
if ($content[0] == '{' && ($temp = json_decode($content, true))) {
$last_error = $temp;
}
} else {
$content = json_encode($last_error);
}
//$buffer .= pre(self::$catchable).'<hr/>';
//$buffer .= '<h3>Existing Fatal Notices</h3>'.pre(self::$fatal_notices).'<hr/>';
$temp = array_reverse(self::$catchable);
foreach ($temp as $error_hash => $info) {
$file = $dataDir . '/data/_site/fatal_' . $error_hash;
gpFiles::Save($file, $content);
$reload = true;
if ($info['catchable_type'] == 'exec') {
break;
}
}
}
//reload non-logged in users automatically, display message to admins
$buffer .= '<p>Oops, an error occurred while generating this page.<p>';
if (!common::LoggedIn()) {
if ($reload) {
$buffer .= 'Reloading... <script type="text/javascript">window.setTimeout(function(){window.location.href = window.location.href},1000);</script>';
} else {
$buffer .= '<p>If you are the site administrator, you can troubleshoot the problem by changing php\'s display_errors setting to 1 in the gpconfig.php file.</p>' . '<p>If the problem is being caused by an addon, you may also be able to bypass the error by enabling gpEasy\'s safe mode in the gpconfig.php file.</p>' . '<p>More information is available in the <a href="http://docs.gpeasy.com/Main/Troubleshooting">gpEasy documentation</a>.</p>' . '<p><a href="">Reload this page to continue</a>.</p>';
}
} else {
$buffer .= '<h3>Error Details</h3>' . pre($last_error) . '<p><a href="">Reload this page</a></p>';
if ($reload) {
$buffer .= '<p><a href="">Reload this page with the faulty component disabled</a></p>' . '<p><a href="?cmd=enable_component&hash=' . $error_hash . '">Reload this page with the faulty component enabled</a></p>';
}
$buffer .= '<p style="font-size:90%">Note: Error details are only displayed for logged in administrators</p>' . common::ErrorBuffer(true, false);
}
}
}
//remove lock
if (defined('gp_has_lock') && gp_has_lock) {
gpFiles::Unlock('write', gp_random);
}
//replace the <head> placeholder with header content
$placeholder = '<!-- get_head_placeholder ' . gp_random . ' -->';
$pos = strpos($buffer, $placeholder);
if ($pos === false) {
return $buffer;
}
$buffer = substr_replace($buffer, $gp_head_content, $pos, strlen($placeholder));
//add jquery if needed
$placeholder = '<!-- jquery_placeholder ' . gp_random . ' -->';
$pos = strpos($buffer, $placeholder);
if ($pos !== false) {
$replacement = '';
if (strpos($buffer, '<script') !== false) {
if ($config['jquery'] != 'local') {
$replacement = "\n<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js\"></script>";
} else {
$replacement = "\n<script type=\"text/javascript\" src=\"" . common::GetDir('/include/thirdparty/js/jquery.js') . "\"></script>";
}
}
$buffer = substr_replace($buffer, $replacement, $pos, strlen($placeholder));
}
//messages
$pos = strpos($buffer, '<!-- message_start ' . gp_random . ' -->');
$len = strpos($buffer, '<!-- message_end -->') - $pos;
if ($pos && $len) {
$replacement = GetMessages(false);
$buffer = substr_replace($buffer, $replacement, $pos, $len + 20);
}
if (strpos($buffer, '<body') !== false && class_exists('admin_tools')) {
if (function_exists('memory_get_peak_usage')) {
$buffer = str_replace('<span gpeasy-memory-usage>?</span>', admin_tools::FormatBytes(memory_get_usage()), $buffer);
$buffer = str_replace('<span gpeasy-memory-max>?</span>', admin_tools::FormatBytes(memory_get_peak_usage()), $buffer);
}
if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
$time = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
} else {
$time = microtime(true) - gp_start_time;
}
$buffer = str_replace('<span gpeasy-seconds>?</span>', round($time, 3), $buffer);
$buffer = str_replace('<span gpeasy-ms>?</span>', round($time * 1000), $buffer);
}
return $buffer;
}
示例4: Exported
function Exported()
{
global $langmessage;
if (count($this->exported) == 0) {
return;
}
echo '<table class="bordered">';
echo '<tr><th>';
echo $langmessage['Previous Exports'];
echo '</th><th> </th><th>';
echo $langmessage['File Size'];
echo '</th><th>';
echo $langmessage['options'];
echo '</th></tr>';
$total_size = 0;
$total_count = 0;
foreach ($this->exported as $file) {
$info = $this->FileInfo($file);
if (!$info) {
continue;
}
$full_path = $this->export_dir . '/' . $file;
if ($total_count % 2 == 0) {
echo '<tr class="even">';
} else {
echo '<tr>';
}
echo '<td>';
echo str_replace(' ', ' ', $info['time']);
echo '</td><td>';
echo implode(', ', $info['exported']);
echo '</td><td>';
$size = filesize($full_path);
echo admin_tools::FormatBytes($size);
echo ' ';
echo $info['ext'];
echo '</td><td>';
echo '<a href="' . common::GetDir('/data/_exports/' . $file) . '">' . $langmessage['Download'] . '</a>';
echo ' ';
if ($this->CanRevert($info['bits'])) {
echo common::Link('Admin_Port', $langmessage['Revert'], 'cmd=revert&archive=' . rawurlencode($file), '', $file);
} else {
echo $langmessage['Revert'];
}
echo ' ';
echo common::Link('Admin_Port', $langmessage['delete'], 'cmd=delete&file=' . rawurlencode($file), array('data-cmd' => 'postlink', 'title' => $langmessage['delete_confirm'], 'class' => 'gpconfirm'), $file);
echo '</td></tr>';
$total_count++;
$total_size += $size;
}
//totals
echo '<tr><th>';
echo $langmessage['Total'];
echo ': ';
echo $total_count;
echo '</th><th> </th><th>';
echo admin_tools::FormatBytes($total_size);
echo '</th><th> </th></tr>';
echo '</table>';
}
示例5: PerformanceStats
/**
* Return Performance Stats about the current request
*
* @return array
*/
public static function PerformanceStats()
{
$stats = array();
if (function_exists('memory_get_peak_usage')) {
$stats['<span gpeasy-memory-usage>?</span>'] = admin_tools::FormatBytes(memory_get_usage());
$stats['<span gpeasy-memory-max>?</span>'] = admin_tools::FormatBytes(memory_get_peak_usage());
}
if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
$time = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
} else {
$time = microtime(true) - gp_start_time;
}
$stats['<span gpeasy-seconds>?</span>'] = round($time, 3);
$stats['<span gpeasy-ms>?</span>'] = round($time * 1000);
return $stats;
}
示例6: ViewHistory
/**
* Display the revision history of the current file
*
*/
function ViewHistory()
{
global $langmessage;
$files = $this->BackupFiles();
krsort($files);
ob_start();
echo '<h2>' . $langmessage['Revision History'] . '</h2>';
echo '<table class="bordered full_width"><tr><th>' . $langmessage['Modified'] . '</th><th>' . $langmessage['File Size'] . '</th><th>' . $langmessage['username'] . '</th><th> </th></tr>';
echo '<tbody>';
$size = filesize($this->file);
echo '<tr><td>';
echo common::date($langmessage['strftime_datetime'], $this->fileModTime);
echo ' (' . $langmessage['Current Page'] . ')</td><td>';
echo admin_tools::FormatBytes($size);
echo '</td><td>' . $this->file_stats['username'] . '</td><td> </td></tr>';
$i = 1;
foreach ($files as $time => $file) {
//remove .gze
if (strpos($file, '.gze') === strlen($file) - 4) {
$file = substr($file, 0, -4);
}
//get info from filename
$name = basename($file);
$parts = explode('.', $name, 3);
$time = array_shift($parts);
$size = array_shift($parts);
$username = false;
if (count($parts)) {
$username = array_shift($parts);
}
//output row
echo '<tr class="' . ($i % 2 ? 'even' : '') . '"><td>';
echo common::date($langmessage['strftime_datetime'], $time);
echo '</td><td>';
if ($size && is_numeric($size)) {
echo admin_tools::FormatBytes($size);
}
echo '</td><td>';
echo $username;
echo '</td><td>';
echo common::Link($this->title, $langmessage['preview'], 'cmd=view_revision&time=' . $time, array('data-cmd' => 'cnreq'));
echo '</td></tr>';
$i++;
}
echo '</tbody>';
echo '</table>';
$this->contentBuffer = ob_get_clean();
}
示例7: SearchDisplayRow
/**
* Display row
*
*/
function SearchDisplayRow($title)
{
global $langmessage, $gpLayouts, $gp_index, $gp_menu;
$title_index = $gp_index[$title];
$is_special = common::SpecialOrAdmin($title);
$file = gpFiles::PageFile($title);
$stats = @stat($file);
$mtime = false;
$size = false;
$layout = admin_menu_tools::CurrentLayout($title_index);
$layout_info = $gpLayouts[$layout];
if ($stats) {
$mtime = $stats['mtime'];
$size = $stats['size'];
}
echo '<tr><td>';
$label = common::GetLabel($title);
echo common::Link($title, common::LabelSpecialChars($label));
//area only display on mouseover
echo '<div><div>';
//style="position:absolute;bottom:0;left:10px;right:10px;"
echo $this->Link('Admin_Menu', $langmessage['rename/details'], 'cmd=renameform&index=' . urlencode($title_index), array('title' => $langmessage['rename/details'], 'data-cmd' => 'gpajax'));
echo $this->Link('Admin_Menu', $langmessage['Copy'], 'cmd=copypage&index=' . urlencode($title_index), array('title' => $langmessage['Copy'], 'data-cmd' => 'gpabox'));
echo '<span>';
echo $langmessage['layout'] . ': ';
echo $this->Link('Admin_Menu', $layout_info['label'], 'cmd=layout&index=' . urlencode($title_index), array('title' => $langmessage['layout'], 'data-cmd' => 'gpabox'));
echo '</span>';
if (!$is_special) {
echo $this->Link('Admin_Menu', $langmessage['delete'], 'cmd=trash&index=' . urlencode($title_index), array('title' => $langmessage['delete_page'], 'data-cmd' => 'postlink', 'class' => 'gpconfirm'));
}
gpPlugin::Action('MenuPageOptions', array($title, $title_index, false, $layout_info));
//stats
if (gpdebug) {
echo '<span>Data Index: ' . $title_index . '</span>';
}
echo '</div> </div>';
//types
echo '</td><td>';
$this->TitleTypes($title_index);
//children
echo '</td><td>';
if (isset($Inherit_Info[$title_index]) && isset($Inherit_Info[$title_index]['children'])) {
echo $Inherit_Info[$title_index]['children'];
} elseif (isset($gp_menu[$title_index])) {
echo '0';
} else {
echo $langmessage['Not In Main Menu'];
}
//size
echo '</td><td>';
if ($size) {
echo admin_tools::FormatBytes($size);
}
//modified
echo '</td><td>';
if ($mtime) {
echo common::date($langmessage['strftime_datetime'], $mtime);
}
echo '</td></tr>';
}
示例8: ViewHistory
/**
* Display the revision history of the current file
*
*/
public function ViewHistory()
{
global $langmessage, $config;
$files = $this->BackupFiles();
$rows = array();
//working draft
if ($this->draft_exists) {
ob_start();
$size = filesize($this->draft_file);
$date = common::date($langmessage['strftime_datetime'], $this->draft_stats['modified']);
echo '<tr><td title="' . htmlspecialchars($date) . '">';
echo '<b>' . $langmessage['Working Draft'] . '</b><br/>';
$elapsed = admin_tools::Elapsed(time() - $this->draft_stats['modified']);
echo sprintf($langmessage['_ago'], $elapsed);
echo '</td><td>';
echo admin_tools::FormatBytes($size);
echo '</td><td>' . $this->draft_stats['username'] . '</td><td>';
echo common::Link($this->title, $langmessage['View']);
echo ' ' . common::Link($this->title, $langmessage['Publish Draft'], 'cmd=PublishDraft', array('data-cmd' => 'cnreq'));
echo '</td></tr>';
$rows[$this->draft_stats['modified']] = ob_get_clean();
}
foreach ($files as $time => $file) {
//remove .gze
if (strpos($file, '.gze') === strlen($file) - 4) {
$file = substr($file, 0, -4);
}
//get info from filename
$name = basename($file);
$parts = explode('.', $name, 3);
$time = array_shift($parts);
$size = array_shift($parts);
$username = false;
$date = common::date($langmessage['strftime_datetime'], $time);
if (count($parts)) {
$username = array_shift($parts);
}
//output row
ob_start();
echo '<tr><td title="' . htmlspecialchars($date) . '">';
$elapsed = admin_tools::Elapsed(time() - $time);
echo sprintf($langmessage['_ago'], $elapsed);
echo '</td><td>';
if ($size && is_numeric($size)) {
echo admin_tools::FormatBytes($size);
}
echo '</td><td>';
echo $username;
echo '</td><td>';
echo common::Link($this->title, $langmessage['View'], 'cmd=ViewRevision&time=' . $time, array('data-cmd' => 'cnreq'));
echo ' ';
echo common::Link($this->title, $langmessage['delete'], 'cmd=DeleteRevision&time=' . $time, array('data-cmd' => 'gpabox', 'class' => 'gpconfirm'));
echo '</td></tr>';
$rows[$time] = ob_get_clean();
}
// current page
// this will likely overwrite one of the history entries
ob_start();
$size = filesize($this->file);
$date = common::date($langmessage['strftime_datetime'], $this->fileModTime);
echo '<tr><td title="' . htmlspecialchars($date) . '">';
echo '<b>' . $langmessage['Current Page'] . '</b><br/>';
$elapsed = admin_tools::Elapsed(time() - $this->fileModTime);
echo sprintf($langmessage['_ago'], $elapsed);
echo '</td><td>';
echo admin_tools::FormatBytes($size);
echo '</td><td>';
if (isset($this->file_stats['username'])) {
echo $this->file_stats['username'];
}
echo '</td><td>';
echo common::Link($this->title, $langmessage['View'], 'cmd=ViewCurrent');
echo '</td></tr>';
$rows[$this->fileModTime] = ob_get_clean();
ob_start();
echo '<h2>' . $langmessage['Revision History'] . '</h2>';
echo '<table class="bordered full_width striped"><tr><th>' . $langmessage['Modified'] . '</th><th>' . $langmessage['File Size'] . '</th><th>' . $langmessage['username'] . '</th><th> </th></tr>';
echo '<tbody>';
krsort($rows);
echo implode('', $rows);
echo '</tbody>';
echo '</table>';
echo '<p>' . $langmessage['history_limit'] . ': ' . $config['history_limit'] . '</p>';
$this->contentBuffer = ob_get_clean();
}