当前位置: 首页>>代码示例>>PHP>>正文


PHP Util::formatByteDown方法代码示例

本文整理汇总了PHP中PMA\libraries\Util::formatByteDown方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::formatByteDown方法的具体用法?PHP Util::formatByteDown怎么用?PHP Util::formatByteDown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PMA\libraries\Util的用法示例。


在下文中一共展示了Util::formatByteDown方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PMA_getLogSelector

/**
 * Returns the html for log selector.
 *
 * @param Array $binary_logs Binary logs file names
 * @param Array $url_params  links parameters
 *
 * @return string
 */
function PMA_getLogSelector($binary_logs, $url_params)
{
    $html = "";
    if (count($binary_logs) > 1) {
        $html .= '<form action="server_binlog.php" method="get">';
        $html .= PMA_URL_getHiddenInputs($url_params);
        $html .= '<fieldset><legend>';
        $html .= __('Select binary log to view');
        $html .= '</legend><select name="log">';
        $full_size = 0;
        foreach ($binary_logs as $each_log) {
            $html .= '<option value="' . $each_log['Log_name'] . '"';
            if ($each_log['Log_name'] == $_REQUEST['log']) {
                $html .= ' selected="selected"';
            }
            $html .= '>' . $each_log['Log_name'];
            if (isset($each_log['File_size'])) {
                $full_size += $each_log['File_size'];
                $html .= ' (' . implode(' ', Util::formatByteDown($each_log['File_size'], 3, 2)) . ')';
            }
            $html .= '</option>';
        }
        $html .= '</select> ';
        $html .= count($binary_logs) . ' ' . __('Files') . ', ';
        if ($full_size > 0) {
            $html .= implode(' ', Util::formatByteDown($full_size));
        }
        $html .= '</fieldset>';
        $html .= '<fieldset class="tblFooters">';
        $html .= '<input type="submit" value="' . __('Go') . '" />';
        $html .= '</fieldset>';
        $html .= '</form>';
    }
    return $html;
}
开发者ID:netroby,项目名称:phpmyadmin,代码行数:43,代码来源:server_bin_log.lib.php

示例2: resolveTypeSize

 /**
  * returns the pbxt engine specific handling for
  * PMA_ENGINE_DETAILS_TYPE_SIZE variables.
  *
  * @param string $formatted_size the size expression (for example 8MB)
  *
  * @return string the formatted value and its unit
  */
 public function resolveTypeSize($formatted_size)
 {
     if (preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)) {
         $value = PMA\libraries\Util::extractValueFromFormattedSize($formatted_size);
     } else {
         $value = $formatted_size;
     }
     return PMA\libraries\Util::formatByteDown($value);
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:17,代码来源:Pbxt.php

示例3: getPageBufferpool

 /**
  * returns html tables with stats over inno db buffer pool
  *
  * @return string  html table with stats
  */
 public function getPageBufferpool()
 {
     // The following query is only possible because we know
     // that we are on MySQL 5 here (checked above)!
     // side note: I love MySQL 5 for this. :-)
     $sql = '
          SHOW STATUS
         WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
            OR Variable_name = \'Innodb_page_size\';';
     $status = $GLOBALS['dbi']->fetchResult($sql, 0, 1);
     $output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n" . '    <caption class="tblHeaders">' . "\n" . '        ' . __('Buffer Pool Usage') . "\n" . '    </caption>' . "\n" . '    <tfoot>' . "\n" . '        <tr>' . "\n" . '            <th colspan="2">' . "\n" . '                ' . __('Total') . "\n" . '                : ' . Util::formatNumber($status['Innodb_buffer_pool_pages_total'], 0) . '&nbsp;' . __('pages') . ' / ' . join('&nbsp;', Util::formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n" . '            </th>' . "\n" . '        </tr>' . "\n" . '    </tfoot>' . "\n" . '    <tbody>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Free pages') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_free'], 0) . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="even">' . "\n" . '            <th>' . __('Dirty pages') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0) . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Pages containing data') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="even">' . "\n" . '            <th>' . __('Pages to be flushed') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Busy pages') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n" . '</td>' . "\n" . '        </tr>';
     // not present at least since MySQL 5.1.40
     if (isset($status['Innodb_buffer_pool_pages_latched'])) {
         $output .= '        <tr class="even">' . '            <th>' . __('Latched pages') . '</th>' . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_latched'], 0) . '</td>' . '        </tr>';
     }
     $output .= '    </tbody>' . "\n" . '</table>' . "\n\n" . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n" . '    <caption class="tblHeaders">' . "\n" . '        ' . __('Buffer Pool Activity') . "\n" . '    </caption>' . "\n" . '    <tbody>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Read requests') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="even">' . "\n" . '            <th>' . __('Write requests') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Read misses') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="even">' . "\n" . '            <th>' . __('Write waits') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Read misses in %') . '</th>' . "\n" . '            <td class="value">' . ($status['Innodb_buffer_pool_read_requests'] == 0 ? '---' : htmlspecialchars(Util::formatNumber($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 3, 2)) . ' %') . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="even">' . "\n" . '            <th>' . __('Write waits in %') . '</th>' . "\n" . '            <td class="value">' . ($status['Innodb_buffer_pool_write_requests'] == 0 ? '---' : htmlspecialchars(Util::formatNumber($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 3, 2)) . ' %') . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '    </tbody>' . "\n" . '</table>' . "\n";
     return $output;
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:23,代码来源:Innodb.php

示例4: _handleNonPrintableContents

 /**
  * Verifies what to do with non-printable contents (binary or BLOB)
  * in Browse mode.
  *
  * @param string  $category              BLOB|BINARY|GEOMETRY
  * @param string  $content               the binary content
  * @param mixed   $transformation_plugin transformation plugin.
  *                                       Can also be the default function:
  *                                       PMA_mimeDefaultFunction
  * @param string  $transform_options     transformation parameters
  * @param string  $default_function      default transformation function
  * @param object  $meta                  the meta-information about the field
  * @param array   $url_params            parameters that should go to the
  *                                       download link
  * @param boolean &$is_truncated         the result is truncated or not
  *
  * @return mixed  string or float
  *
  * @access  private
  *
  * @see     _getDataCellForGeometryColumns(),
  *          _getDataCellForNonNumericColumns(),
  *          _getSortedColumnMessage()
  */
 private function _handleNonPrintableContents($category, $content, $transformation_plugin, $transform_options, $default_function, $meta, $url_params = array(), &$is_truncated = null)
 {
     $is_truncated = false;
     $result = '[' . $category;
     if (isset($content)) {
         $size = mb_strlen($content, '8bit');
         $display_size = Util::formatByteDown($size, 3, 1);
         $result .= ' - ' . $display_size[0] . ' ' . $display_size[1];
     } else {
         $result .= ' - NULL';
         $size = 0;
     }
     $result .= ']';
     // if we want to use a text transformation on a BLOB column
     if (gettype($transformation_plugin) === "object") {
         $posMimeOctetstream = strpos($transformation_plugin->getMIMESubtype(), 'Octetstream');
         $posMimeText = strpos($transformation_plugin->getMIMEtype(), 'Text');
         if ($posMimeOctetstream || $posMimeText !== false) {
             // Applying Transformations on hex string of binary data
             // seems more appropriate
             $result = pack("H*", bin2hex($content));
         }
     }
     if ($size <= 0) {
         return $result;
     }
     if ($default_function != $transformation_plugin) {
         $result = $transformation_plugin->applyTransformation($result, $transform_options, $meta);
         return $result;
     }
     $result = $default_function($result, array(), $meta);
     if ($_SESSION['tmpval']['display_binary'] && $meta->type === self::STRING_FIELD || $_SESSION['tmpval']['display_blob'] && stristr($meta->type, self::BLOB_FIELD)) {
         // in this case, restart from the original $content
         $result = bin2hex($content);
         list($is_truncated, $result, ) = $this->_getPartialText($result);
     }
     /* Create link to download */
     // in PHP < 5.5, empty() only checks variables
     $tmpdb = $this->__get('db');
     if (count($url_params) > 0 && (!empty($tmpdb) && !empty($meta->orgtable))) {
         $result = '<a href="tbl_get_field.php' . PMA_URL_getCommon($url_params) . '" class="disableAjax">' . $result . '</a>';
     }
     return $result;
 }
开发者ID:rugbyprof,项目名称:phpmyadmin,代码行数:68,代码来源:DisplayResults.php

示例5: getValuesForInnodbTable

 /**
  * Get values for InnoDB table
  *
  * @param array  $current_table current table
  * @param double $sum_size      sum size
  *
  * @return array
  */
 protected function getValuesForInnodbTable($current_table, $sum_size)
 {
     $formatted_size = $unit = '';
     if ($current_table['ENGINE'] == 'InnoDB' && $current_table['TABLE_ROWS'] < $GLOBALS['cfg']['MaxExactCount'] || !isset($current_table['TABLE_ROWS'])) {
         $current_table['COUNTED'] = true;
         $current_table['TABLE_ROWS'] = $this->dbi->getTable($this->db, $current_table['TABLE_NAME'])->countRecords(true);
     } else {
         $current_table['COUNTED'] = false;
     }
     if ($this->_is_show_stats) {
         $tblsize = $current_table['Data_length'] + $current_table['Index_length'];
         $sum_size += $tblsize;
         list($formatted_size, $unit) = Util::formatByteDown($tblsize, 3, $tblsize > 0 ? 1 : 0);
     }
     return array($current_table, $formatted_size, $unit, $sum_size);
 }
开发者ID:netroby,项目名称:phpmyadmin,代码行数:24,代码来源:DatabaseStructureController.php

示例6: _formatVariable

 /**
  * Format Variable
  *
  * @param string  $name  variable name
  * @param integer $value variable value
  *
  * @return array formatted string and bool if string is HTML formatted
  */
 private function _formatVariable($name, $value)
 {
     $isHtmlFormatted = false;
     $formattedValue = $value;
     if (is_numeric($value)) {
         if (isset($this->variable_doc_links[$name][3]) && $this->variable_doc_links[$name][3] == 'byte') {
             $isHtmlFormatted = true;
             $formattedValue = '<abbr title="' . htmlspecialchars(Util::formatNumber($value, 0)) . '">' . htmlspecialchars(implode(' ', Util::formatByteDown($value, 3, 3))) . '</abbr>';
         } else {
             $formattedValue = Util::formatNumber($value, 0);
         }
     }
     return array($formattedValue, $isHtmlFormatted);
 }
开发者ID:phpmyadmin,项目名称:phpmyadmin,代码行数:22,代码来源:ServerVariablesController.php

示例7: _formatVariable

 /**
  * Format Variable
  *
  * @param string $name  variable name
  * @param number $value variable value
  *
  * @return string formatted string
  */
 private function _formatVariable($name, $value)
 {
     if (is_numeric($value)) {
         if (isset($this->variable_doc_links[$name][3]) && $this->variable_doc_links[$name][3] == 'byte') {
             return '<abbr title="' . Util::formatNumber($value, 0) . '">' . implode(' ', Util::formatByteDown($value, 3, 3)) . '</abbr>';
         } else {
             return Util::formatNumber($value, 0);
         }
     }
     return $value;
 }
开发者ID:itgsod-philip-skalander,项目名称:phpmyadmin,代码行数:19,代码来源:ServerVariablesController.php

示例8: PMA_getJsonForLogDataTypeGeneral

/**
 * Returns JSon for log data with type: general
 *
 * @param int $start Unix Time: Start time for query
 * @param int $end   Unix Time: End time for query
 *
 * @return array
 */
function PMA_getJsonForLogDataTypeGeneral($start, $end)
{
    $limitTypes = '';
    if (isset($_REQUEST['limitTypes']) && $_REQUEST['limitTypes']) {
        $limitTypes = 'AND argument REGEXP \'^(INSERT|SELECT|UPDATE|DELETE)\' ';
    }
    $query = 'SELECT TIME(event_time) as event_time, user_host, thread_id, ';
    $query .= 'server_id, argument, count(argument) as \'#\' ';
    $query .= 'FROM `mysql`.`general_log` ';
    $query .= 'WHERE command_type=\'Query\' ';
    $query .= 'AND event_time > FROM_UNIXTIME(' . $start . ') ';
    $query .= 'AND event_time < FROM_UNIXTIME(' . $end . ') ';
    $query .= $limitTypes . 'GROUP by argument';
    // HAVING count > 1';
    $result = $GLOBALS['dbi']->tryQuery($query);
    $return = array('rows' => array(), 'sum' => array());
    $insertTables = array();
    $insertTablesFirst = -1;
    $i = 0;
    $removeVars = isset($_REQUEST['removeVariables']) && $_REQUEST['removeVariables'];
    while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
        preg_match('/^(\\w+)\\s/', $row['argument'], $match);
        $type = mb_strtolower($match[1]);
        if (!isset($return['sum'][$type])) {
            $return['sum'][$type] = 0;
        }
        $return['sum'][$type] += $row['#'];
        switch ($type) {
            /** @noinspection PhpMissingBreakStatementInspection */
            case 'insert':
                // Group inserts if selected
                if ($removeVars && preg_match('/^INSERT INTO (`|\'|"|)([^\\s\\1]+)\\1/i', $row['argument'], $matches)) {
                    $insertTables[$matches[2]]++;
                    if ($insertTables[$matches[2]] > 1) {
                        $return['rows'][$insertTablesFirst]['#'] = $insertTables[$matches[2]];
                        // Add a ... to the end of this query to indicate that
                        // there's been other queries
                        $temp = $return['rows'][$insertTablesFirst]['argument'];
                        $return['rows'][$insertTablesFirst]['argument'] .= PMA_getSuspensionPoints($temp[mb_strlen($temp) - 1]);
                        // Group this value, thus do not add to the result list
                        continue 2;
                    } else {
                        $insertTablesFirst = $i;
                        $insertTables[$matches[2]] += $row['#'] - 1;
                    }
                }
                // No break here
            // No break here
            case 'update':
                // Cut off big inserts and updates,
                // but append byte count therefor
                if (mb_strlen($row['argument']) > 220) {
                    $row['argument'] = mb_substr($row['argument'], 0, 200) . '... [' . implode(' ', PMA\libraries\Util::formatByteDown(mb_strlen($row['argument']), 2, 2)) . ']';
                }
                break;
            default:
                break;
        }
        $return['rows'][] = $row;
        $i++;
    }
    $return['sum']['TOTAL'] = array_sum($return['sum']);
    $return['numRows'] = count($return['rows']);
    $GLOBALS['dbi']->freeResult($result);
    return $return;
}
开发者ID:flash1452,项目名称:phpmyadmin,代码行数:74,代码来源:server_status_monitor.lib.php

示例9: getTableStats

 /**
  * Get HTML snippet for display table statistics
  *
  * @return string $html_output
  */
 protected function getTableStats()
 {
     if (empty($this->_showtable)) {
         $this->_showtable = $this->dbi->getTable($this->db, $this->table)->getStatusInfo(null, true);
     }
     if (empty($this->_showtable['Data_length'])) {
         $this->_showtable['Data_length'] = 0;
     }
     if (empty($this->_showtable['Index_length'])) {
         $this->_showtable['Index_length'] = 0;
     }
     $is_innodb = isset($this->_showtable['Type']) && $this->_showtable['Type'] == 'InnoDB';
     $mergetable = $this->table_obj->isMerge();
     // this is to display for example 261.2 MiB instead of 268k KiB
     $max_digits = 3;
     $decimals = 1;
     list($data_size, $data_unit) = Util::formatByteDown($this->_showtable['Data_length'], $max_digits, $decimals);
     if ($mergetable == false) {
         list($index_size, $index_unit) = Util::formatByteDown($this->_showtable['Index_length'], $max_digits, $decimals);
     }
     // InnoDB returns a huge value in Data_free, do not use it
     if (!$is_innodb && isset($this->_showtable['Data_free']) && $this->_showtable['Data_free'] > 0) {
         list($free_size, $free_unit) = Util::formatByteDown($this->_showtable['Data_free'], $max_digits, $decimals);
         list($effect_size, $effect_unit) = Util::formatByteDown($this->_showtable['Data_length'] + $this->_showtable['Index_length'] - $this->_showtable['Data_free'], $max_digits, $decimals);
     } else {
         list($effect_size, $effect_unit) = Util::formatByteDown($this->_showtable['Data_length'] + $this->_showtable['Index_length'], $max_digits, $decimals);
     }
     list($tot_size, $tot_unit) = Util::formatByteDown($this->_showtable['Data_length'] + $this->_showtable['Index_length'], $max_digits, $decimals);
     if ($this->_table_info_num_rows > 0) {
         list($avg_size, $avg_unit) = Util::formatByteDown(($this->_showtable['Data_length'] + $this->_showtable['Index_length']) / $this->_showtable['Rows'], 6, 1);
     } else {
         $avg_size = $avg_unit = '';
     }
     return Template::get('table/structure/display_table_stats')->render(array('showtable' => $this->_showtable, 'table_info_num_rows' => $this->_table_info_num_rows, 'tbl_is_view' => $this->_tbl_is_view, 'db_is_system_schema' => $this->_db_is_system_schema, 'tbl_storage_engine' => $this->_tbl_storage_engine, 'url_query' => $this->_url_query, 'tbl_collation' => $this->_tbl_collation, 'is_innodb' => $is_innodb, 'mergetable' => $mergetable, 'avg_size' => isset($avg_size) ? $avg_size : null, 'avg_unit' => isset($avg_unit) ? $avg_unit : null, 'data_size' => $data_size, 'data_unit' => $data_unit, 'index_size' => isset($index_size) ? $index_size : null, 'index_unit' => isset($index_unit) ? $index_unit : null, 'free_size' => isset($free_size) ? $free_size : null, 'free_unit' => isset($free_unit) ? $free_unit : null, 'effect_size' => $effect_size, 'effect_unit' => $effect_unit, 'tot_size' => $tot_size, 'tot_unit' => $tot_unit));
 }
开发者ID:Gemorroj,项目名称:phpmyadmin,代码行数:40,代码来源:TableStructureController.php

示例10: resolveTypeSize

 /**
  * Returns the engine specific handling for
  * PMA_ENGINE_DETAILS_TYPE_SIZE type variables.
  *
  * This function should be overridden when
  * PMA_ENGINE_DETAILS_TYPE_SIZE type needs to be
  * handled differently for a particular engine.
  *
  * @param integer $value Value to format
  *
  * @return string the formatted value and its unit
  */
 public function resolveTypeSize($value)
 {
     return Util::formatByteDown($value);
 }
开发者ID:itgsod-philip-skalander,项目名称:phpmyadmin,代码行数:16,代码来源:StorageEngine.php


注:本文中的PMA\libraries\Util::formatByteDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。