bug 653764
[phpmyadmin/crack.git] / pdf_pages.php3
blobbe61c76695d0b5219bc8f3584646e0cb0488e7d9
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Gets some core libraries
8 */
9 require('./libraries/grab_globals.lib.php3');
10 require('./libraries/common.lib.php3');
11 require('./db_details_common.php3');
14 /**
15 * Settings for relation stuff
17 require('./libraries/relation.lib.php3');
18 $cfgRelation = PMA_getRelationsParam();
21 /**
22 * Now in ./libraries/relation.lib.php3 we check for all tables
23 * that we need, but if we don't find them we are quiet about it
24 * so people can work without.
25 * This page is absolutely useless if you didn't set up your tables
26 * correctly, so it is a good place to see which tables we can and
27 * complain ;-)
29 if (!$cfgRelation['relwork']) {
30 echo sprintf($strNotSet, 'relation', 'config.inc.php3') . '<br />' . "\n"
31 . '<a href="./Documentation.html#relation" target="documentation">' . $strDocu . '</a>' . "\n";
32 exit();
35 if (!$cfgRelation['displaywork']) {
36 echo sprintf($strNotSet, 'table_info', 'config.inc.php3') . '<br />' . "\n"
37 . '<a href="./Documentation.html#table_info" target="documentation">' . $strDocu . '</a>' . "\n";
38 exit();
41 if (!isset($cfgRelation['table_coords'])){
42 echo sprintf($strNotSet, 'table_coords', 'config.inc.php3') . '<br />' . "\n"
43 . '<a href="./Documentation.html#table_coords" target="documentation">' . $strDocu . '</a>' . "\n";
44 exit();
46 if (!isset($cfgRelation['pdf_pages'])) {
47 echo sprintf($strNotSet, 'pdf_page', 'config.inc.php3') . '<br />' . "\n"
48 . '<a href="./Documentation.html#pdf_pages" target="documentation">' . $strDocu . '</a>' . "\n";
49 exit();
52 if ($cfgRelation['pdfwork']) {
53 // Now is the time to work on all changes
54 if (isset($do)) {
55 switch ($do) {
56 case 'createpage':
57 if (!isset($newpage) || $newpage == '') {
58 $newpage = $strNoDescription;
60 $ins_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['pdf_pages'])
61 . ' (db_name, page_descr)'
62 . ' VALUES (\'' . PMA_sqlAddslashes($db) . '\', \'' . PMA_sqlAddslashes($newpage) . '\')';
63 PMA_query_as_cu($ins_query);
64 break;
66 case 'edcoord':
67 for ($i = 0; $i < $c_table_rows; $i++) {
68 $arrvalue = 'c_table_' . $i;
69 $arrvalue = $$arrvalue;
70 if (!isset($arrvalue['x']) || $arrvalue['x'] == '') {
71 $arrvalue['x'] = 0;
73 if (!isset($arrvalue['y']) || $arrvalue['y'] == '') {
74 $arrvalue['y'] = 0;
76 if (isset($arrvalue['name']) && $arrvalue['name'] != '--') {
77 $test_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['table_coords'])
78 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
79 . ' AND table_name = \'' . PMA_sqlAddslashes($arrvalue['name']) . '\''
80 . ' AND pdf_page_number = ' . $chpage;
81 $test_rs = PMA_query_as_cu($test_query);
82 if ($test_rs && mysql_num_rows($test_rs) > 0) {
83 if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
84 $ch_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords'])
85 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
86 . ' AND table_name = \'' . PMA_sqlAddslashes($arrvalue['name']) . '\''
87 . ' AND pdf_page_number = ' . $chpage;
88 } else {
89 $ch_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_coords']) . ' '
90 . 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y']
91 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
92 . ' AND table_name = \'' . PMA_sqlAddslashes($arrvalue['name']) . '\''
93 . ' AND pdf_page_number = ' . $chpage;
95 } else {
96 $ch_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['table_coords']) . ' '
97 . '(db_name, table_name, pdf_page_number, x, y) '
98 . 'VALUES (\'' . PMA_sqlAddslashes($db) . '\', \'' . PMA_sqlAddslashes($arrvalue['name']) . '\',' . $chpage . ',' . $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
100 PMA_query_as_cu($ch_query);
101 } // end if
102 } // end for
103 break;
104 } // end switch
105 } // end if (isset($do))
107 // We will need an array of all tables in this db
108 $selectboxall[] = '--';
109 $alltab_qry = 'SHOW TABLES FROM ' . PMA_backquote($db);
110 $alltab_rs = @PMA_mysql_query($alltab_qry) or PMA_mysqlDie('', $alltab_qry, '', $err_url_0);
111 while (list($table) = @PMA_mysql_fetch_array($alltab_rs)) {
112 $selectboxall[] = $table;
115 // Now first show some possibility to choose a page for the pdf
116 $page_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
117 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
118 $page_rs = PMA_query_as_cu($page_query);
119 if ($page_rs && mysql_num_rows($page_rs) > 0) {
121 <form method="post" action="pdf_pages.php3" name="selpage">
122 <?php echo $strChoosePage . "\n"; ?>
123 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
124 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
125 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
126 <input type="hidden" name="server" value="<?php echo $server; ?>" />
127 <input type="hidden" name="table" value="<?php echo htmlspecialchars($table); ?>" />
128 <input type="hidden" name="do" value="choosepage" />
129 <select name="chpage" onchange="this.form.submit()">
130 <?php
131 while ($curr_page = @PMA_mysql_fetch_array($page_rs)) {
132 echo "\n" . ' '
133 . '<option value="' . $curr_page['page_nr'] . '"';
134 if (isset($chpage) && $chpage == $curr_page['page_nr']) {
135 echo ' selected="selected"';
137 echo '>' . $curr_page['page_nr'] . ': ' . $curr_page['page_descr'] . '</option>';
138 } // end while
139 echo "\n";
141 </select>
142 <input type="submit" value="<?php echo $strGo; ?>" />
143 </form>
144 <?php
146 echo "\n";
148 // Possibility to create a new page:
150 <form method="post" action="pdf_pages.php3" name="crpage">
151 <?php echo $strCreatePage . "\n"; ?>
152 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
153 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
154 <input type="hidden" name="server" value="<?php echo $server; ?>" />
155 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
156 <input type="hidden" name="table" value="<?php echo htmlspecialchars($table); ?>" />
157 <input type="hidden" name="do" value="createpage" />
158 <input type="text" name="newpage" size="20" maxlength="50" />
159 <input type="submit" value="<?php echo $strGo; ?>" />
160 </form>
161 <?php
162 // Now if we allready have choosen a page number then we should show the
163 // tables involved
164 if (isset($chpage) && $chpage > 0) {
165 echo "\n";
167 <hr />
169 <h2><?php echo $strSelectTables ;?></h2>
170 <form method="post" action="pdf_pages.php3" name="edcoord">
171 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
172 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
173 <input type="hidden" name="server" value="<?php echo $server; ?>" />
174 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
175 <input type="hidden" name="table" value="<?php echo htmlspecialchars($table); ?>" />
176 <input type="hidden" name="chpage" value="<?php echo $chpage; ?>" />
177 <input type="hidden" name="do" value="edcoord" />
178 <table border="0">
179 <tr>
180 <th><?php echo $strTable; ?></th>
181 <th><?php echo $strDelete; ?></th>
182 <th>X</th>
183 <th>Y</th>
184 </tr>
185 <?php
186 if (isset($ctable)) {
187 unset($ctable);
190 $page_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['table_coords'])
191 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
192 . ' AND pdf_page_number = ' . $chpage;
193 $page_rs = PMA_query_as_cu($page_query);
195 $i = 0;
196 while ($sh_page = @PMA_mysql_fetch_array($page_rs)) {
197 echo "\n" . ' <tr ';
198 if ($i % 2 == 0) {
199 echo 'bgcolor="' . $cfg['BgcolorOne'] . '"';
200 } else {
201 echo 'bgcolor="' . $cfg['BgcolorTwo'] . '"';
203 echo '>';
204 echo "\n" . ' <td>'
205 . "\n" . ' <select name="c_table_' . $i . '[name]">';
206 reset($selectboxall);
207 while (list($key, $value) = each($selectboxall)) {
208 echo "\n" . ' <option value="' . $value . '"';
209 if ($value == $sh_page['table_name']) {
210 echo ' selected="selected"';
212 echo '>' . $value . '</option>';
213 } // end while
214 echo "\n" . ' </select>'
215 . "\n" . ' </td>';
216 echo "\n" . ' <td>'
217 . "\n" . ' <input type="checkbox" name="c_table_' . $i . '[delete]" value="y" />' . $strDelete;
218 echo "\n" . ' </td>';
219 echo "\n" . ' <td>'
220 . "\n" . ' <input type="text" name="c_table_' . $i . '[x]" value="' . $sh_page['x'] . '" />';
221 echo "\n" . ' </td>';
222 echo "\n" . ' <td>'
223 . "\n" . ' <input type="text" name="c_table_' . $i . '[y]" value="' . $sh_page['y'] . '" />';
224 echo "\n" . ' </td>';
225 echo "\n" . ' </tr>';
226 $i++;
227 } // end while
228 // Do one more empty row
229 echo "\n" . ' <tr ';
230 if ($i % 2 == 0) {
231 echo 'bgcolor="' . $cfg['BgcolorOne'] . '"';
232 } else {
233 echo 'bgcolor="' . $cfg['BgcolorTwo'] . '"';
235 echo '>';
236 echo "\n" . ' <td>'
237 . "\n" . ' <select name="c_table_' . $i . '[name]">';
238 reset($selectboxall);
239 while (list($key, $value) = each($selectboxall)) {
240 echo "\n" . ' <option value="' . $value . '">' . $value . '</option>';
242 echo "\n" . ' </select>'
243 . "\n" . ' </td>';
244 echo "\n" . ' <td>'
245 . "\n" . ' <input type="checkbox" name="c_table_' . $i . '[delete]" value="y" />' . $strDelete;
246 echo "\n" . ' </td>';
247 echo "\n" . ' <td>'
248 . "\n" . ' <input type="text" name="c_table_' . $i . '[x]" value="' . $sh_page['x'] . '" />';
249 echo "\n" . ' </td>';
250 echo "\n" . ' <td>'
251 . "\n" . ' <input type="text" name="c_table_' . $i . '[y]" value="' . $sh_page['y'] . '" />';
252 echo "\n" . ' </td>';
253 echo "\n" . ' </tr>';
254 echo "\n" . ' </table>' . "\n";
256 echo "\n" . ' <input type="hidden" name="c_table_rows" value="' . ($i + 1) . '" />';
257 echo "\n" . ' <input type="submit" value="' . $strGo . '" />';
258 echo "\n" . '</form>' . "\n\n";
259 } // end if
261 if (isset($do) && ($do == 'edcoord' || $do == 'choosepage')) {
263 <form method="post" action="pdf_schema.php3">
264 <input type="hidden" name="server" value="<?php echo $server; ?>" />
265 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
266 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
267 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
268 <input type="hidden" name="pdf_page_number" value="<?php echo $chpage; ?>" />
269 <?php echo $strDisplayPDF; ?>&nbsp;:<br />
270 <input type="checkbox" name="show_grid" id="show_grid_opt" />
271 <label for="show_grid_opt"><?php echo $strShowGrid; ?></label><br />
272 <input type="checkbox" name="show_color" id="show_color_opt" checked="checked" />
273 <label for="show_color_opt"><?php echo $strShowColor; ?></label><br />
274 <input type="checkbox" name="show_table_dimension" id="show_table_dim_opt" />
275 <label for="show_table_dim_opt"><?php echo $strShowTableDimension; ?></label><br />
276 <input type="checkbox" name="all_tab_same_wide" id="all_tab_same_wide" />
277 <label for="all_tab_same_wide"><?php echo $strAllTableSameWidth; ?></label><br />
278 <input type="checkbox" name="with_doc" id="with_doc" checked="checked" />
279 <label for="with_doc"><?php echo $strDataDict; ?></label> <br />
280 <?php echo $strShowDatadictAs; ?>
281 <select name="orientation">
282 <option value="L"><?php echo $strLandscape;?></option>
283 <option value="P"><?php echo $strPortrait;?></option>
284 </select>
285 &nbsp;&nbsp;<input type="submit" value="<?php echo $strGo; ?>" />
286 </form>
287 <?php
288 } // end if
289 } // end if ($cfgRelation['pdfwork'])
293 * Displays the footer
295 echo "\n";
296 require('./footer.inc.php3');