~n3npq/lsb/distribution-checker

« back to all changes in this revision

Viewing changes to webui/public_html/tests_admin.pl

  • Committer: biga
  • Date: 2009-06-02 12:23:46 UTC
  • Revision ID: biga@spidey.linux-foundation.org-20090602122346-qf0f7hls7hwtfxoc
VersionĀ 4.0.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
 
75
75
print show_error_dlg($error_text);
76
76
 
 
77
my @proxy_auth_modes = (
 
78
        {'ID' => 'basic', 'NAME' => 'Basic'},
 
79
        {'ID' => 'digest', 'NAME' => 'Digest'},
 
80
        {'ID' => 'ntlm', 'NAME' => 'NTLM'},
 
81
        {'ID' => 'negotiate', 'NAME' => 'GSS-Negotiate'},
 
82
        {'ID' => 'anyauth', 'NAME' => 'Autoselect'},
 
83
);
 
84
 
77
85
print <<DATA;
78
86
<div id="ajax_loading" style="display: none; position: fixed; width: 13em; height: 5.8em; top: 40%; left: 50%; margin-top: -2.9em; margin-left: -7.5em; border: solid 1px #00007f; background-color: #e7f0ff; text-align: center; padding: 6px;"><div align="center">
79
87
Please wait&hellip;<br />
122
130
  </tr>
123
131
  <tr>
124
132
    <td valign="top" width="100%">
125
 
      <table cellpadding="0" cellspacing="0" border="0" width="100%">
126
 
        <tr>
127
 
          <td style="border: solid 1px #606090; background: #e0e0ff; text-align: center; font-size: large; padding: 0.3em;">Server Configuration</td>
128
 
        </tr>
129
 
        <tr>
130
 
          <td style="border: solid 1px #606090; border-top: none; vertical-align: top; padding: 10px;">
131
 
            Proxy server for connecting to the Linux Foundation FTP:<br />
132
 
            <input type="text" name="proxy" id="proxy" value="$SERVER_PARAM{'PROXY'}" style="width: 35em;" onfocus="javascript:style.borderColor=input_border_color;" /><br />
133
 
            <br />
134
 
            <input type="button" name="apply_button" id="apply_button" value="Apply" style="width: 7em;" onclick="javascript:onSettingsApply();" />&nbsp;&nbsp;&nbsp;<input type="button" name="clear_button" id="clear_button" value="Clear" style="width: 7em;" onclick="javascript:onSettingsClear();" /><span id="conf_saved_msg" style="display: none;">&nbsp;&nbsp;&nbsp;<b>Configuration saved</b></span>
135
 
          </td>
136
 
        </tr>
137
 
      </table>
 
133
      <form name="server_config" id="server_config" method="post" action="">
 
134
        <table cellpadding="0" cellspacing="0" border="0" width="100%">
 
135
          <tr>
 
136
            <td style="border: solid 1px #606090; background: #e0e0ff; text-align: center; font-size: large; padding: 0.3em;">Server Configuration</td>
 
137
          </tr>
 
138
          <tr>
 
139
            <td style="border: solid 1px #606090; border-top: none; vertical-align: top; padding: 10px;">
 
140
              Proxy servers for connecting to the Linux Foundation servers:<br />
 
141
              <table cellpadding="2" cellspacing="0" border="0" style="margin-top: 0.3em;">
 
142
DATA
 
143
 
 
144
my $same_proxy_sel = '';
 
145
if ($SERVER_PARAM{'PROXY'} or (!$SERVER_PARAM{'PROXY'} and !$SERVER_PARAM{'HTTP_PROXY'} and !$SERVER_PARAM{'FTP_PROXY'})) {
 
146
        $same_proxy_sel = ' checked="checked"';
 
147
}
 
148
 
 
149
print <<DATA;
 
150
                <tr>
 
151
                  <td colspan="3"><label><input type="checkbox" name="same_proxy_config" id="same_proxy_config"$same_proxy_sel onclick="javascript:onSameProxy();" /> Use one configuration for both HTTP and FTP</label></td>
 
152
                </tr>
 
153
DATA
 
154
 
 
155
foreach my $proto (qw/http ftp/) {
 
156
        my $proto_name = uc($proto);
 
157
        my ($user, $pswd, $host, $port) = ('', '', '', '');
 
158
        my ($user_style, $pswd_style, $host_style, $port_style) = (' display: none;', ' display: none;', ' display: none;', ' display: none;');
 
159
        my ($user_hstyle, $pswd_hstyle, $host_hstyle, $port_hstyle) = ('', '', '', '');
 
160
        my $pswd_wstyle = ' display: none;';
 
161
        if ($SERVER_PARAM{$proto_name.'_PROXY'} =~ m/^(?:([A-Za-z0-9\-_.\@]+)(?::(.*))?\@)?([A-Za-z0-9\-_.]+):(\d+)$/) {
 
162
                if ($1) {
 
163
                        $user = $1;
 
164
                        $user_style = '';
 
165
                        $user_hstyle = ' display: none;';
 
166
                }
 
167
                if ($2) {
 
168
                        $pswd = $2;
 
169
                        $pswd_style = '';
 
170
                        $pswd_hstyle = ' display: none;';
 
171
                        $pswd_wstyle = '';
 
172
                }
 
173
                if ($3) {
 
174
                        $host = $3;
 
175
                        $host_style = '';
 
176
                        $host_hstyle = ' display: none;';
 
177
                }
 
178
                if ($4) {
 
179
                        $port = $4;
 
180
                        $port_style = '';
 
181
                        $port_hstyle = ' display: none;';
 
182
                }
 
183
        }
 
184
 
 
185
        print <<DATA;
 
186
                <tr>
 
187
                  <td rowspan="3" id="${proto}_title" style="vertical-align: top; font-weight: bold; width: 4em; height: 2em;">$proto_name:</td>
 
188
                  <td colspan="2"><input type="text" name="${proto}_proxy_host" id="${proto}_proxy_host" value="$host" style="width: 20em; height: 1.2em;$host_style" /><input type="text" name="${proto}_proxy_host_hint" id="${proto}_proxy_host_hint" value="hostname" style="width: 20em; height: 1.2em; color: #a0a0a0; font-style: italic;$host_hstyle" onfocus="javascript:hideHint(this, '${proto}_proxy_host');" /> <input type="text" name="${proto}_proxy_port" id="${proto}_proxy_port" value="$port" style="width: 5em; height: 1.2em;$port_style" /><input type="text" name="${proto}_proxy_port_hint" id="${proto}_proxy_port_hint" value="port" style="width: 5em; height: 1.2em; color: #a0a0a0; font-style: italic;$port_hstyle" onfocus="javascript:hideHint(this, '${proto}_proxy_port');" /></td>
 
189
                </tr>
 
190
                <tr>
 
191
                  <td rowspan="2" id="${proto}_auth_title" style="vertical-align: top; height: 2em;">Authentication:</td>
 
192
                  <td>
 
193
                    <select name="${proto}_proxy_auth" id="${proto}_proxy_auth" style="width: 13em;">
 
194
DATA
 
195
 
 
196
        my ($proxy_auth, $proxy_auth_notunnel) = split(/,/, $SERVER_PARAM{$proto_name.'_PROXY_AUTH'});
 
197
        foreach my $auth_mode (@proxy_auth_modes) {
 
198
                if ($auth_mode->{'ID'} eq $proxy_auth) {
 
199
                        print "                      <option value=\"$auth_mode->{'ID'}\" selected=\"selected\">$auth_mode->{'NAME'}</option>\n";
 
200
                }
 
201
                else {
 
202
                        print "                      <option value=\"$auth_mode->{'ID'}\">$auth_mode->{'NAME'}</option>\n";
 
203
                }
 
204
        }
 
205
        my $proxy_auth_notunnel_sel = (($proxy_auth_notunnel and ($proxy_auth_notunnel eq 'notunnel')) ? ' checked="checked"' : '');
 
206
 
 
207
        print <<DATA;
 
208
                    </select>
 
209
                    <label><input type="checkbox" name="${proto}_proxy_auth_notunnel" id="${proto}_proxy_auth_notunnel"$proxy_auth_notunnel_sel /> <span id="${proto}_auth_notunnel_title">No tunnelling</span></label>
 
210
                  </td>
 
211
                </tr>
 
212
                <tr>
 
213
                  <td style="height: 2em;"><input type="text" name="${proto}_proxy_user" id="${proto}_proxy_user" value="$user" style="width: 7em; height: 1.2em;$user_style" /><input type="text" name="${proto}_proxy_user_hint" id="${proto}_proxy_user_hint" value="username" style="width: 7em; height: 1.2em; color: #a0a0a0; font-style: italic;$user_hstyle" onfocus="javascript:hideHint(this, '${proto}_proxy_user');" /> <input type="password" name="${proto}_proxy_pswd" id="${proto}_proxy_pswd" value="$pswd" style="width: 7em; height: 1.2em;$pswd_style" onchange="javascript:controlPasswordWarning('$proto');" onkeyup="javascript:controlPasswordWarning('$proto');" /><input type="text" name="${proto}_proxy_pswd_hint" id="${proto}_proxy_pswd_hint" value="password" style="width: 7em; height: 1.2em; color: #a0a0a0; font-style: italic;$pswd_hstyle" onfocus="javascript:hideHint(this, '${proto}_proxy_pswd');" /><img src="images/environment-spacer.gif" alt="" style="width: 0.7em; height: 1.0em;" /><a href="tests_help.pl#password_insecure" target="_blank" id="${proto}_proxy_pswd_warning" style="color: red; text-decoration: underline;$pswd_wstyle">Storing the password is insecure!</a></td>
 
214
                </tr>
 
215
                <tr>
 
216
                  <td><img src="images/environment-spacer.gif" alt="" width="1" height="10" /></td>
 
217
                </tr>
 
218
DATA
 
219
 
 
220
}
 
221
 
 
222
print <<DATA;
 
223
              </table>
 
224
              <br />
 
225
              <input type="button" name="apply_button" id="apply_button" value="Apply" style="width: 7em;" onclick="javascript:onSettingsApply();" />&nbsp;&nbsp;&nbsp;<input type="button" name="clear_button" id="clear_button" value="Clear" style="width: 7em;" onclick="javascript:onSettingsClear();" /><span id="conf_saved_msg" style="display: none;">&nbsp;&nbsp;&nbsp;<b>Configuration saved</b></span>
 
226
            </td>
 
227
          </tr>
 
228
        </table>
 
229
      </form>
138
230
    </td>
139
231
  </tr>
140
232
</table>
145
237
preload_images(new Array('expand.png', 'collapse.png', 'ajax_progress.gif'));
146
238
var input_border_color = ((navigator.appName == 'Konqueror') ? '#cccccc' : '');
147
239
 
 
240
// Work with "hint-boxes" (text boxes with "ghost" hint text inside)
 
241
function hideHint(hint_elem, id) {
 
242
        var elem = document.getElementById(id);
 
243
        if (!elem)
 
244
                return;
 
245
        hint_elem.style.display = 'none';
 
246
        elem.style.display = '';
 
247
        // Konqueror cannot set focus immediately for unknown reason. Oh, well, give him some time to think...
 
248
        setTimeout('document.getElementById(\\'' + id + '\\').focus()', 10);
 
249
}
 
250
 
 
251
var saved_control_values = new Array();
 
252
 
 
253
function onSameProxy() {
 
254
        var elem = document.getElementById('same_proxy_config');
 
255
        if (!elem)
 
256
                return;
 
257
        var make_disabled = elem.checked;
 
258
        // TODO: Get rid of plain enumeration (?)
 
259
        var gray_out = new Array('ftp_title', 'ftp_auth_title', 'ftp_auth_notunnel_title');
 
260
        var disable = new Array('ftp_proxy_host', 'ftp_proxy_port', 'ftp_proxy_auth', 'ftp_proxy_auth_notunnel', 'ftp_proxy_user', 'ftp_proxy_pswd');
 
261
        for (var i in gray_out) {
 
262
                document.getElementById(gray_out[i]).style.color = (make_disabled ? 'gray' : 'black');
 
263
        }
 
264
        for (var i in disable) {
 
265
                var id = disable[i];
 
266
                elem = document.getElementById(id);
 
267
                if (elem) {
 
268
                        elem.disabled = make_disabled;
 
269
                        if (make_disabled) {
 
270
                                saved_control_values[id] = elem.value;
 
271
                                elem.value = '';
 
272
                        }
 
273
                        else {
 
274
                                elem.value = saved_control_values[id];
 
275
                        }
 
276
                }
 
277
                var id_hint = id + '_hint';
 
278
                elem = document.getElementById(id_hint);
 
279
                if (elem) {
 
280
                        elem.disabled = make_disabled;
 
281
                        if (make_disabled) {
 
282
                                saved_control_values[id_hint] = elem.value;
 
283
                                elem.value = '';
 
284
                        }
 
285
                        else {
 
286
                                elem.value = saved_control_values[id_hint];
 
287
                        }
 
288
                }
 
289
        }
 
290
        controlPasswordWarning('ftp');
 
291
}
 
292
 
 
293
function controlPasswordWarning(proto) {
 
294
        var pswd = document.getElementById(proto + '_proxy_pswd');
 
295
        document.getElementById(proto + '_proxy_pswd_warning').style.display = ((pswd.value == '') ? 'none' : '');
 
296
}
 
297
 
 
298
DATA
 
299
 
 
300
print "onSameProxy();\n\n" if ($same_proxy_sel);
 
301
 
 
302
print <<DATA;
148
303
// AJAX
149
304
function onStopServer(pid, what) {
150
305
        if (!ajax_req_busy) {
156
311
 
157
312
function onSettingsApply() {
158
313
        if (!ajax_req_busy) {
159
 
                var elem = document.getElementById('proxy');
160
 
                if (!elem)
161
 
                        return;
162
 
                if ((elem.value != '') && (elem.value.search(/^[A-Za-z0-9\\-_.]+:\\d+\$/) != 0)) {
163
 
                        elem.style.borderColor = 'red';
164
 
                        alert('Invalid format for proxy. Should be host:port.');
165
 
                        return;
166
 
                }
167
 
                ajax_call_get('action=server_control&proxy=' + encodeURIComponent(elem.value));
 
314
                ajax_call_post('action=server_control', 'server_config');
168
315
        }
169
316
}
170
317