PageRenderTime 56ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/phpMyAdmin/tbl_change.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip
PHP | 1118 lines | 859 code | 83 blank | 176 comment | 194 complexity | e6804db1858ba0e7b6825c226563e066 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.0, JSON, GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Displays form for editing and inserting new table rows
  5. *
  6. * register_globals_save (mark this file save for disabling register globals)
  7. *
  8. * @package PhpMyAdmin
  9. */
  10. /**
  11. * Gets the variables sent or posted to this script and displays the header
  12. */
  13. require_once './libraries/common.inc.php';
  14. require_once './libraries/common.lib.php';
  15. /**
  16. * Ensures db and table are valid, else moves to the "parent" script
  17. */
  18. require_once './libraries/db_table_exists.lib.php';
  19. // load additional configuration variables
  20. if (PMA_DRIZZLE) {
  21. include_once './libraries/data_drizzle.inc.php';
  22. } else {
  23. include_once './libraries/data_mysql.inc.php';
  24. }
  25. /**
  26. * Sets global variables.
  27. * Here it's better to use a if, instead of the '?' operator
  28. * to avoid setting a variable to '' when it's not present in $_REQUEST
  29. */
  30. if (isset($_REQUEST['where_clause'])) {
  31. $where_clause = $_REQUEST['where_clause'];
  32. }
  33. if (isset($_REQUEST['clause_is_unique'])) {
  34. $clause_is_unique = $_REQUEST['clause_is_unique'];
  35. }
  36. if (isset($_SESSION['edit_next'])) {
  37. $where_clause = $_SESSION['edit_next'];
  38. unset($_SESSION['edit_next']);
  39. $after_insert = 'edit_next';
  40. }
  41. if (isset($_REQUEST['sql_query'])) {
  42. $sql_query = $_REQUEST['sql_query'];
  43. }
  44. if (isset($_REQUEST['ShowFunctionFields'])) {
  45. $cfg['ShowFunctionFields'] = $_REQUEST['ShowFunctionFields'];
  46. }
  47. if (isset($_REQUEST['ShowFieldTypesInDataEditView'])) {
  48. $cfg['ShowFieldTypesInDataEditView'] = $_REQUEST['ShowFieldTypesInDataEditView'];
  49. }
  50. if (isset($_REQUEST['default_action'])) {
  51. $default_action = $_REQUEST['default_action'];
  52. }
  53. /**
  54. * file listing
  55. */
  56. require_once './libraries/file_listing.php';
  57. /**
  58. * Defines the url to return to in case of error in a sql statement
  59. * (at this point, $GLOBALS['goto'] will be set but could be empty)
  60. */
  61. if (empty($GLOBALS['goto'])) {
  62. if (strlen($table)) {
  63. // avoid a problem (see bug #2202709)
  64. $GLOBALS['goto'] = 'tbl_sql.php';
  65. } else {
  66. $GLOBALS['goto'] = 'db_sql.php';
  67. }
  68. }
  69. /**
  70. * @todo check if we could replace by "db_|tbl_" - please clarify!?
  71. */
  72. $_url_params = array(
  73. 'db' => $db,
  74. 'sql_query' => $sql_query
  75. );
  76. if (preg_match('@^tbl_@', $GLOBALS['goto'])) {
  77. $_url_params['table'] = $table;
  78. }
  79. $err_url = $GLOBALS['goto'] . PMA_generate_common_url($_url_params);
  80. unset($_url_params);
  81. /**
  82. * Sets parameters for links
  83. * where is this variable used?
  84. * replace by PMA_generate_common_url($url_params);
  85. */
  86. $url_query = PMA_generate_common_url($url_params, 'html', '');
  87. /**
  88. * get table information
  89. * @todo should be done by a Table object
  90. */
  91. require_once './libraries/tbl_info.inc.php';
  92. /**
  93. * Get comments for table fileds/columns
  94. */
  95. $comments_map = array();
  96. if ($GLOBALS['cfg']['ShowPropertyComments']) {
  97. $comments_map = PMA_getComments($db, $table);
  98. }
  99. /**
  100. * START REGULAR OUTPUT
  101. */
  102. /**
  103. * used in ./libraries/header.inc.php to load JavaScript library file
  104. */
  105. $GLOBALS['js_include'][] = 'functions.js';
  106. $GLOBALS['js_include'][] = 'tbl_change.js';
  107. $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.16.custom.js';
  108. $GLOBALS['js_include'][] = 'jquery/timepicker.js';
  109. $GLOBALS['js_include'][] = 'gis_data_editor.js';
  110. /**
  111. * HTTP and HTML headers
  112. */
  113. require_once './libraries/header.inc.php';
  114. /**
  115. * Displays the query submitted and its result
  116. *
  117. * @todo where does $disp_message and $disp_query come from???
  118. */
  119. if (! empty($disp_message)) {
  120. if (! isset($disp_query)) {
  121. $disp_query = null;
  122. }
  123. PMA_showMessage($disp_message, $disp_query);
  124. }
  125. /**
  126. * Displays top menu links
  127. */
  128. require_once './libraries/tbl_links.inc.php';
  129. /**
  130. * Get the analysis of SHOW CREATE TABLE for this table
  131. * @todo should be handled by class Table
  132. */
  133. $show_create_table = PMA_DBI_fetch_value(
  134. 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
  135. 0, 1);
  136. $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
  137. unset($show_create_table);
  138. /**
  139. * Get the list of the fields of the current table
  140. */
  141. PMA_DBI_select_db($db);
  142. $table_fields = array_values(PMA_DBI_get_columns($db, $table));
  143. $rows = array();
  144. if (isset($where_clause)) {
  145. // when in edit mode load all selected rows from table
  146. $insert_mode = false;
  147. if (is_array($where_clause)) {
  148. $where_clause_array = $where_clause;
  149. } else {
  150. $where_clause_array = array(0 => $where_clause);
  151. }
  152. $result = array();
  153. $found_unique_key = false;
  154. $where_clauses = array();
  155. foreach ($where_clause_array as $key_id => $where_clause) {
  156. $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';';
  157. $result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE);
  158. $rows[$key_id] = PMA_DBI_fetch_assoc($result[$key_id]);
  159. $where_clauses[$key_id] = str_replace('\\', '\\\\', $where_clause);
  160. // No row returned
  161. if (! $rows[$key_id]) {
  162. unset($rows[$key_id], $where_clause_array[$key_id]);
  163. PMA_showMessage(__('MySQL returned an empty result set (i.e. zero rows).'), $local_query);
  164. echo "\n";
  165. include './libraries/footer.inc.php';
  166. } else { // end if (no row returned)
  167. $meta = PMA_DBI_get_fields_meta($result[$key_id]);
  168. list($unique_condition, $tmp_clause_is_unique) = PMA_getUniqueCondition($result[$key_id], count($meta), $meta, $rows[$key_id], true);
  169. if (! empty($unique_condition)) {
  170. $found_unique_key = true;
  171. }
  172. unset($unique_condition, $tmp_clause_is_unique);
  173. }
  174. }
  175. } else {
  176. // no primary key given, just load first row - but what happens if table is empty?
  177. $insert_mode = true;
  178. $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE);
  179. $rows = array_fill(0, $cfg['InsertRows'], false);
  180. }
  181. // Copying a row - fetched data will be inserted as a new row, therefore the where clause is needless.
  182. if (isset($default_action) && $default_action === 'insert') {
  183. unset($where_clause, $where_clauses);
  184. }
  185. // retrieve keys into foreign fields, if any
  186. $foreigners = PMA_getForeigners($db, $table);
  187. /**
  188. * Displays the form
  189. */
  190. // autocomplete feature of IE kills the "onchange" event handler and it
  191. // must be replaced by the "onpropertychange" one in this case
  192. $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5 && PMA_USR_BROWSER_VER < 7)
  193. ? 'onpropertychange'
  194. : 'onchange';
  195. // Had to put the URI because when hosted on an https server,
  196. // some browsers send wrongly this form to the http server.
  197. ?>
  198. <!-- Set on key handler for moving using by Ctrl+arrows -->
  199. <script src="./js/keyhandler.js" type="text/javascript"></script>
  200. <script type="text/javascript">
  201. //<![CDATA[
  202. var switch_movement = 0;
  203. document.onkeydown = onKeyDownArrowsHandler;
  204. //]]>
  205. </script>
  206. <?php
  207. $_form_params = array(
  208. 'db' => $db,
  209. 'table' => $table,
  210. 'goto' => $GLOBALS['goto'],
  211. 'err_url' => $err_url,
  212. 'sql_query' => $sql_query,
  213. );
  214. if (isset($where_clauses)) {
  215. foreach ($where_clause_array as $key_id => $where_clause) {
  216. $_form_params['where_clause[' . $key_id . ']'] = trim($where_clause);
  217. }
  218. }
  219. if (isset($clause_is_unique)) {
  220. $_form_params['clause_is_unique'] = $clause_is_unique;
  221. }
  222. ?>
  223. <!-- Insert/Edit form -->
  224. <form id="insertForm" method="post" action="tbl_replace.php" name="insertForm" <?php if ($is_upload) { echo ' enctype="multipart/form-data"'; } ?>>
  225. <?php
  226. echo PMA_generate_common_hidden_inputs($_form_params);
  227. $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
  228. // Set if we passed the first timestamp field
  229. $timestamp_seen = 0;
  230. $fields_cnt = count($table_fields);
  231. $tabindex = 0;
  232. $tabindex_for_function = +3000;
  233. $tabindex_for_null = +6000;
  234. $tabindex_for_value = 0;
  235. $o_rows = 0;
  236. $biggest_max_file_size = 0;
  237. // user can toggle the display of Function column
  238. // (currently does not work for multi-edits)
  239. $url_params['db'] = $db;
  240. $url_params['table'] = $table;
  241. if (isset($where_clause)) {
  242. $url_params['where_clause'] = trim($where_clause);
  243. }
  244. if (! empty($sql_query)) {
  245. $url_params['sql_query'] = $sql_query;
  246. }
  247. if (! $cfg['ShowFunctionFields'] || ! $cfg['ShowFieldTypesInDataEditView']) {
  248. echo __('Show');
  249. }
  250. if (! $cfg['ShowFunctionFields']) {
  251. $this_url_params = array_merge($url_params,
  252. array('ShowFunctionFields' => 1, 'ShowFieldTypesInDataEditView' => $cfg['ShowFieldTypesInDataEditView'], 'goto' => 'sql.php'));
  253. echo ' : <a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '">' . __('Function') . '</a>' . "\n";
  254. }
  255. if (! $cfg['ShowFieldTypesInDataEditView']) {
  256. $this_other_url_params = array_merge($url_params,
  257. array('ShowFieldTypesInDataEditView' => 1, 'ShowFunctionFields' => $cfg['ShowFunctionFields'], 'goto' => 'sql.php'));
  258. echo ' : <a href="tbl_change.php' . PMA_generate_common_url($this_other_url_params) . '">' . __('Type') . '</a>' . "\n";
  259. }
  260. foreach ($rows as $row_id => $vrow) {
  261. if ($vrow === false) {
  262. unset($vrow);
  263. }
  264. $jsvkey = $row_id;
  265. $rownumber_param = '&amp;rownumber=' . $row_id;
  266. $vkey = '[multi_edit][' . $jsvkey . ']';
  267. $vresult = (isset($result) && is_array($result) && isset($result[$row_id]) ? $result[$row_id] : $result);
  268. if ($insert_mode && $row_id > 0) {
  269. echo '<input type="checkbox" checked="checked" name="insert_ignore_' . $row_id . '" id="insert_ignore_' . $row_id . '" />';
  270. echo '<label for="insert_ignore_' . $row_id . '">' . __('Ignore') . '</label><br />' . "\n";
  271. }
  272. ?>
  273. <table class="insertRowTable">
  274. <thead>
  275. <tr>
  276. <th><?php echo __('Column'); ?></th>
  277. <?php
  278. if ($cfg['ShowFieldTypesInDataEditView']) {
  279. $this_url_params = array_merge($url_params,
  280. array('ShowFieldTypesInDataEditView' => 0, 'ShowFunctionFields' => $cfg['ShowFunctionFields'], 'goto' => 'sql.php'));
  281. echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . __('Hide') . '">' . __('Type') . '</a></th>' . "\n";
  282. }
  283. if ($cfg['ShowFunctionFields']) {
  284. $this_url_params = array_merge($url_params,
  285. array('ShowFunctionFields' => 0, 'ShowFieldTypesInDataEditView' => $cfg['ShowFieldTypesInDataEditView'], 'goto' => 'sql.php'));
  286. echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . __('Hide') . '">' . __('Function') . '</a></th>' . "\n";
  287. }
  288. ?>
  289. <th><?php echo __('Null'); ?></th>
  290. <th><?php echo __('Value'); ?></th>
  291. </tr>
  292. </thead>
  293. <tfoot>
  294. <tr>
  295. <th colspan="5" align="right" class="tblFooters">
  296. <input type="submit" value="<?php echo __('Go'); ?>" />
  297. </th>
  298. </tr>
  299. </tfoot>
  300. <tbody>
  301. <?php
  302. // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
  303. $m_rows = $o_rows + 1;
  304. $odd_row = true;
  305. for ($i = 0; $i < $fields_cnt; $i++) {
  306. if (! isset($table_fields[$i]['processed'])) {
  307. $table_fields[$i]['Field_html'] = htmlspecialchars($table_fields[$i]['Field']);
  308. $table_fields[$i]['Field_md5'] = md5($table_fields[$i]['Field']);
  309. // True_Type contains only the type (stops at first bracket)
  310. $table_fields[$i]['True_Type'] = preg_replace('@\(.*@s', '', $table_fields[$i]['Type']);
  311. // d a t e t i m e
  312. //
  313. // Current date should not be set as default if the field is NULL
  314. // for the current row, but do not put here the current datetime
  315. // if there is a default value (the real default value will be set
  316. // in the Default value logic below)
  317. // Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
  318. // $field['Default'] is not set if it contains NULL:
  319. // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime)
  320. // but, look what we get if we switch to iso: (Default is NULL)
  321. // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime)
  322. // so I force a NULL into it (I don't think it's possible
  323. // to have an empty default value for DATETIME)
  324. // then, the "if" after this one will work
  325. if ($table_fields[$i]['Type'] == 'datetime'
  326. && ! isset($table_fields[$i]['Default'])
  327. && isset($table_fields[$i]['Null'])
  328. && $table_fields[$i]['Null'] == 'YES') {
  329. $table_fields[$i]['Default'] = null;
  330. }
  331. $table_fields[$i]['len']
  332. = preg_match('@float|double@', $table_fields[$i]['Type']) ? 100 : -1;
  333. if (isset($comments_map[$table_fields[$i]['Field']])) {
  334. $table_fields[$i]['Field_title'] = '<span style="border-bottom: 1px dashed black;" title="'
  335. . htmlspecialchars($comments_map[$table_fields[$i]['Field']]) . '">'
  336. . $table_fields[$i]['Field_html'] . '</span>';
  337. } else {
  338. $table_fields[$i]['Field_title'] = $table_fields[$i]['Field_html'];
  339. }
  340. // The type column.
  341. // Fix for bug #3152931 'ENUM and SET cannot have "Binary" option'
  342. // If check to ensure types such as "enum('one','two','binary',..)" or
  343. // "enum('one','two','varbinary',..)" are not categorized as binary.
  344. if (stripos($table_fields[$i]['Type'], 'binary') === 0
  345. || stripos($table_fields[$i]['Type'], 'varbinary') === 0) {
  346. $table_fields[$i]['is_binary'] = stristr($table_fields[$i]['Type'], 'binary');
  347. } else {
  348. $table_fields[$i]['is_binary'] = false;
  349. }
  350. // If check to ensure types such as "enum('one','two','blob',..)" or
  351. // "enum('one','two','tinyblob',..)" etc. are not categorized as blob.
  352. if (stripos($table_fields[$i]['Type'], 'blob') === 0
  353. || stripos($table_fields[$i]['Type'], 'tinyblob') === 0
  354. || stripos($table_fields[$i]['Type'], 'mediumblob') === 0
  355. || stripos($table_fields[$i]['Type'], 'longblob') === 0) {
  356. $table_fields[$i]['is_blob'] = stristr($table_fields[$i]['Type'], 'blob');
  357. } else {
  358. $table_fields[$i]['is_blob'] = false;
  359. }
  360. // If check to ensure types such as "enum('one','two','char',..)" or
  361. // "enum('one','two','varchar',..)" are not categorized as char.
  362. if (stripos($table_fields[$i]['Type'], 'char') === 0
  363. || stripos($table_fields[$i]['Type'], 'varchar') === 0) {
  364. $table_fields[$i]['is_char'] = stristr($table_fields[$i]['Type'], 'char');
  365. } else {
  366. $table_fields[$i]['is_char'] = false;
  367. }
  368. $table_fields[$i]['first_timestamp'] = false;
  369. switch ($table_fields[$i]['True_Type']) {
  370. case 'set':
  371. $table_fields[$i]['pma_type'] = 'set';
  372. $table_fields[$i]['wrap'] = '';
  373. break;
  374. case 'enum':
  375. $table_fields[$i]['pma_type'] = 'enum';
  376. $table_fields[$i]['wrap'] = '';
  377. break;
  378. case 'timestamp':
  379. if (!$timestamp_seen) { // can only occur once per table
  380. $timestamp_seen = 1;
  381. $table_fields[$i]['first_timestamp'] = true;
  382. }
  383. $table_fields[$i]['pma_type'] = $table_fields[$i]['Type'];
  384. $table_fields[$i]['wrap'] = ' nowrap="nowrap"';
  385. break;
  386. default:
  387. $table_fields[$i]['pma_type'] = $table_fields[$i]['Type'];
  388. $table_fields[$i]['wrap'] = ' nowrap="nowrap"';
  389. break;
  390. }
  391. }
  392. $field = $table_fields[$i];
  393. $extracted_fieldspec = PMA_extractFieldSpec($field['Type']);
  394. if (-1 === $field['len']) {
  395. $field['len'] = PMA_DBI_field_len($vresult, $i);
  396. // length is unknown for geometry fields, make enough space to edit very simple WKTs
  397. if (-1 === $field['len']) {
  398. $field['len'] = 30;
  399. }
  400. }
  401. //Call validation when the form submited...
  402. $unnullify_trigger = $chg_evt_handler . "=\"return verificationsAfterFieldChange('". PMA_escapeJsString($field['Field_md5']) . "', '"
  403. . PMA_escapeJsString($jsvkey) . "','".$field['pma_type']."')\"";
  404. // Use an MD5 as an array index to avoid having special characters in the name atttibute (see bug #1746964 )
  405. $field_name_appendix = $vkey . '[' . $field['Field_md5'] . ']';
  406. if ($field['Type'] == 'datetime'
  407. && ! isset($field['Default'])
  408. && ! is_null($field['Default'])
  409. && ($insert_mode || ! isset($vrow[$field['Field']]))) {
  410. // INSERT case or
  411. // UPDATE case with an NULL value
  412. $vrow[$field['Field']] = date('Y-m-d H:i:s', time());
  413. }
  414. ?>
  415. <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
  416. <td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($field['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center">
  417. <?php echo $field['Field_title']; ?>
  418. <input type="hidden" name="fields_name<?php echo $field_name_appendix; ?>" value="<?php echo $field['Field_html']; ?>"/>
  419. </td>
  420. <?php if ($cfg['ShowFieldTypesInDataEditView']) { ?>
  421. <td align="center"<?php echo $field['wrap']; ?>><span class="column_type"><?php echo $field['pma_type']; ?></span>
  422. </td>
  423. <?php } //End if
  424. // Get a list of GIS data types.
  425. $gis_data_types = PMA_getGISDatatypes();
  426. // Prepares the field value
  427. $real_null_value = false;
  428. $special_chars_encoded = '';
  429. if (isset($vrow)) {
  430. // (we are editing)
  431. if (is_null($vrow[$field['Field']])) {
  432. $real_null_value = true;
  433. $vrow[$field['Field']] = '';
  434. $special_chars = '';
  435. $data = $vrow[$field['Field']];
  436. } elseif ($field['True_Type'] == 'bit') {
  437. $special_chars = PMA_printable_bit_value($vrow[$field['Field']], $extracted_fieldspec['spec_in_brackets']);
  438. } elseif (in_array($field['True_Type'], $gis_data_types)) {
  439. // Convert gis data to Well Know Text format
  440. $vrow[$field['Field']] = PMA_asWKT($vrow[$field['Field']], true);
  441. $special_chars = htmlspecialchars($vrow[$field['Field']]);
  442. } else {
  443. // special binary "characters"
  444. if ($field['is_binary'] || ($field['is_blob'] && ! $cfg['ProtectBinary'])) {
  445. if ($_SESSION['tmp_user_values']['display_binary_as_hex'] && $cfg['ShowFunctionFields']) {
  446. $vrow[$field['Field']] = bin2hex($vrow[$field['Field']]);
  447. $field['display_binary_as_hex'] = true;
  448. } else {
  449. $vrow[$field['Field']] = PMA_replace_binary_contents($vrow[$field['Field']]);
  450. }
  451. } // end if
  452. $special_chars = htmlspecialchars($vrow[$field['Field']]);
  453. //We need to duplicate the first \n or otherwise we will lose the first newline entered in a VARCHAR or TEXT column
  454. $special_chars_encoded = PMA_duplicateFirstNewline($special_chars);
  455. $data = $vrow[$field['Field']];
  456. } // end if... else...
  457. //when copying row, it is useful to empty auto-increment column to prevent duplicate key error
  458. if (isset($default_action) && $default_action === 'insert') {
  459. if ($field['Key'] === 'PRI' && strpos($field['Extra'], 'auto_increment') !== false) {
  460. $data = $special_chars_encoded = $special_chars = null;
  461. }
  462. }
  463. // If a timestamp field value is not included in an update
  464. // statement MySQL auto-update it to the current timestamp;
  465. // however, things have changed since MySQL 4.1, so
  466. // it's better to set a fields_prev in this situation
  467. $backup_field = '<input type="hidden" name="fields_prev'
  468. . $field_name_appendix . '" value="'
  469. . htmlspecialchars($vrow[$field['Field']]) . '" />';
  470. } else {
  471. // (we are inserting)
  472. // display default values
  473. if (! isset($field['Default'])) {
  474. $field['Default'] = '';
  475. $real_null_value = true;
  476. $data = '';
  477. } else {
  478. $data = $field['Default'];
  479. }
  480. if ($field['True_Type'] == 'bit') {
  481. $special_chars = PMA_convert_bit_default_value($field['Default']);
  482. } else {
  483. $special_chars = htmlspecialchars($field['Default']);
  484. }
  485. $backup_field = '';
  486. $special_chars_encoded = PMA_duplicateFirstNewline($special_chars);
  487. // this will select the UNHEX function while inserting
  488. if (($field['is_binary'] || ($field['is_blob'] && ! $cfg['ProtectBinary'])) && $_SESSION['tmp_user_values']['display_binary_as_hex'] && $cfg['ShowFunctionFields']) {
  489. $field['display_binary_as_hex'] = true;
  490. }
  491. }
  492. $idindex = ($o_rows * $fields_cnt) + $i + 1;
  493. $tabindex = $idindex;
  494. // Get a list of data types that are not yet supported.
  495. $no_support_types = PMA_unsupportedDatatypes();
  496. // The function column
  497. // -------------------
  498. // We don't want binary data to be destroyed
  499. // Note: from the MySQL manual: "BINARY doesn't affect how the column is
  500. // stored or retrieved" so it does not mean that the contents is
  501. // binary
  502. if ($cfg['ShowFunctionFields']) {
  503. if (($cfg['ProtectBinary'] && $field['is_blob'] && !$is_upload)
  504. || ($cfg['ProtectBinary'] == 'all' && $field['is_binary'])) {
  505. echo ' <td align="center">' . __('Binary') . '</td>' . "\n";
  506. } elseif (strstr($field['True_Type'], 'enum') || strstr($field['True_Type'], 'set') || in_array($field['pma_type'], $no_support_types)) {
  507. echo ' <td align="center">--</td>' . "\n";
  508. } else {
  509. ?>
  510. <td>
  511. <select name="funcs<?php echo $field_name_appendix; ?>" <?php echo $unnullify_trigger; ?> tabindex="<?php echo ($tabindex + $tabindex_for_function); ?>" id="field_<?php echo $idindex; ?>_1">
  512. <?php
  513. echo PMA_getFunctionsForField($field, $insert_mode);
  514. ?>
  515. </select>
  516. </td>
  517. <?php
  518. }
  519. } // end if ($cfg['ShowFunctionFields'])
  520. // The null column
  521. // ---------------
  522. $foreignData = PMA_getForeignData($foreigners, $field['Field'], false, '', '');
  523. echo ' <td>' . "\n";
  524. if ($field['Null'] == 'YES') {
  525. echo ' <input type="hidden" name="fields_null_prev' . $field_name_appendix . '"';
  526. if ($real_null_value && !$field['first_timestamp']) {
  527. echo ' value="on"';
  528. }
  529. echo ' />' . "\n";
  530. echo ' <input type="checkbox" class="checkbox_null" tabindex="' . ($tabindex + $tabindex_for_null) . '"'
  531. . ' name="fields_null' . $field_name_appendix . '"';
  532. if ($real_null_value && !$field['first_timestamp']) {
  533. echo ' checked="checked"';
  534. }
  535. echo ' id="field_' . ($idindex) . '_2" />';
  536. // nullify_code is needed by the js nullify() function
  537. if (strstr($field['True_Type'], 'enum')) {
  538. if (strlen($field['Type']) > 20) {
  539. $nullify_code = '1';
  540. } else {
  541. $nullify_code = '2';
  542. }
  543. } elseif (strstr($field['True_Type'], 'set')) {
  544. $nullify_code = '3';
  545. } elseif ($foreigners && isset($foreigners[$field['Field']]) && $foreignData['foreign_link'] == false) {
  546. // foreign key in a drop-down
  547. $nullify_code = '4';
  548. } elseif ($foreigners && isset($foreigners[$field['Field']]) && $foreignData['foreign_link'] == true) {
  549. // foreign key with a browsing icon
  550. $nullify_code = '6';
  551. } else {
  552. $nullify_code = '5';
  553. }
  554. // to be able to generate calls to nullify() in jQuery
  555. echo '<input type="hidden" class="nullify_code" name="nullify_code' . $field_name_appendix . '" value="' . $nullify_code . '" />';
  556. echo '<input type="hidden" class="hashed_field" name="hashed_field' . $field_name_appendix . '" value="' . $field['Field_md5'] . '" />';
  557. echo '<input type="hidden" class="multi_edit" name="multi_edit' . $field_name_appendix . '" value="' . PMA_escapeJsString($vkey) . '" />';
  558. }
  559. echo ' </td>' . "\n";
  560. // The value column (depends on type)
  561. // ----------------
  562. // See bug #1667887 for the reason why we don't use the maxlength
  563. // HTML attribute
  564. echo ' <td>' . "\n";
  565. // Will be used by js/tbl_change.js to set the default value
  566. // for the "Continue insertion" feature
  567. echo '<span class="default_value hide">' . $special_chars . '</span>';
  568. if ($foreignData['foreign_link'] == true) {
  569. echo $backup_field . "\n";
  570. ?>
  571. <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>"
  572. value="foreign" />
  573. <input type="text" name="fields<?php echo $field_name_appendix; ?>"
  574. class="textfield" <?php echo $unnullify_trigger; ?>
  575. tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
  576. id="field_<?php echo ($idindex); ?>_3"
  577. value="<?php echo htmlspecialchars($data); ?>" />
  578. <a class="hide foreign_values_anchor" target="_blank" onclick="window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes,resizable=yes'); return false;" href="browse_foreigners.php?<?php echo PMA_generate_common_url($db, $table); ?>&amp;field=<?php echo PMA_escapeJsString(urlencode($field['Field']) . $rownumber_param); ?>"><?php echo str_replace("'", "\'", $titles['Browse']); ?></a>
  579. <?php
  580. } elseif (is_array($foreignData['disp_row'])) {
  581. echo $backup_field . "\n";
  582. ?>
  583. <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>"
  584. value="foreign" />
  585. <select name="fields<?php echo $field_name_appendix; ?>"
  586. <?php echo $unnullify_trigger; ?>
  587. class="textfield"
  588. tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
  589. id="field_<?php echo ($idindex); ?>_3">
  590. <?php echo PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $data, $cfg['ForeignKeyMaxLimit']); ?>
  591. </select>
  592. <?php
  593. // still needed? :
  594. unset($foreignData['disp_row']);
  595. } elseif ($cfg['LongtextDoubleTextarea'] && strstr($field['pma_type'], 'longtext')) {
  596. ?>
  597. &nbsp;</td>
  598. </tr>
  599. <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
  600. <td colspan="5" align="right">
  601. <?php echo $backup_field . "\n"; ?>
  602. <textarea name="fields<?php echo $field_name_appendix; ?>"
  603. rows="<?php echo ($cfg['TextareaRows']*2); ?>"
  604. cols="<?php echo ($cfg['TextareaCols']*2); ?>"
  605. dir="<?php echo $text_dir; ?>"
  606. id="field_<?php echo ($idindex); ?>_3"
  607. <?php echo $unnullify_trigger; ?>
  608. tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
  609. ><?php echo $special_chars_encoded; ?></textarea>
  610. <?php
  611. } elseif (strstr($field['pma_type'], 'text')) {
  612. echo $backup_field . "\n";
  613. ?>
  614. <textarea name="fields<?php echo $field_name_appendix; ?>"
  615. rows="<?php echo $cfg['TextareaRows']; ?>"
  616. cols="<?php echo $cfg['TextareaCols']; ?>"
  617. dir="<?php echo $text_dir; ?>"
  618. id="field_<?php echo ($idindex); ?>_3"
  619. <?php echo $unnullify_trigger; ?>
  620. tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
  621. ><?php echo $special_chars_encoded; ?></textarea>
  622. <?php
  623. echo "\n";
  624. if (strlen($special_chars) > 32000) {
  625. echo " </td>\n";
  626. echo ' <td>' . __('Because of its length,<br /> this column might not be editable');
  627. }
  628. } elseif ($field['pma_type'] == 'enum') {
  629. if (! isset($table_fields[$i]['values'])) {
  630. $table_fields[$i]['values'] = array();
  631. foreach ($extracted_fieldspec['enum_set_values'] as $val) {
  632. // Removes automatic MySQL escape format
  633. $val = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $val));
  634. $table_fields[$i]['values'][] = array(
  635. 'plain' => $val,
  636. 'html' => htmlspecialchars($val),
  637. );
  638. }
  639. }
  640. $field_enum_values = $table_fields[$i]['values'];
  641. ?>
  642. <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="enum" />
  643. <input type="hidden" name="fields<?php echo $field_name_appendix; ?>" value="" />
  644. <?php
  645. echo "\n" . ' ' . $backup_field . "\n";
  646. // show dropdown or radio depend on length
  647. if (strlen($field['Type']) > 20) {
  648. ?>
  649. <select name="fields<?php echo $field_name_appendix; ?>"
  650. <?php echo $unnullify_trigger; ?>
  651. class="textfield"
  652. tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
  653. id="field_<?php echo ($idindex); ?>_3">
  654. <option value="">&nbsp;</option>
  655. <?php
  656. echo "\n";
  657. foreach ($field_enum_values as $enum_value) {
  658. echo ' ';
  659. echo '<option value="' . $enum_value['html'] . '"';
  660. if ($data == $enum_value['plain']
  661. || ($data == ''
  662. && (! isset($where_clause) || $field['Null'] != 'YES')
  663. && isset($field['Default'])
  664. && $enum_value['plain'] == $field['Default'])) {
  665. echo ' selected="selected"';
  666. }
  667. echo '>' . $enum_value['html'] . '</option>' . "\n";
  668. } // end for
  669. ?>
  670. </select>
  671. <?php
  672. } else {
  673. $j = 0;
  674. foreach ($field_enum_values as $enum_value) {
  675. echo ' ';
  676. echo '<input type="radio" name="fields' . $field_name_appendix . '"';
  677. echo ' class="textfield"';
  678. echo ' value="' . $enum_value['html'] . '"';
  679. echo ' id="field_' . ($idindex) . '_3_' . $j . '"';
  680. echo $unnullify_trigger;
  681. if ($data == $enum_value['plain']
  682. || ($data == ''
  683. && (! isset($where_clause) || $field['Null'] != 'YES')
  684. && isset($field['Default'])
  685. && $enum_value['plain'] == $field['Default'])) {
  686. echo ' checked="checked"';
  687. }
  688. echo ' tabindex="' . ($tabindex + $tabindex_for_value) . '" />';
  689. echo '<label for="field_' . $idindex . '_3_' . $j . '">'
  690. . $enum_value['html'] . '</label>' . "\n";
  691. $j++;
  692. } // end for
  693. } // end else
  694. } elseif ($field['pma_type'] == 'set') {
  695. if (! isset($table_fields[$i]['values'])) {
  696. $table_fields[$i]['values'] = array();
  697. foreach ($extracted_fieldspec['enum_set_values'] as $val) {
  698. $table_fields[$i]['values'][] = array(
  699. 'plain' => $val,
  700. 'html' => htmlspecialchars($val),
  701. );
  702. }
  703. $table_fields[$i]['select_size'] = min(4, count($table_fields[$i]['values']));
  704. }
  705. $field_set_values = $table_fields[$i]['values'];
  706. $select_size = $table_fields[$i]['select_size'];
  707. $vset = array_flip(explode(',', $data));
  708. echo $backup_field . "\n";
  709. ?>
  710. <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="set" />
  711. <select name="fields<?php echo $field_name_appendix . '[]'; ?>"
  712. class="textfield"
  713. size="<?php echo $select_size; ?>"
  714. multiple="multiple" <?php echo $unnullify_trigger; ?>
  715. tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
  716. id="field_<?php echo ($idindex); ?>_3">
  717. <?php
  718. foreach ($field_set_values as $field_set_value) {
  719. echo ' ';
  720. echo '<option value="' . $field_set_value['html'] . '"';
  721. if (isset($vset[$field_set_value['plain']])) {
  722. echo ' selected="selected"';
  723. }
  724. echo '>' . $field_set_value['html'] . '</option>' . "\n";
  725. } // end for
  726. ?>
  727. </select>
  728. <?php
  729. // We don't want binary data destroyed
  730. } elseif ($field['is_binary'] || $field['is_blob']) {
  731. if (($cfg['ProtectBinary'] && $field['is_blob'])
  732. || ($cfg['ProtectBinary'] == 'all' && $field['is_binary'])
  733. ) {
  734. echo "\n";
  735. // for blobstreaming
  736. if (PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type)
  737. && PMA_BS_IsPBMSReference($data, $db)
  738. ) {
  739. echo '<input type="hidden" name="remove_blob_ref_' . $field['Field_md5'] . $vkey . '" value="' . $data . '" />';
  740. echo '<input type="checkbox" name="remove_blob_repo_' . $field['Field_md5'] . $vkey . '" /> ' . __('Remove BLOB Repository Reference') . "<br />";
  741. echo PMA_BS_CreateReferenceLink($data, $db);
  742. echo "<br />";
  743. } else {
  744. echo __('Binary - do not edit');
  745. if (isset($data)) {
  746. $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
  747. echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
  748. unset($data_size);
  749. }
  750. echo "\n";
  751. } // end if (PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type) && PMA_BS_IsPBMSReference($data, $db))
  752. ?>
  753. <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="protected" />
  754. <input type="hidden" name="fields<?php echo $field_name_appendix; ?>" value="" />
  755. <?php
  756. } elseif ($field['is_blob']) {
  757. echo "\n";
  758. echo $backup_field . "\n";
  759. ?>
  760. <textarea name="fields<?php echo $field_name_appendix; ?>"
  761. rows="<?php echo $cfg['TextareaRows']; ?>"
  762. cols="<?php echo $cfg['TextareaCols']; ?>"
  763. dir="<?php echo $text_dir; ?>"
  764. id="field_<?php echo ($idindex); ?>_3"
  765. <?php echo $unnullify_trigger; ?>
  766. tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
  767. ><?php echo $special_chars_encoded; ?></textarea>
  768. <?php
  769. } else {
  770. // field size should be at least 4 and max $cfg['LimitChars']
  771. $fieldsize = min(max($field['len'], 4), $cfg['LimitChars']);
  772. echo "\n";
  773. echo $backup_field . "\n";
  774. ?>
  775. <input type="text" name="fields<?php echo $field_name_appendix; ?>"
  776. value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>"
  777. class="textfield" <?php echo $unnullify_trigger; ?>
  778. tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
  779. id="field_<?php echo ($idindex); ?>_3" />
  780. <?php
  781. } // end if...elseif...else
  782. // Upload choice (only for BLOBs because the binary
  783. // attribute does not imply binary contents)
  784. // (displayed whatever value the ProtectBinary has)
  785. if ($is_upload && $field['is_blob']) {
  786. // check if field type is of longblob and if the table is PBMS enabled.
  787. if (($field['pma_type'] == "longblob")
  788. && PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type)
  789. ) {
  790. echo '<br />';
  791. echo '<input type="checkbox" name="upload_blob_repo' . $vkey . '[' . $field['Field_md5'] . ']" /> ' . __('Upload to BLOB repository');
  792. }
  793. echo '<br />';
  794. echo '<input type="file" name="fields_upload' . $vkey . '[' . $field['Field_md5'] . ']" class="textfield" id="field_' . $idindex . '_3" size="10" ' . $unnullify_trigger . '/>&nbsp;';
  795. // find maximum upload size, based on field type
  796. /**
  797. * @todo with functions this is not so easy, as you can basically
  798. * process any data with function like MD5
  799. */
  800. $max_field_sizes = array(
  801. 'tinyblob' => '256',
  802. 'blob' => '65536',
  803. 'mediumblob' => '16777216',
  804. 'longblob' => '4294967296'); // yeah, really
  805. $this_field_max_size = $max_upload_size; // from PHP max
  806. if ($this_field_max_size > $max_field_sizes[$field['pma_type']]) {
  807. $this_field_max_size = $max_field_sizes[$field['pma_type']];
  808. }
  809. echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n";
  810. // do not generate here the MAX_FILE_SIZE, because we should
  811. // put only one in the form to accommodate the biggest field
  812. if ($this_field_max_size > $biggest_max_file_size) {
  813. $biggest_max_file_size = $this_field_max_size;
  814. }
  815. }
  816. if (!empty($cfg['UploadDir'])) {
  817. $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']));
  818. if ($files === false) {
  819. echo ' <font color="red">' . __('Error') . '</font><br />' . "\n";
  820. echo ' ' . __('The directory you set for upload work cannot be reached') . "\n";
  821. } elseif (!empty($files)) {
  822. echo "<br />\n";
  823. echo ' <i>' . __('Or') . '</i>' . ' ' . __('web server upload directory') . ':<br />' . "\n";
  824. echo ' <select size="1" name="fields_uploadlocal' . $vkey . '[' . $field['Field_md5'] . ']">' . "\n";
  825. echo ' <option value="" selected="selected"></option>' . "\n";
  826. echo $files;
  827. echo ' </select>' . "\n";
  828. }
  829. } // end if (web-server upload directory)
  830. // end elseif (binary or blob)
  831. } elseif (! in_array($field['pma_type'], $no_support_types)) {
  832. // ignore this column to avoid changing it
  833. if ($field['is_char']) {
  834. $fieldsize = $extracted_fieldspec['spec_in_brackets'];
  835. } else {
  836. /**
  837. * This case happens for example for INT or DATE columns;
  838. * in these situations, the value returned in $field['len']
  839. * seems appropriate.
  840. */
  841. $fieldsize = $field['len'];
  842. }
  843. $fieldsize = min(max($fieldsize, $cfg['MinSizeForInputField']), $cfg['MaxSizeForInputField']);
  844. echo $backup_field . "\n";
  845. if ($field['is_char']
  846. && ($cfg['CharEditing'] == 'textarea'
  847. || strpos($data, "\n") !== false)
  848. ) {
  849. echo "\n";
  850. ?>
  851. <textarea class="char" name="fields<?php echo $field_name_appendix; ?>"
  852. rows="<?php echo $cfg['CharTextareaRows']; ?>"
  853. cols="<?php echo $cfg['CharTextareaCols']; ?>"
  854. dir="<?php echo $text_dir; ?>"
  855. id="field_<?php echo ($idindex); ?>_3"
  856. <?php echo $unnullify_trigger; ?>
  857. tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
  858. ><?php echo $special_chars_encoded; ?></textarea>
  859. <?php
  860. } else {
  861. $the_class = 'textfield';
  862. if ($field['pma_type'] == 'date') {
  863. $the_class .= ' datefield';
  864. } elseif ($field['pma_type'] == 'datetime'
  865. || substr($field['pma_type'], 0, 9) == 'timestamp'
  866. ) {
  867. $the_class .= ' datetimefield';
  868. }
  869. ?>
  870. <input type="text" name="fields<?php echo $field_name_appendix; ?>"
  871. value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>"
  872. class="<?php echo $the_class; ?>" <?php echo $unnullify_trigger; ?>
  873. tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
  874. id="field_<?php echo ($idindex); ?>_3" />
  875. <?php
  876. if ($field['Extra'] == 'auto_increment') {
  877. ?>
  878. <input type="hidden" name="auto_increment<?php echo $field_name_appendix; ?>" value="1" />
  879. <?php
  880. } // end if
  881. if (substr($field['pma_type'], 0, 9) == 'timestamp') {
  882. ?>
  883. <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="timestamp" />
  884. <?php
  885. }
  886. if (substr($field['pma_type'], 0, 8) == 'datetime') {
  887. ?>
  888. <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="datetime" />
  889. <?php
  890. }
  891. if ($field['True_Type'] == 'bit') {
  892. ?>
  893. <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="bit" />
  894. <?php
  895. }
  896. if ($field['pma_type'] == 'date'
  897. || $field['pma_type'] == 'datetime'
  898. || substr($field['pma_type'], 0, 9) == 'timestamp'
  899. ) {
  900. // the _3 suffix points to the date field
  901. // the _2 suffix points to the corresponding NULL checkbox
  902. // in dateFormat, 'yy' means the year with 4 digits
  903. }
  904. }
  905. }
  906. if (in_array($field['pma_type'], $gis_data_types)) {
  907. $data_val = isset($vrow[$field['Field']]) ? $vrow[$field['Field']] : '';
  908. $_url_params = array(
  909. 'field' => $field['Field_title'],
  910. 'value' => $data_val,
  911. );
  912. if ($field['pma_type'] != 'geometry') {
  913. $_url_params = $_url_params + array('gis_data[gis_type]' => strtoupper($field['pma_type']));
  914. }
  915. $edit_url = 'gis_data_editor.php' . PMA_generate_common_url($_url_params);
  916. $edit_str = PMA_getIcon('b_edit.png', __('Edit/Insert'));
  917. echo('<span class="open_gis_editor">');
  918. echo(PMA_linkOrButton($edit_url, $edit_str, array(), false, false, '_blank'));
  919. echo('</span>');
  920. }
  921. ?>
  922. </td>
  923. </tr>
  924. <?php
  925. $odd_row = !$odd_row;
  926. } // end for
  927. $o_rows++;
  928. echo ' </tbody></table><br />';
  929. } // end foreach on multi-edit
  930. ?>
  931. <div id="gis_editor"></div><div id="popup_background"></div>
  932. <br />
  933. <fieldset id="actions_panel">
  934. <table border="0" cellpadding="5" cellspacing="0">
  935. <tr>
  936. <td valign="middle" nowrap="nowrap">
  937. <select name="submit_type" class="control_at_footer" tabindex="<?php echo ($tabindex + $tabindex_for_value + 1); ?>">
  938. <?php
  939. if (isset($where_clause)) {
  940. ?>
  941. <option value="save"><?php echo __('Save'); ?></option>
  942. <?php
  943. }
  944. ?>
  945. <option value="insert"><?php echo __('Insert as new row'); ?></option>
  946. <option value="insertignore"><?php echo __('Insert as new row and ignore errors'); ?></option>
  947. <option value="showinsert"><?php echo __('Show insert query'); ?></option>
  948. </select>
  949. <?php
  950. echo "\n";
  951. if (! isset($after_insert)) {
  952. $after_insert = 'back';
  953. }
  954. ?>
  955. </td>
  956. <td valign="middle">
  957. &nbsp;&nbsp;&nbsp;<strong><?php echo __('and then'); ?></strong>&nbsp;&nbsp;&nbsp;
  958. </td>
  959. <td valign="middle" nowrap="nowrap">
  960. <select name="after_insert">
  961. <option value="back" <?php echo ($after_insert == 'back' ? 'selected="selected"' : ''); ?>><?php echo __('Go back to previous page'); ?></option>
  962. <option value="new_insert" <?php echo ($after_insert == 'new_insert' ? 'selected="selected"' : ''); ?>><?php echo __('Insert another new row'); ?></option>
  963. <?php
  964. if (isset($where_clause)) {
  965. ?>
  966. <option value="same_insert" <?php echo ($after_insert == 'same_insert' ? 'selected="selected"' : ''); ?>><?php echo __('Go back to this page'); ?></option>
  967. <?php
  968. // If we have just numeric primary key, we can also edit next
  969. // in 2.8.2, we were looking for `field_name` = numeric_value
  970. //if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $where_clause)) {
  971. // in 2.9.0, we are looking for `table_name`.`field_name` = numeric_value
  972. if ($found_unique_key && preg_match('@^[\s]*`[^`]*`[\.]`[^`]*` = [0-9]+@', $where_clause)) {
  973. ?>
  974. <option value="edit_next" <?php echo ($after_insert == 'edit_next' ? 'selected="selected"' : ''); ?>><?php echo __('Edit next row'); ?></option>
  975. <?php
  976. }
  977. }
  978. ?>
  979. </select>
  980. </td>
  981. </tr>
  982. <tr>
  983. <td>
  984. <?php echo PMA_showHint(__('Use TAB key to move from value to value, or CTRL+arrows to move anywhere')); ?>
  985. </td>
  986. <td colspan="3" align="right" valign="middle">
  987. <input type="submit" class="control_at_footer" value="<?php echo __('Go'); ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value + 6); ?>" id="buttonYes" />
  988. <input type="reset" class="control_at_footer" value="<?php echo __('Reset'); ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value + 7); ?>" />
  989. </td>
  990. </tr>
  991. </table>
  992. </fieldset>
  993. <?php if ($biggest_max_file_size > 0) {
  994. echo ' ' . PMA_generateHiddenMaxFileSize($biggest_max_file_size) . "\n";
  995. } ?>
  996. </form>
  997. <?php
  998. if ($insert_mode) {
  999. ?>
  1000. <!-- Continue insertion form -->
  1001. <form id="continueForm" method="post" action="tbl_replace.php" name="continueForm" >
  1002. <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  1003. <input type="hidden" name="goto" value="<?php echo htmlspecialchars($GLOBALS['goto']); ?>" />
  1004. <input type="hidden" name="err_url" value="<?php echo htmlspecialchars($err_url); ?>" />
  1005. <input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
  1006. <?php
  1007. if (isset($where_clauses)) {
  1008. foreach ($where_clause_array as $key_id => $where_clause) {
  1009. echo '<input type="hidden" name="where_clause[' . $key_id . ']" value="' . htmlspecialchars(trim($where_clause)) . '" />'. "\n";
  1010. }
  1011. }
  1012. $tmp = '<select name="insert_rows" id="insert_rows">' . "\n";
  1013. $option_values = array(1,2,5,10,15,20,30,40);
  1014. foreach ($option_values as $value) {
  1015. $tmp .= '<option value="' . $value . '"';
  1016. if ($value == $cfg['InsertRows']) {
  1017. $tmp .= ' selected="selected"';
  1018. }
  1019. $tmp .= '>' . $value . '</option>' . "\n";
  1020. }
  1021. $tmp .= '</select>' . "\n";
  1022. echo "\n" . sprintf(__('Continue insertion with %s rows'), $tmp);
  1023. unset($tmp);
  1024. echo '<noscript><input type="submit" value="' . __('Go') . '" /></noscript>' . "\n";
  1025. echo '</form>' . "\n";
  1026. }
  1027. /**
  1028. * Displays…

Large files files are truncated, but you can click here to view the full file