Merge commit 'origin/master' into local

Conflicts:
	server_status.php
This commit is contained in:
Martynas Mickevicius
2010-07-29 14:14:26 +03:00
342 changed files with 194811 additions and 179626 deletions

View File

@@ -3,7 +3,6 @@
/**
* Misc functions used all over the scripts.
*
* @version $Id$
* @package phpMyAdmin
*/
@@ -130,7 +129,6 @@ function PMA_getIcon($icon, $alternate = '', $container = false, $force_text = f
/**
* Displays the maximum size for an upload
*
* @uses __('Max: %s%s')
* @uses PMA_formatByteDown()
* @uses sprintf()
* @param integer the size
@@ -320,7 +318,7 @@ function PMA_formatSql($parsed_sql, $unparsed_sql = '')
switch ($cfg['SQP']['fmtType']) {
case 'none':
if ($unparsed_sql != '') {
$formatted_sql = "<pre>\n" . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n</pre>";
$formatted_sql = '<span class="inner_sql"><pre>' . "\n" . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n" . '</pre></span>';
} else {
$formatted_sql = PMA_SQP_formatNone($parsed_sql);
}
@@ -346,7 +344,6 @@ function PMA_formatSql($parsed_sql, $unparsed_sql = '')
* @uses $cfg['MySQLManualType']
* @uses $cfg['MySQLManualBase']
* @uses $cfg['ReplaceHelpImg']
* @uses __('Documentation')
* @uses $GLOBALS['pmaThemeImage']
* @uses PMA_MYSQL_INT_VERSION
* @uses strtolower()
@@ -501,11 +498,7 @@ function PMA_showHint($message, $bbcode = false, $type = 'notice')
* @uses footer.inc.php
* @uses header.inc.php
* @uses $GLOBALS['sql_query']
* @uses __('Error')
* @uses __('SQL query')
* @uses $GLOBALS['pmaThemeImage']
* @uses __('Edit')
* @uses __('MySQL said: ')
* @uses $GLOBALS['cfg']['PropertiesIconic']
* @uses $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']
* @uses PMA_backquote()
@@ -661,19 +654,19 @@ function PMA_mysqlDie($error_message = '', $the_query = '',
$back_url .= '?no_history=true';
}
$_SESSION['Import_message']['go_back_url'] = $back_url;
$_SESSION['Import_message']['go_back_url'] = $back_url;
$error_msg_output .= '<fieldset class="tblFooters">';
$error_msg_output .= '[ <a href="' . $back_url . '">' . __('Back') . '</a> ]';
$error_msg_output .= '</fieldset>' . "\n\n";
}
}
echo $error_msg_output;
/**
* display footer and exit
*/
echo $error_msg_output;
/**
* display footer and exit
*/
require_once './libraries/footer.inc.php';
require './libraries/footer.inc.php';
} else {
echo $error_msg_output;
}
@@ -798,18 +791,11 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count =
// load PMA configuration
$PMA_Config = $GLOBALS['PMA_Config'];
// if PMA configuration exists
if (!empty($PMA_Config))
$session_bs_tables = $GLOBALS['PMA_Config']->get('BLOBSTREAMING_TABLES');
foreach ($tables as $table_name => $table) {
// if BS tables exist
if (isset($session_bs_tables))
// compare table name to tables in list of blobstreaming tables
foreach ($session_bs_tables as $table_key=>$table_val)
// if table is in list, skip outer foreach loop
if ($table_name == $table_key)
continue 2;
if (PMA_BS_IsHiddenTable($table_name)) {
continue;
}
// check for correct row count
if (null === $table['Rows']) {
@@ -1137,7 +1123,11 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
if (! empty($GLOBALS['show_as_php'])) {
$query_base = '$sql = "' . $query_base;
} elseif (! empty($GLOBALS['validatequery'])) {
$query_base = PMA_validateSQL($query_base);
try {
$query_base = PMA_validateSQL($query_base);
} catch (Exception $e) {
PMA_Message::error(__('Failed to connect to SQL validator!'))->display();
}
} elseif (isset($parsed_sql)) {
$query_base = PMA_formatSql($parsed_sql, $query_base);
}
@@ -1188,7 +1178,9 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
$url_params['sql_query'] = $sql_query;
$url_params['show_query'] = 1;
if (! empty($cfg['SQLQuery']['Edit']) && ! $query_too_big) {
// even if the query is big and was truncated, offer the chance
// to edit it (unless it's enormous, see PMA_linkOrButton() )
if (! empty($cfg['SQLQuery']['Edit'])) {
if ($cfg['EditInWindow'] == true) {
$onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($sql_query, false) . '\'); return false;';
} else {
@@ -1251,7 +1243,11 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
$validate_link = '';
} //validator
echo '<code class="sql">';
if (!empty($GLOBALS['validatequery'])) {
echo '<div class="sqlvalidate">';
} else {
echo '<code class="sql">';
}
if ($query_too_big) {
echo $shortened_query_base;
} else {
@@ -1262,7 +1258,11 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
if (! empty($GLOBALS['show_as_php'])) {
echo '";';
}
echo '</code>';
if (!empty($GLOBALS['validatequery'])) {
echo '</div>';
} else {
echo '</code>';
}
echo '<div class="tools">';
// avoid displaying a Profiling checkbox that could
@@ -1270,6 +1270,17 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
if (! empty($refresh_link)) {
PMA_profilingCheckbox($sql_query);
}
// if needed, generate an invisible form that contains controls for the
// Inline link; this way, the behavior of the Inline link does not
// depend on the profiling support or on the refresh link
if (empty($refresh_link) || ! PMA_profilingSupported()) {
echo '<form action="sql.php" method="post">';
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']);
echo '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />';
echo '</form>';
}
// see in js/functions.js the jQuery code attached to id inline_edit
$inline_edit = "<script type=\"text/javascript\">\n" .
"//<![CDATA[\n" .
"document.write('[<a href=\"#\" title=\"" .
@@ -1624,8 +1635,6 @@ function PMA_localisedDate($timestamp = -1, $format = '')
* If the variables $link and $args ar left empty, an inactive tab is created
*
* @uses $GLOBALS['PMA_PHP_SELF']
* @uses __('Empty')
* @uses __('Drop')
* @uses $GLOBALS['active_page']
* @uses $GLOBALS['url_query']
* @uses $cfg['MainPageIconic']
@@ -1778,6 +1787,13 @@ function PMA_generate_html_tabs($tabs, $url_params)
function PMA_linkOrButton($url, $message, $tag_params = array(),
$new_form = true, $strip_img = false, $target = '')
{
$url_length = strlen($url);
// with this we should be able to catch case of image upload
// into a (MEDIUM) BLOB; not worth generating even a form for these
if ($url_length > $GLOBALS['cfg']['LinkLengthLimit'] * 100) {
return '';
}
if (! is_array($tag_params)) {
$tmp = $tag_params;
$tag_params = array();
@@ -1799,7 +1815,7 @@ function PMA_linkOrButton($url, $message, $tag_params = array(),
$tag_params_strings[] = $par_name . '="' . $par_value . '"';
}
if (strlen($url) <= $GLOBALS['cfg']['LinkLengthLimit']) {
if ($url_length <= $GLOBALS['cfg']['LinkLengthLimit']) {
// no whitespace within an <a> else Safari will make it part of the link
$ret = "\n" . '<a href="' . $url . '" '
. implode(' ', $tag_params_strings) . '>'
@@ -1885,7 +1901,6 @@ function PMA_linkOrButton($url, $message, $tag_params = array(),
/**
* Returns a given timespan value in a readable format.
*
* @uses __('%s days, %s hours, %s minutes and %s seconds')
* @uses sprintf()
* @uses floor()
* @param int the timespan
@@ -2102,7 +2117,8 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force
$condition .= 'IS NULL AND';
} else {
// timestamp is numeric on some MySQL 4.1
if ($meta->numeric && $meta->type != 'timestamp') {
// for real we use CONCAT above and it should compare to string
if ($meta->numeric && $meta->type != 'timestamp' && $meta->type != 'real') {
$condition .= '= ' . $row[$i] . ' AND';
} elseif (($meta->type == 'blob' || $meta->type == 'string')
// hexify only if this is a true not empty BLOB or a BINARY
@@ -2194,7 +2210,6 @@ function PMA_buttonOrImage($button_name, $button_class, $image_name, $text,
* Generate a pagination selector for browsing resultsets
*
* @todo $url is not javascript escaped!?
* @uses __('Page number:')
* @uses range()
* @param string URL for the JavaScript
* @param string Number of rows in the pagination set
@@ -2298,7 +2313,6 @@ function PMA_pageselector($url, $rows, $pageNow = 1, $nbTotalPage = 1,
* Generate navigation for a list
*
* @todo use $pos from $_url_params
* @uses __('Page number:')
* @uses range()
* @param integer number of elements in the list
* @param integer current position in the list
@@ -2409,7 +2423,6 @@ function PMA_userDir($dir)
*
* @uses $cfg['DefaultTabDatabase']
* @uses $GLOBALS['db']
* @uses __('Jump to database &quot;%s&quot;.')
* @uses PMA_generate_common_url()
* @uses PMA_unescape_mysql_wildcards()
* @uses strlen()
@@ -2439,7 +2452,6 @@ function PMA_getDbLink($database = null)
* that affects a functionality
*
* @uses PMA_MYSQL_INT_VERSION
* @uses __('The %s functionality is affected by a known bug, see %s')
* @uses PMA_showHint()
* @uses sprintf()
* @param string $functionality localized message explaining the func.
@@ -2829,7 +2841,7 @@ function PMA_getTitleForTarget($target) {
$mapping = array(
// Values for $cfg['DefaultTabTable']
'tbl_structure.php' => __('Structure'),
'tbl_structure.php' => __('Structure'),
'tbl_sql.php' => __('SQL'),
'tbl_select.php' =>__('Search'),
'tbl_change.php' =>__('Insert'),
@@ -2844,19 +2856,72 @@ $mapping = array(
return $mapping[$target];
}
function PMA_js($code, $print=true)
{
// these generated newlines are needed
$out = '';
$out .= '<script type="text/javascript">'."\n";
$out .= "\n" . '// <![CDATA[' . "\n";
$out .= $code;
$out .= "\n" . '// ]]>' . "\n";
$out .= '</script>'."\n";
/**
* Formats user string, expading @VARIABLES@, accepting strftime format string.
*
* @param string Text where to do expansion.
* @param function Function to call for escaping variable values.
* @param array Array with overrides for default parameters (obtained from GLOBALS).
*/
function PMA_expandUserString($string, $escape = NULL, $updates = array()) {
/* Content */
$vars['http_host'] = PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '';
$vars['server_name'] = $GLOBALS['cfg']['Server']['host'];
$vars['server_verbose'] = $GLOBALS['cfg']['Server']['verbose'];
$vars['server_verbose_or_name'] = !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : $GLOBALS['cfg']['Server']['host'];
$vars['database'] = $GLOBALS['db'];
$vars['table'] = $GLOBALS['table'];
$vars['phpmyadmin_version'] = 'phpMyAdmin ' . PMA_VERSION;
if ($print)
echo $out;
/* Update forced variables */
foreach($updates as $key => $val) {
$vars[$key] = $val;
}
return $out;
/* Replacement mapping */
/*
* The __VAR__ ones are for backward compatibility, because user
* might still have it in cookies.
*/
$replace = array(
'@HTTP_HOST@' => $vars['http_host'],
'@SERVER@' => $vars['server_name'],
'__SERVER__' => $vars['server_name'],
'@VERBOSE@' => $vars['server_verbose'],
'@VSERVER@' => $vars['server_verbose_or_name'],
'@DATABASE@' => $vars['database'],
'__DB__' => $vars['database'],
'@TABLE@' => $vars['table'],
'__TABLE__' => $vars['table'],
'@PHPMYADMIN@' => $vars['phpmyadmin_version'],
);
/* Optional escaping */
if (!is_null($escape)) {
foreach($replace as $key => $val) {
$replace[$key] = $escape($val);
}
}
/* Fetch fields list if required */
if (strpos($string, '@FIELDS@') !== FALSE) {
$fields_list = PMA_DBI_fetch_result(
'SHOW COLUMNS FROM ' . PMA_backquote($GLOBALS['db'])
. '.' . PMA_backquote($GLOBALS['table']));
$field_names = array();
foreach ($fields_list as $field) {
if (!is_null($escape)) {
$field_names[] = $escape($field['Field']);
} else {
$field_names[] = $field['Field'];
}
}
$replace['@FIELDS@'] = implode(',', $field_names);
}
/* Do the replacement */
return str_replace(array_keys($replace), array_values($replace), strftime($string));
}
?>