PageRenderTime 57ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/moodle1917/configuracionCated/phpmyadmin/libraries/Util.class.php

https://github.com/gustavoramirezrugerio/moodle1.9.17
PHP | 4366 lines | 2759 code | 384 blank | 1223 comment | 568 complexity | 8ba5cd070d21be19294b0d5747e0d2d9 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, BSD-3-Clause, LGPL-2.0, GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Hold the PMA_Util class
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /**
  12. * Misc functions used all over the scripts.
  13. *
  14. * @package PhpMyAdmin
  15. */
  16. class PMA_Util
  17. {
  18. /**
  19. * Detects which function to use for pow.
  20. *
  21. * @return string Function name.
  22. */
  23. public static function detectPow()
  24. {
  25. if (function_exists('bcpow')) {
  26. // BCMath Arbitrary Precision Mathematics Function
  27. return 'bcpow';
  28. } elseif (function_exists('gmp_pow')) {
  29. // GMP Function
  30. return 'gmp_pow';
  31. } else {
  32. // PHP function
  33. return 'pow';
  34. }
  35. }
  36. /**
  37. * Exponential expression / raise number into power
  38. *
  39. * @param string $base base to raise
  40. * @param string $exp exponent to use
  41. * @param mixed $use_function pow function to use, or false for auto-detect
  42. *
  43. * @return mixed string or float
  44. */
  45. public static function pow($base, $exp, $use_function = false)
  46. {
  47. static $pow_function = null;
  48. if ($pow_function == null) {
  49. $pow_function = self::detectPow();
  50. }
  51. if (! $use_function) {
  52. if ($exp < 0) {
  53. $use_function = 'pow';
  54. } else {
  55. $use_function = $pow_function;
  56. }
  57. }
  58. if (($exp < 0) && ($use_function != 'pow')) {
  59. return false;
  60. }
  61. switch ($use_function) {
  62. case 'bcpow' :
  63. // bcscale() needed for testing pow() with base values < 1
  64. bcscale(10);
  65. $pow = bcpow($base, $exp);
  66. break;
  67. case 'gmp_pow' :
  68. $pow = gmp_strval(gmp_pow($base, $exp));
  69. break;
  70. case 'pow' :
  71. $base = (float) $base;
  72. $exp = (int) $exp;
  73. $pow = pow($base, $exp);
  74. break;
  75. default:
  76. $pow = $use_function($base, $exp);
  77. }
  78. return $pow;
  79. }
  80. /**
  81. * Checks whether configuration value tells to show icons.
  82. *
  83. * @param string $value Configuration option name
  84. *
  85. * @return boolean Whether to show icons.
  86. */
  87. public static function showIcons($value)
  88. {
  89. return in_array($GLOBALS['cfg'][$value], array('icons', 'both'));
  90. }
  91. /**
  92. * Checks whether configuration value tells to show text.
  93. *
  94. * @param string $value Configuration option name
  95. *
  96. * @return boolean Whether to show text.
  97. */
  98. public static function showText($value)
  99. {
  100. return in_array($GLOBALS['cfg'][$value], array('text', 'both'));
  101. }
  102. /**
  103. * Returns an HTML IMG tag for a particular icon from a theme,
  104. * which may be an actual file or an icon from a sprite.
  105. * This function takes into account the ActionLinksMode
  106. * configuration setting and wraps the image tag in a span tag.
  107. *
  108. * @param string $icon name of icon file
  109. * @param string $alternate alternate text
  110. * @param boolean $force_text whether to force alternate text to be displayed
  111. * @param boolean $menu_icon whether this icon is for the menu bar or not
  112. * @param string $control_param which directive controls the display
  113. *
  114. * @return string an html snippet
  115. */
  116. public static function getIcon(
  117. $icon, $alternate = '', $force_text = false,
  118. $menu_icon = false, $control_param = 'ActionLinksMode'
  119. ) {
  120. $include_icon = $include_text = false;
  121. if (self::showIcons($control_param)) {
  122. $include_icon = true;
  123. }
  124. if ($force_text
  125. || self::showText($control_param)
  126. ) {
  127. $include_text = true;
  128. }
  129. // Sometimes use a span (we rely on this in js/sql.js). But for menu bar
  130. // we don't need a span
  131. $button = $menu_icon ? '' : '<span class="nowrap">';
  132. if ($include_icon) {
  133. $button .= self::getImage($icon, $alternate);
  134. }
  135. if ($include_icon && $include_text) {
  136. $button .= ' ';
  137. }
  138. if ($include_text) {
  139. $button .= $alternate;
  140. }
  141. $button .= $menu_icon ? '' : '</span>';
  142. return $button;
  143. }
  144. /**
  145. * Returns an HTML IMG tag for a particular image from a theme,
  146. * which may be an actual file or an icon from a sprite
  147. *
  148. * @param string $image The name of the file to get
  149. * @param string $alternate Used to set 'alt' and 'title' attributes
  150. * of the image
  151. * @param array $attributes An associative array of other attributes
  152. *
  153. * @return string an html IMG tag
  154. */
  155. public static function getImage($image, $alternate = '', $attributes = array())
  156. {
  157. static $sprites; // cached list of available sprites (if any)
  158. if (defined('TESTSUITE')) {
  159. // prevent caching in testsuite
  160. unset($sprites);
  161. }
  162. $url = '';
  163. $is_sprite = false;
  164. $alternate = htmlspecialchars($alternate);
  165. // If it's the first time this function is called
  166. if (! isset($sprites)) {
  167. // Try to load the list of sprites
  168. $sprite_file = $_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php';
  169. if (is_readable($sprite_file)) {
  170. include_once $sprite_file;
  171. $sprites = PMA_sprites();
  172. } else {
  173. // No sprites are available for this theme
  174. $sprites = array();
  175. }
  176. }
  177. // Check if we have the requested image as a sprite
  178. // and set $url accordingly
  179. $class = str_replace(array('.gif','.png'), '', $image);
  180. if (array_key_exists($class, $sprites)) {
  181. $is_sprite = true;
  182. $url = (defined('PMA_TEST_THEME') ? '../' : '') . 'themes/dot.gif';
  183. } else {
  184. $url = $GLOBALS['pmaThemeImage'] . $image;
  185. }
  186. // set class attribute
  187. if ($is_sprite) {
  188. if (isset($attributes['class'])) {
  189. $attributes['class'] = "icon ic_$class " . $attributes['class'];
  190. } else {
  191. $attributes['class'] = "icon ic_$class";
  192. }
  193. }
  194. // set all other attributes
  195. $attr_str = '';
  196. foreach ($attributes as $key => $value) {
  197. if (! in_array($key, array('alt', 'title'))) {
  198. $attr_str .= " $key=\"$value\"";
  199. }
  200. }
  201. // override the alt attribute
  202. if (isset($attributes['alt'])) {
  203. $alt = $attributes['alt'];
  204. } else {
  205. $alt = $alternate;
  206. }
  207. // override the title attribute
  208. if (isset($attributes['title'])) {
  209. $title = $attributes['title'];
  210. } else {
  211. $title = $alternate;
  212. }
  213. // generate the IMG tag
  214. $template = '<img src="%s" title="%s" alt="%s"%s />';
  215. $retval = sprintf($template, $url, $title, $alt, $attr_str);
  216. return $retval;
  217. }
  218. /**
  219. * Returns the formatted maximum size for an upload
  220. *
  221. * @param integer $max_upload_size the size
  222. *
  223. * @return string the message
  224. *
  225. * @access public
  226. */
  227. public static function getFormattedMaximumUploadSize($max_upload_size)
  228. {
  229. // I have to reduce the second parameter (sensitiveness) from 6 to 4
  230. // to avoid weird results like 512 kKib
  231. list($max_size, $max_unit) = self::formatByteDown($max_upload_size, 4);
  232. return '(' . sprintf(__('Max: %s%s'), $max_size, $max_unit) . ')';
  233. }
  234. /**
  235. * Generates a hidden field which should indicate to the browser
  236. * the maximum size for upload
  237. *
  238. * @param integer $max_size the size
  239. *
  240. * @return string the INPUT field
  241. *
  242. * @access public
  243. */
  244. public static function generateHiddenMaxFileSize($max_size)
  245. {
  246. return '<input type="hidden" name="MAX_FILE_SIZE" value="'
  247. . $max_size . '" />';
  248. }
  249. /**
  250. * Add slashes before "'" and "\" characters so a value containing them can
  251. * be used in a sql comparison.
  252. *
  253. * @param string $a_string the string to slash
  254. * @param bool $is_like whether the string will be used in a 'LIKE' clause
  255. * (it then requires two more escaped sequences) or not
  256. * @param bool $crlf whether to treat cr/lfs as escape-worthy entities
  257. * (converts \n to \\n, \r to \\r)
  258. * @param bool $php_code whether this function is used as part of the
  259. * "Create PHP code" dialog
  260. *
  261. * @return string the slashed string
  262. *
  263. * @access public
  264. */
  265. public static function sqlAddSlashes(
  266. $a_string = '', $is_like = false, $crlf = false, $php_code = false
  267. ) {
  268. if ($is_like) {
  269. $a_string = str_replace('\\', '\\\\\\\\', $a_string);
  270. } else {
  271. $a_string = str_replace('\\', '\\\\', $a_string);
  272. }
  273. if ($crlf) {
  274. $a_string = strtr(
  275. $a_string,
  276. array("\n" => '\n', "\r" => '\r', "\t" => '\t')
  277. );
  278. }
  279. if ($php_code) {
  280. $a_string = str_replace('\'', '\\\'', $a_string);
  281. } else {
  282. $a_string = str_replace('\'', '\'\'', $a_string);
  283. }
  284. return $a_string;
  285. } // end of the 'sqlAddSlashes()' function
  286. /**
  287. * Add slashes before "_" and "%" characters for using them in MySQL
  288. * database, table and field names.
  289. * Note: This function does not escape backslashes!
  290. *
  291. * @param string $name the string to escape
  292. *
  293. * @return string the escaped string
  294. *
  295. * @access public
  296. */
  297. public static function escapeMysqlWildcards($name)
  298. {
  299. return strtr($name, array('_' => '\\_', '%' => '\\%'));
  300. } // end of the 'escapeMysqlWildcards()' function
  301. /**
  302. * removes slashes before "_" and "%" characters
  303. * Note: This function does not unescape backslashes!
  304. *
  305. * @param string $name the string to escape
  306. *
  307. * @return string the escaped string
  308. *
  309. * @access public
  310. */
  311. public static function unescapeMysqlWildcards($name)
  312. {
  313. return strtr($name, array('\\_' => '_', '\\%' => '%'));
  314. } // end of the 'unescapeMysqlWildcards()' function
  315. /**
  316. * removes quotes (',",`) from a quoted string
  317. *
  318. * checks if the string is quoted and removes this quotes
  319. *
  320. * @param string $quoted_string string to remove quotes from
  321. * @param string $quote type of quote to remove
  322. *
  323. * @return string unqoted string
  324. */
  325. public static function unQuote($quoted_string, $quote = null)
  326. {
  327. $quotes = array();
  328. if ($quote === null) {
  329. $quotes[] = '`';
  330. $quotes[] = '"';
  331. $quotes[] = "'";
  332. } else {
  333. $quotes[] = $quote;
  334. }
  335. foreach ($quotes as $quote) {
  336. if (substr($quoted_string, 0, 1) === $quote
  337. && substr($quoted_string, -1, 1) === $quote
  338. ) {
  339. $unquoted_string = substr($quoted_string, 1, -1);
  340. // replace escaped quotes
  341. $unquoted_string = str_replace(
  342. $quote . $quote,
  343. $quote,
  344. $unquoted_string
  345. );
  346. return $unquoted_string;
  347. }
  348. }
  349. return $quoted_string;
  350. }
  351. /**
  352. * format sql strings
  353. *
  354. * @param string $sql_query raw SQL string
  355. * @param boolean $truncate truncate the query if it is too long
  356. *
  357. * @return string the formatted sql
  358. *
  359. * @global array $cfg the configuration array
  360. *
  361. * @access public
  362. * @todo move into PMA_Sql
  363. */
  364. public static function formatSql($sql_query, $truncate = false)
  365. {
  366. global $cfg;
  367. if ($truncate
  368. && strlen($sql_query) > $cfg['MaxCharactersInDisplayedSQL']
  369. ) {
  370. $sql_query = $GLOBALS['PMA_String']->substr(
  371. $sql_query,
  372. 0,
  373. $cfg['MaxCharactersInDisplayedSQL']
  374. ) . '[...]';
  375. }
  376. return '<code class="sql"><pre>' . "\n"
  377. . htmlspecialchars($sql_query) . "\n"
  378. . '</pre></code>';
  379. } // end of the "formatSql()" function
  380. /**
  381. * Displays a link to the documentation as an icon
  382. *
  383. * @param string $link documentation link
  384. * @param string $target optional link target
  385. *
  386. * @return string the html link
  387. *
  388. * @access public
  389. */
  390. public static function showDocLink($link, $target = 'documentation')
  391. {
  392. return '<a href="' . $link . '" target="' . $target . '">'
  393. . self::getImage('b_help.png', __('Documentation'))
  394. . '</a>';
  395. } // end of the 'showDocLink()' function
  396. /**
  397. * Get a URL link to the official MySQL documentation
  398. *
  399. * @param string $link contains name of page/anchor that is being linked
  400. * @param string $anchor anchor to page part
  401. *
  402. * @return string the URL link
  403. *
  404. * @access public
  405. */
  406. public static function getMySQLDocuURL($link, $anchor = '')
  407. {
  408. global $cfg;
  409. // Fixup for newly used names:
  410. $link = str_replace('_', '-', strtolower($link));
  411. if (empty($link)) {
  412. $link = 'index';
  413. }
  414. $mysql = '5.5';
  415. $lang = 'en';
  416. if (defined('PMA_MYSQL_INT_VERSION')) {
  417. if (PMA_MYSQL_INT_VERSION >= 50600) {
  418. $mysql = '5.6';
  419. } else if (PMA_MYSQL_INT_VERSION >= 50500) {
  420. $mysql = '5.5';
  421. } else if (PMA_MYSQL_INT_VERSION >= 50100) {
  422. $mysql = '5.1';
  423. } else {
  424. $mysql = '5.0';
  425. }
  426. }
  427. $url = 'http://dev.mysql.com/doc/refman/'
  428. . $mysql . '/' . $lang . '/' . $link . '.html';
  429. if (! empty($anchor)) {
  430. $url .= '#' . $anchor;
  431. }
  432. return PMA_linkURL($url);
  433. }
  434. /**
  435. * Displays a link to the official MySQL documentation
  436. *
  437. * @param string $link contains name of page/anchor that is being linked
  438. * @param bool $big_icon whether to use big icon (like in left frame)
  439. * @param string $anchor anchor to page part
  440. * @param bool $just_open whether only the opening <a> tag should be returned
  441. *
  442. * @return string the html link
  443. *
  444. * @access public
  445. */
  446. public static function showMySQLDocu(
  447. $link, $big_icon = false, $anchor = '', $just_open = false
  448. ) {
  449. $url = self::getMySQLDocuURL($link, $anchor);
  450. $open_link = '<a href="' . $url . '" target="mysql_doc">';
  451. if ($just_open) {
  452. return $open_link;
  453. } elseif ($big_icon) {
  454. return $open_link
  455. . self::getImage('b_sqlhelp.png', __('Documentation')) . '</a>';
  456. } else {
  457. return self::showDocLink($url, 'mysql_doc');
  458. }
  459. } // end of the 'showMySQLDocu()' function
  460. /**
  461. * Returns link to documentation.
  462. *
  463. * @param string $page Page in documentation
  464. * @param string $anchor Optional anchor in page
  465. *
  466. * @return string URL
  467. */
  468. public static function getDocuLink($page, $anchor = '')
  469. {
  470. /* Construct base URL */
  471. $url = $page . '.html';
  472. if (!empty($anchor)) {
  473. $url .= '#' . $anchor;
  474. }
  475. /* Check if we have built local documentation */
  476. if (defined('TESTSUITE')) {
  477. /* Provide consistent URL for testsuite */
  478. return PMA_linkURL('http://docs.phpmyadmin.net/en/latest/' . $url);
  479. } else if (file_exists('doc/html/index.html')) {
  480. if (defined('PMA_SETUP')) {
  481. return '../doc/html/' . $url;
  482. } else {
  483. return './doc/html/' . $url;
  484. }
  485. } else {
  486. /* TODO: Should link to correct branch for released versions */
  487. return PMA_linkURL('http://docs.phpmyadmin.net/en/latest/' . $url);
  488. }
  489. }
  490. /**
  491. * Displays a link to the phpMyAdmin documentation
  492. *
  493. * @param string $page Page in documentation
  494. * @param string $anchor Optional anchor in page
  495. *
  496. * @return string the html link
  497. *
  498. * @access public
  499. */
  500. public static function showDocu($page, $anchor = '')
  501. {
  502. return self::showDocLink(self::getDocuLink($page, $anchor));
  503. } // end of the 'showDocu()' function
  504. /**
  505. * Displays a link to the PHP documentation
  506. *
  507. * @param string $target anchor in documentation
  508. *
  509. * @return string the html link
  510. *
  511. * @access public
  512. */
  513. public static function showPHPDocu($target)
  514. {
  515. $url = PMA_getPHPDocLink($target);
  516. return self::showDocLink($url);
  517. } // end of the 'showPHPDocu()' function
  518. /**
  519. * Returns HTML code for a tooltip
  520. *
  521. * @param string $message the message for the tooltip
  522. *
  523. * @return string
  524. *
  525. * @access public
  526. */
  527. public static function showHint($message)
  528. {
  529. if ($GLOBALS['cfg']['ShowHint']) {
  530. $classClause = ' class="pma_hint"';
  531. } else {
  532. $classClause = '';
  533. }
  534. return '<span' . $classClause . '>'
  535. . self::getImage('b_help.png')
  536. . '<span class="hide">' . $message . '</span>'
  537. . '</span>';
  538. }
  539. /**
  540. * Displays a MySQL error message in the main panel when $exit is true.
  541. * Returns the error message otherwise.
  542. *
  543. * @param string $error_message the error message
  544. * @param string $the_query the sql query that failed
  545. * @param bool $is_modify_link whether to show a "modify" link or not
  546. * @param string $back_url the "back" link url (full path is not required)
  547. * @param bool $exit EXIT the page?
  548. *
  549. * @return mixed
  550. *
  551. * @global string $table the curent table
  552. * @global string $db the current db
  553. *
  554. * @access public
  555. */
  556. public static function mysqlDie(
  557. $error_message = '', $the_query = '',
  558. $is_modify_link = true, $back_url = '', $exit = true
  559. ) {
  560. global $table, $db;
  561. $error_msg = '';
  562. if (! $error_message) {
  563. $error_message = $GLOBALS['dbi']->getError();
  564. }
  565. if (! $the_query && ! empty($GLOBALS['sql_query'])) {
  566. $the_query = $GLOBALS['sql_query'];
  567. }
  568. // --- Added to solve bug #641765
  569. if (! function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
  570. $formatted_sql = htmlspecialchars($the_query);
  571. } elseif (empty($the_query) || (trim($the_query) == '')) {
  572. $formatted_sql = '';
  573. } else {
  574. $formatted_sql = self::formatSql($the_query, true);
  575. }
  576. // ---
  577. $error_msg .= "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
  578. $error_msg .= ' <div class="error"><h1>' . __('Error')
  579. . '</h1>' . "\n";
  580. // if the config password is wrong, or the MySQL server does not
  581. // respond, do not show the query that would reveal the
  582. // username/password
  583. if (! empty($the_query) && ! strstr($the_query, 'connect')) {
  584. // --- Added to solve bug #641765
  585. if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
  586. $error_msg .= PMA_SQP_getErrorString() . "\n";
  587. $error_msg .= '<br />' . "\n";
  588. }
  589. // ---
  590. // modified to show the help on sql errors
  591. $error_msg .= '<p><strong>' . __('SQL query:') . '</strong>' . "\n";
  592. if (strstr(strtolower($formatted_sql), 'select')) {
  593. // please show me help to the error on select
  594. $error_msg .= self::showMySQLDocu('SELECT');
  595. }
  596. if ($is_modify_link) {
  597. $_url_params = array(
  598. 'sql_query' => $the_query,
  599. 'show_query' => 1,
  600. );
  601. if (strlen($table)) {
  602. $_url_params['db'] = $db;
  603. $_url_params['table'] = $table;
  604. $doedit_goto = '<a href="tbl_sql.php'
  605. . PMA_URL_getCommon($_url_params) . '">';
  606. } elseif (strlen($db)) {
  607. $_url_params['db'] = $db;
  608. $doedit_goto = '<a href="db_sql.php'
  609. . PMA_URL_getCommon($_url_params) . '">';
  610. } else {
  611. $doedit_goto = '<a href="server_sql.php'
  612. . PMA_URL_getCommon($_url_params) . '">';
  613. }
  614. $error_msg .= $doedit_goto
  615. . self::getIcon('b_edit.png', __('Edit'))
  616. . '</a>';
  617. } // end if
  618. $error_msg .= ' </p>' . "\n"
  619. .'<p>' . "\n"
  620. . $formatted_sql . "\n"
  621. . '</p>' . "\n";
  622. } // end if
  623. if (! empty($error_message)) {
  624. $error_message = preg_replace(
  625. "@((\015\012)|(\015)|(\012)){3,}@",
  626. "\n\n",
  627. $error_message
  628. );
  629. }
  630. // modified to show the help on error-returns
  631. // (now error-messages-server)
  632. $error_msg .= '<p>' . "\n"
  633. . ' <strong>' . __('MySQL said: ') . '</strong>'
  634. . self::showMySQLDocu('Error-messages-server')
  635. . "\n"
  636. . '</p>' . "\n";
  637. // The error message will be displayed within a CODE segment.
  638. // To preserve original formatting, but allow wordwrapping,
  639. // we do a couple of replacements
  640. // Replace all non-single blanks with their HTML-counterpart
  641. $error_message = str_replace(' ', '&nbsp;&nbsp;', $error_message);
  642. // Replace TAB-characters with their HTML-counterpart
  643. $error_message = str_replace(
  644. "\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $error_message
  645. );
  646. // Replace linebreaks
  647. $error_message = nl2br($error_message);
  648. $error_msg .= '<code>' . "\n"
  649. . $error_message . "\n"
  650. . '</code><br />' . "\n";
  651. $error_msg .= '</div>';
  652. $_SESSION['Import_message']['message'] = $error_msg;
  653. if ($exit) {
  654. /**
  655. * If in an Ajax request
  656. * - avoid displaying a Back link
  657. * - use PMA_Response() to transmit the message and exit
  658. */
  659. if (isset($GLOBALS['is_ajax_request'])
  660. && $GLOBALS['is_ajax_request'] == true
  661. ) {
  662. $response = PMA_Response::getInstance();
  663. $response->isSuccess(false);
  664. $response->addJSON('message', $error_msg);
  665. exit;
  666. }
  667. if (! empty($back_url)) {
  668. if (strstr($back_url, '?')) {
  669. $back_url .= '&amp;no_history=true';
  670. } else {
  671. $back_url .= '?no_history=true';
  672. }
  673. $_SESSION['Import_message']['go_back_url'] = $back_url;
  674. $error_msg .= '<fieldset class="tblFooters">'
  675. . '[ <a href="' . $back_url . '">' . __('Back') . '</a> ]'
  676. . '</fieldset>' . "\n\n";
  677. }
  678. echo $error_msg;
  679. exit;
  680. } else {
  681. return $error_msg;
  682. }
  683. } // end of the 'mysqlDie()' function
  684. /**
  685. * returns array with tables of given db with extended information and grouped
  686. *
  687. * @param string $db name of db
  688. * @param string $tables name of tables
  689. * @param integer $limit_offset list offset
  690. * @param int|bool $limit_count max tables to return
  691. *
  692. * @return array (recursive) grouped table list
  693. */
  694. public static function getTableList(
  695. $db, $tables = null, $limit_offset = 0, $limit_count = false
  696. ) {
  697. $sep = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
  698. if ($tables === null) {
  699. $tables = $GLOBALS['dbi']->getTablesFull(
  700. $db, false, false, null, $limit_offset, $limit_count
  701. );
  702. if ($GLOBALS['cfg']['NaturalOrder']) {
  703. uksort($tables, 'strnatcasecmp');
  704. }
  705. }
  706. if (count($tables) < 1) {
  707. return $tables;
  708. }
  709. $default = array(
  710. 'Name' => '',
  711. 'Rows' => 0,
  712. 'Comment' => '',
  713. 'disp_name' => '',
  714. );
  715. $table_groups = array();
  716. foreach ($tables as $table_name => $table) {
  717. // check for correct row count
  718. if ($table['Rows'] === null) {
  719. // Do not check exact row count here,
  720. // if row count is invalid possibly the table is defect
  721. // and this would break left frame;
  722. // but we can check row count if this is a view or the
  723. // information_schema database
  724. // since PMA_Table::countRecords() returns a limited row count
  725. // in this case.
  726. // set this because PMA_Table::countRecords() can use it
  727. $tbl_is_view = $table['TABLE_TYPE'] == 'VIEW';
  728. if ($tbl_is_view || $GLOBALS['dbi']->isSystemSchema($db)) {
  729. $table['Rows'] = PMA_Table::countRecords(
  730. $db,
  731. $table['Name'],
  732. false,
  733. true
  734. );
  735. }
  736. }
  737. // in $group we save the reference to the place in $table_groups
  738. // where to store the table info
  739. if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']
  740. && $sep && strstr($table_name, $sep)
  741. ) {
  742. $parts = explode($sep, $table_name);
  743. $group =& $table_groups;
  744. $i = 0;
  745. $group_name_full = '';
  746. $parts_cnt = count($parts) - 1;
  747. while (($i < $parts_cnt)
  748. && ($i < $GLOBALS['cfg']['NavigationTreeTableLevel'])
  749. ) {
  750. $group_name = $parts[$i] . $sep;
  751. $group_name_full .= $group_name;
  752. if (! isset($group[$group_name])) {
  753. $group[$group_name] = array();
  754. $group[$group_name]['is' . $sep . 'group'] = true;
  755. $group[$group_name]['tab' . $sep . 'count'] = 1;
  756. $group[$group_name]['tab' . $sep . 'group']
  757. = $group_name_full;
  758. } elseif (! isset($group[$group_name]['is' . $sep . 'group'])) {
  759. $table = $group[$group_name];
  760. $group[$group_name] = array();
  761. $group[$group_name][$group_name] = $table;
  762. unset($table);
  763. $group[$group_name]['is' . $sep . 'group'] = true;
  764. $group[$group_name]['tab' . $sep . 'count'] = 1;
  765. $group[$group_name]['tab' . $sep . 'group']
  766. = $group_name_full;
  767. } else {
  768. $group[$group_name]['tab' . $sep . 'count']++;
  769. }
  770. $group =& $group[$group_name];
  771. $i++;
  772. }
  773. } else {
  774. if (! isset($table_groups[$table_name])) {
  775. $table_groups[$table_name] = array();
  776. }
  777. $group =& $table_groups;
  778. }
  779. $table['disp_name'] = $table['Name'];
  780. $group[$table_name] = array_merge($default, $table);
  781. }
  782. return $table_groups;
  783. }
  784. /* ----------------------- Set of misc functions ----------------------- */
  785. /**
  786. * Adds backquotes on both sides of a database, table or field name.
  787. * and escapes backquotes inside the name with another backquote
  788. *
  789. * example:
  790. * <code>
  791. * echo backquote('owner`s db'); // `owner``s db`
  792. *
  793. * </code>
  794. *
  795. * @param mixed $a_name the database, table or field name to "backquote"
  796. * or array of it
  797. * @param boolean $do_it a flag to bypass this function (used by dump
  798. * functions)
  799. *
  800. * @return mixed the "backquoted" database, table or field name
  801. *
  802. * @access public
  803. */
  804. public static function backquote($a_name, $do_it = true)
  805. {
  806. if (is_array($a_name)) {
  807. foreach ($a_name as &$data) {
  808. $data = self::backquote($data, $do_it);
  809. }
  810. return $a_name;
  811. }
  812. if (! $do_it) {
  813. global $PMA_SQPdata_forbidden_word;
  814. if (! in_array(strtoupper($a_name), $PMA_SQPdata_forbidden_word)) {
  815. return $a_name;
  816. }
  817. }
  818. // '0' is also empty for php :-(
  819. if (strlen($a_name) && $a_name !== '*') {
  820. return '`' . str_replace('`', '``', $a_name) . '`';
  821. } else {
  822. return $a_name;
  823. }
  824. } // end of the 'backquote()' function
  825. /**
  826. * Adds quotes on both sides of a database, table or field name.
  827. * in compatibility mode
  828. *
  829. * example:
  830. * <code>
  831. * echo backquote('owner`s db'); // `owner``s db`
  832. *
  833. * </code>
  834. *
  835. * @param mixed $a_name the database, table or field name to
  836. * "backquote" or array of it
  837. * @param string $compatibility string compatibility mode (used by dump
  838. * functions)
  839. * @param boolean $do_it a flag to bypass this function (used by dump
  840. * functions)
  841. *
  842. * @return mixed the "backquoted" database, table or field name
  843. *
  844. * @access public
  845. */
  846. public static function backquoteCompat(
  847. $a_name, $compatibility = 'MSSQL', $do_it = true
  848. ) {
  849. if (is_array($a_name)) {
  850. foreach ($a_name as &$data) {
  851. $data = self::backquoteCompat($data, $compatibility, $do_it);
  852. }
  853. return $a_name;
  854. }
  855. if (! $do_it) {
  856. global $PMA_SQPdata_forbidden_word;
  857. if (! in_array(strtoupper($a_name), $PMA_SQPdata_forbidden_word)) {
  858. return $a_name;
  859. }
  860. }
  861. // @todo add more compatibility cases (ORACLE for example)
  862. switch ($compatibility) {
  863. case 'MSSQL':
  864. $quote = '"';
  865. break;
  866. default:
  867. (isset($GLOBALS['sql_backquotes'])) ? $quote = "`" : $quote = '';
  868. break;
  869. }
  870. // '0' is also empty for php :-(
  871. if (strlen($a_name) && $a_name !== '*') {
  872. return $quote . $a_name . $quote;
  873. } else {
  874. return $a_name;
  875. }
  876. } // end of the 'backquoteCompat()' function
  877. /**
  878. * Defines the <CR><LF> value depending on the user OS.
  879. *
  880. * @return string the <CR><LF> value to use
  881. *
  882. * @access public
  883. */
  884. public static function whichCrlf()
  885. {
  886. // The 'PMA_USR_OS' constant is defined in "libraries/Config.class.php"
  887. // Win case
  888. if (PMA_USR_OS == 'Win') {
  889. $the_crlf = "\r\n";
  890. } else {
  891. // Others
  892. $the_crlf = "\n";
  893. }
  894. return $the_crlf;
  895. } // end of the 'whichCrlf()' function
  896. /**
  897. * Prepare the message and the query
  898. * usually the message is the result of the query executed
  899. *
  900. * @param string $message the message to display
  901. * @param string $sql_query the query to display
  902. * @param string $type the type (level) of the message
  903. * @param boolean $is_view is this a message after a VIEW operation?
  904. *
  905. * @return string
  906. *
  907. * @access public
  908. */
  909. public static function getMessage(
  910. $message, $sql_query = null, $type = 'notice', $is_view = false
  911. ) {
  912. global $cfg;
  913. $retval = '';
  914. if (null === $sql_query) {
  915. if (! empty($GLOBALS['display_query'])) {
  916. $sql_query = $GLOBALS['display_query'];
  917. } elseif (! empty($GLOBALS['unparsed_sql'])) {
  918. $sql_query = $GLOBALS['unparsed_sql'];
  919. } elseif (! empty($GLOBALS['sql_query'])) {
  920. $sql_query = $GLOBALS['sql_query'];
  921. } else {
  922. $sql_query = '';
  923. }
  924. }
  925. if (isset($GLOBALS['using_bookmark_message'])) {
  926. $retval .= $GLOBALS['using_bookmark_message']->getDisplay();
  927. unset($GLOBALS['using_bookmark_message']);
  928. }
  929. // In an Ajax request, $GLOBALS['cell_align_left'] may not be defined. Hence,
  930. // check for it's presence before using it
  931. $retval .= '<div id="result_query"'
  932. . ( isset($GLOBALS['cell_align_left'])
  933. ? ' style="text-align: ' . $GLOBALS['cell_align_left'] . '"'
  934. : '' )
  935. . '>' . "\n";
  936. if ($message instanceof PMA_Message) {
  937. if (isset($GLOBALS['special_message'])) {
  938. $message->addMessage($GLOBALS['special_message']);
  939. unset($GLOBALS['special_message']);
  940. }
  941. $retval .= $message->getDisplay();
  942. } else {
  943. $retval .= '<div class="' . $type . '">';
  944. $retval .= PMA_sanitize($message);
  945. if (isset($GLOBALS['special_message'])) {
  946. $retval .= PMA_sanitize($GLOBALS['special_message']);
  947. unset($GLOBALS['special_message']);
  948. }
  949. $retval .= '</div>';
  950. }
  951. if ($cfg['ShowSQL'] == true && ! empty($sql_query)) {
  952. // Html format the query to be displayed
  953. // If we want to show some sql code it is easiest to create it here
  954. /* SQL-Parser-Analyzer */
  955. if (! empty($GLOBALS['show_as_php'])) {
  956. $new_line = '\\n"<br />' . "\n"
  957. . '&nbsp;&nbsp;&nbsp;&nbsp;. "';
  958. $query_base = htmlspecialchars(addslashes($sql_query));
  959. $query_base = preg_replace(
  960. '/((\015\012)|(\015)|(\012))/', $new_line, $query_base
  961. );
  962. } else {
  963. $query_base = $sql_query;
  964. }
  965. $query_too_big = false;
  966. if (strlen($query_base) > $cfg['MaxCharactersInDisplayedSQL']) {
  967. // when the query is large (for example an INSERT of binary
  968. // data), the parser chokes; so avoid parsing the query
  969. $query_too_big = true;
  970. $shortened_query_base = nl2br(
  971. htmlspecialchars(
  972. substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL'])
  973. . '[...]'
  974. )
  975. );
  976. } elseif (! empty($GLOBALS['parsed_sql'])
  977. && $query_base == $GLOBALS['parsed_sql']['raw']
  978. ) {
  979. // (here, use "! empty" because when deleting a bookmark,
  980. // $GLOBALS['parsed_sql'] is set but empty
  981. $parsed_sql = $GLOBALS['parsed_sql'];
  982. } else {
  983. // Parse SQL if needed
  984. $parsed_sql = PMA_SQP_parse($query_base);
  985. }
  986. // Analyze it
  987. if (isset($parsed_sql) && ! PMA_SQP_isError()) {
  988. $analyzed_display_query = PMA_SQP_analyze($parsed_sql);
  989. // Same as below (append LIMIT), append the remembered ORDER BY
  990. if ($GLOBALS['cfg']['RememberSorting']
  991. && isset($analyzed_display_query[0]['queryflags']['select_from'])
  992. && isset($GLOBALS['sql_order_to_append'])
  993. ) {
  994. $query_base = $analyzed_display_query[0]['section_before_limit']
  995. . "\n" . $GLOBALS['sql_order_to_append']
  996. . $analyzed_display_query[0]['limit_clause'] . ' '
  997. . $analyzed_display_query[0]['section_after_limit'];
  998. // Need to reparse query
  999. $parsed_sql = PMA_SQP_parse($query_base);
  1000. // update the $analyzed_display_query
  1001. $analyzed_display_query[0]['section_before_limit']
  1002. .= $GLOBALS['sql_order_to_append'];
  1003. $analyzed_display_query[0]['order_by_clause']
  1004. = $GLOBALS['sorted_col'];
  1005. }
  1006. // Here we append the LIMIT added for navigation, to
  1007. // enable its display. Adding it higher in the code
  1008. // to $sql_query would create a problem when
  1009. // using the Refresh or Edit links.
  1010. // Only append it on SELECTs.
  1011. /**
  1012. * @todo what would be the best to do when someone hits Refresh:
  1013. * use the current LIMITs ?
  1014. */
  1015. if (isset($analyzed_display_query[0]['queryflags']['select_from'])
  1016. && ! empty($GLOBALS['sql_limit_to_append'])
  1017. ) {
  1018. $query_base = $analyzed_display_query[0]['section_before_limit']
  1019. . "\n" . $GLOBALS['sql_limit_to_append']
  1020. . $analyzed_display_query[0]['section_after_limit'];
  1021. // Need to reparse query
  1022. $parsed_sql = PMA_SQP_parse($query_base);
  1023. }
  1024. }
  1025. if (! empty($GLOBALS['show_as_php'])) {
  1026. $query_base = '$sql = "' . $query_base;
  1027. } elseif (! empty($GLOBALS['validatequery'])) {
  1028. try {
  1029. $query_base = PMA_validateSQL($query_base);
  1030. } catch (Exception $e) {
  1031. $retval .= PMA_Message::error(
  1032. __('Failed to connect to SQL validator!')
  1033. )->getDisplay();
  1034. }
  1035. } elseif (isset($query_base)) {
  1036. $query_base = self::formatSql($query_base);
  1037. }
  1038. // Prepares links that may be displayed to edit/explain the query
  1039. // (don't go to default pages, we must go to the page
  1040. // where the query box is available)
  1041. // Basic url query part
  1042. $url_params = array();
  1043. if (! isset($GLOBALS['db'])) {
  1044. $GLOBALS['db'] = '';
  1045. }
  1046. if (strlen($GLOBALS['db'])) {
  1047. $url_params['db'] = $GLOBALS['db'];
  1048. if (strlen($GLOBALS['table'])) {
  1049. $url_params['table'] = $GLOBALS['table'];
  1050. $edit_link = 'tbl_sql.php';
  1051. } else {
  1052. $edit_link = 'db_sql.php';
  1053. }
  1054. } else {
  1055. $edit_link = 'server_sql.php';
  1056. }
  1057. // Want to have the query explained
  1058. // but only explain a SELECT (that has not been explained)
  1059. /* SQL-Parser-Analyzer */
  1060. $explain_link = '';
  1061. $is_select = preg_match('@^SELECT[[:space:]]+@i', $sql_query);
  1062. if (! empty($cfg['SQLQuery']['Explain']) && ! $query_too_big) {
  1063. $explain_params = $url_params;
  1064. // Detect if we are validating as well
  1065. // To preserve the validate uRL data
  1066. if (! empty($GLOBALS['validatequery'])) {
  1067. $explain_params['validatequery'] = 1;
  1068. }
  1069. if ($is_select) {
  1070. $explain_params['sql_query'] = 'EXPLAIN ' . $sql_query;
  1071. $_message = __('Explain SQL');
  1072. } elseif (
  1073. preg_match(
  1074. '@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query
  1075. )
  1076. ) {
  1077. $explain_params['sql_query'] = substr($sql_query, 8);
  1078. $_message = __('Skip Explain SQL');
  1079. }
  1080. if (isset($explain_params['sql_query'])) {
  1081. $explain_link = 'import.php'
  1082. . PMA_URL_getCommon($explain_params);
  1083. $explain_link = ' ['
  1084. . self::linkOrButton($explain_link, $_message) . ']';
  1085. }
  1086. } //show explain
  1087. $url_params['sql_query'] = $sql_query;
  1088. $url_params['show_query'] = 1;
  1089. // even if the query is big and was truncated, offer the chance
  1090. // to edit it (unless it's enormous, see linkOrButton() )
  1091. if (! empty($cfg['SQLQuery']['Edit'])) {
  1092. if ($cfg['EditInWindow'] == true) {
  1093. $onclick = 'PMA_querywindow.focus(\''
  1094. . PMA_jsFormat($sql_query, false) . '\'); return false;';
  1095. } else {
  1096. $onclick = '';
  1097. }
  1098. $edit_link .= PMA_URL_getCommon($url_params) . '#querybox';
  1099. $edit_link = ' ['
  1100. . self::linkOrButton(
  1101. $edit_link, __('Edit'),
  1102. array('onclick' => $onclick, 'class' => 'disableAjax')
  1103. )
  1104. . ']';
  1105. } else {
  1106. $edit_link = '';
  1107. }
  1108. // Also we would like to get the SQL formed in some nice
  1109. // php-code
  1110. if (! empty($cfg['SQLQuery']['ShowAsPHP']) && ! $query_too_big) {
  1111. $php_params = $url_params;
  1112. if (! empty($GLOBALS['show_as_php'])) {
  1113. $_message = __('Without PHP Code');
  1114. } else {
  1115. $php_params['show_as_php'] = 1;
  1116. $_message = __('Create PHP Code');
  1117. }
  1118. $php_link = 'import.php' . PMA_URL_getCommon($php_params);
  1119. $php_link = ' [' . self::linkOrButton($php_link, $_message) . ']';
  1120. if (isset($GLOBALS['show_as_php'])) {
  1121. $runquery_link = 'import.php'
  1122. . PMA_URL_getCommon($url_params);
  1123. $php_link .= ' ['
  1124. . self::linkOrButton($runquery_link, __('Submit Query'))
  1125. . ']';
  1126. }
  1127. } else {
  1128. $php_link = '';
  1129. } //show as php
  1130. // Refresh query
  1131. if (! empty($cfg['SQLQuery']['Refresh'])
  1132. && ! isset($GLOBALS['show_as_php']) // 'Submit query' does the same
  1133. && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)
  1134. ) {
  1135. $refresh_link = 'import.php' . PMA_URL_getCommon($url_params);
  1136. $refresh_link = ' ['
  1137. . self::linkOrButton($refresh_link, __('Refresh')) . ']';
  1138. } else {
  1139. $refresh_link = '';
  1140. } //refresh
  1141. if (! empty($cfg['SQLValidator']['use'])
  1142. && ! empty($cfg['SQLQuery']['Validate'])
  1143. ) {
  1144. $validate_params = $url_params;
  1145. if (! empty($GLOBALS['validatequery'])) {
  1146. $validate_message = __('Skip Validate SQL');
  1147. } else {
  1148. $validate_params['validatequery'] = 1;
  1149. $validate_message = __('Validate SQL');
  1150. }
  1151. $validate_link = 'import.php'
  1152. . PMA_URL_getCommon($validate_params);
  1153. $validate_link = ' ['
  1154. . self::linkOrButton($validate_link, $validate_message) . ']';
  1155. } else {
  1156. $validate_link = '';
  1157. } //validator
  1158. if (! empty($GLOBALS['validatequery'])) {
  1159. $retval .= '<div class="sqlvalidate">';
  1160. } else {
  1161. $retval .= '<div class="sqlOuter">';
  1162. }
  1163. if ($query_too_big) {
  1164. $retval .= $shortened_query_base;
  1165. } else {
  1166. $retval .= $query_base;
  1167. }
  1168. //Clean up the end of the PHP
  1169. if (! empty($GLOBALS['show_as_php'])) {
  1170. $retval .= '";';
  1171. }
  1172. $retval .= '</div>';
  1173. $retval .= '<div class="tools">';
  1174. $retval .= '<form action="sql.php" method="post">';
  1175. $retval .= PMA_URL_getHiddenInputs(
  1176. $GLOBALS['db'], $GLOBALS['table']
  1177. );
  1178. $retval .= '<input type="hidden" name="sql_query" value="'
  1179. . htmlspecialchars($sql_query) . '" />';
  1180. // avoid displaying a Profiling checkbox that could
  1181. // be checked, which would reexecute an INSERT, for example
  1182. if (! empty($refresh_link) && self::profilingSupported()) {
  1183. $retval .= '<input type="hidden" name="profiling_form" value="1" />';
  1184. $retval .= self::getCheckbox(
  1185. 'profiling', __('Profiling'), isset($_SESSION['profiling']), true
  1186. );
  1187. }
  1188. $retval .= '</form>';
  1189. /**
  1190. * TODO: Should we have $cfg['SQLQuery']['InlineEdit']?
  1191. */
  1192. if (! empty($cfg['SQLQuery']['Edit']) && ! $query_too_big) {
  1193. $inline_edit_link = ' ['
  1194. . self::linkOrButton(
  1195. '#',
  1196. _pgettext('Inline edit query', 'Inline'),
  1197. array('class' => 'inline_edit_sql')
  1198. )
  1199. . ']';
  1200. } else {
  1201. $inline_edit_link = '';
  1202. }
  1203. $retval .= $inline_edit_link . $edit_link . $explain_link . $php_link
  1204. . $refresh_link . $validate_link;
  1205. $retval .= '</div>';
  1206. }
  1207. $retval .= '</div>';
  1208. if ($GLOBALS['is_ajax_request'] === false) {
  1209. $retval .= '<br class="clearfloat" />';
  1210. }
  1211. return $retval;
  1212. } // end of the 'getMessage()' function
  1213. /**
  1214. * Verifies if current MySQL server supports profiling
  1215. *
  1216. * @access public
  1217. *
  1218. * @return boolean whether profiling is supported
  1219. */
  1220. public static function profilingSupported()
  1221. {
  1222. if (!self::cacheExists('profiling_supported', true)) {
  1223. // 5.0.37 has profiling but for example, 5.1.20 does not
  1224. // (avoid a trip to the server for MySQL before 5.0.37)
  1225. // and do not set a constant as we might be switching servers
  1226. if (defined('PMA_MYSQL_INT_VERSION')
  1227. && (PMA_MYSQL_INT_VERSION >= 50037)
  1228. && $GLOBALS['dbi']->fetchValue("SHOW VARIABLES LIKE 'profiling'")
  1229. ) {
  1230. self::cacheSet('profiling_supported', true, true);
  1231. } else {
  1232. self::cacheSet('profiling_supported', false, true);
  1233. }
  1234. }
  1235. return self::cacheGet('profiling_supported', true);
  1236. }
  1237. /**
  1238. * Formats $value to byte view
  1239. *
  1240. * @param double $value the value to format
  1241. * @param int $limes the sensitiveness
  1242. * @param int $comma the number of decimals to retain
  1243. *
  1244. * @return array the formatted value and its unit
  1245. *
  1246. * @access public
  1247. */
  1248. public static function formatByteDown($value, $limes = 6, $comma = 0)
  1249. {
  1250. if ($value === null) {
  1251. return null;
  1252. }
  1253. $byteUnits = array(
  1254. /* l10n: shortcuts for Byte */
  1255. __('B'),
  1256. /* l10n: shortcuts for Kilobyte */
  1257. __('KiB'),
  1258. /* l10n: shortcuts for Megabyte */
  1259. __('MiB'),
  1260. /* l10n: shortcuts for Gigabyte */
  1261. __('GiB'),
  1262. /* l10n: shortcuts for Terabyte */
  1263. __('TiB'),
  1264. /* l10n: shortcuts for Petabyte */
  1265. __('PiB'),
  1266. /* l10n: shortcuts for Exabyte */
  1267. __('EiB')
  1268. );
  1269. $dh = self::pow(10, $comma);
  1270. $li = self::pow(10, $limes);
  1271. $unit = $byteUnits[0];
  1272. for ($d = 6, $ex = 15; $d >= 1; $d--, $ex-=3) {
  1273. if (isset($byteUnits[$d]) && ($value >= $li * self::pow(10, $ex))) {
  1274. // use 1024.0 to avoid integer overflow on 64-bit machines
  1275. $value = round($value / (self::pow(1024, $d) / $dh)) /$dh;
  1276. $unit = $byteUnits[$d];
  1277. break 1;
  1278. } // end if
  1279. } // end for
  1280. if ($unit != $byteUnits[0]) {
  1281. // if the unit is not bytes (as represented in current language)
  1282. // reformat with max length of 5
  1283. // 4th parameter=true means do not reformat if value < 1
  1284. $return_value = self::formatNumber($value, 5, $comma, true);
  1285. } else {
  1286. // do not reformat, just handle the locale
  1287. $return_value = self::formatNumber($value, 0);
  1288. }
  1289. return array(trim($return_value), $unit);
  1290. } // end of the 'formatByteDown' function
  1291. /**
  1292. * Changes thousands and decimal separators to locale specific values.
  1293. *
  1294. * @param string $value the value
  1295. *
  1296. * @return string
  1297. */
  1298. public static function localizeNumber($value)
  1299. {
  1300. return str_replace(
  1301. array(',', '.'),
  1302. array(
  1303. /* l10n: Thousands separator */
  1304. __(','),
  1305. /* l10n: Decimal separator */
  1306. __('.'),
  1307. ),
  1308. $value
  1309. );
  1310. }
  1311. /**
  1312. * Formats $value to the given length and appends SI prefixes
  1313. * with a $length of 0 no tru…

Large files files are truncated, but you can click here to view the full file