incorrect XHTNL attribute
[phpmyadmin/crack.git] / libraries / select_server.lib.php
blobc5d921162fec82aa9a35f58c847c61bec324df81
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Code for displaying server selection written by nijel
6 * @version $Id$
7 */
9 /**
10 * display server selection in list or selectbox form, or option tags only
12 * @uses $GLOBALS['cfg']['DisplayServersList']
13 * @uses $GLOBALS['strServer']
14 * @uses $GLOBALS['cfg']['Servers']
15 * @uses $GLOBALS['strGo']
16 * @uses implode()
17 * @uses htmlspecialchars()
18 * @uses PMA_generate_common_hidden_inputs()
19 * @uses PMA_generate_common_url()
20 * @param boolean $not_only_options whether to include form tags or not
21 * @param boolean $ommit_fieldset whether to ommit fieldset tag or not
23 function PMA_select_server($not_only_options, $ommit_fieldset)
25 // Show as list?
26 if ($not_only_options) {
27 $list = $GLOBALS['cfg']['DisplayServersList'];
28 $not_only_options =! $list;
29 } else {
30 $list = false;
33 if ($not_only_options) {
34 echo '<form method="post" action="index.php" target="_parent">';
35 echo PMA_generate_common_hidden_inputs();
37 if (! $ommit_fieldset) {
38 echo '<fieldset>';
40 echo '<label for="select_server">' . $GLOBALS['strServer'] . ':</label> ';
42 echo '<select name="server" id="select_server"'
43 . ' onchange="if (this.value != \'\') this.form.submit();">';
44 echo '<option value="">(' . $GLOBALS['strServers'] . ') ...</option>' . "\n";
45 } elseif ($list) {
46 echo $GLOBALS['strServer'] . ':<br />';
47 echo '<ul id="list_server">';
50 foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
51 if (empty($server['host'])) {
52 continue;
55 if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
56 $selected = 1;
57 } else {
58 $selected = 0;
61 if (!empty($server['verbose'])) {
62 $label = $server['verbose'];
63 } else {
64 $label = $server['host'];
65 if (!empty($server['port'])) {
66 $label .= ':' . $server['port'];
69 if (! empty($server['only_db'])) {
70 if (! is_array($server['only_db'])) {
71 $label .= ' - ' . $server['only_db'];
72 // try to avoid displaying a too wide selector
73 } elseif (count($server['only_db']) < 4) {
74 $label .= ' - ' . implode(', ', $server['only_db']);
77 if (!empty($server['user']) && $server['auth_type'] == 'config') {
78 $label .= ' (' . $server['user'] . ')';
81 if ($list) {
82 echo '<li>';
83 if ($selected && !$ommit_fieldset) {
84 echo '<b>' . htmlspecialchars($label) . '</b>';
85 } else {
87 echo '<a class="item" href="index.php'
88 . PMA_generate_common_url(array('server' => $key))
89 . '" target="_top">' . htmlspecialchars($label) . '</a>';
91 echo '</li>';
92 } else {
93 echo '<option value="' . $key . '" '
94 . ($selected ? ' selected="selected"' : '') . '>'
95 . htmlspecialchars($label) . '</option>' . "\n";
97 } // end while
99 if ($not_only_options) {
100 echo '</select>';
101 // Show submit button if we have just one server (this happens with no default)
102 echo '<noscript>';
103 echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
104 echo '</noscript>';
105 if (! $ommit_fieldset) {
106 echo '</fieldset>';
108 echo '</form>';
109 } elseif ($list) {
110 echo '</ul>';