Translated using Weblate (Polish)
[phpmyadmin.git] / pmd_pdf.php
blob141fcd4806ed4ee525eff669ef5f6f7f69850e37
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * PDF export for PMD
6 * @package PhpMyAdmin-Designer
7 */
9 require_once './libraries/common.inc.php';
10 require_once 'libraries/pmd_common.php';
12 /**
13 * Validate vulnerable POST parameters
15 if (isset($_POST['scale']) && ! PMA_isValid($_POST['scale'], 'numeric')) {
16 die('Attack stopped');
19 /**
20 * Sets globals from $_POST
22 $post_params = array(
23 'db'
26 foreach ($post_params as $one_post_param) {
27 if (isset($_POST[$one_post_param])) {
28 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
32 /**
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';
55 } else {
56 $message = PMA_Message::error(__('Page creation failed'));
58 } else {
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 .'
80 WHERE
81 ' . $pmd_table . '.`db_name`=' . $pma_table . '.`db_name`
82 AND
83 ' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name`
84 AND
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();
96 <br/>
97 <div>
98 <?php
99 if (! empty($message)) {
100 $message->display();
103 <form name="form1" method="post" action="pmd_pdf.php">
104 <?php
105 echo PMA_URL_getHiddenInputs($db);
106 echo '<div>';
107 echo '<fieldset><legend>' . __('Import/Export coordinates for PDF schema') . '</legend>';
109 $choices = array();
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']);
124 echo '</option>';
126 echo '</select>';
127 echo '</p>';
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" />';
136 } else {
137 echo PMA_Util::getRadioFields(
138 'mode', $choices, $checked_choice = '', $line_break = true,
139 $escape_label = false, $class = ''
142 echo '<br />';
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'); ?>)
153 </option>
154 <option value="4">1:4</option>
155 <option value="5">1:5</option>
156 </select>
157 </p>
158 <input type="submit" value="<?php echo __('Go'); ?>"/>
159 </fieldset>
160 </div>
161 </form>
162 </div>