2 /* vim: set expandtab sw=4 ts=4 sts=4: */
6 * @package PhpMyAdmin-Designer
9 require_once './libraries/common.inc.php';
10 require_once 'libraries/pmd_common.php';
13 * Validate vulnerable POST parameters
15 if (isset($_POST['scale']) && ! PMA_isValid($_POST['scale'], 'numeric')) {
16 die('Attack stopped');
20 * Sets globals from $_POST
26 foreach ($post_params as $one_post_param) {
27 if (isset($_POST[$one_post_param])) {
28 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
33 * If called directly from the designer, first save the positions
35 if (! isset($_POST['scale'])) {
36 include_once 'pmd_save_pos.php';
39 if (isset($_POST['mode'])) {
40 if ('create_export' != $_POST['mode'] && empty($_POST['pdf_page_number'])) {
41 die("<script>alert('Pages not found!');history.go(-2);</script>");
44 $pmd_table = PMA_Util
::backquote($GLOBALS['cfgRelation']['db']) . '.'
45 . PMA_Util
::backquote($GLOBALS['cfgRelation']['designer_coords']);
46 $pma_table = PMA_Util
::backquote($GLOBALS['cfgRelation']['db']) . '.'
47 . PMA_Util
::backquote($cfgRelation['table_coords']);
48 $scale_q = PMA_Util
::sqlAddSlashes($_POST['scale']);
50 if ('create_export' == $_POST['mode']) {
51 $pdf_page_number = PMA_REL_createPage($_POST['newpage'], $cfgRelation, $db);
52 if ($pdf_page_number > 0) {
53 $message = PMA_Message
::success(__('Page has been created'));
54 $_POST['mode'] = 'export';
56 $message = PMA_Message
::error(__('Page creation failed'));
59 $pdf_page_number = $_POST['pdf_page_number'];
62 $pdf_page_number_q = PMA_Util
::sqlAddSlashes($pdf_page_number);
64 if ('export' == $_POST['mode']) {
65 $sql = "REPLACE INTO " . $pma_table
66 . " (db_name, table_name, pdf_page_number, x, y)"
67 . " SELECT db_name, table_name, " . $pdf_page_number_q . ","
68 . " ROUND(x/" . $scale_q . ") , ROUND(y/" . $scale_q . ") y"
69 . " FROM " . $pmd_table
70 . " WHERE db_name = '" . PMA_Util
::sqlAddSlashes($db) . "'";
72 PMA_queryAsControlUser($sql, true, PMA_DatabaseInterface
::QUERY_STORE
);
75 if ('import' == $_POST['mode']) {
76 PMA_queryAsControlUser(
77 'UPDATE ' . $pma_table . ',' . $pmd_table .
78 ' SET ' . $pmd_table . '.`x`= ' . $pma_table . '.`x` * '. $scale_q . ',
79 ' . $pmd_table . '.`y`= ' . $pma_table . '.`y` * '. $scale_q .'
81 ' . $pmd_table . '.`db_name`=' . $pma_table . '.`db_name`
83 ' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name`
85 ' . $pmd_table . '.`db_name`=\''. PMA_Util
::sqlAddSlashes($db) . '\'
86 AND pdf_page_number = ' . $pdf_page_number_q . ';',
87 true, PMA_DatabaseInterface
::QUERY_STORE
92 $response = PMA_Response
::getInstance();
93 $response->getFooter()->setMinimal();
99 if (! empty($message)) {
103 <form name
="form1" method
="post" action
="pmd_pdf.php">
105 echo PMA_URL_getHiddenInputs($db);
107 echo '<fieldset><legend>' . __('Import/Export coordinates for PDF schema') . '</legend>';
111 $table_info_result = PMA_queryAsControlUser(
112 'SELECT * FROM ' . PMA_Util
::backquote($GLOBALS['cfgRelation']['db'])
113 . '.' . PMA_Util
::backquote($cfgRelation['pdf_pages'])
114 . ' WHERE db_name = \'' . PMA_Util
::sqlAddSlashes($db) . '\''
117 if ($GLOBALS['dbi']->numRows($table_info_result) > 0) {
118 echo '<p>' . __('Page:');
119 echo '<select name="pdf_page_number">';
121 while ($page = $GLOBALS['dbi']->fetchAssoc($table_info_result)) {
122 echo '<option value="' . $page['page_nr'] . '">';
123 echo htmlspecialchars($page['page_descr']);
128 $choices['import'] = __('Import from selected page');
129 $choices['export'] = __('Export to selected page');
131 $choices['create_export'] = __('Create a page and export to it');
133 if (1 == count($choices)) {
134 echo $choices['create_export'];
135 echo '<input type="hidden" name="mode" value="create_export" />';
137 echo PMA_Util
::getRadioFields(
138 'mode', $choices, $checked_choice = '', $line_break = true,
139 $escape_label = false, $class = ''
143 echo '<label for="newpage">' . __('New page name: ') . '</label>';
144 echo '<input id="newpage" type="text" name="newpage" />';
146 echo '<p>' . __('Export/Import to scale:');
148 <select name
="scale">
149 <option value
="1">1:1</option
>
150 <option value
="2">1:2</option
>
151 <option value
="3" selected
="selected">
152 1:3 (<?php
echo __('recommended'); ?
>)
154 <option value
="4">1:4</option
>
155 <option value
="5">1:5</option
>
158 <input type
="submit" value
="<?php echo __('Go'); ?>"/>