' . "\n" . (($cfg['SQP']['fmtType'] == 'none' && $unparsed_sql != '') ? $unparsed_sql : $parsed_sql) . "\n" . ''; return $formatted_sql; } $formatted_sql = ''; switch ($cfg['SQP']['fmtType']) { case 'none': if ($unparsed_sql != '') { $formatted_sql = '
' . "\n" . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n" . ''; } else { $formatted_sql = PMA_SQP_formatNone($parsed_sql); } break; case 'html': $formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'color'); break; case 'text': $formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'text'); break; default: break; } // end switch return $formatted_sql; } // end of the "PMA_formatSql()" function /** * Displays a link to the official MySQL documentation * * @uses $cfg['MySQLManualType'] * @uses $cfg['MySQLManualBase'] * @uses $cfg['ReplaceHelpImg'] * @uses $GLOBALS['pmaThemeImage'] * @uses PMA_MYSQL_INT_VERSION * @uses strtolower() * @uses str_replace() * @param string chapter of "HTML, one page per chapter" documentation * @param string contains name of page/anchor that is being linked * @param bool whether to use big icon (like in left frame) * @param string anchor to page part * * @return string the html link * * @access public */ function PMA_showMySQLDocu($chapter, $link, $big_icon = false, $anchor = '', $just_open = false) { global $cfg; if ($cfg['MySQLManualType'] == 'none' || empty($cfg['MySQLManualBase'])) { return ''; } // Fixup for newly used names: $chapter = str_replace('_', '-', strtolower($chapter)); $link = str_replace('_', '-', strtolower($link)); switch ($cfg['MySQLManualType']) { case 'chapters': if (empty($chapter)) { $chapter = 'index'; } if (empty($anchor)) { $anchor = $link; } $url = $cfg['MySQLManualBase'] . '/' . $chapter . '.html#' . $anchor; break; case 'big': if (empty($anchor)) { $anchor = $link; } $url = $cfg['MySQLManualBase'] . '#' . $anchor; break; case 'searchable': if (empty($link)) { $link = 'index'; } $url = $cfg['MySQLManualBase'] . '/' . $link . '.html'; if (!empty($anchor)) { $url .= '#' . $anchor; } break; case 'viewable': default: if (empty($link)) { $link = 'index'; } $mysql = '5.0'; $lang = 'en'; if (defined('PMA_MYSQL_INT_VERSION')) { if (PMA_MYSQL_INT_VERSION >= 50500) { $mysql = '5.5'; /* l10n: Language to use for MySQL 5.5 documentation, please use only languages which do exist in official documentation. */ $lang = _pgettext('MySQL 5.5 documentation language', 'en'); } else if (PMA_MYSQL_INT_VERSION >= 50100) { $mysql = '5.1'; /* l10n: Language to use for MySQL 5.1 documentation, please use only languages which do exist in official documentation. */ $lang = _pgettext('MySQL 5.1 documentation language', 'en'); } elseif (PMA_MYSQL_INT_VERSION >= 50000) { $mysql = '5.0'; /* l10n: Language to use for MySQL 5.0 documentation, please use only languages which do exist in official documentation. */ $lang = _pgettext('MySQL 5.0 documentation language', 'en'); } } $url = $cfg['MySQLManualBase'] . '/' . $mysql . '/' . $lang . '/' . $link . '.html'; if (!empty($anchor)) { $url .= '#' . $anchor; } break; } if ($just_open) { return ''; } elseif ($big_icon) { return '
' . __('SQL query') . ':' . "\n"; if (strstr(strtolower($formatted_sql), 'select')) { // please show me help to the error on select $error_msg_output .= PMA_showMySQLDocu('SQL-Syntax', 'SELECT'); } if ($is_modify_link) { $_url_params = array( 'sql_query' => $the_query, 'show_query' => 1, ); if (strlen($table)) { $_url_params['db'] = $db; $_url_params['table'] = $table; $doedit_goto = ''; } elseif (strlen($db)) { $_url_params['db'] = $db; $doedit_goto = ''; } else { $doedit_goto = ''; } $error_msg_output .= $doedit_goto . PMA_getIcon('b_edit.png', __('Edit')) . ''; } // end if $error_msg_output .= '
' . "\n" .'' . "\n" .' ' . $formatted_sql . "\n" .'
' . "\n"; } // end if if (!empty($error_message)) { $error_message = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $error_message); } // modified to show the help on error-returns // (now error-messages-server) $error_msg_output .= '' . "\n" . ' ' . __('MySQL said: ') . '' . PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server') . "\n" . '
' . "\n"; // The error message will be displayed within a CODE segment. // To preserve original formatting, but allow wordwrapping, we do a couple of replacements // Replace all non-single blanks with their HTML-counterpart $error_message = str_replace(' ', ' ', $error_message); // Replace TAB-characters with their HTML-counterpart $error_message = str_replace("\t", ' ', $error_message); // Replace linebreaks $error_message = nl2br($error_message); $error_msg_output .= '' . "\n"
. $error_message . "\n"
. '
* echo PMA_backquote('owner`s db'); // `owner``s db`
*
*
*
* @uses PMA_backquote()
* @uses is_array()
* @uses strlen()
* @uses str_replace()
* @param mixed $a_name the database, table or field name to "backquote"
* or array of it
* @param boolean $do_it a flag to bypass this function (used by dump
* functions)
* @return mixed the "backquoted" database, table or field name if the
* current MySQL release is >= 3.23.6, the original one
* else
* @access public
*/
function PMA_backquote($a_name, $do_it = true)
{
if (is_array($a_name)) {
foreach ($a_name as &$data) {
$data = PMA_backquote($data, $do_it);
}
return $a_name;
}
if (! $do_it) {
global $PMA_SQPdata_forbidden_word;
global $PMA_SQPdata_forbidden_word_cnt;
if(! PMA_STR_binarySearchInArr(strtoupper($a_name), $PMA_SQPdata_forbidden_word, $PMA_SQPdata_forbidden_word_cnt)) {
return $a_name;
}
}
// '0' is also empty for php :-(
if (strlen($a_name) && $a_name !== '*') {
return '`' . str_replace('`', '``', $a_name) . '`';
} else {
return $a_name;
}
} // end of the 'PMA_backquote()' function
/**
* Defines the ';
}
if ($query_too_big) {
echo $shortened_query_base;
} else {
echo $query_base;
}
//Clean up the end of the PHP
if (! empty($GLOBALS['show_as_php'])) {
echo '";';
}
if (!empty($GLOBALS['validatequery'])) {
echo '
* echo PMA_formatNumber(123456789, 6); // 123,457 k
* echo PMA_formatNumber(-123456789, 4, 2); // -123.46 M
* echo PMA_formatNumber(-0.003, 6); // -3 m
* echo PMA_formatNumber(0.003, 3, 3); // 0.003
* echo PMA_formatNumber(0.00003, 3, 2); // 0.03 m
* echo PMA_formatNumber(0, 6); // 0
*
*
* @param double $value the value to format
* @param integer $length the max length
* @param integer $comma the number of decimals to retain
* @param boolean $only_down do not reformat numbers below 1
*
* @return string the formatted value and its unit
*
* @access public
*
* @version 1.1.0 - 2005-10-27
*/
function PMA_formatNumber($value, $length = 3, $comma = 0, $only_down = false)
{
//number_format is not multibyte safe, str_replace is safe
if ($length === 0) {
return PMA_localizeNumber(number_format($value, $comma));
}
// this units needs no translation, ISO
$units = array(
-8 => 'y',
-7 => 'z',
-6 => 'a',
-5 => 'f',
-4 => 'p',
-3 => 'n',
-2 => 'µ',
-1 => 'm',
0 => ' ',
1 => 'k',
2 => 'M',
3 => 'G',
4 => 'T',
5 => 'P',
6 => 'E',
7 => 'Z',
8 => 'Y'
);
// we need at least 3 digits to be displayed
if (3 > $length + $comma) {
$length = 3 - $comma;
}
// check for negative value to retain sign
if ($value < 0) {
$sign = '-';
$value = abs($value);
} else {
$sign = '';
}
$dh = PMA_pow(10, $comma);
$li = PMA_pow(10, $length);
$unit = $units[0];
if ($value >= 1) {
for ($d = 8; $d >= 0; $d--) {
if (isset($units[$d]) && $value >= $li * PMA_pow(1000, $d-1)) {
$value = round($value / (PMA_pow(1000, $d) / $dh)) /$dh;
$unit = $units[$d];
break 1;
} // end if
} // end for
} elseif (!$only_down && (float) $value !== 0.0) {
for ($d = -8; $d <= 8; $d++) {
// force using pow() because of the negative exponent
if (isset($units[$d]) && $value <= $li * PMA_pow(1000, $d-1, 'pow')) {
$value = round($value / (PMA_pow(1000, $d, 'pow') / $dh)) /$dh;
$unit = $units[$d];
break 1;
} // end if
} // end for
} // end if ($value >= 1) elseif (!$only_down && (float) $value !== 0.0)
//number_format is not multibyte safe, str_replace is safe
$value = PMA_localizeNumber(number_format($value, $comma));
return $sign . $value . ' ' . $unit;
} // end of the 'PMA_formatNumber' function
/**
* Returns the number of bytes when a formatted size is given
*
* @param string $size the size expression (for example 8MB)
* @uses PMA_pow()
* @return integer The numerical part of the expression (for example 8)
*/
function PMA_extractValueFromFormattedSize($formatted_size)
{
$return_value = -1;
if (preg_match('/^[0-9]+GB$/', $formatted_size)) {
$return_value = substr($formatted_size, 0, -2) * PMA_pow(1024, 3);
} elseif (preg_match('/^[0-9]+MB$/', $formatted_size)) {
$return_value = substr($formatted_size, 0, -2) * PMA_pow(1024, 2);
} elseif (preg_match('/^[0-9]+K$/', $formatted_size)) {
$return_value = substr($formatted_size, 0, -1) * PMA_pow(1024, 1);
}
return $return_value;
}// end of the 'PMA_extractValueFromFormattedSize' function
/**
* Writes localised date
*
* @param string the current timestamp
*
* @return string the formatted date
*
* @access public
*/
function PMA_localisedDate($timestamp = -1, $format = '')
{
$month = array(
/* l10n: Short month name */
__('Jan'),
/* l10n: Short month name */
__('Feb'),
/* l10n: Short month name */
__('Mar'),
/* l10n: Short month name */
__('Apr'),
/* l10n: Short month name */
_pgettext('Short month name', 'May'),
/* l10n: Short month name */
__('Jun'),
/* l10n: Short month name */
__('Jul'),
/* l10n: Short month name */
__('Aug'),
/* l10n: Short month name */
__('Sep'),
/* l10n: Short month name */
__('Oct'),
/* l10n: Short month name */
__('Nov'),
/* l10n: Short month name */
__('Dec'));
$day_of_week = array(
/* l10n: Short week day name */
__('Sun'),
/* l10n: Short week day name */
__('Mon'),
/* l10n: Short week day name */
__('Tue'),
/* l10n: Short week day name */
__('Wed'),
/* l10n: Short week day name */
__('Thu'),
/* l10n: Short week day name */
__('Fri'),
/* l10n: Short week day name */
__('Sat'));
if ($format == '') {
/* l10n: See http://www.php.net/manual/en/function.strftime.php to define the format string */
$format = __('%B %d, %Y at %I:%M %p');
}
if ($timestamp == -1) {
$timestamp = time();
}
$date = preg_replace('@%[aA]@', $day_of_week[(int)strftime('%w', $timestamp)], $format);
$date = preg_replace('@%[bB]@', $month[(int)strftime('%m', $timestamp)-1], $date);
return strftime($date, $timestamp);
} // end of the 'PMA_localisedDate()' function
/**
* returns a tab for tabbed navigation.
* If the variables $link and $args ar left empty, an inactive tab is created
*
* @uses $GLOBALS['PMA_PHP_SELF']
* @uses $GLOBALS['active_page']
* @uses $GLOBALS['url_query']
* @uses $cfg['MainPageIconic']
* @uses $GLOBALS['pmaThemeImage']
* @uses PMA_generate_common_url()
* @uses E_USER_NOTICE
* @uses htmlentities()
* @uses urlencode()
* @uses sprintf()
* @uses trigger_error()
* @uses array_merge()
* @uses basename()
* @param array $tab array with all options
* @param array $url_params
* @return string html code for one tab, a link if valid otherwise a span
* @access public
*/
function PMA_generate_html_tab($tab, $url_params = array())
{
// default values
$defaults = array(
'text' => '',
'class' => '',
'active' => null,
'link' => '',
'sep' => '?',
'attr' => '',
'args' => '',
'warning' => '',
'fragment' => '',
'id' => '',
);
$tab = array_merge($defaults, $tab);
// determine additionnal style-class
if (empty($tab['class'])) {
if (! empty($tab['active'])
|| PMA_isValid($GLOBALS['active_page'], 'identical', $tab['link'])) {
$tab['class'] = 'active';
} elseif (is_null($tab['active']) && empty($GLOBALS['active_page'])
&& basename($GLOBALS['PMA_PHP_SELF']) == $tab['link']
&& empty($tab['warning'])) {
$tab['class'] = 'active';
}
}
if (!empty($tab['warning'])) {
$tab['class'] .= ' error';
$tab['attr'] .= ' title="' . htmlspecialchars($tab['warning']) . '"';
}
// If there are any tab specific URL parameters, merge those with the general URL parameters
if(! empty($tab['url_params']) && is_array($tab['url_params'])) {
$url_params = array_merge($url_params, $tab['url_params']);
}
// build the link
if (!empty($tab['link'])) {
$tab['link'] = htmlentities($tab['link']);
$tab['link'] = $tab['link'] . PMA_generate_common_url($url_params);
if (! empty($tab['args'])) {
foreach ($tab['args'] as $param => $value) {
$tab['link'] .= PMA_get_arg_separator('html') . urlencode($param) . '='
. urlencode($value);
}
}
}
if (! empty($tab['fragment'])) {
$tab['link'] .= $tab['fragment'];
}
// display icon, even if iconic is disabled but the link-text is missing
if (($GLOBALS['cfg']['MainPageIconic'] || empty($tab['text']))
&& isset($tab['icon'])) {
// avoid generating an alt tag, because it only illustrates
// the text that follows and if browser does not display
// images, the text is duplicated
$image = '' . $error_message . '