PageRenderTime 59ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/phpMyAdmin/tbl_replace.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip
PHP | 609 lines | 426 code | 72 blank | 111 comment | 112 complexity | 554cd8b94487af0fded5e2faa851e5fd MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.0, JSON, GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * manipulation of table data like inserting, replacing and updating
  5. *
  6. * usally called as form action from tbl_change.php to insert or update table rows
  7. *
  8. *
  9. * @todo 'edit_next' tends to not work as expected if used ... at least there is no order by
  10. * it needs the original query and the row number and than replace the LIMIT clause
  11. * @package PhpMyAdmin
  12. */
  13. /**
  14. * do not import request variable into global scope
  15. *
  16. * cannot be used as long as it could happen that the $goto file that is included
  17. * at the end of this script is not updated to work without imported request variables
  18. *
  19. * @todo uncomment this if all possible included files to rely on import request variables
  20. if (! defined('PMA_NO_VARIABLES_IMPORT')) {
  21. define('PMA_NO_VARIABLES_IMPORT', true);
  22. }
  23. */
  24. /**
  25. * Gets some core libraries
  26. */
  27. require_once './libraries/common.inc.php';
  28. $blob_streaming_active = $GLOBALS['PMA_Config']->get('BLOBSTREAMING_PLUGINS_EXIST');
  29. // Check parameters
  30. PMA_checkParameters(array('db', 'table', 'goto'));
  31. PMA_DBI_select_db($GLOBALS['db']);
  32. /**
  33. * Initializes some variables
  34. */
  35. $goto_include = false;
  36. $GLOBALS['js_include'][] = 'makegrid.js';
  37. // Needed for generation of Inline Edit anchors
  38. $GLOBALS['js_include'][] = 'sql.js';
  39. if (isset($_REQUEST['insert_rows']) && is_numeric($_REQUEST['insert_rows']) && $_REQUEST['insert_rows'] != $cfg['InsertRows']) {
  40. $cfg['InsertRows'] = $_REQUEST['insert_rows'];
  41. $GLOBALS['js_include'][] = 'tbl_change.js';
  42. include_once './libraries/header.inc.php';
  43. include './tbl_change.php';
  44. exit;
  45. }
  46. if (isset($_REQUEST['after_insert'])
  47. && in_array($_REQUEST['after_insert'], array('new_insert', 'same_insert', 'edit_next'))) {
  48. $url_params['after_insert'] = $_REQUEST['after_insert'];
  49. //$GLOBALS['goto'] = 'tbl_change.php';
  50. $goto_include = 'tbl_change.php';
  51. if (isset($_REQUEST['where_clause'])) {
  52. if ($_REQUEST['after_insert'] == 'same_insert') {
  53. foreach ($_REQUEST['where_clause'] as $one_where_clause) {
  54. $url_params['where_clause'][] = $one_where_clause;
  55. }
  56. } elseif ($_REQUEST['after_insert'] == 'edit_next') {
  57. foreach ($_REQUEST['where_clause'] as $one_where_clause) {
  58. $local_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($GLOBALS['table'])
  59. . ' WHERE ' . str_replace('` =', '` >', $one_where_clause)
  60. . ' LIMIT 1;';
  61. $res = PMA_DBI_query($local_query);
  62. $row = PMA_DBI_fetch_row($res);
  63. $meta = PMA_DBI_get_fields_meta($res);
  64. // must find a unique condition based on unique key,
  65. // not a combination of all fields
  66. list($unique_condition, $clause_is_unique) = PMA_getUniqueCondition($res, count($meta), $meta, $row, true);
  67. if (! empty($unique_condition)) {
  68. $_SESSION['edit_next'] = $unique_condition;
  69. }
  70. unset($unique_condition, $clause_is_unique);
  71. }
  72. }
  73. }
  74. } elseif (! empty($GLOBALS['goto'])) {
  75. if (! preg_match('@^[a-z_]+\.php$@', $GLOBALS['goto'])) {
  76. // this should NOT happen
  77. //$GLOBALS['goto'] = false;
  78. $goto_include = false;
  79. } else {
  80. $goto_include = $GLOBALS['goto'];
  81. }
  82. if ($GLOBALS['goto'] == 'db_sql.php' && strlen($GLOBALS['table'])) {
  83. $GLOBALS['table'] = '';
  84. }
  85. }
  86. if (! $goto_include) {
  87. if (! strlen($GLOBALS['table'])) {
  88. $goto_include = 'db_sql.php';
  89. } else {
  90. $goto_include = 'tbl_sql.php';
  91. }
  92. }
  93. // Defines the url to return in case of failure of the query
  94. if (isset($_REQUEST['err_url'])) {
  95. $err_url = $_REQUEST['err_url'];
  96. } else {
  97. $err_url = 'tbl_change.php' . PMA_generate_common_url($url_params);
  98. }
  99. /**
  100. * Prepares the update/insert of a row
  101. */
  102. if (isset($_REQUEST['where_clause'])) {
  103. // we were editing something => use the WHERE clause
  104. $loop_array = (is_array($_REQUEST['where_clause']) ? $_REQUEST['where_clause'] : array($_REQUEST['where_clause']));
  105. $using_key = true;
  106. $is_insert = ($_REQUEST['submit_type'] == 'insert') || ($_REQUEST['submit_type'] == 'showinsert') || ($_REQUEST['submit_type'] == 'insertignore');
  107. $is_insertignore = ($_REQUEST['submit_type'] == 'insertignore');
  108. } else {
  109. // new row => use indexes
  110. $loop_array = array();
  111. foreach ($_REQUEST['fields']['multi_edit'] as $key => $dummy) {
  112. $loop_array[] = $key;
  113. }
  114. $using_key = false;
  115. $is_insert = true;
  116. $is_insertignore = false;
  117. }
  118. $query = array();
  119. $value_sets = array();
  120. $func_no_param = array(
  121. 'CONNECTION_ID',
  122. 'CURRENT_USER',
  123. 'CURDATE',
  124. 'CURTIME',
  125. 'CURRENT_DATE',
  126. 'CURRENT_TIME',
  127. 'DATABASE',
  128. 'LAST_INSERT_ID',
  129. 'NOW',
  130. 'PI',
  131. 'RAND',
  132. 'SYSDATE',
  133. 'UNIX_TIMESTAMP',
  134. 'USER',
  135. 'UTC_DATE',
  136. 'UTC_TIME',
  137. 'UTC_TIMESTAMP',
  138. 'UUID',
  139. 'VERSION',
  140. );
  141. $func_optional_param = array(
  142. 'RAND',
  143. 'UNIX_TIMESTAMP',
  144. );
  145. $gis_from_text_functions = array(
  146. 'GeomFromText',
  147. 'GeomCollFromText',
  148. 'LineFromText',
  149. 'MLineFromText',
  150. 'PointFromText',
  151. 'MPointFromText',
  152. 'PolyFromText',
  153. 'MPolyFromText',
  154. );
  155. $gis_from_wkb_functions = array(
  156. 'GeomFromWKB',
  157. 'GeomCollFromWKB',
  158. 'LineFromWKB',
  159. 'MLineFromWKB',
  160. 'PointFromWKB',
  161. 'MPointFromWKB',
  162. 'PolyFromWKB',
  163. 'MPolyFromWKB',
  164. );
  165. foreach ($loop_array as $rownumber => $where_clause) {
  166. // skip fields to be ignored
  167. if (! $using_key && isset($_REQUEST['insert_ignore_' . $where_clause])) {
  168. continue;
  169. }
  170. // Defines the SET part of the sql query
  171. $query_values = array();
  172. // Map multi-edit keys to single-level arrays, dependent on how we got the fields
  173. $me_fields
  174. = isset($_REQUEST['fields']['multi_edit'][$rownumber])
  175. ? $_REQUEST['fields']['multi_edit'][$rownumber]
  176. : array();
  177. $me_fields_name
  178. = isset($_REQUEST['fields_name']['multi_edit'][$rownumber])
  179. ? $_REQUEST['fields_name']['multi_edit'][$rownumber]
  180. : null;
  181. $me_fields_prev
  182. = isset($_REQUEST['fields_prev']['multi_edit'][$rownumber])
  183. ? $_REQUEST['fields_prev']['multi_edit'][$rownumber]
  184. : null;
  185. $me_funcs
  186. = isset($_REQUEST['funcs']['multi_edit'][$rownumber])
  187. ? $_REQUEST['funcs']['multi_edit'][$rownumber]
  188. : null;
  189. $me_fields_type
  190. = isset($_REQUEST['fields_type']['multi_edit'][$rownumber])
  191. ? $_REQUEST['fields_type']['multi_edit'][$rownumber]
  192. : null;
  193. $me_fields_null
  194. = isset($_REQUEST['fields_null']['multi_edit'][$rownumber])
  195. ? $_REQUEST['fields_null']['multi_edit'][$rownumber]
  196. : null;
  197. $me_fields_null_prev
  198. = isset($_REQUEST['fields_null_prev']['multi_edit'][$rownumber])
  199. ? $_REQUEST['fields_null_prev']['multi_edit'][$rownumber]
  200. : null;
  201. $me_auto_increment
  202. = isset($_REQUEST['auto_increment']['multi_edit'][$rownumber])
  203. ? $_REQUEST['auto_increment']['multi_edit'][$rownumber]
  204. : null;
  205. // Fetch the current values of a row to use in case we have a protected field
  206. // @todo possibly move to ./libraries/tbl_replace_fields.inc.php
  207. if ($is_insert && $using_key && isset($me_fields_type) && is_array($me_fields_type) && isset($where_clause)) {
  208. $prot_row = PMA_DBI_fetch_single_row('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';');
  209. }
  210. // When a select field is nullified, it's not present in $_REQUEST
  211. // so initialize it; this way, the foreach($me_fields) will process it
  212. foreach ($me_fields_name as $key => $val) {
  213. if (! isset($me_fields[$key])) {
  214. $me_fields[$key] = '';
  215. }
  216. }
  217. // Iterate in the order of $me_fields_name, not $me_fields, to avoid problems
  218. // when inserting multiple entries
  219. foreach ($me_fields_name as $key => $field_name) {
  220. $val = $me_fields[$key];
  221. // Note: $key is an md5 of the fieldname. The actual fieldname is available in $me_fields_name[$key]
  222. include './libraries/tbl_replace_fields.inc.php';
  223. // for blobstreaming
  224. if ($blob_streaming_active) {
  225. $remove_blob_repo = isset($_REQUEST['remove_blob_repo_' . $key]) ? $_REQUEST['remove_blob_repo_' . $key] : null;
  226. $upload_blob_repo = isset($_REQUEST['upload_blob_repo_' . $key]) ? $_REQUEST['upload_blob_repo_' . $key] : null;
  227. // checks if an existing blob repository reference should be removed
  228. if (isset($remove_blob_repo) && ! isset($upload_blob_repo)) {
  229. $remove_blob_reference = $_REQUEST['remove_blob_ref_' . $key];
  230. if (isset($remove_blob_reference)) {
  231. $val = "NULL";
  232. }
  233. }
  234. // checks if this field requires a bs reference attached to it
  235. if (isset($upload_blob_repo)) {
  236. // get the most recent BLOB reference
  237. $bs_reference = PMA_File::getRecentBLOBReference();
  238. // if the most recent BLOB reference exists, set it as a field value
  239. if (!is_null($bs_reference)) {
  240. $val = "'" . PMA_sqlAddSlashes($bs_reference) . "'";
  241. }
  242. }
  243. }
  244. if (empty($me_funcs[$key])) {
  245. $cur_value = $val;
  246. } elseif ('UUID' === $me_funcs[$key]) {
  247. /* This way user will know what UUID new row has */
  248. $uuid = PMA_DBI_fetch_value('SELECT UUID()');
  249. $cur_value = "'" . $uuid . "'";
  250. } elseif ((in_array($me_funcs[$key], $gis_from_text_functions)
  251. && substr($val, 0, 3) == "'''")
  252. || in_array($me_funcs[$key], $gis_from_wkb_functions)
  253. ) {
  254. // Remove enclosing apostrophes
  255. $val = substr($val, 1, strlen($val) - 2);
  256. // Remove escaping apostrophes
  257. $val = str_replace("''", "'", $val);
  258. $cur_value = $me_funcs[$key] . '(' . $val . ')';
  259. } elseif (! in_array($me_funcs[$key], $func_no_param)
  260. || ($val != "''" && in_array($me_funcs[$key], $func_optional_param))) {
  261. $cur_value = $me_funcs[$key] . '(' . $val . ')';
  262. } else {
  263. $cur_value = $me_funcs[$key] . '()';
  264. }
  265. // i n s e r t
  266. if ($is_insert) {
  267. // no need to add column into the valuelist
  268. if (strlen($cur_value)) {
  269. $query_values[] = $cur_value;
  270. // first inserted row so prepare the list of fields
  271. if (empty($value_sets)) {
  272. $query_fields[] = PMA_backquote($me_fields_name[$key]);
  273. }
  274. }
  275. // u p d a t e
  276. } elseif (!empty($me_fields_null_prev[$key])
  277. && ! isset($me_fields_null[$key])) {
  278. // field had the null checkbox before the update
  279. // field no longer has the null checkbox
  280. $query_values[] = PMA_backquote($me_fields_name[$key]) . ' = ' . $cur_value;
  281. } elseif (empty($me_funcs[$key])
  282. && isset($me_fields_prev[$key])
  283. && ("'" . PMA_sqlAddSlashes($me_fields_prev[$key]) . "'" == $val)) {
  284. // No change for this column and no MySQL function is used -> next column
  285. continue;
  286. } elseif (! empty($val)) {
  287. // avoid setting a field to NULL when it's already NULL
  288. // (field had the null checkbox before the update
  289. // field still has the null checkbox)
  290. if (empty($me_fields_null_prev[$key])
  291. || empty($me_fields_null[$key])) {
  292. $query_values[] = PMA_backquote($me_fields_name[$key]) . ' = ' . $cur_value;
  293. }
  294. }
  295. } // end foreach ($me_fields as $key => $val)
  296. if (count($query_values) > 0) {
  297. if ($is_insert) {
  298. $value_sets[] = implode(', ', $query_values);
  299. } else {
  300. // build update query
  301. $query[] = 'UPDATE ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($GLOBALS['table'])
  302. . ' SET ' . implode(', ', $query_values) . ' WHERE ' . $where_clause . ($_REQUEST['clause_is_unique'] ? '' : ' LIMIT 1');
  303. }
  304. }
  305. } // end foreach ($loop_array as $where_clause)
  306. unset($me_fields_name, $me_fields_prev, $me_funcs, $me_fields_type, $me_fields_null, $me_fields_null_prev,
  307. $me_auto_increment, $cur_value, $key, $val, $loop_array, $where_clause, $using_key,
  308. $func_no_param);
  309. // Builds the sql query
  310. if ($is_insert && count($value_sets) > 0) {
  311. if ($is_insertignore) {
  312. $insert_command = 'INSERT IGNORE ';
  313. } else {
  314. $insert_command = 'INSERT ';
  315. }
  316. $query[] = $insert_command . 'INTO ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($GLOBALS['table'])
  317. . ' (' . implode(', ', $query_fields) . ') VALUES (' . implode('), (', $value_sets) . ')';
  318. unset($insert_command);
  319. unset($query_fields);
  320. } elseif (empty($query)) {
  321. // No change -> move back to the calling script
  322. //
  323. // Note: logic passes here for inline edit
  324. $message = PMA_Message::success(__('No change'));
  325. $active_page = $goto_include;
  326. if (! $GLOBALS['is_ajax_request'] == true) {
  327. include_once './libraries/header.inc.php';
  328. }
  329. include './' . PMA_securePath($goto_include);
  330. exit;
  331. }
  332. unset($me_fields, $is_insertignore);
  333. /**
  334. * Executes the sql query and get the result, then move back to the calling
  335. * page
  336. */
  337. if (! empty($GLOBALS['sql_query'])) {
  338. $url_params['sql_query'] = $GLOBALS['sql_query'];
  339. $return_to_sql_query = $GLOBALS['sql_query'];
  340. }
  341. $GLOBALS['sql_query'] = implode('; ', $query) . ';';
  342. // to ensure that the query is displayed in case of
  343. // "insert as new row" and then "insert another new row"
  344. $GLOBALS['display_query'] = $GLOBALS['sql_query'];
  345. $total_affected_rows = 0;
  346. $last_messages = array();
  347. $warning_messages = array();
  348. $error_messages = array();
  349. foreach ($query as $single_query) {
  350. if ($_REQUEST['submit_type'] == 'showinsert') {
  351. $last_messages[] = PMA_Message::notice(__('Showing SQL query'));
  352. continue;
  353. }
  354. if ($GLOBALS['cfg']['IgnoreMultiSubmitErrors']) {
  355. $result = PMA_DBI_try_query($single_query);
  356. } else {
  357. $result = PMA_DBI_query($single_query);
  358. }
  359. if (! $result) {
  360. $error_messages[] = PMA_Message::sanitize(PMA_DBI_getError());
  361. } else {
  362. // The next line contains a real assignment, it's not a typo
  363. if ($tmp = @PMA_DBI_affected_rows()) {
  364. $total_affected_rows += $tmp;
  365. }
  366. unset($tmp);
  367. $insert_id = PMA_DBI_insert_id();
  368. if ($insert_id != 0) {
  369. // insert_id is id of FIRST record inserted in one insert, so if we
  370. // inserted multiple rows, we had to increment this
  371. if ($total_affected_rows > 0) {
  372. $insert_id = $insert_id + $total_affected_rows - 1;
  373. }
  374. $last_message = PMA_Message::notice(__('Inserted row id: %1$d'));
  375. $last_message->addParam($insert_id);
  376. $last_messages[] = $last_message;
  377. }
  378. PMA_DBI_free_result($result);
  379. } // end if
  380. foreach (PMA_DBI_get_warnings() as $warning) {
  381. $warning_messages[]
  382. = PMA_Message::sanitize(
  383. $warning['Level'] . ': #' . $warning['Code'] . ' ' . $warning['Message']
  384. );
  385. }
  386. unset($result);
  387. }
  388. unset($single_query, $query);
  389. if ($is_insert && count($value_sets) > 0) {
  390. $message = PMA_Message::inserted_rows($total_affected_rows);
  391. } else {
  392. $message = PMA_Message::affected_rows($total_affected_rows);
  393. }
  394. $message->addMessages($last_messages, '<br />');
  395. if (! empty($warning_messages)) {
  396. $message->addMessages($warning_messages, '<br />');
  397. $message->isError(true);
  398. }
  399. if (! empty($error_messages)) {
  400. $message->addMessages($error_messages);
  401. $message->isError(true);
  402. }
  403. unset($error_messages, $warning_messages, $total_affected_rows, $last_messages, $last_message);
  404. if ($GLOBALS['is_ajax_request'] == true) {
  405. /**
  406. * If we are in grid editing, we need to process the relational and
  407. * transformed fields, if they were edited. After that, output the correct
  408. * link/transformed value and exit
  409. *
  410. * Logic taken from libraries/display_tbl.lib.php
  411. */
  412. if (isset($_REQUEST['rel_fields_list']) && $_REQUEST['rel_fields_list'] != '') {
  413. //handle relations work here for updated row.
  414. include_once './libraries/relation.lib.php';
  415. $map = PMA_getForeigners($db, $table, '', 'both');
  416. $rel_fields = array();
  417. parse_str($_REQUEST['rel_fields_list'], $rel_fields);
  418. // loop for each relation cell
  419. foreach ( $rel_fields as $cell_index => $curr_cell_rel_field) {
  420. foreach ( $curr_cell_rel_field as $rel_field => $rel_field_value) {
  421. $where_comparison = "='" . $rel_field_value . "'";
  422. $display_field = PMA_getDisplayField($map[$rel_field]['foreign_db'], $map[$rel_field]['foreign_table']);
  423. // Field to display from the foreign table?
  424. if (isset($display_field) && strlen($display_field)) {
  425. $dispsql = 'SELECT ' . PMA_backquote($display_field)
  426. . ' FROM ' . PMA_backquote($map[$rel_field]['foreign_db'])
  427. . '.' . PMA_backquote($map[$rel_field]['foreign_table'])
  428. . ' WHERE ' . PMA_backquote($map[$rel_field]['foreign_field'])
  429. . $where_comparison;
  430. $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
  431. if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
  432. list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
  433. } else {
  434. //$dispval = __('Link not found');
  435. }
  436. @PMA_DBI_free_result($dispresult);
  437. } else {
  438. $dispval = '';
  439. } // end if... else...
  440. if ('K' == $_SESSION['tmp_user_values']['relational_display']) {
  441. // user chose "relational key" in the display options, so
  442. // the title contains the display field
  443. $title = (! empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
  444. } else {
  445. $title = ' title="' . htmlspecialchars($rel_field_value) . '"';
  446. }
  447. $_url_params = array(
  448. 'db' => $map[$rel_field]['foreign_db'],
  449. 'table' => $map[$rel_field]['foreign_table'],
  450. 'pos' => '0',
  451. 'sql_query' => 'SELECT * FROM '
  452. . PMA_backquote($map[$rel_field]['foreign_db']) . '.' . PMA_backquote($map[$rel_field]['foreign_table'])
  453. . ' WHERE ' . PMA_backquote($map[$rel_field]['foreign_field'])
  454. . $where_comparison
  455. );
  456. $output = '<a href="sql.php' . PMA_generate_common_url($_url_params) . '"' . $title . '>';
  457. if ('D' == $_SESSION['tmp_user_values']['relational_display']) {
  458. // user chose "relational display field" in the
  459. // display options, so show display field in the cell
  460. $output .= (!empty($dispval)) ? htmlspecialchars($dispval) : '';
  461. } else {
  462. // otherwise display data in the cell
  463. $output .= htmlspecialchars($rel_field_value);
  464. }
  465. $output .= '</a>';
  466. $extra_data['relations'][$cell_index] = $output;
  467. }
  468. } // end of loop for each relation cell
  469. }
  470. if (isset($_REQUEST['do_transformations']) && $_REQUEST['do_transformations'] == true ) {
  471. include_once './libraries/transformations.lib.php';
  472. //if some posted fields need to be transformed, generate them here.
  473. $mime_map = PMA_getMIME($db, $table);
  474. if ($mime_map === false) {
  475. $mime_map = array();
  476. }
  477. $edited_values = array();
  478. parse_str($_REQUEST['transform_fields_list'], $edited_values);
  479. foreach ($mime_map as $transformation) {
  480. $include_file = PMA_securePath($transformation['transformation']);
  481. $column_name = $transformation['column_name'];
  482. foreach ($edited_values as $cell_index => $curr_cell_edited_values) {
  483. if (isset($curr_cell_edited_values[$column_name])) {
  484. $column_data = $curr_cell_edited_values[$column_name];
  485. $_url_params = array(
  486. 'db' => $db,
  487. 'table' => $table,
  488. 'where_clause' => $_REQUEST['where_clause'],
  489. 'transform_key' => $column_name,
  490. );
  491. if (file_exists('./libraries/transformations/' . $include_file)) {
  492. $transformfunction_name = str_replace('.inc.php', '', $transformation['transformation']);
  493. include_once './libraries/transformations/' . $include_file;
  494. if (function_exists('PMA_transformation_' . $transformfunction_name)) {
  495. $transform_function = 'PMA_transformation_' . $transformfunction_name;
  496. $transform_options = PMA_transformation_getOptions((isset($transformation['transformation_options']) ? $transformation['transformation_options'] : ''));
  497. $transform_options['wrapper_link'] = PMA_generate_common_url($_url_params);
  498. }
  499. }
  500. $extra_data['transformations'][$cell_index] = $transform_function($column_data, $transform_options);
  501. }
  502. } // end of loop for each transformation cell
  503. } // end of loop for each $mime_map
  504. }
  505. /**Get the total row count of the table*/
  506. $extra_data['row_count'] = PMA_Table::countRecords($_REQUEST['db'], $_REQUEST['table']);
  507. $extra_data['sql_query'] = PMA_showMessage($message, $GLOBALS['display_query']);
  508. PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
  509. }
  510. if (isset($return_to_sql_query)) {
  511. $disp_query = $GLOBALS['sql_query'];
  512. $disp_message = $message;
  513. unset($message);
  514. $GLOBALS['sql_query'] = $return_to_sql_query;
  515. }
  516. $GLOBALS['js_include'][] = 'tbl_change.js';
  517. // in case we call sql.php which needs those:
  518. $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.16.custom.js';
  519. $active_page = $goto_include;
  520. /**
  521. * If user asked for "and then Insert another new row" we have to remove
  522. * WHERE clause information so that tbl_change.php does not go back
  523. * to the current record
  524. */
  525. if (isset($_REQUEST['after_insert']) && 'new_insert' == $_REQUEST['after_insert']) {
  526. unset($_REQUEST['where_clause']);
  527. }
  528. /**
  529. * Load header.
  530. */
  531. require_once './libraries/header.inc.php';
  532. /**
  533. * Load target page.
  534. */
  535. require './' . PMA_securePath($goto_include);
  536. exit;
  537. ?>