bug #1455373, CONVERT not in reserved words
[phpmyadmin/crack.git] / browse_foreigners.php
bloba03e8e67e959ed0f69ce6405a1544290a6d5ae93
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4 /**
5 * display selection for relational field values
6 */
8 /**
9 * Gets a core script and starts output buffering work
11 require_once('./libraries/common.lib.php');
13 PMA_checkParameters(array('db', 'table', 'field'));
15 require_once('./libraries/ob.lib.php');
16 if ($cfg['OBGzip']) {
17 $ob_mode = PMA_outBufferModeGet();
18 if ($ob_mode) {
19 PMA_outBufferPre($ob_mode);
22 require_once('./libraries/header_http.inc.php');
23 $field = urldecode($field);
25 /**
26 * Displays the frame
28 $per_page = 200;
29 require_once('./libraries/relation.lib.php'); // foreign keys
30 require_once('./libraries/transformations.lib.php'); // Transformations
31 $cfgRelation = PMA_getRelationsParam();
32 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
34 $override_total = TRUE;
36 if (!isset($pos)) {
37 $pos = 0;
40 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' ';
41 if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
42 unset($foreign_limit);
45 require('./libraries/get_foreign.lib.php');
47 if (isset($pk)) {
48 $pk_uri = '&amp;pk=' . urlencode($pk);
50 <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
51 <?php
52 } else {
53 $pk_uri = '';
56 $gotopage = '';
57 $showall = '';
59 if (isset($disp_row) && is_array($disp_row)) {
60 $count = count( $disp_row );
62 if ( $cfg['ShowAll'] && ($count > $per_page) ) {
63 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
66 $session_max_rows = $per_page;
67 $pageNow = @floor($pos / $session_max_rows) + 1;
68 $nbTotalPage = @ceil($count / $session_max_rows);
70 if ( $count > $per_page ) {
71 $gotopage = PMA_pageselector(
72 'browse_foreigners.php?field=' . urlencode($field) .
73 '&amp;' . PMA_generate_common_url($db, $table)
74 . $pk_uri .
75 '&amp;fieldkey=' . (isset($fieldkey) ? $fieldkey : '') .
76 '&amp;foreign_filter=' . (isset($foreign_filter) ? htmlspecialchars($foreign_filter) : '') .
77 '&amp;',
78 $session_max_rows,
79 $pageNow,
80 $nbTotalPage
85 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
86 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
87 <html xmlns="http://www.w3.org/1999/xhtml"
88 xml:lang="<?php echo $available_languages[$lang][2]; ?>"
89 lang="<?php echo $available_languages[$lang][2]; ?>"
90 dir="<?php echo $text_dir; ?>">
92 <head>
93 <title>phpMyAdmin</title>
94 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
95 <link rel="stylesheet" type="text/css"
96 href="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url( '', '' ); ?>&amp;js_frame=right" />
97 <script src="./js/functions.js" type="text/javascript" language="javascript"></script>
98 <script type="text/javascript" language="javascript">
99 //<![CDATA[
100 self.focus();
101 function formupdate( field, key ) {
102 if (opener && opener.document && opener.document.insertForm) {
103 var field = 'field_' + field;
105 <?php if ( isset( $pk ) ) { ?>
106 var element_name = field + '[multi_edit][<?php echo urlencode( $pk ); ?>][]';
107 <?php } else { ?>
108 var element_name = field + '[]';
109 <?php } ?>
111 <?php if ( isset( $fieldkey ) ) { ?>
112 var element_name_alt = field + '[<?php echo $fieldkey; ?>]';
113 <?php } else { ?>
114 var element_name_alt = field + '[0]';
115 <?php } ?>
117 if (opener.document.insertForm.elements[element_name]) {
118 // Edit/Insert form
119 opener.document.insertForm.elements[element_name].value = key;
120 self.close();
121 return false;
122 } else if (opener.document.insertForm.elements[element_name_alt]) {
123 // Search form
124 opener.document.insertForm.elements[element_name_alt].value = key;
125 self.close();
126 return false;
130 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
132 //]]>
133 </script>
134 </head>
136 <body id="body_browse_foreigners">
138 <form action="browse_foreigners.php" method="post">
139 <fieldset>
140 <?php echo PMA_generate_common_hidden_inputs( $db, $table ); ?>
141 <input type="hidden" name="field" value="<?php echo urlencode($field); ?>" />
142 <input type="hidden" name="fieldkey"
143 value="<?php echo isset($fieldkey) ? $fieldkey : ''; ?>" />
144 <?php if ( isset( $pk ) ) { ?>
145 <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
146 <?php } ?>
147 <span class="formelement">
148 <label for="input_foreign_filter"><?php echo $strSearch . ':'; ?></label>
149 <input type="text" name="foreign_filter" id="input_foreign_filter"
150 value="<?php echo isset($foreign_filter) ? htmlspecialchars($foreign_filter) : ''; ?>" />
151 <input type="submit" name="submit_foreign_filter" value="<?php echo $strGo;?>" />
152 </span>
153 <span class="formelement">
154 <?php echo $gotopage; ?>
155 </span>
156 <span class="formelement">
157 <?php echo $showall; ?>
158 </span>
159 </fieldset>
160 </form>
162 <table width="100%">
163 <?php
164 if (isset($disp_row) && is_array($disp_row)) {
165 $header = '<tr>
166 <th>' . $strKeyname . '</th>
167 <th>' . $strDescription . '</th>
168 <td width="20%"></td>
169 <th>' . $strDescription . '</th>
170 <th>' . $strKeyname . '</th>
171 </tr>';
173 echo '<thead>' . $header . '</thead>' . "\n"
174 .'<tfoot>' . $header . '</tfoot>' . "\n"
175 .'<tbody>' . "\n";
177 $values = array();
178 $keys = array();
179 foreach ( $disp_row as $relrow ) {
180 if ($foreign_display != FALSE) {
181 $values[] = $relrow[$foreign_display];
182 } else {
183 $values[] = '';
186 $keys[] = $relrow[$foreign_field];
189 asort( $keys );
191 $hcount = 0;
192 $odd_row = true;
193 $val_ordered_current_row = 0;
194 $val_ordered_current_equals_data = false;
195 $key_ordered_current_equals_data = false;
196 foreach ( $keys as $key_ordered_current_row => $value ) {
197 //for ( $i = 0; $i < $count; $i++ ) {
198 $hcount++;
200 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
201 echo $header;
202 $hcount = 0;
203 $odd_row = true;
206 $key_ordered_current_key = $keys[$key_ordered_current_row];
207 $key_ordered_current_val = $values[$key_ordered_current_row];
209 $val_ordered_current_key = $keys[$val_ordered_current_row];
210 $val_ordered_current_val = $values[$val_ordered_current_row];
212 $val_ordered_current_row++;
214 if (PMA_strlen( $val_ordered_current_val ) <= $cfg['LimitChars']) {
215 $val_ordered_current_val = htmlspecialchars($val_ordered_current_val);
216 $val_ordered_current_val_title = '';
217 } else {
218 $val_ordered_current_val_title =
219 htmlspecialchars( $val_ordered_current_val );
220 $val_ordered_current_val =
221 htmlspecialchars( PMA_substr( $val_ordered_current_val, 0,
222 $cfg['LimitChars'] ) . '...' );
224 if (PMA_strlen( $key_ordered_current_val ) <= $cfg['LimitChars']) {
225 $key_ordered_current_val = htmlspecialchars($key_ordered_current_val);
226 $key_ordered_current_val_title = '';
227 } else {
228 $key_ordered_current_val_title =
229 htmlspecialchars( $key_ordered_current_val );
230 $key_ordered_current_val =
231 htmlspecialchars( PMA_substr( $key_ordered_current_val, 0,
232 $cfg['LimitChars'] ) . '...' );
235 if ( ! empty( $data ) ) {
236 $val_ordered_current_equals_data = $val_ordered_current_key == $data;
237 $key_ordered_current_equals_data = $key_ordered_current_key == $data;
241 <tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
242 <td nowrap="nowrap">
243 <?php
244 echo ($key_ordered_current_equals_data ? '<b>' : '')
245 .'<a href="#" title="' . $strUseThisValue
246 . ($key_ordered_current_val_title != '' ? ': ' . $key_ordered_current_val_title : '') . '"'
247 .' onclick="formupdate(\'' . md5($field) . '\', \''
248 . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
249 .htmlspecialchars($key_ordered_current_key) . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
250 ?></td>
251 <td>
252 <?php
253 echo ($key_ordered_current_equals_data ? '<b>' : '')
254 . '<a href="#" title="' . $strUseThisValue . ($key_ordered_current_val_title != '' ? ': '
255 . $key_ordered_current_val_title : '') . '" onclick="formupdate(\''
256 . md5($field) . '\', \'' . htmlspecialchars($key_ordered_current_key) . '\'); return false;">'
257 . $key_ordered_current_val . '</a>' . ($key_ordered_current_equals_data ? '</b>' : '');
258 ?></td>
259 <td width="20%">
260 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
261 alt="" width="1" height="1"></td>
263 <td>
264 <?php
265 echo ($val_ordered_current_equals_data ? '<b>' : '')
266 . '<a href="#" title="' . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': '
267 . $val_ordered_current_val_title : '') . '" onclick="formupdate(\'' . md5($field)
268 . '\', \'' . htmlspecialchars($val_ordered_current_key) . '\'); return false;">'
269 . $val_ordered_current_val . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
270 ?></td>
271 <td nowrap="nowrap">
272 <?php
273 echo ($val_ordered_current_equals_data ? '<b>' : '') . '<a href="#" title="'
274 . $strUseThisValue . ($val_ordered_current_val_title != '' ? ': ' . $val_ordered_current_val_title : '')
275 . '" onclick="formupdate(\'' . md5($field) . '\', \''
276 . htmlspecialchars($val_ordered_current_key) . '\'); return false;">' . htmlspecialchars($val_ordered_current_key)
277 . '</a>' . ($val_ordered_current_equals_data ? '</b>' : '');
278 ?></td>
279 </tr>
280 <?php
281 } // end while
284 </tbody>
285 </table>
287 </body>
288 </html>
290 <?php
292 * Close MySql connections
294 if (isset($controllink) && $controllink) {
295 @PMA_DBI_close($controllink);
297 if (isset($userlink) && $userlink) {
298 @PMA_DBI_close($userlink);
303 * Sends bufferized data
305 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
306 && isset($ob_mode) && $ob_mode) {
307 PMA_outBufferPost($ob_mode);