1<?php 2/* vim: set expandtab sw=4 ts=4 sts=4: */ 3/** 4 * handle row specific actions like edit, delete, export 5 * 6 * @package PhpMyAdmin 7 */ 8 9use PhpMyAdmin\Response; 10use PhpMyAdmin\Sql; 11use PhpMyAdmin\Url; 12 13/** 14 * 15 */ 16require_once 'libraries/common.inc.php'; 17 18if (isset($_POST['submit_mult'])) { 19 $submit_mult = $_POST['submit_mult']; 20 // workaround for IE problem: 21} elseif (isset($_POST['submit_mult_delete_x'])) { 22 $submit_mult = 'row_delete'; 23} elseif (isset($_POST['submit_mult_change_x'])) { 24 $submit_mult = 'row_edit'; 25} elseif (isset($_POST['submit_mult_export_x'])) { 26 $submit_mult = 'row_export'; 27} 28 29// If the 'Ask for confirmation' button was pressed, this can only come 30// from 'delete' mode, so we set it straight away. 31if (isset($_POST['mult_btn'])) { 32 $submit_mult = 'row_delete'; 33} 34 35if (! isset($submit_mult)) { 36 $submit_mult = 'row_edit'; 37} 38 39switch($submit_mult) { 40case 'row_delete': 41case 'row_edit': 42case 'row_copy': 43case 'row_export': 44 // leave as is 45 break; 46 47case 'export': 48 $submit_mult = 'row_export'; 49 break; 50 51case 'delete': 52 $submit_mult = 'row_delete'; 53 break; 54 55case 'copy': 56 $submit_mult = 'row_copy'; 57 break; 58 59case 'edit': 60default: 61 $submit_mult = 'row_edit'; 62 break; 63} 64 65if (!empty($submit_mult)) { 66 67 if (isset($_POST['goto']) 68 && (! isset($_POST['rows_to_delete']) 69 || ! is_array($_POST['rows_to_delete'])) 70 ) { 71 $response = Response::getInstance(); 72 $response->setRequestStatus(false); 73 $response->addJSON('message', __('No row selected.')); 74 } 75 76 switch($submit_mult) { 77 /** @noinspection PhpMissingBreakStatementInspection */ 78 case 'row_copy': 79 $_POST['default_action'] = 'insert'; 80 // no break to allow for fallthough 81 case 'row_edit': 82 // As we got the rows to be edited from the 83 // 'rows_to_delete' checkbox, we use the index of it as the 84 // indicating WHERE clause. Then we build the array which is used 85 // for the tbl_change.php script. 86 $where_clause = array(); 87 if (isset($_POST['rows_to_delete']) 88 && is_array($_POST['rows_to_delete']) 89 ) { 90 foreach ($_POST['rows_to_delete'] as $i => $i_where_clause) { 91 $where_clause[] = $i_where_clause; 92 } 93 } 94 $active_page = 'tbl_change.php'; 95 include 'tbl_change.php'; 96 break; 97 98 case 'row_export': 99 // Needed to allow SQL export 100 $single_table = true; 101 102 // As we got the rows to be exported from the 103 // 'rows_to_delete' checkbox, we use the index of it as the 104 // indicating WHERE clause. Then we build the array which is used 105 // for the tbl_change.php script. 106 $where_clause = array(); 107 if (isset($_POST['rows_to_delete']) 108 && is_array($_POST['rows_to_delete']) 109 ) { 110 foreach ($_POST['rows_to_delete'] as $i => $i_where_clause) { 111 $where_clause[] = $i_where_clause; 112 } 113 } 114 $active_page = 'tbl_export.php'; 115 include 'tbl_export.php'; 116 break; 117 118 case 'row_delete': 119 default: 120 $action = 'tbl_row_action.php'; 121 $err_url = 'tbl_row_action.php' 122 . Url::getCommon($GLOBALS['url_params']); 123 if (! isset($_POST['mult_btn'])) { 124 $original_sql_query = $sql_query; 125 if (! empty($url_query)) { 126 $original_url_query = $url_query; 127 } 128 } 129 include 'libraries/mult_submits.inc.php'; 130 $_url_params = $GLOBALS['url_params']; 131 $_url_params['goto'] = 'tbl_sql.php'; 132 $url_query = Url::getCommon($_url_params); 133 134 135 /** 136 * Show result of multi submit operation 137 */ 138 // sql_query is not set when user does not confirm multi-delete 139 if ((! empty($submit_mult) || isset($_POST['mult_btn'])) 140 && ! empty($sql_query) 141 ) { 142 $disp_message = __('Your SQL query has been executed successfully.'); 143 $disp_query = $sql_query; 144 } 145 146 if (isset($original_sql_query)) { 147 $sql_query = $original_sql_query; 148 } 149 150 if (isset($original_url_query)) { 151 $url_query = $original_url_query; 152 } 153 154 $active_page = 'sql.php'; 155 $sql = new Sql(); 156 $sql->executeQueryAndSendQueryResponse( 157 null, // analyzed_sql_results 158 false, // is_gotofile 159 $db, // db 160 $table, // table 161 null, // find_real_end 162 null, // sql_query_for_bookmark 163 null, // extra_data 164 null, // message_to_show 165 null, // message 166 null, // sql_data 167 $goto, // goto 168 $pmaThemeImage, // pmaThemeImage 169 null, // disp_query 170 null, // disp_message 171 null, // query_type 172 $sql_query, // sql_query 173 null, // selectedTables 174 null // complete_query 175 ); 176 } 177} 178