bug #1233349 db search in MySQL 5.0.x on fields without a charset
[phpmyadmin/crack.git] / browse_foreigners.php
blob1b05088184ee45a24dd6dc14e57645563fa2acb9
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 /**
6 * Get the variables sent or posted to this script and displays the header
7 */
8 require_once('./libraries/grab_globals.lib.php');
10 /**
11 * Gets a core script and starts output buffering work
13 require_once('./libraries/common.lib.php');
15 PMA_checkParameters(array('db', 'table', 'field'));
17 require_once('./libraries/ob.lib.php');
18 if ($cfg['OBGzip']) {
19 $ob_mode = PMA_outBufferModeGet();
20 if ($ob_mode) {
21 PMA_outBufferPre($ob_mode);
24 require_once('./libraries/header_http.inc.php');
25 $field = urldecode($field);
27 /**
28 * Displays the frame
30 // Gets the font sizes to use
31 PMA_setFontSizes();
33 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
34 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
35 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $available_languages[$lang][2]; ?>" lang="<?php echo $available_languages[$lang][2]; ?>" dir="<?php echo $text_dir; ?>">
37 <head>
38 <title>phpMyAdmin</title>
39 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
40 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> />
41 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&amp;js_frame=right" />
42 <script src="libraries/functions.js" type="text/javascript" language="javascript"></script>
43 <script type="text/javascript" language="javascript">
44 self.focus();
45 function formupdate(field, key) {
46 if (opener && opener.document && opener.document.insertForm) {
47 if (opener.document.insertForm.elements['field_' + field + '<?php echo (isset($pk) ? '[multi_edit][' . urlencode($pk) . ']' : ''); ?>[]']) {
48 // Edit/Insert form
49 opener.document.insertForm.elements['field_' + field + '<?php echo (isset($pk) ? '[multi_edit][' . urlencode($pk) . ']' : ''); ?>[]'].value = key;
50 self.close();
51 return false;
52 } else if (opener.document.insertForm.elements['field_' + field + '[<?php echo isset($fieldkey) ? $fieldkey : 0; ?>]']) {
53 // Search form
54 opener.document.insertForm.elements['field_' + field + '[<?php echo isset($fieldkey) ? $fieldkey : 0; ?>]'].value = key;
55 self.close();
56 return false;
60 alert('<?php echo PMA_jsFormat($strWindowNotFound); ?>');
62 </script>
63 </head>
65 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>" style="margin-left: 5px; margin-top: 5px; margin-right: 5px; margin-bottom: 0px">
66 <?php
67 $per_page = 200;
68 require_once('./libraries/relation.lib.php'); // foreign keys
69 require_once('./libraries/transformations.lib.php'); // Transformations
70 $cfgRelation = PMA_getRelationsParam();
71 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
73 $override_total = TRUE;
75 if (!isset($pos)) {
76 $pos = 0;
79 $foreign_limit = 'LIMIT ' . $pos . ', ' . $per_page . ' ';
80 if (isset($foreign_navig) && $foreign_navig == $strShowAll) {
81 unset($foreign_limit);
84 require('./libraries/get_foreign.lib.php');
87 <form action="browse_foreigners.php" method="post">
88 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
89 <input type="hidden" name="field" value="<?php echo urlencode($field); ?>" />
90 <input type="hidden" name="field" value="<?php echo isset($fieldkey) ? $fieldkey : ''; ?>" />
91 <?php
92 if (isset($pk)) {
93 $pk_uri = '&amp;pk=' . urlencode($pk);
95 <input type="hidden" name="pk" value="<?php echo urlencode($pk); ?>" />
96 <?php
97 } else {
98 $pk_uri = '&amp;';
102 <table width="100%">
103 <?php
104 if ($cfg['ShowAll'] && ($the_total > $per_page)) {
105 $showall = '<input type="submit" name="foreign_navig" value="' . $strShowAll . '" />';
106 } else {
107 $showall = '';
110 $session_max_rows = $per_page;
111 $pageNow = @floor($pos / $session_max_rows) + 1;
112 $nbTotalPage = @ceil($the_total / $session_max_rows);
114 if ($the_total > $per_page) {
115 $gotopage = PMA_pageselector(
116 'browse_foreigners.php?field=' . urlencode($field) .
117 '&amp;' . PMA_generate_common_url($db, $table)
118 . $pk_uri .
119 '&amp;fieldkey=' . (isset($fieldkey) ? $fieldkey : '') .
120 '&amp;',
121 $session_max_rows,
122 $pageNow,
123 $nbTotalPage
125 } else {
126 $gotopage = '';
129 $header = ' <tr>
130 <th align="left" nowrap="nowrap">' . $strKeyname . '</th>
131 <th>' . $strDescription . '</th>
132 <td align="center" width="20%" valign="top">
133 ' . $showall . '
134 ' . $gotopage . '
135 </td>
136 <th>' . $strDescription . '</th>
137 <th align="left" nowrap="nowrap">' . $strKeyname . '</th>
138 </tr>';
140 echo $header;
142 if (isset($disp_row) && is_array($disp_row)) {
143 function dimsort($arrayA, $arrayB) {
144 $keyA = key($arrayA);
145 $keyB = key($arrayB);
147 if ($arrayA[$keyA] == $arrayB[$keyB]) {
148 return 0;
151 return ($arrayA[$keyA] < $arrayB[$keyB]) ? -1 : 1;
154 $mysql_key_relrow = array();
155 $mysql_val_relrow = array();
156 $count = 0;
157 foreach ($disp_row AS $disp_row_key => $relrow) {
158 if ($foreign_display != FALSE) {
159 $val = $relrow[$foreign_display];
160 } else {
161 $val = '';
164 $mysql_key_relrow[$count] = array($relrow[$foreign_field] => $val);
165 $mysql_val_relrow[$count] = array($val => $relrow[$foreign_field]);
166 $count++;
169 usort($mysql_val_relrow, 'dimsort');
171 $hcount = 0;
172 for ($i = 0; $i < $count; $i++) {
173 $hcount++;
174 $bgcolor = ($hcount % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
176 if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
177 echo $header;
178 $hcount = -1;
182 $val = key($mysql_val_relrow[$i]);
183 $key = $mysql_val_relrow[$i][$val];
185 if (PMA_strlen($val) <= $cfg['LimitChars']) {
186 $value = htmlspecialchars($val);
187 $vtitle = '';
188 } else {
189 $vtitle = htmlspecialchars($val);
190 $value = htmlspecialchars(PMA_substr($val, 0, $cfg['LimitChars']) . '...');
193 $key_equals_data = isset($data) && $key == $data;
195 <tr>
196 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>"><?php echo ($key_equals_data ? '<b>' : '') . '<a href="#" title="' . $strUseThisValue . ($vtitle != '' ? ': ' . $vtitle : '') . '" onclick="formupdate(\'' . md5($field) . '\', \'' . htmlspecialchars($key) . '\'); return false;">' . htmlspecialchars($key) . '</a>' . ($key_equals_data ? '</b>' : ''); ?></td>
197 <td bgcolor="<?php echo $bgcolor; ?>"><?php echo ($key_equals_data ? '<b>' : '') . '<a href="#" title="' . $strUseThisValue . ($vtitle != '' ? ': ' . $vtitle : '') . '" onclick="formupdate(\'' . md5($field) . '\', \'' . htmlspecialchars($key) . '\'); return false;">' . $value . '</a>' . ($key_equals_data ? '</b>' : ''); ?></td>
198 <td width="20%"><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" alt="" width="1" height="1"></td>
199 <?php
200 $key = key($mysql_key_relrow[$i]);
201 $val = $mysql_key_relrow[$i][$key];
202 if (PMA_strlen($val) <= $cfg['LimitChars']) {
203 $value = htmlspecialchars($val);
204 $vtitle = '';
205 } else {
206 $vtitle = htmlspecialchars($val);
207 $value = htmlspecialchars(PMA_substr($val, 0, $cfg['LimitChars']) . '...');
210 $key_equals_data = isset($data) && $key == $data;
212 <td bgcolor="<?php echo $bgcolor; ?>"><?php echo ($key_equals_data ? '<b>' : '') . '<a href="#" title="' . $strUseThisValue . ($vtitle != '' ? ': ' . $vtitle : '') . '" onclick="formupdate(\'' . md5($field) . '\', \'' . htmlspecialchars($key) . '\'); return false;">' . $value . '</a>' . ($key_equals_data ? '</b>' : ''); ?></td>
213 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>"><?php echo ($key_equals_data ? '<b>' : '') . '<a href="#" title="' . $strUseThisValue . ($vtitle != '' ? ': ' . $vtitle : '') . '" onclick="formupdate(\'' . md5($field) . '\', \'' . htmlspecialchars($key) . '\'); return false;">' . htmlspecialchars($key) . '</a>' . ($key_equals_data ? '</b>' : ''); ?></td>
214 </tr>
215 <?php
216 unset($key_equals_data);
217 } // end while
220 echo $header;
222 </table>
223 </form>
225 </body>
226 </html>
228 <?php
230 * Close MySql connections
232 if (isset($dbh) && $dbh) {
233 @PMA_DBI_close($dbh);
235 if (isset($userlink) && $userlink) {
236 @PMA_DBI_close($userlink);
241 * Sends bufferized data
243 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
244 && isset($ob_mode) && $ob_mode) {
245 PMA_outBufferPost($ob_mode);