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