本文整理汇总了PHP中PMA_Util::timespanFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Util::timespanFormat方法的具体用法?PHP PMA_Util::timespanFormat怎么用?PHP PMA_Util::timespanFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_Util
的用法示例。
在下文中一共展示了PMA_Util::timespanFormat方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_getHtmlForServerStateGeneralInfo
/**
* Prints server state General information
*
* @param PMA_ServerStatusData $ServerStatusData Server status data
*
* @return string
*/
function PMA_getHtmlForServerStateGeneralInfo($ServerStatusData)
{
$start_time = $GLOBALS['dbi']->fetchValue('SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime']);
$retval = '<h3>';
$bytes_received = $ServerStatusData->status['Bytes_received'];
$bytes_sent = $ServerStatusData->status['Bytes_sent'];
$retval .= sprintf(__('Network traffic since startup: %s'), implode(' ', PMA_Util::formatByteDown($bytes_received + $bytes_sent, 3, 1)));
$retval .= '</h3>';
$retval .= '<p>';
$retval .= sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'), PMA_Util::timespanFormat($ServerStatusData->status['Uptime']), PMA_Util::localisedDate($start_time)) . "\n";
$retval .= '</p>';
return $retval;
}
示例2: PMA_getHtmlForServerStateGeneralInfo
/**
* Prints server state General information
*
* @param PMA_ServerStatusData $ServerStatusData Server status data
*
* @return string
*/
function PMA_getHtmlForServerStateGeneralInfo($ServerStatusData)
{
$start_time = $GLOBALS['dbi']->fetchValue('SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime']);
$retval = '<h3>';
$bytes_received = $ServerStatusData->status['Bytes_received'];
$bytes_sent = $ServerStatusData->status['Bytes_sent'];
$retval .= sprintf(__('Network traffic since startup: %s'), implode(' ', PMA_Util::formatByteDown($bytes_received + $bytes_sent, 3, 1)));
$retval .= '</h3>';
$retval .= '<p>';
$retval .= sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'), PMA_Util::timespanFormat($ServerStatusData->status['Uptime']), PMA_Util::localisedDate($start_time)) . "\n";
$retval .= '</p>';
if ($GLOBALS['replication_info']['master']['status'] || $GLOBALS['replication_info']['slave']['status']) {
$retval .= '<p class="notice">';
if ($GLOBALS['replication_info']['master']['status'] && $GLOBALS['replication_info']['slave']['status']) {
$retval .= __('This MySQL server works as <b>master</b> and ' . '<b>slave</b> in <b>replication</b> process.');
} elseif ($GLOBALS['replication_info']['master']['status']) {
$retval .= __('This MySQL server works as <b>master</b> ' . 'in <b>replication</b> process.');
} elseif ($GLOBALS['replication_info']['slave']['status']) {
$retval .= __('This MySQL server works as <b>slave</b> ' . 'in <b>replication</b> process.');
}
$retval .= '</p>';
}
/*
* if the server works as master or slave in replication process,
* display useful information
*/
if ($GLOBALS['replication_info']['master']['status'] || $GLOBALS['replication_info']['slave']['status']) {
$retval .= '<hr class="clearfloat" />';
$retval .= '<h3><a name="replication">';
$retval .= __('Replication status');
$retval .= '</a></h3>';
foreach ($GLOBALS['replication_types'] as $type) {
if (isset($GLOBALS['replication_info'][$type]['status']) && $GLOBALS['replication_info'][$type]['status']) {
$retval .= PMA_getHtmlForReplicationStatusTable($type);
}
}
}
return $retval;
}
示例3: ADVISOR_timespanFormat
/**
* Wrapper for PMA_Util::timespanFormat
*
* @param int $seconds the timespan
*
* @return string the formatted value
*/
function ADVISOR_timespanFormat($seconds)
{
return PMA_Util::timespanFormat($seconds);
}
示例4: getServerTrafficHtml
/**
* Prints server traffic information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function getServerTrafficHtml($ServerStatusData)
{
$hour_factor = 3600 / $ServerStatusData->status['Uptime'];
$start_time = PMA_DBI_fetch_value('SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime']);
$retval = '<h3>';
$retval .= sprintf(__('Network traffic since startup: %s'), implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'], 3, 1)));
$retval .= '</h3>';
$retval .= '<p>';
$retval .= sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'), PMA_Util::timespanFormat($ServerStatusData->status['Uptime']), PMA_Util::localisedDate($start_time)) . "\n";
$retval .= '</p>';
if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
$retval .= '<p class="notice">';
if ($GLOBALS['server_master_status'] && $GLOBALS['server_slave_status']) {
$retval .= __('This MySQL server works as <b>master</b> and ' . '<b>slave</b> in <b>replication</b> process.');
} elseif ($GLOBALS['server_master_status']) {
$retval .= __('This MySQL server works as <b>master</b> ' . 'in <b>replication</b> process.');
} elseif ($GLOBALS['server_slave_status']) {
$retval .= __('This MySQL server works as <b>slave</b> ' . 'in <b>replication</b> process.');
}
$retval .= ' ';
$retval .= __('For further information about replication status on the server, ' . 'please visit the <a href="#replication">replication section</a>.');
$retval .= '</p>';
}
/*
* if the server works as master or slave in replication process,
* display useful information
*/
if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
$retval .= '<hr class="clearfloat" />';
$retval .= '<h3><a name="replication">';
$retval .= __('Replication status');
$retval .= '</a></h3>';
foreach ($GLOBALS['replication_types'] as $type) {
if (isset(${"server_{$type}_status"}) && ${"server_{$type}_status"}) {
PMA_replication_print_status_table($type);
}
}
}
$retval .= '<table id="serverstatustraffic" class="data noclick">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th colspan="2">';
$retval .= __('Traffic') . ' ';
$retval .= PMA_Util::showHint(__('On a busy server, the byte counters may overrun, so those statistics ' . 'as reported by the MySQL server may be incorrect.'));
$retval .= '</th>';
$retval .= '<th>ø ' . __('per hour') . '</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('Received') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'], 3, 1));
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1));
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="even">';
$retval .= '<th class="name">' . __('Sent') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_sent'], 3, 1));
$retval .= '</td>';
$retval .= '<td class="value"><?php echo';
$retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_sent'] * $hour_factor, 3, 1));
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('Total') . '</th>';
$retval .= '<td class="value">';
$retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'], 3, 1));
$retval .= '</td>';
$retval .= '<td class="value">';
$retval .= implode(' ', PMA_Util::formatByteDown(($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent']) * $hour_factor, 3, 1));
$retval .= '</td>';
$retval .= '</tr>';
$retval .= '</tbody>';
$retval .= '</table>';
$retval .= '<table id="serverstatusconnections" class="data noclick">';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th colspan="2">' . __('Connections') . '</th>';
$retval .= '<th>ø ' . __('per hour') . '</th>';
$retval .= '<th>%</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$retval .= '<tr class="odd">';
$retval .= '<th class="name">' . __('max. concurrent connections') . '</th>';
$retval .= '<td class="value">';
$retval .= PMA_Util::formatNumber($ServerStatusData->status['Max_used_connections'], 0);
$retval .= '</td>';
$retval .= '<td class="value">--- </td>';
//.........这里部分代码省略.........
示例5: PMA_getHtmlForRenderVariables
/**
* Returns HTML for render variables list
*
* @param PMA_ServerStatusData $ServerStatusData Server status data
* @param Array $alerts Alert Array
* @param Array $strShowStatus Status Array
*
* @return string
*/
function PMA_getHtmlForRenderVariables($ServerStatusData, $alerts, $strShowStatus)
{
$retval = '<table class="data sortable noclick" id="serverstatusvariables">';
$retval .= '<col class="namecol" />';
$retval .= '<col class="valuecol" />';
$retval .= '<col class="descrcol" />';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th>' . __('Variable') . '</th>';
$retval .= '<th>' . __('Value') . '</th>';
$retval .= '<th>' . __('Description') . '</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$odd_row = false;
foreach ($ServerStatusData->status as $name => $value) {
$odd_row = !$odd_row;
$retval .= '<tr class="' . ($odd_row ? 'odd' : 'even') . (isset($ServerStatusData->allocationMap[$name]) ? ' s_' . $ServerStatusData->allocationMap[$name] : '') . '">';
$retval .= '<th class="name">';
$retval .= htmlspecialchars(str_replace('_', ' ', $name));
// Fields containing % are calculated,
// they can not be described in MySQL documentation
if (strpos($name, '%') === false) {
$retval .= PMA_Util::showMySQLDocu('server-status-variables', false, 'statvar_' . $name);
}
$retval .= '</th>';
$retval .= '<td class="value"><span class="formatted">';
if (isset($alerts[$name])) {
if ($value > $alerts[$name]) {
$retval .= '<span class="attention">';
} else {
$retval .= '<span class="allfine">';
}
}
if ('%' === substr($name, -1, 1)) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 0, 2)) . ' %';
} elseif (strpos($name, 'Uptime') !== false) {
$retval .= htmlspecialchars(PMA_Util::timespanFormat($value));
} elseif (is_numeric($value) && $value > 1000) {
$retval .= '<abbr title="' . htmlspecialchars(PMA_Util::formatNumber($value, 0)) . '">' . htmlspecialchars(PMA_Util::formatNumber($value, 3, 1)) . '</abbr>';
} elseif (is_numeric($value)) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 3, 1));
} else {
$retval .= htmlspecialchars($value);
}
if (isset($alerts[$name])) {
$retval .= '</span>';
}
$retval .= '</span>';
$retval .= '<span style="display:none;" class="original">';
if (isset($alerts[$name])) {
if ($value > $alerts[$name]) {
$retval .= '<span class="attention">';
} else {
$retval .= '<span class="allfine">';
}
}
$retval .= $value;
if (isset($alerts[$name])) {
$retval .= '</span>';
}
$retval .= '</span>';
$retval .= '</td>';
$retval .= '<td class="descr">';
if (isset($strShowStatus[$name])) {
$retval .= $strShowStatus[$name];
}
if (isset($ServerStatusData->links[$name])) {
foreach ($ServerStatusData->links[$name] as $link_name => $link_url) {
if ('doc' == $link_name) {
$retval .= PMA_Util::showMySQLDocu($link_url);
} else {
$retval .= ' <a href="' . $link_url . '">' . $link_name . '</a>';
}
}
unset($link_url, $link_name);
}
$retval .= '</td>';
$retval .= '</tr>';
}
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}
示例6: printVariablesTable
//.........这里部分代码省略.........
// depends on Key_write_requests
// normaly nearly 1:1
'Key_writes' => isset($server_status['Key_write_requests'])
? (0.9 * $server_status['Key_write_requests']) : 0,
'Key_buffer_fraction' => 0.5,
// alert if more than 95% of thread cache is in use
'Threads_cached' => isset($server_variables['thread_cache_size'])
? 0.95 * $server_variables['thread_cache_size'] : 0
// higher is better
// variable => min value
//'Handler read key' => '> ',
);
?>
<table class="data sortable noclick" id="serverstatusvariables">
<col class="namecol" />
<col class="valuecol" />
<col class="descrcol" />
<thead>
<tr>
<th><?php echo __('Variable'); ?></th>
<th><?php echo __('Value'); ?></th>
<th><?php echo __('Description'); ?></th>
</tr>
</thead>
<tbody>
<?php
$odd_row = false;
foreach ($server_status as $name => $value) {
$odd_row = !$odd_row;
echo '<tr class="' . ($odd_row ? 'odd' : 'even')
. (isset($allocationMap[$name])?' s_' . $allocationMap[$name] : '')
. '">';
echo '<th class="name">';
echo htmlspecialchars(str_replace('_', ' ', $name));
/* Fields containing % are calculated, they can not be described in MySQL documentation */
if (strpos($name, '%') === false) {
echo PMA_Util::showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name);
}
echo '</th>';
echo '<td class="value"><span class="formatted">';
if (isset($alerts[$name])) {
if ($value > $alerts[$name]) {
echo '<span class="attention">';
} else {
echo '<span class="allfine">';
}
}
if ('%' === substr($name, -1, 1)) {
echo htmlspecialchars(PMA_Util::formatNumber($value, 0, 2)) . ' %';
} elseif (strpos($name, 'Uptime') !== false) {
echo htmlspecialchars(
PMA_Util::timespanFormat($value)
);
} elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
echo htmlspecialchars(PMA_Util::formatNumber($value, 3, 1));
} elseif (is_numeric($value) && $value == (int) $value) {
echo htmlspecialchars(PMA_Util::formatNumber($value, 3, 0));
} elseif (is_numeric($value)) {
echo htmlspecialchars(PMA_Util::formatNumber($value, 3, 1));
} else {
echo htmlspecialchars($value);
}
if (isset($alerts[$name])) {
echo '</span>';
}
echo '</span>';
echo '<span style="display:none;" class="original">';
echo $value;
echo '</span>';
echo '</td>';
echo '<td class="descr">';
if (isset($strShowStatus[$name ])) {
echo $strShowStatus[$name];
}
if (isset($links[$name])) {
foreach ($links[$name] as $link_name => $link_url) {
if ('doc' == $link_name) {
echo PMA_Util::showMySQLDocu($link_url, $link_url);
} else {
echo ' <a href="' . $link_url . '">' . $link_name . '</a>' .
"\n";
}
}
unset($link_url, $link_name);
}
echo '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
}
示例7: testTimespanFormat
/**
* localised timestamp test, globals are defined
*
* @param int $a Timespan in seconds
* @param string $e Expected output
*
* @return void
*
* @dataProvider timespanFormatDataProvider
*/
public function testTimespanFormat($a, $e)
{
$GLOBALS['timespanfmt'] = '%s days, %s hours, %s minutes and %s seconds';
$this->assertEquals($e, PMA_Util::timespanFormat($a));
}
示例8: getVariablesTableHtml
/**
* Returns a table with variables information
*
* @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
*
* @return string
*/
function getVariablesTableHtml($ServerStatusData)
{
$retval = '';
$strShowStatus = getStatusVariablesDescriptions();
/**
* define some alerts
*/
// name => max value before alert
$alerts = array('Aborted_clients' => 0, 'Aborted_connects' => 0, 'Binlog_cache_disk_use' => 0, 'Created_tmp_disk_tables' => 0, 'Handler_read_rnd' => 0, 'Handler_read_rnd_next' => 0, 'Innodb_buffer_pool_pages_dirty' => 0, 'Innodb_buffer_pool_reads' => 0, 'Innodb_buffer_pool_wait_free' => 0, 'Innodb_log_waits' => 0, 'Innodb_row_lock_time_avg' => 10, 'Innodb_row_lock_time_max' => 50, 'Innodb_row_lock_waits' => 0, 'Slow_queries' => 0, 'Delayed_errors' => 0, 'Select_full_join' => 0, 'Select_range_check' => 0, 'Sort_merge_passes' => 0, 'Opened_tables' => 0, 'Table_locks_waited' => 0, 'Qcache_lowmem_prunes' => 0, 'Qcache_free_blocks' => isset($ServerStatusData->server_status['Qcache_total_blocks']) ? $ServerStatusData->server_status['Qcache_total_blocks'] / 5 : 0, 'Slow_launch_threads' => 0, 'Key_reads' => isset($ServerStatusData->status['Key_read_requests']) ? 0.01 * $ServerStatusData->status['Key_read_requests'] : 0, 'Key_writes' => isset($ServerStatusData->status['Key_write_requests']) ? 0.9 * $ServerStatusData->status['Key_write_requests'] : 0, 'Key_buffer_fraction' => 0.5, 'Threads_cached' => isset($ServerStatusData->variables['thread_cache_size']) ? 0.95 * $ServerStatusData->variables['thread_cache_size'] : 0);
$retval .= '<table class="data sortable noclick" id="serverstatusvariables">';
$retval .= '<col class="namecol" />';
$retval .= '<col class="valuecol" />';
$retval .= '<col class="descrcol" />';
$retval .= '<thead>';
$retval .= '<tr>';
$retval .= '<th>' . __('Variable') . '</th>';
$retval .= '<th>' . __('Value') . '</th>';
$retval .= '<th>' . __('Description') . '</th>';
$retval .= '</tr>';
$retval .= '</thead>';
$retval .= '<tbody>';
$odd_row = false;
foreach ($ServerStatusData->status as $name => $value) {
$odd_row = !$odd_row;
$retval .= '<tr class="' . ($odd_row ? 'odd' : 'even') . (isset($ServerStatusData->allocationMap[$name]) ? ' s_' . $ServerStatusData->allocationMap[$name] : '') . '">';
$retval .= '<th class="name">';
$retval .= htmlspecialchars(str_replace('_', ' ', $name));
/* Fields containing % are calculated, they can not be described in MySQL documentation */
if (strpos($name, '%') === false) {
$retval .= PMA_Util::showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name);
}
$retval .= '</th>';
$retval .= '<td class="value"><span class="formatted">';
if (isset($alerts[$name])) {
if ($value > $alerts[$name]) {
$retval .= '<span class="attention">';
} else {
$retval .= '<span class="allfine">';
}
}
if ('%' === substr($name, -1, 1)) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 0, 2)) . ' %';
} elseif (strpos($name, 'Uptime') !== false) {
$retval .= htmlspecialchars(PMA_Util::timespanFormat($value));
} elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
$retval .= '<abbr title="' . htmlspecialchars(PMA_Util::formatNumber($value, 0)) . '">' . htmlspecialchars(PMA_Util::formatNumber($value, 3, 1));
} elseif (is_numeric($value) && $value == (int) $value) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 3, 0));
} elseif (is_numeric($value)) {
$retval .= htmlspecialchars(PMA_Util::formatNumber($value, 3, 1));
} else {
$retval .= htmlspecialchars($value);
}
if (isset($alerts[$name])) {
$retval .= '</span>';
}
$retval .= '</span>';
$retval .= '<span style="display:none;" class="original">';
$retval .= $value;
$retval .= '</span>';
$retval .= '</td>';
$retval .= '<td class="descr">';
if (isset($strShowStatus[$name])) {
$retval .= $strShowStatus[$name];
}
if (isset($ServerStatusData->links[$name])) {
foreach ($ServerStatusData->links[$name] as $link_name => $link_url) {
if ('doc' == $link_name) {
$retval .= PMA_Util::showMySQLDocu($link_url, $link_url);
} else {
$retval .= ' <a href="' . $link_url . '">' . $link_name . '</a>';
}
}
unset($link_url, $link_name);
}
$retval .= '</td>';
$retval .= '</tr>';
}
$retval .= '</tbody>';
$retval .= '</table>';
return $retval;
}