' . "\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_formatText($parsed_sql); $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 * * @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) * * @return string the html link * * @access public */ function PMA_showMySQLDocu($chapter, $link, $big_icon = 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'; $url = $cfg['MySQLManualBase'] . '/' . $chapter . '.html#' . $link; break; case 'big': $url = $cfg['MySQLManualBase'] . '#' . $link; break; case 'searchable': if (empty($link)) $link = 'index'; $url = $cfg['MySQLManualBase'] . '/' . $link . '.html'; break; case 'viewable': default: if (empty($link)) $link = 'index'; $mysql = '4.1'; if (PMA_MYSQL_INT_VERSION > 50100) { $mysql = '5.1'; } elseif (PMA_MYSQL_INT_VERSION > 50000) { $mysql = '5.0'; } $url = $cfg['MySQLManualBase'] . '/' . $mysql . '/en/' . $link . '.html'; break; } if ($big_icon) { return ''; } elseif ($GLOBALS['cfg']['ReplaceHelpImg']) { return ''; }else{ return '[' . $GLOBALS['strDocu'] . ']'; } } // end of the 'PMA_showMySQLDocu()' function /** * Displays a hint icon, on mouse over show the hint * * @param string the error message * * @access public */ function PMA_showHint($hint_message) { //return ''; return ''; } /** * Displays a MySQL error message in the right frame. * * @param string the error message * @param string the sql query that failed * @param boolean whether to show a "modify" link or not * @param string the "back" link url (full path is not required) * @param boolean EXIT the page? * * @global array the configuration array * * @access public */ function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = TRUE, $back_url = '', $exit = TRUE) { global $cfg, $table, $db, $sql_query; require_once('./header.inc.php'); if (!$error_message) { $error_message = PMA_DBI_getError(); } if (!$the_query && !empty($GLOBALS['sql_query'])) { $the_query = $GLOBALS['sql_query']; } // --- Added to solve bug #641765 // Robbat2 - 12 January 2003, 9:46PM // Revised, Robbat2 - 13 January 2003, 2:59PM if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) { $formatted_sql = htmlspecialchars($the_query); } elseif (empty($the_query) || trim($the_query) == '') { $formatted_sql = ''; } else { $formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query); } // --- echo "\n" . '' . "\n"; echo '
' . $GLOBALS['strSQLQuery'] . ':' . "\n"; if (strstr(strtolower($formatted_sql),'select')) { // please show me help to the error on select echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT'); } if ($is_modify_link && isset($db)) { if (isset($table)) { $doedit_goto = ''; } else { $doedit_goto = ''; } if ($GLOBALS['cfg']['PropertiesIconic']) { echo $doedit_goto . '' . ''; } else { echo ' [' . $doedit_goto . $GLOBALS['strEdit'] . '' . ']' . "\n"; } } // end if echo '
' . "\n" .'' . "\n" .' ' . $formatted_sql . "\n" .'
' . "\n"; } // end if $tmp_mysql_error = ''; // for saving the original $error_message if (!empty($error_message)) { $tmp_mysql_error = strtolower($error_message); // save the original $error_message $error_message = htmlspecialchars($error_message); $error_message = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $error_message); } // modified to show me the help on error-returns (Michael Keck) echo '' . "\n" . ' ' . $GLOBALS['strMySQLSaid'] . '' . PMA_showMySQLDocu('Error-returns', 'Error-returns') . "\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); echo '' . "\n"
. $error_message . "\n"
. '
* 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
*
* @author staybyte, sebastian mendel
* @version 1.1.0 - 2005-10-27
*/
function PMA_formatNumber( $value, $length = 3, $comma = 0, $only_down = false ) {
if ( $length === 0 ) {
return number_format( $value,
$comma,
$GLOBALS['number_decimal_separator'],
$GLOBALS['number_thousands_separator'] );
}
// 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 negativ value to retain sign
if ( $value < 0 ) {
$sign = '-';
$value = abs( $value );
} else {
$sign = '';
}
$dh = pow(10, $comma);
$li = pow(10, $length);
$unit = $units[0];
if ( $value >= 1 ) {
for ( $d = 8; $d >= 0; $d-- ) {
if (isset($units[$d]) && $value >= $li * pow(1000, $d-1)) {
$value = round($value / ( 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++ ) {
if (isset($units[$d]) && $value <= $li * pow(1000, $d-1)) {
$value = round($value / ( pow(1000, $d) / $dh) ) /$dh;
$unit = $units[$d];
break 1;
} // end if
} // end for
} // end if ( $value >= 1 ) elseif ( ! $only_down && (float) $value !== 0.0 )
$value = number_format( $value,
$comma,
$GLOBALS['number_decimal_separator'],
$GLOBALS['number_thousands_separator'] );
return $sign . $value . ' ' . $unit;
} // end of the 'PMA_formatNumber' function
/**
* Extracts ENUM / SET options from a type definition string
*
* @param string The column type definition
*
* @return array The options or
* boolean FALSE in case of an error.
*
* @author rabus
*/
function PMA_getEnumSetOptions($type_def) {
$open = strpos($type_def, '(');
$close = strrpos($type_def, ')');
if (!$open || !$close) {
return FALSE;
}
$options = substr($type_def, $open + 2, $close - $open - 3);
$options = explode('\',\'', $options);
return $options;
} // end of the 'PMA_getEnumSetOptions' function
/**
* Writes localised date
*
* @param string the current timestamp
*
* @return string the formatted date
*
* @access public
*/
function PMA_localisedDate($timestamp = -1, $format = '')
{
global $datefmt, $month, $day_of_week;
if ($format == '') {
$format = $datefmt;
}
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 array_merge()
* basename()
* $GLOBALS['strEmpty']
* $GLOBALS['strDrop']
* $GLOBALS['active_page']
* $GLOBALS['PHP_SELF']
* htmlentities()
* PMA_generate_common_url()
* $GLOBALS['url_query']
* urlencode()
* $GLOBALS['cfg']['MainPageIconic']
* $GLOBALS['pmaThemeImage']
* sprintf()
* trigger_error()
* E_USER_NOTICE
* @param array $tab array with all options
* @return string html code for one tab, a link if valid otherwise a span
* @access public
*/
function PMA_getTab( $tab )
{
// default values
$defaults = array(
'text' => '',
'class' => '',
'active' => false,
'link' => '',
'sep' => '?',
'attr' => '',
'args' => '',
);
$tab = array_merge( $defaults, $tab );
// determine aditional style-class
if ( empty( $tab['class'] ) ) {
if ( $tab['text'] == $GLOBALS['strEmpty']
|| $tab['text'] == $GLOBALS['strDrop'] ) {
$tab['class'] = 'caution';
}
elseif ( isset( $tab['active'] ) && $tab['active']
|| isset( $GLOBALS['active_page'] )
&& $GLOBALS['active_page'] == $tab['link']
|| basename( $GLOBALS['PHP_SELF'] ) == $tab['link'] )
{
$tab['class'] = 'active';
}
}
// build the link
if ( ! empty( $tab['link'] ) ) {
$tab['link'] = htmlentities( $tab['link'] );
$tab['link'] = $tab['link'] . $tab['sep']
.( empty( $GLOBALS['url_query'] ) ?
PMA_generate_common_url() : $GLOBALS['url_query'] );
if ( ! empty( $tab['args'] ) ) {
foreach( $tab['args'] as $param => $value ) {
$tab['link'] .= '&' . urlencode( $param ) . '='
. urlencode( $value );
}
}
}
// display icon, even if iconic is disabled but the link-text is missing
if ( ( $GLOBALS['cfg']['MainPageIconic'] || empty( $tab['text'] ) )
&& isset( $tab['icon'] ) ) {
$image = '%2$s';
$tab['text'] = sprintf( $image, htmlentities( $tab['icon'] ), $tab['text'] );
}
// check to not display an empty link-text
elseif ( empty( $tab['text'] ) ) {
$tab['text'] = '?';
trigger_error( __FILE__ . '(' . __LINE__ . '): '
. 'empty linktext in function ' . __FUNCTION__ . '()',
E_USER_NOTICE );
}
if ( ! empty( $tab['link'] ) ) {
$out = ''
. $tab['text'] . '';
} else {
$out = ''
. $tab['text'] . '';
}
return $out;
} // end of the 'PMA_printTab()' function
/**
* returns html-code for a tab navigation
*
* @uses PMA_getTab()
* @uses htmlentities()
* @param array $tabs one element per tab
* @param string $tag_id id used for the html-tag
* @return string html-code for tab-navigation
*/
function PMA_getTabs( $tabs, $tag_id = 'topmenu' ) {
$tab_navigation =
'' . $error_message . '