pmd_save_pos.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. *
  5. * @package PhpMyAdmin-Designer
  6. */
  7. /**
  8. *
  9. */
  10. require_once './libraries/common.inc.php';
  11. require_once 'libraries/pmd_common.php';
  12. $cfgRelation = PMA_getRelationsParam();
  13. if (! $cfgRelation['designerwork']) {
  14. PMD_err_sav();
  15. }
  16. /**
  17. * Sets globals from $_POST
  18. */
  19. $post_params = array(
  20. 'IS_AJAX',
  21. 'die_save_pos',
  22. 'server',
  23. 't_h',
  24. 't_v',
  25. 't_x',
  26. 't_y'
  27. );
  28. foreach ($post_params as $one_post_param) {
  29. if (isset($_POST[$one_post_param])) {
  30. $GLOBALS[$one_post_param] = $_POST[$one_post_param];
  31. }
  32. }
  33. foreach ($t_x as $key => $value) {
  34. // table name decode (post PDF exp/imp)
  35. $KEY = empty($IS_AJAX) ? urldecode($key) : $key;
  36. list($DB,$TAB) = explode(".", $KEY);
  37. PMA_queryAsControlUser(
  38. 'DELETE FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
  39. . '.' . PMA_Util::backquote($GLOBALS['cfgRelation']['designer_coords'])
  40. . ' WHERE `db_name` = \'' . PMA_Util::sqlAddSlashes($DB) . '\''
  41. . ' AND `table_name` = \'' . PMA_Util::sqlAddSlashes($TAB) . '\'',
  42. true, PMA_DBI_QUERY_STORE
  43. );
  44. PMA_queryAsControlUser(
  45. 'INSERT INTO ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
  46. . '.' . PMA_Util::backquote($GLOBALS['cfgRelation']['designer_coords'])
  47. . ' (db_name, table_name, x, y, v, h)'
  48. . ' VALUES ('
  49. . '\'' . PMA_Util::sqlAddSlashes($DB) . '\', '
  50. . '\'' . PMA_Util::sqlAddSlashes($TAB) . '\', '
  51. . '\'' . PMA_Util::sqlAddSlashes($t_x[$key]) . '\', '
  52. . '\'' . PMA_Util::sqlAddSlashes($t_y[$key]) . '\', '
  53. . '\'' . PMA_Util::sqlAddSlashes($t_v[$key]) . '\', '
  54. . '\'' . PMA_Util::sqlAddSlashes($t_h[$key]) . '\')',
  55. true, PMA_DBI_QUERY_STORE
  56. );
  57. }
  58. //----------------------------------------------------------------------------
  59. function PMD_err_sav()
  60. {
  61. global $die_save_pos; // if this file included
  62. if (! empty($die_save_pos)) {
  63. header("Content-Type: text/xml; charset=utf-8");
  64. header("Cache-Control: no-cache");
  65. die('<root act="save_pos" return="' . __('Error saving coordinates for Designer.') . '"></root>');
  66. }
  67. }
  68. if (! empty($die_save_pos)) {
  69. header("Content-Type: text/xml; charset=utf-8");
  70. header("Cache-Control: no-cache");
  71. ?>
  72. <root act='save_pos' return='<?php echo __('Modifications have been saved'); ?>'></root>
  73. <?php
  74. }
  75. ?>