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