diff --git a/ChangeLog b/ChangeLog
index 12f94bfeef..06745bbc90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,6 +43,7 @@ VerboseMultiSubmit, ReplaceHelpImg
+ Add Ajax support to Fast filter in order to search the term in all database tables
- bug #3535015 [navi] DbFilter, TableFilter clear button hidden on Chrome
+ rfe #3528994 [interface] Allow wrapping possibly long values in replication-status table
++ [interface] Autoselect username input on cookie login page
3.5.3.0 (not yet released)
- bug #3539044 [interface] Browse mode "Show" button gives blank page if no results anymore
@@ -55,6 +56,12 @@ VerboseMultiSubmit, ReplaceHelpImg
- bug #3547825 [edit] BLOB download no longer works
- bug #3541966 [config] Error in generated configuration arrray
- bug #3553551 [GUI] Invalid HTML code in multi submits confirmation form
+- [interface] Designer sometimes places tables on the top menu
+- bug #3546277 [core] Call to undefined function __() when config file has wrong permissions
+- bug #3540922 [edit] Error searching table with many fields
+
+3.5.2.1 (2012-08-03)
+- [security] Fixed local path disclosure vulnerability, see PMASA-2012-3
3.5.2.0 (2012-07-07)
- bug #3521416 [interface] JS error when editing index
@@ -164,11 +171,11 @@ VerboseMultiSubmit, ReplaceHelpImg
+ patch #3303195 [interface] Checkbox to have SQL input remain
- patch #3472899 [export] Fixed CSV escape for the export
- patch #3475424 [import] Fixed CSV escape for the import
-- bug #3482734 [interface] No warning on syntax error in search form
+- bug #3482734 [interface] No warning on syntax error in search form
- bug #3423717 [core] Improved detection of SSL connection
+ FULLTEXT support for InnoDB, starting with MySQL 5.6.4
- bug #3497151 [interface] Duplicate inline query edit box
-- bug #3504567 [mime] Description of the transformation missing in the tooltip
+- bug #3504567 [mime] Description of the transformation missing in the tooltip
3.4.11.0 (2012-04-14)
- bug #3486970 [import] Exception on XML import
diff --git a/db_operations.php b/db_operations.php
index 8f6d027797..0bdb94f046 100644
--- a/db_operations.php
+++ b/db_operations.php
@@ -18,6 +18,11 @@
require_once 'libraries/common.inc.php';
require_once 'libraries/mysql_charsets.lib.php';
+/**
+ * functions implementation for this script
+ */
+require_once 'libraries/operations.lib.php';
+
// add a javascript file for jQuery functions to handle Ajax actions
$response = PMA_Response::getInstance();
$header = $response->getHeader();
@@ -25,76 +30,27 @@ $scripts = $header->getScripts();
$scripts->addFile('db_operations.js');
$common_functions = PMA_CommonFunctions::getInstance();
-/**
- * Sets globals from $_REQUEST (we're using GET on ajax, POST otherwise)
- */
-$request_params = array(
- 'add_constraints',
- 'comment',
- 'create_database_before_copying',
- 'db_collation',
- 'db_copy',
- 'db_rename',
- 'drop_if_exists',
- 'newname',
- 'sql_auto_increment',
- 'submitcollation',
- 'switch_to_new',
- 'what'
-);
-foreach ($request_params as $one_request_param) {
- if (isset($_REQUEST[$one_request_param])) {
- $GLOBALS[$one_request_param] = $_REQUEST[$one_request_param];
- }
-}
-
/**
* Rename/move or copy database
*/
-if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
+if (strlen($db) && (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_copy']))) {
- if (! empty($db_rename)) {
+ if (! empty($_REQUEST['db_rename'])) {
$move = true;
} else {
$move = false;
}
- if (! isset($newname) || ! strlen($newname)) {
+ if (! isset($_REQUEST['newname']) || ! strlen($_REQUEST['newname'])) {
$message = PMA_Message::error(__('The database name is empty!'));
} else {
$sql_query = ''; // in case target db exists
$_error = false;
if ($move
- || (isset($create_database_before_copying)
- && $create_database_before_copying)
+ || (isset($_REQUEST['create_database_before_copying'])
+ && $_REQUEST['create_database_before_copying'])
) {
- // lower_case_table_names=1 `DB` becomes `db`
- if (! PMA_DRIZZLE) {
- $lower_case_table_names = PMA_DBI_fetch_value(
- 'SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1
- );
- if ($lower_case_table_names === '1') {
- $newname = PMA_strtolower($newname);
- }
- }
-
- $local_query = 'CREATE DATABASE ' . $common_functions->backquote($newname);
- if (isset($db_collation)) {
- $local_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
- }
- $local_query .= ';';
- $sql_query = $local_query;
- // save the original db name because Tracker.class.php which
- // may be called under PMA_DBI_query() changes $GLOBALS['db']
- // for some statements, one of which being CREATE DATABASE
- $original_db = $db;
- PMA_DBI_query($local_query);
- $db = $original_db;
- unset($original_db);
-
- // rebuild the database list because PMA_Table::moveCopy
- // checks in this list if the target db exists
- $GLOBALS['pma']->databases->build();
+ $sql_query = PMA_getSqlQueryAndCreateDbBeforeCopy();
}
// here I don't use DELIMITER because it's not part of the
@@ -103,37 +59,12 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
// to avoid selecting alternatively the current and new db
// we would need to modify the CREATE definitions to qualify
// the db name
- $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
- if ($procedure_names) {
- foreach ($procedure_names as $procedure_name) {
- PMA_DBI_select_db($db);
- $tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name);
- // collect for later display
- $GLOBALS['sql_query'] .= "\n" . $tmp_query;
- PMA_DBI_select_db($newname);
- PMA_DBI_query($tmp_query);
- }
- }
-
- $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
- if ($function_names) {
- foreach ($function_names as $function_name) {
- PMA_DBI_select_db($db);
- $tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name);
- // collect for later display
- $GLOBALS['sql_query'] .= "\n" . $tmp_query;
- PMA_DBI_select_db($newname);
- PMA_DBI_query($tmp_query);
- }
- }
+ PMA_runProcedureAndFunctionDefinitions($db);
// go back to current db, just in case
PMA_DBI_select_db($db);
- $GLOBALS['sql_constraints_query_full_db'] = array();
-
$tables_full = PMA_DBI_get_tables_full($db);
- $views = array();
require_once "libraries/plugin_interface.lib.php";
// remove all foreign key constraints, otherwise we can get errors
@@ -145,173 +76,43 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
'single_table' => isset($single_table)
)
);
- foreach ($tables_full as $each_table => $tmp) {
- $sql_constraints = '';
- $sql_drop_foreign_keys = '';
- $sql_structure = $export_sql_plugin->getTableDef(
- $db, $each_table, "\n", '', false, false
+ $GLOBALS['sql_constraints_query_full_db'] =
+ PMA_getSqlConstraintsQueryForFullDb(
+ $tables_full, $export_sql_plugin, $move, $db
);
- if ($move && ! empty($sql_drop_foreign_keys)) {
- PMA_DBI_query($sql_drop_foreign_keys);
- }
- // keep the constraint we just dropped
- if (! empty($sql_constraints)) {
- $GLOBALS['sql_constraints_query_full_db'][] = $sql_constraints;
- }
- }
- unset($sql_constraints, $sql_drop_foreign_keys, $sql_structure);
- foreach ($tables_full as $each_table => $tmp) {
- // to be able to rename a db containing views,
- // first all the views are collected and a stand-in is created
- // the real views are created after the tables
- if (PMA_Table::isView($db, $each_table)) {
- $views[] = $each_table;
- // Create stand-in definition to resolve view dependencies
- $sql_view_standin = $export_sql_plugin->getTableDefStandIn(
- $db, $each_table, "\n"
- );
- PMA_DBI_select_db($newname);
- PMA_DBI_query($sql_view_standin);
- $GLOBALS['sql_query'] .= "\n" . $sql_view_standin;
- }
- }
+ $views = PMA_getViewsAndCreateSqlViewStandIn(
+ $tables_full, $export_sql_plugin, $db
+ );
- foreach ($tables_full as $each_table => $tmp) {
- // skip the views; we have creted stand-in definitions
- if (PMA_Table::isView($db, $each_table)) {
- continue;
- }
- $back = $sql_query;
- $sql_query = '';
-
- // value of $what for this table only
- $this_what = $what;
-
- // do not copy the data from a Merge table
- // note: on the calling FORM, 'data' means 'structure and data'
- if (PMA_Table::isMerge($db, $each_table)) {
- if ($this_what == 'data') {
- $this_what = 'structure';
- }
- if ($this_what == 'dataonly') {
- $this_what = 'nocopy';
- }
- }
-
- if ($this_what != 'nocopy') {
- // keep the triggers from the original db+table
- // (third param is empty because delimiters are only intended
- // for importing via the mysql client or our Import feature)
- $triggers = PMA_DBI_get_triggers($db, $each_table, '');
-
- if (! PMA_Table::moveCopy(
- $db, $each_table, $newname, $each_table,
- isset($this_what) ? $this_what : 'data',
- $move, 'db_copy'
- )) {
- $_error = true;
- // $sql_query is filled by PMA_Table::moveCopy()
- $sql_query = $back . $sql_query;
- break;
- }
- // apply the triggers to the destination db+table
- if ($triggers) {
- PMA_DBI_select_db($newname);
- foreach ($triggers as $trigger) {
- PMA_DBI_query($trigger['create']);
- $GLOBALS['sql_query'] .= "\n" . $trigger['create'] . ';';
- }
- unset($trigger);
- }
- unset($triggers);
-
- // this does not apply to a rename operation
- if (isset($GLOBALS['add_constraints'])
- && ! empty($GLOBALS['sql_constraints_query'])
- ) {
- $GLOBALS['sql_constraints_query_full_db'][] = $GLOBALS['sql_constraints_query'];
- unset($GLOBALS['sql_constraints_query']);
- }
- }
- // $sql_query is filled by PMA_Table::moveCopy()
- $sql_query = $back . $sql_query;
- } // end (foreach)
- unset($each_table);
+ list($sql_query, $_error) = PMA_getSqlQueryForCopyTable(
+ $tables_full, $sql_query, $move, $db
+ );
// handle the views
if (! $_error) {
- // temporarily force to add DROP IF EXIST to CREATE VIEW query,
- // to remove stand-in VIEW that was created earlier
- if (isset($GLOBALS['drop_if_exists'])) {
- $temp_drop_if_exists = $GLOBALS['drop_if_exists'];
- }
- $GLOBALS['drop_if_exists'] = 'true';
-
- foreach ($views as $view) {
- if (! PMA_Table::moveCopy($db, $view, $newname, $view, 'structure', $move, 'db_copy')) {
- $_error = true;
- break;
- }
- }
- unset($GLOBALS['drop_if_exists']);
- if (isset($temp_drop_if_exists)) {
- // restore previous value
- $GLOBALS['drop_if_exists'] = $temp_drop_if_exists;
- unset($temp_drop_if_exists);
- }
+ $_error = PMA_handleTheViews($views, $move, $db);
}
- unset($view, $views);
+ unset($views);
// now that all tables exist, create all the accumulated constraints
if (! $_error && count($GLOBALS['sql_constraints_query_full_db']) > 0) {
- PMA_DBI_select_db($newname);
- foreach ($GLOBALS['sql_constraints_query_full_db'] as $one_query) {
- PMA_DBI_query($one_query);
- // and prepare to display them
- $GLOBALS['sql_query'] .= "\n" . $one_query;
- }
-
- unset($GLOBALS['sql_constraints_query_full_db'], $one_query);
+ PMA_createAllAccumulatedConstraints();
}
if (! PMA_DRIZZLE && PMA_MYSQL_INT_VERSION >= 50100) {
// here DELIMITER is not used because it's not part of the
// language; each statement is sent one by one
- // to avoid selecting alternatively the current and new db
- // we would need to modify the CREATE definitions to qualify
- // the db name
- $event_names = PMA_DBI_fetch_result(
- 'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \''
- . $common_functions->sqlAddSlashes($db, true) . '\';'
- );
- if ($event_names) {
- foreach ($event_names as $event_name) {
- PMA_DBI_select_db($db);
- $tmp_query = PMA_DBI_get_definition($db, 'EVENT', $event_name);
- // collect for later display
- $GLOBALS['sql_query'] .= "\n" . $tmp_query;
- PMA_DBI_select_db($newname);
- PMA_DBI_query($tmp_query);
- }
- }
+ PMA_runEventDefinitionsForDb($db);
}
// go back to current db, just in case
PMA_DBI_select_db($db);
// Duplicate the bookmarks for this db (done once for each db)
- if (! $_error && $db != $newname) {
- $get_fields = array('user', 'label', 'query');
- $where_fields = array('dbase' => $db);
- $new_fields = array('dbase' => $newname);
- PMA_Table::duplicateInfo(
- 'bookmarkwork', 'bookmark', $get_fields,
- $where_fields, $new_fields
- );
- }
-
+ PMA_duplicateBookmarks($_error, $db);
+
if (! $_error && $move) {
/**
* cleanup pmadb stuff for this db
@@ -326,21 +127,21 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
$message = PMA_Message::success(__('Database %1$s has been renamed to %2$s'));
$message->addParam($db);
- $message->addParam($newname);
+ $message->addParam($_REQUEST['newname']);
} elseif (! $_error) {
$message = PMA_Message::success(__('Database %1$s has been copied to %2$s'));
$message->addParam($db);
- $message->addParam($newname);
+ $message->addParam($_REQUEST['newname']);
}
$reload = true;
/* Change database to be used */
if (! $_error && $move) {
- $db = $newname;
+ $db = $_REQUEST['newname'];
} elseif (! $_error) {
- if (isset($switch_to_new) && $switch_to_new == 'true') {
+ if (isset($_REQUEST['switch_to_new']) && $_REQUEST['switch_to_new'] == 'true') {
$GLOBALS['PMA_Config']->setCookie('pma_switch_to_new', 'true');
- $db = $newname;
+ $db = $_REQUEST['newname'];
} else {
$GLOBALS['PMA_Config']->setCookie('pma_switch_to_new', '');
}
@@ -359,7 +160,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
$response = PMA_Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('message', $message);
- $response->addJSON('newname', $newname);
+ $response->addJSON('newname', $_REQUEST['newname']);
$response->addJSON(
'sql_query',
$common_functions->getMessage(null, $sql_query)
@@ -368,7 +169,6 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
}
}
-
/**
* Settings for relations stuff
*/
@@ -380,7 +180,7 @@ $cfgRelation = PMA_getRelationsParam();
* (must be done before displaying the menu tabs)
*/
if (isset($_REQUEST['comment'])) {
- PMA_setDbComment($db, $comment);
+ PMA_setDbComment($db, $_REQUEST['comment']);
}
/**
@@ -402,7 +202,7 @@ if (empty($is_info)) {
}
}
-$db_collation = PMA_getDbCollation($db);
+$_REQUEST['db_collation'] = PMA_getDbCollation($db);
$is_information_schema = PMA_is_system_schema($db);
if (!$is_information_schema) {
@@ -410,237 +210,69 @@ if (!$is_information_schema) {
/**
* database comment
*/
- ?>
-
-
-
- addHTML(PMA_getHtmlForDatabaseComment($db));
}
- ?>
-
-
-
- addHTML('');
+ ob_start();
+ include 'libraries/display_create_table.lib.php';
+ $content = ob_get_contents();
+ ob_end_clean();
+ $response->addHTML($content);
+ $response->addHTML('
');
+
/**
* rename database
*/
-if ($db != 'mysql') {
- ?>
-
-
-
-
-
-
- getImage('b_deltbl.png');
-}
-echo __('Remove database');
-?>
-
-
-backquote($GLOBALS['db']);
- $this_url_params = array(
- 'sql_query' => $this_sql_query,
- 'back' => 'db_operations.php',
- 'goto' => 'main.php',
- 'reload' => '1',
- 'purge' => '1',
- 'message_to_show' => sprintf(__('Database %s has been dropped.'), htmlspecialchars($common_functions->backquote($db))),
- 'db' => null,
- );
- ?>
- >
-
- showMySQLDocu('SQL-Syntax', 'DROP_DATABASE'); ?>
-
-
-
-
-
-
-
-
- addHTML(PMA_getHtmlForCopyDatabase($db));
/**
* Change database charset
*/
- echo '
' . "\n";
+ $response->addHTML(PMA_getHtmlForChangeDatabaseCharset($db, $table));
if ($num_tables > 0
&& ! $cfgRelation['allworks']
&& $cfg['PmaNoRelation_DisableWarning'] == false
) {
- $message = PMA_Message::notice(__('The phpMyAdmin configuration storage has been deactivated. To find out why click %shere%s.'));
- $message->addParam('', false);
+ $message = PMA_Message::notice(
+ __('The phpMyAdmin configuration storage has been deactivated. To find out why click %shere%s.')
+ );
+ $message->addParam(
+ ' ',
+ false
+ );
$message->addParam(' ', false);
/* Show error if user has configured something, notice elsewhere */
if (!empty($cfg['Servers'][$server]['pmadb'])) {
$message->isError(true);
}
- echo '';
- $message->display();
- echo '
';
+ $response->addHTML('');
+ $response->addHTML($message->getDisplay());
+ $response->addHTML('
');
} // end if
} // end if (!$is_information_schema)
// not sure about displaying the PDF dialog in case db is information_schema
-if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
-
-
- 0) {
// We only show this if we find something in the new pdf_pages table
-
$test_query = '
SELECT *
FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db'])
@@ -651,11 +283,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
/*
* Export Relational Schema View
*/
- echo '';
+ $response->addHTML(PMA_getHtmlForExportRelationalSchemaView($url_query));
} // end if
?>
diff --git a/js/functions.js b/js/functions.js
index e7877e0db2..0f88ac2205 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -3871,5 +3871,7 @@ $(function () {
* Reveal the login form to users with JS enabled
*/
$(function () {
- $('.js-show').show();
+ var $loginform = $('#loginform');
+ $loginform.find('.js-show').show();
+ $loginform.find('#input_username').select();
});
diff --git a/js/tbl_select.js b/js/tbl_select.js
index b8c9f386d5..f04b4e3553 100644
--- a/js/tbl_select.js
+++ b/js/tbl_select.js
@@ -52,7 +52,39 @@ $(function() {
PMA_prepareForAjaxRequest($search_form);
- $.post($search_form.attr('action'), $search_form.serialize(), function(data) {
+ var values = {};
+ $search_form.find(':input').each(function() {
+ var $input = $(this);
+ if ($input.attr('type') == 'checkbox' || $input.attr('type') == 'radio') {
+ if ($input.is(':checked')) {
+ values[this.name] = $input.val();
+ }
+ } else {
+ values[this.name] = $input.val();
+ }
+ });
+ var columnCount = $('select[name="columnsToDisplay[]"] option').length;
+ // Submit values only for the columns that have a search criteria
+ for (var a = 0; a < columnCount; a++) {
+ if (values['criteriaValues[' + a + ']'] == '') {
+ delete values['criteriaValues[' + a + ']'];
+ delete values['criteriaColumnOperators[' + a + ']'];
+ delete values['criteriaColumnNames[' + a + ']'];
+ delete values['criteriaColumnTypes[' + a + ']'];
+ delete values['criteriaColumnCollations[' + a + ']'];
+ }
+ }
+ // If all columns are selected, use a single parameter to indicate that
+ if (values['columnsToDisplay[]'] != null) {
+ if (values['columnsToDisplay[]'].length == columnCount) {
+ delete values['columnsToDisplay[]'];
+ values['displayAllColumns'] = true;
+ }
+ } else {
+ values['displayAllColumns'] = true;
+ }
+
+ $.post($search_form.attr('action'), values, function(data) {
PMA_ajaxRemoveMessage($msgbox);
if (data.success == true) {
// found results
diff --git a/libraries/Config.class.php b/libraries/Config.class.php
index 01d47aa670..648f4aab5e 100644
--- a/libraries/Config.class.php
+++ b/libraries/Config.class.php
@@ -634,8 +634,6 @@ class PMA_Config
$this->checkPmaAbsoluteUri();
$this->checkFontsize();
- $this->checkPermissions();
-
// Handling of the collation must be done after merging of $cfg
// (from config.inc.php) so that $cfg['DefaultConnectionCollation']
// can have an effect. Note that the presence of collation
diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php
index 0674115400..d67237f1a5 100644
--- a/libraries/DisplayResults.class.php
+++ b/libraries/DisplayResults.class.php
@@ -2789,6 +2789,7 @@ class PMA_DisplayResults
$vertical_display = $this->__get('_vertical_display');
// Check whether the field needs to display with syntax highlighting
+
if ($this->_isNeedToSytaxHighlight($meta->name)
&& (trim($row[$i]) != '')
) {
@@ -2811,7 +2812,7 @@ class PMA_DisplayResults
'_', '/',
$this->sytax_highlighting_column_info[strtolower($this->__get('_db'))][strtolower($this->__get('_table'))][strtolower($meta->name)][2]
);
-
+
}
// Check for the predefined fields need to show as link in schemas
@@ -3042,7 +3043,6 @@ class PMA_DisplayResults
return false;
}
-
/**
* Check whether the field needs to be link
*
@@ -3644,6 +3644,7 @@ class PMA_DisplayResults
if ((PMA_strlen($column) > $GLOBALS['cfg']['LimitChars'])
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
&& ! $this->_isNeedToSytaxHighlight(strtolower($meta->name))
+
) {
$column = PMA_substr($column, 0, $GLOBALS['cfg']['LimitChars'])
. '...';
diff --git a/libraries/Response.class.php b/libraries/Response.class.php
index c341acc614..d10aecb0e0 100644
--- a/libraries/Response.class.php
+++ b/libraries/Response.class.php
@@ -136,7 +136,7 @@ class PMA_Response
* Returns true or false depending on whether
* we are servicing an ajax request
*
- * @return void
+ * @return bool
*/
public function isAjax()
{
diff --git a/libraries/Table.class.php b/libraries/Table.class.php
index e504746fd5..c6138e55a9 100644
--- a/libraries/Table.class.php
+++ b/libraries/Table.class.php
@@ -319,7 +319,6 @@ class PMA_Table
static public function sGetStatusInfo($db, $table, $info = null,
$force_read = false, $disable_error = false
) {
-
if (! empty($_SESSION['is_multi_query'])) {
$disable_error = true;
}
diff --git a/libraries/TableSearch.class.php b/libraries/TableSearch.class.php
index be354cadea..107efbf712 100644
--- a/libraries/TableSearch.class.php
+++ b/libraries/TableSearch.class.php
@@ -103,7 +103,6 @@ class PMA_TableSearch
* @param string $db Database name
* @param string $table Table name
* @param string $searchType Whether normal or zoom search
- *
*/
public function __construct($db, $table, $searchType)
{
@@ -134,6 +133,7 @@ class PMA_TableSearch
* Gets all the columns of a table along with their types, collations
* and whether null or not.
*
+ * @return void
*/
private function _loadTableInfo()
{
@@ -445,38 +445,34 @@ EOT;
*/
private function _getEnumWhereClause($criteriaValues, $func_type)
{
- $where = '';
$common_functions = PMA_CommonFunctions::getInstance();
- if (! empty($criteriaValues)) {
- if (! is_array($criteriaValues)) {
- $criteriaValues = explode(',', $criteriaValues);
- }
- $enum_selected_count = count($criteriaValues);
- if ($func_type == '=' && $enum_selected_count > 1) {
- $func_type = 'IN';
- $parens_open = '(';
- $parens_close = ')';
-
- } elseif ($func_type == '!=' && $enum_selected_count > 1) {
- $func_type = 'NOT IN';
- $parens_open = '(';
- $parens_close = ')';
-
- } else {
- $parens_open = '';
- $parens_close = '';
- }
- $enum_where = '\''
- . $common_functions->sqlAddSlashes($criteriaValues[0]) . '\'';
- for ($e = 1; $e < $enum_selected_count; $e++) {
- $enum_where .= ', \''
- . $common_functions->sqlAddSlashes($criteriaValues[$e]) . '\'';
- }
-
- $where = ' ' . $func_type . ' ' . $parens_open
- . $enum_where . $parens_close;
+ if (! is_array($criteriaValues)) {
+ $criteriaValues = explode(',', $criteriaValues);
}
- return $where;
+ $enum_selected_count = count($criteriaValues);
+ if ($func_type == '=' && $enum_selected_count > 1) {
+ $func_type = 'IN';
+ $parens_open = '(';
+ $parens_close = ')';
+
+ } elseif ($func_type == '!=' && $enum_selected_count > 1) {
+ $func_type = 'NOT IN';
+ $parens_open = '(';
+ $parens_close = ')';
+
+ } else {
+ $parens_open = '';
+ $parens_close = '';
+ }
+ $enum_where = '\''
+ . $common_functions->sqlAddSlashes($criteriaValues[0]) . '\'';
+ for ($e = 1; $e < $enum_selected_count; $e++) {
+ $enum_where .= ', \''
+ . $common_functions->sqlAddSlashes($criteriaValues[$e]) . '\'';
+ }
+
+ return ' ' . $func_type . ' ' . $parens_open
+ . $enum_where . $parens_close;
}
/**
@@ -564,7 +560,7 @@ EOT;
$criteriaValues = '';
$where = $backquoted_name . ' ' . $func_type;
- } elseif (strncasecmp($types, 'enum', 4) == 0) {
+ } elseif (strncasecmp($types, 'enum', 4) == 0 && ! empty($criteriaValues)) {
$where = $backquoted_name;
$where .= $this->_getEnumWhereClause($criteriaValues, $func_type);
@@ -643,10 +639,9 @@ EOT;
if (isset($_POST['zoom_submit'])) {
$sql_query .= '* ';
} else {
- $sql_query .= (count($_POST['columnsToDisplay'])
- == count($_POST['criteriaColumnNames'])
+ $sql_query .= ! empty($_POST['displayAllColumns'])
? '* '
- : implode(', ', $this->getCommonFunctions()->backquote($_POST['columnsToDisplay'])));
+ : implode(', ', $this->getCommonFunctions()->backquote($_POST['columnsToDisplay']));
} // end if
$sql_query .= ' FROM ' . $this->getCommonFunctions()->backquote($_POST['table']);
diff --git a/libraries/common.inc.php b/libraries/common.inc.php
index 3190eb7ec6..43f29ea686 100644
--- a/libraries/common.inc.php
+++ b/libraries/common.inc.php
@@ -568,6 +568,8 @@ if ($GLOBALS['text_dir'] == 'ltr') {
* check for errors occurred while loading configuration
* this check is done here after loading language files to present errors in locale
*/
+$GLOBALS['PMA_Config']->checkPermissions();
+
if ($GLOBALS['PMA_Config']->error_config_file) {
$error = '[strong]' . __('Failed to read configuration file') . '[/strong]'
. '[br][br]'
diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php
index 30b934a697..9902cf1e90 100644
--- a/libraries/database_interface.lib.php
+++ b/libraries/database_interface.lib.php
@@ -743,6 +743,33 @@ function PMA_DBI_get_tables_full($database, $table = false,
}
}
+
+/**
+ * Get VIEWs in a particular database
+ *
+ * @param string $db Database name to look in
+ *
+ * @return array $views Set of VIEWs inside the database
+ */
+function PMA_DBI_getVirtualTables($db)
+{
+
+ $tables_full = PMA_DBI_get_tables_full($db);
+ $views = array();
+
+ foreach ($tables_full as $table=>$tmp) {
+
+ if (PMA_Table::isView($db, $table)) {
+ $views[] = $table;
+ }
+
+ }
+
+ return $views;
+
+}
+
+
/**
* returns array with databases containing extended infos about them
*
diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php
index 680db4d2ac..3008805431 100644
--- a/libraries/mult_submits.inc.php
+++ b/libraries/mult_submits.inc.php
@@ -8,6 +8,8 @@ if (! defined('PHPMYADMIN')) {
exit;
}
+require_once 'libraries/transformations.lib.php';
+
$common_functions = PMA_CommonFunctions::getInstance();
$request_params = array(
@@ -137,6 +139,7 @@ if (! empty($submit_mult)
}
} // end if
+$views = PMA_DBI_getVirtualTables($db);
/**
* Displays the confirmation form if required
@@ -487,6 +490,15 @@ if (!empty($submit_mult) && !empty($what)) {
PMA_DBI_select_db($db);
}
$result = PMA_DBI_query($a_query);
+
+ if ($query_type == 'drop_db') {
+ PMA_clearTransformations($selected[$i]);
+ } elseif ($query_type == 'drop_tbl') {
+ PMA_clearTransformations($db, $selected[$i]);
+ } else if ($query_type == 'drop_fld') {
+ PMA_clearTransformations($db, $table ,$selected[$i]);
+ }
+
} // end if
} // end for
diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php
new file mode 100644
index 0000000000..d1196a5b46
--- /dev/null
+++ b/libraries/operations.lib.php
@@ -0,0 +1,1392 @@
+'
+ . ''
+ . '';
+
+ return $html_output;
+}
+
+/**
+ * Get HTML output for rename database
+ *
+ * @param $db database name
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForRenameDatabase($db)
+{
+ $html_output = ''
+ . ''
+ . '
';
+
+ return $html_output;
+}
+
+/**
+ * Get HTML for database drop link
+ *
+ * @param $db database name
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForDropDatabaseLink($db)
+{
+ $common_functions = PMA_CommonFunctions::getInstance();
+
+ $this_sql_query = 'DROP DATABASE ' . $common_functions->backquote($db);
+ $this_url_params = array(
+ 'sql_query' => $this_sql_query,
+ 'back' => 'db_operations.php',
+ 'goto' => 'main.php',
+ 'reload' => '1',
+ 'purge' => '1',
+ 'message_to_show' => sprintf(
+ __('Database %s has been dropped.')
+ , htmlspecialchars($common_functions->backquote($db))
+ ),
+ 'db' => null,
+ );
+
+ $html_output = ''
+ . '
';
+ $html_output .= '';
+ if ($GLOBALS['cfg']['PropertiesIconic']) {
+ $html_output .= $common_functions->getImage('b_deltbl.png');
+ }
+ $html_output .= __('Remove database')
+ . ' ';
+ $html_output .= '';
+ $html_output .= PMA_getDeleteDataOrTablelink(
+ $this_url_params,
+ 'DROP_DATABASE',
+ __('Drop the database (DROP)'),
+ 'drop_db_anchor');
+ $html_output .= ' '
+ . '
';
+
+ return $html_output;
+}
+
+/**
+ * Get HTML snippet for copy database
+ *
+ * @param $db database name
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForCopyDatabase($db)
+{
+ $drop_clause = 'DROP TABLE / DROP VIEW';
+ $choices = array(
+ 'structure' => __('Structure only'),
+ 'data' => __('Structure and data'),
+ 'dataonly' => __('Data only')
+ );
+
+ if (isset($_COOKIE)
+ && isset($_COOKIE['pma_switch_to_new'])
+ && $_COOKIE['pma_switch_to_new'] == 'true'
+ ) {
+ $pma_switch_to_new = 'true';
+ }
+
+ $html_output = '';
+ $html_output .= ''
+ . '
';
+
+ return $html_output;
+}
+
+/**
+ * Get HTML snippet for change database charset
+ *
+ * @param $db database name
+ * @param $table tabel name
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForChangeDatabaseCharset($db, $table)
+{
+ $html_output = '
' . "\n";
+
+ return $html_output;
+}
+
+/**
+ * Get HTML snippet for export relational schema view
+ *
+ * @param string $url_query
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForExportRelationalSchemaView($url_query)
+{
+ $html_output = '';
+
+ return $html_output;
+}
+
+/**
+ * Run the Procedure definitions and function definitions
+ *
+ * to avoid selecting alternatively the current and new db
+ * we would need to modify the CREATE definitions to qualify
+ * the db name
+ *
+ * @param $db database name
+ */
+function PMA_runProcedureAndFunctionDefinitions($db)
+{
+ $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
+ if ($procedure_names) {
+ foreach ($procedure_names as $procedure_name) {
+ PMA_DBI_select_db($db);
+ $tmp_query = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name);
+ // collect for later display
+ $GLOBALS['sql_query'] .= "\n" . $tmp_query;
+ PMA_DBI_select_db($_REQUEST['newname']);
+ PMA_DBI_query($tmp_query);
+ }
+ }
+
+ $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
+ if ($function_names) {
+ foreach ($function_names as $function_name) {
+ PMA_DBI_select_db($db);
+ $tmp_query = PMA_DBI_get_definition($db, 'FUNCTION', $function_name);
+ // collect for later display
+ $GLOBALS['sql_query'] .= "\n" . $tmp_query;
+ PMA_DBI_select_db($_REQUEST['newname']);
+ PMA_DBI_query($tmp_query);
+ }
+ }
+}
+
+/**
+ * Get sql query and create database before copy
+ *
+ * @return string $sql_query
+ */
+function PMA_getSqlQueryAndCreateDbBeforeCopy()
+{
+ // lower_case_table_names=1 `DB` becomes `db`
+ if (! PMA_DRIZZLE) {
+ $lower_case_table_names = PMA_DBI_fetch_value(
+ 'SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1
+ );
+ if ($lower_case_table_names === '1') {
+ $_REQUEST['newname'] = PMA_strtolower($_REQUEST['newname']);
+ }
+ }
+
+ $local_query = 'CREATE DATABASE '
+ . PMA_CommonFunctions::getInstance()->backquote($_REQUEST['newname']);
+ if (isset($_REQUEST['db_collation'])) {
+ $local_query .= ' DEFAULT'
+ . PMA_generateCharsetQueryPart($_REQUEST['db_collation']);
+ }
+ $local_query .= ';';
+ $sql_query = $local_query;
+ // save the original db name because Tracker.class.php which
+ // may be called under PMA_DBI_query() changes $GLOBALS['db']
+ // for some statements, one of which being CREATE DATABASE
+ $original_db = $GLOBALS['db'];
+ PMA_DBI_query($local_query);
+ $GLOBALS['db'] = $original_db;
+
+ // rebuild the database list because PMA_Table::moveCopy
+ // checks in this list if the target db exists
+ $GLOBALS['pma']->databases->build();
+
+ return $sql_query;
+}
+
+/**
+ * remove all foreign key constraints and return sql constraints query for full database
+ *
+ * @param array $tables_full array of all tables in given db or dbs
+ * @param instance $export_sql_plugin export plugin instance
+ * @param boolean $move whether databse name is empty or not
+ * @param $db database name
+ */
+function PMA_getSqlConstraintsQueryForFullDb($tables_full, $export_sql_plugin, $move, $db)
+{
+ $sql_constraints_query_full_db = array();
+ foreach ($tables_full as $each_table => $tmp) {
+ $sql_constraints = '';
+ $sql_drop_foreign_keys = '';
+ $sql_structure = $export_sql_plugin->getTableDef(
+ $db, $each_table, "\n", '', false, false
+ );
+ if ($move && ! empty($sql_drop_foreign_keys)) {
+ PMA_DBI_query($sql_drop_foreign_keys);
+ }
+ // keep the constraint we just dropped
+ if (! empty($sql_constraints)) {
+ $sql_constraints_query_full_db[] = $sql_constraints;
+ }
+ }
+ return $sql_constraints_query_full_db;
+}
+
+/**
+ * Get views as an array and create SQL view stand-in
+ *
+ * @param array $tables_full array of all tables in given db or dbs
+ * @param instance $export_sql_plugin export plugin instance
+ * @param $db database name
+ *
+ * @return array $views
+ */
+function PMA_getViewsAndCreateSqlViewStandIn($tables_full, $export_sql_plugin, $db)
+{
+ $views = array();
+ foreach ($tables_full as $each_table => $tmp) {
+ // to be able to rename a db containing views,
+ // first all the views are collected and a stand-in is created
+ // the real views are created after the tables
+ if (PMA_Table::isView($db, $each_table)) {
+ $views[] = $each_table;
+ // Create stand-in definition to resolve view dependencies
+ $sql_view_standin = $export_sql_plugin->getTableDefStandIn(
+ $db, $each_table, "\n"
+ );
+ PMA_DBI_select_db($_REQUEST['newname']);
+ PMA_DBI_query($sql_view_standin);
+ $GLOBALS['sql_query'] .= "\n" . $sql_view_standin;
+ }
+ }
+ return $views;
+}
+
+/**
+ * Get sql query for copy/rename table and boolean for whether copy/rename or not
+ *
+ * @param array $tables_full array of all tables in given db or dbs
+ * @param string $sql_query sql query for all operations
+ * @param boolean $move whether databse name is empty or not
+ * @param $db database name
+ *
+ * @return array ($sql_query, $error)
+ */
+function PMA_getSqlQueryForCopyTable($tables_full, $sql_query, $move, $db)
+{
+ $error = false;
+ foreach ($tables_full as $each_table => $tmp) {
+ // skip the views; we have creted stand-in definitions
+ if (PMA_Table::isView($db, $each_table)) {
+ continue;
+ }
+ $back = $sql_query;
+ $sql_query = '';
+
+ // value of $what for this table only
+ $this_what = $_REQUEST['what'];
+
+ // do not copy the data from a Merge table
+ // note: on the calling FORM, 'data' means 'structure and data'
+ if (PMA_Table::isMerge($db, $each_table)) {
+ if ($this_what == 'data') {
+ $this_what = 'structure';
+ }
+ if ($this_what == 'dataonly') {
+ $this_what = 'nocopy';
+ }
+ }
+
+ if ($this_what != 'nocopy') {
+ // keep the triggers from the original db+table
+ // (third param is empty because delimiters are only intended
+ // for importing via the mysql client or our Import feature)
+ $triggers = PMA_DBI_get_triggers($db, $each_table, '');
+
+ if (! PMA_Table::moveCopy(
+ $db, $each_table, $_REQUEST['newname'], $each_table,
+ isset($this_what) ? $this_what : 'data',
+ $move, 'db_copy'
+ )) {
+ $error = true;
+ // $sql_query is filled by PMA_Table::moveCopy()
+ $sql_query = $back . $sql_query;
+ break;
+ }
+ // apply the triggers to the destination db+table
+ if ($triggers) {
+ PMA_DBI_select_db($_REQUEST['newname']);
+ foreach ($triggers as $trigger) {
+ PMA_DBI_query($trigger['create']);
+ $GLOBALS['sql_query'] .= "\n" . $trigger['create'] . ';';
+ }
+ }
+
+ // this does not apply to a rename operation
+ if (isset($_REQUEST['add_constraints'])
+ && ! empty($GLOBALS['sql_constraints_query'])
+ ) {
+ $GLOBALS['sql_constraints_query_full_db'][]
+ = $GLOBALS['sql_constraints_query'];
+ unset($GLOBALS['sql_constraints_query']);
+ }
+ }
+ // $sql_query is filled by PMA_Table::moveCopy()
+ $sql_query = $back . $sql_query;
+ }
+ return array($sql_query, $error);
+}
+
+/**
+ * Run the EVENT definition for selected database
+ *
+ * to avoid selecting alternatively the current and new db
+ * we would need to modify the CREATE definitions to qualify
+ * the db name
+ *
+ * @param $db database name
+ */
+function PMA_runEventDefinitionsForDb($db)
+{
+ $event_names = PMA_DBI_fetch_result(
+ 'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \''
+ . PMA_CommonFunctions::getInstance()->sqlAddSlashes($db, true) . '\';'
+ );
+ if ($event_names) {
+ foreach ($event_names as $event_name) {
+ PMA_DBI_select_db($db);
+ $tmp_query = PMA_DBI_get_definition($db, 'EVENT', $event_name);
+ // collect for later display
+ $GLOBALS['sql_query'] .= "\n" . $tmp_query;
+ PMA_DBI_select_db($_REQUEST['newname']);
+ PMA_DBI_query($tmp_query);
+ }
+ }
+}
+
+/**
+ * Handle the views, return the boolean value whether table rename/copy or not
+ *
+ * @param array $views views as an array
+ * @param boolean $move whether databse name is empty or not
+ * @param $db database name
+ *
+ * @return boolean $_error whether table rename/copy or not
+ */
+function PMA_handleTheViews($views, $move, $db)
+{
+ $_error = false;
+ // temporarily force to add DROP IF EXIST to CREATE VIEW query,
+ // to remove stand-in VIEW that was created earlier
+ if (isset($_REQUEST['drop_if_exists'])) {
+ $temp_drop_if_exists = $_REQUEST['drop_if_exists'];
+ }
+ $_REQUEST['drop_if_exists'] = 'true';
+
+ foreach ($views as $view) {
+ if (! PMA_Table::moveCopy($db, $view, $_REQUEST['newname'],
+ $view, 'structure', $move, 'db_copy')
+ ) {
+ $_error = true;
+ break;
+ }
+ }
+ unset($_REQUEST['drop_if_exists']);
+ if (isset($temp_drop_if_exists)) {
+ // restore previous value
+ $_REQUEST['drop_if_exists'] = $temp_drop_if_exists;
+ }
+ return $_error;
+}
+
+/**
+ * Create all accumulated constraaints
+ */
+function PMA_createAllAccumulatedConstraints()
+{
+ PMA_DBI_select_db($_REQUEST['newname']);
+ foreach ($GLOBALS['sql_constraints_query_full_db'] as $one_query) {
+ PMA_DBI_query($one_query);
+ // and prepare to display them
+ $GLOBALS['sql_query'] .= "\n" . $one_query;
+ }
+ unset($GLOBALS['sql_constraints_query_full_db']);
+}
+
+/**
+ * Duplicate the bookmarks for the db (done once for each db)
+ *
+ * @param boolean $_error whether table rename/copy or not
+ * @param string $db database name
+ */
+function PMA_duplicateBookmarks($_error, $db)
+{
+ if (! $_error && $db != $_REQUEST['newname']) {
+ $get_fields = array('user', 'label', 'query');
+ $where_fields = array('dbase' => $db);
+ $new_fields = array('dbase' => $_REQUEST['newname']);
+ PMA_Table::duplicateInfo(
+ 'bookmarkwork', 'bookmark', $get_fields,
+ $where_fields, $new_fields
+ );
+ }
+}
+
+/**
+ * Get the HTML snippet for order the table
+ *
+ * @param type $columns columns array
+ *
+ * @return string $html_out
+ */
+function PMA_getHtmlForOrderTheTable($columns)
+{
+ $html_output = '';
+ $html_output .= ''
+ . '
';
+
+ return $html_output;
+}
+
+/**
+ * Get the HTML snippet for move table
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForMoveTable()
+{
+ $html_output = '';
+ $html_output .= ''
+ . '
';
+
+ return $html_output;
+}
+
+/**
+ * Get the HTML div for Table option
+ *
+ * @param string $comment Comment
+ * @param array $tbl_collation table collation
+ * @param string $tbl_storage_engine table storage engine
+ * @param boolean $is_myisam_or_aria whether MYISAM | ARIA or not
+ * @param boolean $is_isam whether ISAM or not
+ * @param array $pack_keys pack keys
+ * @param string $delay_key_write delay key write
+ * @param string $auto_increment value of auto increment
+ * @param string $transactional value of transactional
+ * @param string $page_checksum value of page checksum
+ * @param boolean $is_innodb whether INNODB or not
+ * @param boolean $is_pbxt whether PBXT or not
+ * @param boolean $is_aria whether ARIA or not
+ *
+ * @return string $html_output
+ */
+function PMA_getTableOptionDiv($comment, $tbl_collation, $tbl_storage_engine,
+ $is_myisam_or_aria, $is_isam, $pack_keys, $auto_increment, $delay_key_write,
+ $transactional, $page_checksum, $is_innodb, $is_pbxt, $is_aria
+) {
+ $html_output = '';
+ $html_output .= ''
+ . '
';
+
+ return $html_output;
+}
+
+/**
+ * Get HTML fieldset for Table option, it contains HTML table for options
+ *
+ * @param string $comment Comment
+ * @param array $tbl_collation table collation
+ * @param string $tbl_storage_engine table storage engine
+ * @param boolean $is_myisam_or_aria whether MYISAM | ARIA or not
+ * @param boolean $is_isam whether ISAM or not
+ * @param array $pack_keys pack keys
+ * @param string $delay_key_write delay key write
+ * @param string $auto_increment value of auto increment
+ * @param string $transactional value of transactional
+ * @param string $page_checksum value of page checksum
+ * @param boolean $is_innodb whether INNODB or not
+ * @param boolean $is_pbxt whether PBXT or not
+ * @param boolean $is_aria whether ARIA or not
+ *
+ * @return string $html_output
+ */
+function PMA_getTableOptionFieldset($comment, $tbl_collation, $tbl_storage_engine,
+ $is_myisam_or_aria, $is_isam, $pack_keys, $delay_key_write, $auto_increment,
+ $transactional, $page_checksum, $is_innodb, $is_pbxt, $is_aria
+) {
+ $html_output = ''
+ . '' . __('Table options') . ' ';
+
+ $html_output .= '';
+ //Change table name
+ $html_output .= '' . __('Rename table to') . ' '
+ . ' '
+ . ' '
+ . ' ';
+
+ //Table comments
+ $html_output .= '' . __('Table comments') . ' '
+ . ' '
+ . ' '
+ . ' '
+ . ' ';
+
+ //Storage engine
+ $html_output .= '' . __('Storage Engine')
+ . PMA_CommonFunctions::getInstance()->showMySQLDocu(
+ 'Storage_engines', 'Storage_engines'
+ )
+ . ' '
+ . ''
+ . PMA_StorageEngine::getHtmlSelect(
+ 'new_tbl_storage_engine', null, $tbl_storage_engine
+ )
+ . ' '
+ . ' ';
+
+ //Table character set
+ $html_output .= '' . __('Collation') . ' '
+ . ''
+ . PMA_generateCharsetDropdownBox(
+ PMA_CSDROPDOWN_COLLATION,
+ 'tbl_collation', null, $tbl_collation, false, 3
+ )
+ . ' '
+ . ' ';
+
+ if ($is_myisam_or_aria || $is_isam) {
+ $html_output .= ''
+ . 'PACK_KEYS '
+ . '';
+
+ $html_output .= ''
+ . ' '
+ . ' ';
+ } // end if (MYISAM|ISAM)
+
+ if ($is_myisam_or_aria) {
+ $html_output .= PMA_getTableRow(
+ 'new_checksum',
+ 'CHECKSUM',
+ $checksum
+ );
+
+ $html_output .= PMA_getTableRow(
+ 'new_delay_key_write',
+ 'DELAY_KEY_WRITE',
+ $delay_key_write
+ );
+ } // end if (MYISAM)
+
+ if ($is_aria) {
+ $html_output .= PMA_getTableRow(
+ 'new_transactional',
+ 'TRANSACTIONAL',
+ $transactional
+ );
+
+ $html_output .= PMA_getTableRow(
+ 'new_page_checksum',
+ 'PAGE_CHECKSUM',
+ $page_checksum
+ );
+ } // end if (ARIA)
+
+ if (isset($_REQUEST['auto_increment'])
+ && strlen($_REQUEST['auto_increment']) > 0
+ && ($is_myisam_or_aria || $is_innodb || $is_pbxt)
+ ) {
+ $html_output .= ''
+ . 'AUTO_INCREMENT '
+ . ' '
+ . ' ';
+ } // end if (MYISAM|INNODB)
+
+ $possible_row_formats = PMA_getPossibleRowFormat();
+
+ // for MYISAM there is also COMPRESSED but it can be set only by the
+ // myisampack utility, so don't offer here the choice because if we
+ // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
+ // does not return a warning
+ // (if the table was compressed, it can be seen on the Structure page)
+
+ if (isset($possible_row_formats[$tbl_storage_engine])) {
+ $current_row_format = strtoupper($GLOBALS['showtable']['Row_format']);
+ $html_output .= ''
+ . 'ROW_FORMAT '
+ . '';
+ $html_output .= PMA_CommonFunctions::getInstance()->getDropdown(
+ 'new_row_format', $possible_row_formats[$tbl_storage_engine],
+ $current_row_format, 'new_row_format'
+ );
+ $html_output .= ' ';
+ }
+ $html_output .= '
'
+ . ' ';
+
+ return $html_output;
+}
+
+/**
+ * Get the common HTML table row (tr) for new_checksum, new_delay_key_write,
+ * new_transactional and new_page_checksum
+ *
+ * @param string $attribute class, name and id attribute
+ * @param string $label label value
+ * @param string $val checksum, delay_key_write, transactional, page_checksum
+ *
+ * @return string $html_output
+ */
+function PMA_getTableRow($attribute, $label, $val)
+{
+ return ''
+ . '' . $label . ' '
+ . ' '
+ . ' ';
+}
+
+/**
+ * Get array of possible row formats
+ *
+ * @return array $possible_row_formats
+ */
+function PMA_getPossibleRowFormat()
+{
+ // the outer array is for engines, the inner array contains the dropdown
+ // option values as keys then the dropdown option labels
+
+ $possible_row_formats = array(
+ 'ARIA' => array(
+ 'FIXED' => 'FIXED',
+ 'DYNAMIC' => 'DYNAMIC',
+ 'PAGE' => 'PAGE'
+ ),
+ 'MARIA' => array(
+ 'FIXED' => 'FIXED',
+ 'DYNAMIC' => 'DYNAMIC',
+ 'PAGE' => 'PAGE'
+ ),
+ 'MYISAM' => array(
+ 'FIXED' => 'FIXED',
+ 'DYNAMIC' => 'DYNAMIC'
+ ),
+ 'PBXT' => array(
+ 'FIXED' => 'FIXED',
+ 'DYNAMIC' => 'DYNAMIC'
+ ),
+ 'INNODB' => array(
+ 'COMPACT' => 'COMPACT',
+ 'REDUNDANT' => 'REDUNDANT')
+ );
+
+ $innodb_engine_plugin = PMA_StorageEngine::getEngine('innodb');
+ $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
+ if (!empty($innodb_plugin_version)) {
+ $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
+ } else {
+ $innodb_file_format = '';
+ }
+ if ('Barracuda' == $innodb_file_format
+ && $innodb_engine_plugin->supportsFilePerTable()
+ ) {
+ $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
+ $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
+ }
+
+ return $possible_row_formats;
+}
+
+/**
+ * Get HTML div for copy table
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForCopytable()
+{
+ $html_output = '';
+ $html_output .= ''
+ . '
';
+
+ return $html_output;
+}
+
+/**
+ * Get HTML snippet for table maintence
+ *
+ * @param boolean $is_myisam_or_aria whether MYISAM | ARIA or not
+ * @param boolean $is_innodb whether innodb or not
+ * @param boolean $is_berkeleydb whether berkeleydb or not
+ * @param array $url_params array of URL parameters
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForTableMaintenance(
+ $is_myisam_or_aria, $is_innodb, $is_berkeleydb, $url_params
+) {
+ $common_functions = PMA_CommonFunctions::getInstance();
+
+ $html_output = '';
+ $html_output .= '
'
+ . '' . __('Table maintenance') . ' ';
+ $html_output .= '';
+
+ // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
+ $html_output .= PMA_getListofMaintainActionLink($is_myisam_or_aria,
+ $is_innodb, $url_params, $is_berkeleydb
+ );
+
+ $html_output .= ' '
+ . ' '
+ . '
';
+
+ return $html_output;
+}
+
+/**
+ * Get HTML 'li' having a link of maintain action
+ *
+ * @param boolean $is_myisam_or_aria whether MYISAM | ARIA or not
+ * @param boolean $is_innodb whether innodb or not
+ * @param array $url_params array of URL parameters
+ * @param boolean $is_berkeleydb whether berkeleydb or not
+ *
+ * @return string $html_output
+ */
+function PMA_getListofMaintainActionLink($is_myisam_or_aria,
+ $is_innodb, $url_params, $is_berkeleydb
+) {
+ $common_functions = PMA_CommonFunctions::getInstance();
+ $html_output = '';
+
+ if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
+ if ($is_myisam_or_aria || $is_innodb) {
+ $params = array(
+ 'sql_query' => 'CHECK TABLE '
+ . $common_functions->backquote($GLOBALS['table']),
+ 'table_maintenance' => 'Go',
+ );
+ $html_output .= PMA_getMaintainActionlink(
+ 'Check table',
+ $params,
+ $url_params,
+ 'CHECK_TABLE'
+ );
+ }
+ if ($is_innodb) {
+ $params = array(
+ 'sql_query' => 'ALTER TABLE '
+ . $common_functions->backquote($GLOBALS['table'])
+ . ' ENGINE = InnoDB;'
+ );
+ $html_output .= PMA_getMaintainActionlink(
+ 'Defragment table',
+ $params,
+ $url_params,
+ 'InnoDB_File_Defragmenting',
+ 'Table_types'
+ );
+ }
+ if ($is_myisam_or_aria || $is_berkeleydb) {
+ $params = array(
+ 'sql_query' => 'ANALYZE TABLE '
+ . $common_functions->backquote($GLOBALS['table']),
+ 'table_maintenance' => 'Go',
+ );
+ $html_output .= PMA_getMaintainActionlink(
+ 'Analyze table',
+ $params,
+ $url_params,
+ 'ANALYZE_TABLE'
+ );
+ }
+ if ($is_myisam_or_aria && !PMA_DRIZZLE) {
+ $params = array(
+ 'sql_query' => 'REPAIR TABLE '
+ . $common_functions->backquote($GLOBALS['table']),
+ 'table_maintenance' => 'Go',
+ );
+ $html_output .= PMA_getMaintainActionlink(
+ 'Repair table',
+ $params,
+ $url_params,
+ 'REPAIR_TABLE'
+ );
+ }
+ if (($is_myisam_or_aria || $is_innodb || $is_berkeleydb) && !PMA_DRIZZLE) {
+ $params = array(
+ 'sql_query' => 'OPTIMIZE TABLE '
+ . $common_functions->backquote($GLOBALS['table']),
+ 'table_maintenance' => 'Go',
+ );
+ $html_output .= PMA_getMaintainActionlink(
+ 'Optimize table',
+ $params,
+ $url_params,
+ 'OPTIMIZE_TABLE'
+ );
+ }
+ } // end MYISAM or BERKELEYDB case
+
+ $params = array(
+ 'sql_query' => 'FLUSH TABLE '
+ . $common_functions->backquote($GLOBALS['table']),
+ 'message_to_show' => sprintf(
+ __('Table %s has been flushed'),
+ htmlspecialchars($GLOBALS['table'])
+ ),
+ 'reload' => 1,
+ );
+
+ $html_output .= PMA_getMaintainActionlink(
+ 'Flush the table (FLUSH)',
+ $params,
+ $url_params,
+ 'FLUSH'
+ );
+
+ return $html_output;
+}
+
+/**
+ * Get maintain action HTML link
+ *
+ * @param array $params url parameters array
+ * @param string $link contains name of page/anchor that is being linked
+ * @param string $chapter chapter of "HTML, one page per chapter" documentation
+ *
+ * @return string $html_output
+ */
+function PMA_getMaintainActionlink($action, $params, $url_params, $link,
+ $chapter = 'MySQL_Database_Administration'
+) {
+ return ''
+ . ''
+ . __($action)
+ . ' '
+ . PMA_CommonFunctions::getInstance()->showMySQLDocu(
+ $chapter,
+ $link
+ )
+ . ' ';
+}
+
+/**
+ * Get HTML for Delete data or table (truncate table, drop table)
+ *
+ * @param array $truncate_table_url_params url parameter array for truncate table
+ * @param array $drop_table_url_params url parameter array for drop table
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForDeleteDataOrTable(
+ $truncate_table_url_params,
+ $drop_table_url_params
+) {
+ $html_output = ''
+ . '
'
+ . '' . __('Delete data or table') . ' ';
+
+ $html_output .= '';
+
+ if (!empty ($truncate_table_url_params)){
+ $html_output .= PMA_getDeleteDataOrTablelink(
+ $truncate_table_url_params,
+ 'TRUNCATE_TABLE',
+ __('Empty the table (TRUNCATE)'),
+ 'truncate_tbl_anchor'
+ );
+ }
+ if (!empty ($drop_table_url_params)) {
+ $html_output .= PMA_getDeleteDataOrTablelink(
+ $drop_table_url_params,
+ 'DROP_TABLE',
+ __('Delete the table (DROP)'),
+ 'drop_tbl_anchor'
+ );
+ }
+ $html_output .= ' ';
+
+ return $html_output;
+}
+
+/**
+ * Get the HTML link for Truncate table, Drop table and Drop db
+ *
+ * @param array $url_params url parameter array for delete data or table
+ * @param string $syntax TRUNCATE_TABLE or DROP_TABLE or DROP_DATABASE
+ * @param string $link link to be shown
+ *
+ * @return String html output
+ */
+function PMA_getDeleteDataOrTablelink($url_params, $syntax, $link, $id)
+{
+ return ''
+ . $link . ' '
+ . PMA_CommonFunctions::getInstance()->showMySQLDocu(
+ 'SQL-Syntax', $syntax
+ )
+ . ' ';
+}
+
+/**
+ * Get HTML snippet for partition maintenance
+ *
+ * @param array $partition_names array of partition names for a specific db/table
+ * @param array $url_params url parameters
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForPartitionMaintenance($partition_names, $url_params)
+{
+ $common_functions = PMA_CommonFunctions::getInstance();
+
+ $choices = array(
+ 'ANALYZE' => __('Analyze'),
+ 'CHECK' => __('Check'),
+ 'OPTIMIZE' => __('Optimize'),
+ 'REBUILD' => __('Rebuild'),
+ 'REPAIR' => __('Repair')
+ );
+
+ $html_output = '';
+
+ return $html_output;
+}
+
+/**
+ * Get the HTML for Referential Integrity check
+ *
+ * @param array $foreign all Relations to foreign tables for a given table
+ * or optionally a given column in a table
+ * @param array $url_params array of url parameters
+ *
+ * @return string $html_output
+ */
+function PMA_getHtmlForReferentialIntegrityCheck($foreign, $url_params)
+{
+ $common_functions = PMA_CommonFunctions::getInstance();
+
+ $html_output = ''
+ . '
'
+ . '' . __('Check referential integrity:') . ' ';
+
+ $html_output .= '' . '"\n"';
+
+ foreach ($foreign AS $master => $arr) {
+ $join_query = 'SELECT ' . $common_functions->backquote(
+ $GLOBALS['table']) . '.* FROM '
+ . $common_functions->backquote($GLOBALS['table']) . ' LEFT JOIN '
+ . $common_functions->backquote($arr['foreign_table']);
+ if ($arr['foreign_table'] == $GLOBALS['table']) {
+ $foreign_table = $GLOBALS['table'] . '1';
+ $join_query .= ' AS ' . $common_functions->backquote($foreign_table);
+ } else {
+ $foreign_table = $arr['foreign_table'];
+ }
+ $join_query .= ' ON '
+ . $common_functions->backquote($GLOBALS['table']) . '.'
+ . $common_functions->backquote($master)
+ . ' = ' . $common_functions->backquote($foreign_table) . '.'
+ . $common_functions->backquote($arr['foreign_field'])
+ . ' WHERE '
+ . $common_functions->backquote($foreign_table) . '.'
+ . $common_functions->backquote($arr['foreign_field'])
+ . ' IS NULL AND '
+ . $common_functions->backquote($GLOBALS['table']) . '.'
+ . $common_functions->backquote($master)
+ . ' IS NOT NULL';
+ $this_url_params = array_merge(
+ $url_params,
+ array('sql_query' => $join_query)
+ );
+
+ $html_output .= ''
+ . ''
+ . $master . ' -> ' . $arr['foreign_table'] . '.'
+ . $arr['foreign_field']
+ . ' ' . "\n";
+ } // foreach $foreign
+ $html_output .= ' ';
+
+ return $html_output;
+}
+
+function PMA_getQueryAndResultForReorderingTable()
+{
+ $common_functions = PMA_CommonFunctions::getInstance();
+
+ $sql_query = '
+ ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . '
+ ORDER BY ' . $common_functions->backquote(urldecode($_REQUEST['order_field']));
+ if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
+ $sql_query .= ' DESC';
+ }
+ $sql_query .= ';';
+ $result = PMA_DBI_query($sql_query);
+
+ return array($sql_query, $result);
+}
+
+
+?>
diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php
index 1649a8d149..278883b2d7 100644
--- a/libraries/server_privileges.lib.php
+++ b/libraries/server_privileges.lib.php
@@ -1732,7 +1732,7 @@ function PMA_getStandardLinks($conditional_class)
* @return array $extra_data
*/
function PMA_getExtraDataForAjaxBehavior($password, $link_export, $sql_query,
- $link_edit, $dbname_is_wildcard
+ $link_edit, $dbname_is_wildcard, $hostname, $username
) {
if (strlen($sql_query)) {
$extra_data['sql_query']
@@ -1745,16 +1745,16 @@ function PMA_getExtraDataForAjaxBehavior($password, $link_export, $sql_query,
*/
$new_user_string = ''."\n"
. ' '
+ . 'value="'
+ . htmlspecialchars($username)
+ . '' . htmlspecialchars($hostname) . '" />'
. ' ' . "\n"
. ''
. (empty($_REQUEST['username'])
? '' . __('Any') . ' '
- : htmlspecialchars($_REQUEST['username']) ) . ' ' . "\n"
- . '' . htmlspecialchars($_REQUEST['hostname']) . ' ' . "\n";
-
+ : htmlspecialchars($username) ) . '' . "\n"
+ . '' . htmlspecialchars($hostname) . ' ' . "\n";
+
$new_user_string .= '';
if (! empty($password) || isset($_POST['pma_pw'])) {
@@ -1781,15 +1781,15 @@ function PMA_getExtraDataForAjaxBehavior($password, $link_export, $sql_query,
$new_user_string .= ' '
. sprintf($link_edit,
- urlencode($_REQUEST['username']),
- urlencode($_REQUEST['hostname']),
+ urlencode($username),
+ urlencode($hostname),
'', ''
)
. ' ' . "\n";
$new_user_string .= ''
. sprintf($link_export,
- urlencode($_REQUEST['username']),
- urlencode($_REQUEST['hostname']),
+ urlencode($username),
+ urlencode($hostname),
(isset($_GET['initial']) ? $_GET['initial'] : '')
)
. ' ' . "\n";
@@ -1802,7 +1802,7 @@ function PMA_getExtraDataForAjaxBehavior($password, $link_export, $sql_query,
* Generate the string for this alphabet's initial, to update the user
* pagination
*/
- $new_user_initial = strtoupper(substr($_REQUEST['username'], 0, 1));
+ $new_user_initial = strtoupper(substr($username, 0, 1));
$new_user_initial_string = ''
. $new_user_initial . ' ';
diff --git a/libraries/tbl_views.lib.php b/libraries/tbl_views.lib.php
new file mode 100644
index 0000000000..4b94439e2e
--- /dev/null
+++ b/libraries/tbl_views.lib.php
@@ -0,0 +1,161 @@
+ 0) {
+
+ for ($i=0; $itable;
+ $map['refering_column'] = $real_source_fields_meta[$i]->name;
+
+ if (count($view_columns) > 1) {
+ $map['real_column'] = $view_columns[$i];
+ }
+
+ $column_map[] = $map;
+
+ }
+
+ }
+
+ }
+ unset($real_source_result);
+
+ return $column_map;
+
+}
+
+
+/**
+ * Get existing data on tranformations applyed for
+ * columns in a particular table
+ *
+ * @param string $db Database name looking for
+ *
+ * @return mysqli_result Result of executed SQL query
+ */
+function PMA_getExistingTranformationData($db)
+{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+ $cfgRelation = PMA_getRelationsParam();
+
+ // Get the existing transformation details of the same database
+ // from pma_column_info table
+ $pma_transformation_sql = 'SELECT * FROM '
+ . $common_functions->backquote($cfgRelation['db']) . '.'
+ . $common_functions->backquote($cfgRelation['column_info'])
+ . ' WHERE `db_name` = \''
+ . $common_functions->sqlAddSlashes($db) . '\'';
+
+ return PMA_DBI_try_query($pma_transformation_sql);
+
+}
+
+
+/**
+ * Get SQL query for store new transformation details of a VIEW
+ *
+ * @param mysqli_result $pma_tranformation_data Result set of SQL execution
+ * @param array $column_map Details of VIEW columns
+ * @param string $view_name Name of the VIEW
+ * @param string $db Database name of the VIEW
+ *
+ * @return string $new_transformations_sql SQL query for new tranformations
+ */
+function PMA_getNewTransformationDataSql(
+ $pma_tranformation_data, $column_map, $view_name, $db
+) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+ $cfgRelation = PMA_getRelationsParam();
+
+ // Need to store new transformation details for VIEW
+ $new_transformations_sql = 'INSERT INTO '
+ . $common_functions->backquote($cfgRelation['db']) . '.'
+ . $common_functions->backquote($cfgRelation['column_info'])
+ . ' (`db_name`, `table_name`, `column_name`, `comment`, '
+ . '`mimetype`, `transformation`, `transformation_options`)'
+ . ' VALUES ';
+
+ $column_count = 0;
+ $add_comma = false;
+
+ while ($data_row = PMA_DBI_fetch_assoc($pma_tranformation_data)) {
+
+ foreach ($column_map as $column) {
+
+ if ($data_row['table_name'] == $column['table_name']
+ && $data_row['column_name'] == $column['refering_column']
+ ) {
+
+ $new_transformations_sql .= $add_comma ? ', ' : '';
+
+ $new_transformations_sql .= '('
+ . '\'' . $db . '\', '
+ . '\'' . $view_name . '\', '
+ . '\'';
+
+ $new_transformations_sql .= (isset($column['real_column']))
+ ? $column['real_column']
+ : $column['refering_column'];
+
+ $new_transformations_sql .= '\', '
+ . '\'' . $data_row['comment'] . '\', '
+ . '\'' . $data_row['mimetype'] . '\', '
+ . '\'' . $data_row['transformation'] . '\', '
+ . '\''
+ . $common_functions->sqlAddSlashes(
+ $data_row['transformation_options']
+ )
+ . '\')';
+
+ $add_comma = true;
+ $column_count++;
+ break;
+
+ }
+
+ }
+
+ if ($column_count == count($column_map)) {
+ break;
+ }
+
+ }
+
+ return ($column_count > 0) ? $new_transformations_sql : '';
+
+}
+
+
+?>
diff --git a/libraries/transformations.lib.php b/libraries/transformations.lib.php
index a653570d93..561406e0eb 100644
--- a/libraries/transformations.lib.php
+++ b/libraries/transformations.lib.php
@@ -365,4 +365,46 @@ function PMA_transformation_global_html_replace($buffer, $options = array())
$return = str_replace("[__BUFFER__]", $buffer, $options['string']);
return $return;
}
+
+
+/**
+ * Delete related transformation details
+ * after deleting database. table or column
+ *
+ * @param string $db Database name
+ * @param string $table Table name
+ * @param string $column Column name
+ *
+ * @return boolean State of the query execution
+ */
+function PMA_clearTransformations($db, $table = '', $column = '')
+{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+ $cfgRelation = PMA_getRelationsParam();
+
+ $delete_sql = 'DELETE FROM '
+ . $common_functions->backquote($cfgRelation['db']) . '.'
+ . $common_functions->backquote($cfgRelation['column_info'])
+ . ' WHERE ';
+
+ if (($column != '') && ($table != '')) {
+
+ $delete_sql .= '`db_name` = \'' . $db . '\' AND '
+ . '`table_name` = \'' . $table . '\' AND '
+ . '`column_name` = \'' . $column . '\' ';
+
+ } else if ($table != '') {
+
+ $delete_sql .= '`db_name` = \'' . $db . '\' AND '
+ . '`table_name` = \'' . $table . '\' ';
+
+ } else {
+ $delete_sql .= '`db_name` = \'' . $db . '\' ';
+ }
+
+ return PMA_DBI_try_query($delete_sql);
+
+}
+
?>
diff --git a/pmd_general.php b/pmd_general.php
index 2feeb249ac..690107e50a 100644
--- a/pmd_general.php
+++ b/pmd_general.php
@@ -48,27 +48,27 @@ $scripts->addFile('pmd/ajax.js');
$scripts->addFile('pmd/history.js');
$scripts->addFile('pmd/move.js');
$scripts->addFile('pmd/iecanvas.js', true);
-$scripts->addCode('
- var server = "' . PMA_escapeJsString($server) . '";
+$scripts->addCode(
+ 'var server = "' . PMA_escapeJsString($server) . '";
var db = "' . PMA_escapeJsString($db) . '";
- var token = "' . PMA_escapeJsString($token) . '";
-');
+ var token = "' . PMA_escapeJsString($token) . '";'
+);
if (isset($_REQUEST['query'])) {
- $scripts->addCode('
- $(function() {
- $(".trigger").click(function() {
- $(".panel").toggle("fast");
- $(this).toggleClass("active");
- return false;
- });
- });
- ');
+ $scripts->addCode(
+ '$(function() {
+ $(".trigger").click(function() {
+ $(".panel").toggle("fast");
+ $(this).toggleClass("active");
+ return false;
+ });
+ });'
+ );
}
-$scripts->addCode('
- $(function() {
+$scripts->addCode(
+ '$(function() {
Main();
- });
-');
+ });'
+);
$scripts->addCode($script_tabs);
$scripts->addCode($script_contr);
$scripts->addCode($script_display_field);
@@ -78,55 +78,66 @@ require 'libraries/db_info.inc.php';
?>