~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/console/console.js

  • Committer: wagrant
  • Date: 2008-12-23 01:58:44 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1063
Set PATH_INFO and PATH_TRANSLATED properly for student CGI scripts.

If the requested path doesn't exist, interpretservice now traverses up the
directory tree until it finds a prefix of the path that does exist. If we are
allowed to execute that path, we do so, giving it the trimmed bits in
PATH_INFO. If execution is not permissible, we 404 anyway.

Fixes [ 2094777 ] Serve: Allow path after CGI script

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
            tmp_path.pop();
82
82
            path = path_join("/home", tmp_path.join('/'));
83
83
        }
84
 
        ajax_call(callback1, "console", "service", {"ivle.op": "start", "cwd": path}, "POST");
 
84
        ajax_call(callback1, "consoleservice", "start", {"startdir": path}, "POST");
85
85
    }
86
86
    else
87
87
    {
88
88
        // No current_path - let the server decide
89
 
        ajax_call(callback1, "console", "service", {"ivle.op": "start"}, "POST");
 
89
        ajax_call(callback1, "consoleservice", "start", {}, "POST");
90
90
    }
91
91
}
92
92
 
254
254
 
255
255
    if (typeof(inputbox) == "string")
256
256
    {
257
 
        var inputline = inputbox + "\n";
 
257
        var inputline = inputbox;
258
258
        inputbox = null;
 
259
        var graytimer = null;
259
260
    }
260
261
    else
261
262
    {
262
 
        /* Disable the text box */
263
 
        inputbox.setAttribute("disabled", "disabled");
264
 
 
 
263
        GLOBAL_inputbox = inputbox;     /* For timer */
265
264
        var inputline = inputbox.value + "\n";
 
265
        var graytimer = setTimeout("GLOBAL_inputbox.setAttribute(\"class\", "
 
266
            + "\"disabled\");", 100);
266
267
    }
267
268
    var output = document.getElementById("console_output");
268
269
    {
269
270
        // Print ">>>" span
270
271
        var span = document.createElement("span");
271
272
        span.setAttribute("class", "inputPrompt");
272
 
        span.appendChild(document.createTextNode(
273
 
              document.getElementById("console_prompt").firstChild.nodeValue)
274
 
                        );
 
273
        span.appendChild(document.createTextNode(">>> "));
275
274
        output.appendChild(span);
276
275
        // Print input line itself in a span
277
276
        var span = document.createElement("span");
279
278
        span.appendChild(document.createTextNode(inputline));
280
279
        output.appendChild(span);
281
280
    }
282
 
    var args = {"ivle.op": "chat", "kind": which, "key": server_key, "text":inputline};
 
281
    var args = {"key": server_key, "text":inputline};
283
282
    var callback = function(xhr)
284
283
        {
285
 
            console_response(inputbox, inputline, xhr.responseText);
 
284
            console_response(inputbox, graytimer, inputline, xhr.responseText);
286
285
        }
287
 
    ajax_call(callback, "console", "service", args, "POST");
 
286
    /* Disable the text box */
 
287
    if (inputbox != null)
 
288
        inputbox.setAttribute("disabled", "disabled");
 
289
    ajax_call(callback, "consoleservice", which, args, "POST");
288
290
}
289
291
 
290
 
function console_response(inputbox, inputline, responseText)
 
292
function console_response(inputbox, graytimer, inputline, responseText)
291
293
{
292
294
    try
293
295
    {
346
348
        }
347
349
        var callback = function(xhr)
348
350
            {
349
 
                console_response(inputbox, null, xhr.responseText);
 
351
                console_response(inputbox, graytimer,
 
352
                                 null, xhr.responseText);
350
353
            }
351
354
        if (interrupted)
352
355
        {
356
359
        {
357
360
            var kind = "chat";
358
361
        }
359
 
        var args = {"ivle.op": "chat", "kind": kind, "key": server_key, "text":''};
360
 
        ajax_call(callback, "console", "service", args, "POST");
 
362
        var args = {"key": server_key, "text":''};
 
363
        ajax_call(callback, "consoleservice", kind, args, "POST");
361
364
 
362
365
        // Open up the console so we can see the output
363
366
        // FIXME: do we need to maximize here?
378
381
    if (inputbox != null)
379
382
    {
380
383
        /* Re-enable the text box */
 
384
        clearTimeout(graytimer);
381
385
        inputbox.removeAttribute("disabled");
 
386
        inputbox.removeAttribute("class");
382
387
        interrupted = false;
383
388
    }
384
389
 
463
468
    }
464
469
    else
465
470
    {
466
 
        xhr = ajax_call(null, "console", "service", {"ivle.op": "chat", "kind": "terminate", "key": server_key}, "POST");
467
 
        console_response(null, null, xhr.responseText);
 
471
        xhr = ajax_call(null, "consoleservice", "restart", {"key": server_key}, "POST");
 
472
        console_response(null, null, null, xhr.responseText);
468
473
    }
469
474
}
470
475