Passed
Push — master ( 545bfd...abc97e )
by Stefan
02:21
created
Labels
Severity
1
<?php
2
/*
3
Copyright (C) 2014-2015 Universitätsbibliothek Mannheim
4
See file LICENSE for license details.
5
6
Authors: Alexander Wagner, Stefan Weil, Dennis Müller
7
8
References:
9
10
File upload (general)
11
12
* http://www.php.net/manual/en/features.file-upload.post-method.php
13
14
File upload with dropzone
15
16
* http://www.dropzonejs.com/
17
* http://www.startutorial.com/articles/view/how-to-build-a-file-upload-form-using-dropzonejs-and-php
18
* http://maxoffsky.com/code-blog/howto-ajax-multiple-file-upload-in-laravel/
19
20
Websockets:
21
22
* https://en.wikipedia.org/wiki/Server-sent_events
23
* https://developer.mozilla.org/en-US/docs/WebSockets/Writing_WebSocket_client_applications
24
* http://code.google.com/p/phpwebsocket/
25
* http://dharman.eu/?menu=phpWebSocketsTutorial
26
27
Keyboard input
28
29
* http://jsfiddle.net/angusgrant/E3tE6/
30
* http://stackoverflow.com/questions/3181648/how-can-i-handle-arrowkeys-and-greater-than-in-a-javascript-function-which
31
* http://stackoverflow.com/questions/5597060/detecting-arrow-key-presses-in-javascript
32
* http://www.quirksmode.org/js/keys.html
33
34
Key symbols
35
36
* http://www.tcl.tk/man/tcl8.4/TkCmd/keysyms.htm
37
38
* wmctrl, suckless-tools (lsw, sprop, wmname, ...)
39
40
* display.im6, evince
41
42
Authorization
43
44
* http://aktuell.de.selfhtml.org/artikel/php/loginsystem/
45
46
Overlays
47
48
* http://answers.oreilly.com/topic/1823-adding-a-page-overlay-in-javascript/
49
50
*/
51
52
    session_start();
53
if (isset($_REQUEST['monitor'])) {
54
    $monitor = $_REQUEST['monitor'];
55
    $_SESSION['monitor'] = $monitor;
56
} elseif (!isset($_SESSION['monitor'])) {
57
    $_SESSION['monitor'] = '???';
58
}
59
    $_SESSION['referer'] = 'index.php';
60
    require_once('auth.php');
61
62
    // Connect to database and get configuration constants.
63
    require_once('DBConnector.class.php');
64
    $dbcon = new palma\DBConnector();
65
66
    // Support localisation.
67
    require_once('i12n.php');
68
69
    $user = false;
70
if (isset($_SESSION['username'])) {
71
    # PHP session based authorization.
72
    $username = $_SESSION['username'];
73
    $address = $_SESSION['address'];
74
    $user = "$username@$address";
75
} elseif (isset($_SERVER['PHP_AUTH_USER'])) {
76
    # .htaccess basic authorization.
77
    $user = $_SERVER['PHP_AUTH_USER'];
78
}
79
80
    require_once('globals.php');
81
    /*
82
     * file paths for vnc downloads
83
     */
84
    $winvnc = CONFIG_START_URL . "theme/" . CONFIG_THEME . "/winvnc-palma.exe";
85
    $macvnc = CONFIG_START_URL . "theme/" . CONFIG_THEME . "/osx-vnc.dmg";
86
    $linuxsh = CONFIG_START_URL . "theme/" . CONFIG_THEME . "/x11.sh";
87
88
?>
89
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
90
       "http://www.w3.org/TR/html4/strict.dtd">
91
92
<html>
93
94
<head>
95
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
96
<meta name="viewport" content="width=device-width, initial-scale=1">
97
<title>PalMA</title>
98
99
<link rel="icon" href="theme/<?=CONFIG_THEME?>/favicon.ico" type="image/x-icon">
100
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
101
<link rel="stylesheet" href="pure-min.css">
102
<link rel="stylesheet" href="palma.css" type="text/css">
103
104
<script type="text/javascript" src="jquery.min.js"></script>
105
106
<script src="dropzone.min.js"></script>
107
<link
108
  rel="stylesheet"
109
  href="dropzone.min.css"
110
  type="text/css"
111
/>
112
113
<script type="text/javascript">
114
115
// Screen section which responds to keyboard input.
116
var focus_section = '1';
117
118
function sendToNuc(command) {
119
  var xmlHttp = new XMLHttpRequest();
120
  if (!xmlHttp) {
121
    // TODO
122
    alert('XMLHttpRequest failed!');
123
    return;
124
  }
125
  var url = 'control.php?' + command;
126
  var response = "";
127
  xmlHttp.open("get", url, true);
128
  xmlHttp.onreadystatechange = function () {
129
      if (xmlHttp.readyState == 1) {
130
          // Server connection established (IE only).
131
      } else if (xmlHttp.readyState == 2) {
132
          // Data transferred to server.
133
      } else if (xmlHttp.readyState == 3) {
134
          // Server is answering.
135
      } else if (xmlHttp.readyState == 4) {
136
          // Received all data from server.
137
          return xmlHttp.responseText;
138
      } else {
139
          alert("Got xmlHttp.readyState " + xmlHttp.readyState);
140
      }
141
  };
142
  xmlHttp.send(null);
143
  //~ alert("sendToNuc " + url);
144
}
145
146
function keyControl(number, image, controlClass, key, handler, disabled, title) {
147
    // "number" refers to the slected screensection
148
149
  var keyHandler = getHandlerCommand(handler, key);
150
  if ( (keyHandler == "") || (keyHandler == null) ) {
151
    keyHandler = "default";
152
  }
153
  var button = document.createElement('button');
154
  var icon = document.createElement('i');
155
  if (!disabled) {
156
    icon.setAttribute('class', image);
157
    button.appendChild(icon);
158
    button.setAttribute('class', controlClass);
159
    button.setAttribute('onmousedown',
160
                     'sendToNuc("window=' + number + '&keydown=' + encodeURIComponent(keyHandler) + '")');
161
    button.setAttribute('onmouseup',
162
                     'sendToNuc("window=' + number + '&keyup=' + encodeURIComponent(keyHandler) + '")');
163
    button.setAttribute('title', title);
164
  } else {
165
    icon.setAttribute('class', image + " unavailable");
166
    button.appendChild(icon);
167
    button.setAttribute("class", "unavailable");
168
    button.setAttribute('title', title + " " + "<?=addslashes(__('not available'))?>");
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

168
    button.setAttribute('title', title + " " + "<?=addslashes(/** @scrutinizer ignore-call */ __('not available'))?>");
Loading history...
169
  }
170
  return button;
171
}
172
173
function downloadFile(screensection) {
174
175
    // wrong path if copied to /home/directory
176
    // TODO: check file and path
177
178
   var url = document.URL;
179
   var url_path = url.split("/");
180
181
   var file = document.getElementById("file" + screensection).innerHTML;
182
   var file = document.getElementById("file" + screensection).getAttribute("title");
183
184
   // Download with download.php
185
   var download = url_path[0]+"/"+url_path[1]+"/"+url_path[2]+"/"+url_path[3]+"/download.php?file="+encodeURIComponent(file);
186
187
   var name = "Download";
188
189
   if(file.indexOf("www.") > -1) {
190
        window.open(file, name);
191
   } else {
192
        window.open(download, name);
193
    }
194
}
195
196
function is_valid_url(url)
197
{
198
    return url.match(/(^(ht|f)tps?:\/\/)([a-zA-Z0-9\.-])+(\.([a-zA-Z]{2,}))?(\:([0-9]{1,5}))?(\/([^\s\<\>\,\{\}\\\|\^\[\]\'])*)?$/);
199
}
200
201
function urlToNuc() {
202
    var url = document.getElementById('url_field').value;
203
    if (is_valid_url(url)) {
204
        // Encode special characters
205
        url = encodeURIComponent(url);
206
        sendToNuc('openURL='+url);
207
    } else {
208
        var urlfield = document.getElementById('url_field');
209
        urlfield.setAttribute('value', '<?=addslashes(__("Enter valid URL"))?>');
210
    }
211
212
    setTimeout(function(){location.reload()}, 1000);
213
}
214
215
function showLayout(layout, controls, window) {
216
    //~ console.log("Layout: " + layout);
217
    //~ for (i = 0; i < controls.length; i++) {
218
    //~     console.log("SL " + i + ": " + controls[i]);
219
    //~ }
220
221
    document.onkeydown = function(evt) {
222
        evt = evt || window.event;
223
        var section = focus_section;
224
        var handler = controls[focus_section][0];
225
        var keyHandler;
226
        //~ console.log("Key down: " + evt.keyCode);
227
        switch (evt.keyCode) {
228
        case 33: // page up
229
            keyHandler = encodeURIComponent(getHandlerCommand(handler, 'prior'));
230
            sendToNuc('window=' + section + '&key=' + keyHandler);
231
            break;
232
        case 34: // page down
233
            keyHandler = encodeURIComponent(getHandlerCommand(handler, 'next'));
234
            sendToNuc('window=' + section + '&key=' + keyHandler);
235
            break;
236
        case 35: // end
237
            keyHandler = encodeURIComponent(getHandlerCommand(handler, 'end'));
238
            sendToNuc('window=' + section + '&key=' + keyHandler);
239
            break;
240
        case 36: // home
241
            keyHandler = encodeURIComponent(getHandlerCommand(handler, 'home'));
242
            sendToNuc('window=' + section + '&key=' + keyHandler);
243
            break;
244
        case 37: // left
245
            keyHandler = encodeURIComponent(getHandlerCommand(handler, 'left'));
246
            sendToNuc('window=' + section + '&key=' + keyHandler);
247
            break;
248
        case 38: // up
249
            keyHandler = encodeURIComponent(getHandlerCommand(handler, 'up'));
250
            sendToNuc('window=' + section + '&key=' + keyHandler);
251
            break;
252
        case 39: // right
253
            keyHandler = encodeURIComponent(getHandlerCommand(handler, 'right'));
254
            sendToNuc('window=' + section + '&key=' + keyHandler);
255
            break;
256
        case 40: // down
257
            keyHandler = encodeURIComponent(getHandlerCommand(handler, 'down'));
258
            sendToNuc('window=' + section + '&key=' + keyHandler);
259
            break;
260
        }
261
    };
262
263
    document.onkeypress = function(evt) {
264
        evt = evt || window.event;
265
        //~ console.log("Key press: " + evt.keyCode);
266
        var charCode = evt.which || evt.keyCode;
267
        var charStr = String.fromCharCode(charCode);
268
        var section = focus_section;
269
        var handler = controls[focus_section][0];
270
        var keyHandler;
271
        switch (charStr) {
272
        case "1": // select section 1
273
        case "2": // select section 2
274
        case "3": // select section 3
275
        case "4": // select section 4
276
            focus_section = charStr;
277
            break;
278
        case "+": // zoom in
279
            keyHandler = encodeURIComponent(getHandlerCommand(handler, 'zoomin'));
280
            sendToNuc('window=' + section + '&key=' + keyHandler);
281
            break;
282
        case "-": // zoom out
283
            keyHandler = encodeURIComponent(getHandlerCommand(handler, 'zoomout'));
284
            sendToNuc('window=' + section + '&key=' + keyHandler);
285
            break;
286
        }
287
    };
288
289
    var windowlist = document.getElementById('windowlist');
290
    var entries = windowlist.getElementsByClassName('window_entry');
291
    var screensection, file, status;
292
    markCurrentLayout(layout);
293
    for (var n = 0; n < window.length; n++) {
294
        screensection = window[n].section;
295
        file = window[n].file;
296
        status = window[n].state;
297
        entries[n].appendChild(addWindowControls(layout, controls, screensection, file, status));
298
    }
299
}
300
301
function markCurrentLayout(layout) {
302
    var layoutDivs = document.getElementsByClassName("screenlayout");
303
    for (var i = 0 ; i < layoutDivs.length ; i++) {
304
        var children = layoutDivs[i].getElementsByClassName("pure-button");
305
        for (var k = 0 ; k < children.length ; k++) {
306
            children[k].style.backgroundColor = "";
307
        }
308
    }
309
    document.getElementById(layout).style.backgroundColor = "#232e58";
310
}
311
312
function miniDisplaySelect(element) {
313
    sendToNuc('layout=' + element.id);
314
    markCurrentLayout(element.id);
315
}
316
317
function getHandlerCommand(handle, task) {
318
319
    // console.log("getHandlerCommand "+handle+" - "+task);
320
    // to deactivate buttons just add 'undefined' as keystroke
321
322
    var handler = [];
323
324
    handler["default"] = {};
325
    // handler["default"]["init"] = "";
326
    handler["default"]["up"] = "Up";
327
    handler["default"]["down"] = "Down";
328
    handler["default"]["left"] = "Left";
329
    handler["default"]["right"] = "Right";
330
    handler["default"]["next"] = "Next";
331
    handler["default"]["prior"] = "Prior";
332
    handler["default"]["home"] = "Home";
333
    handler["default"]["end"] = "End";
334
    handler["default"]["zoomin"] = "ctrl+plus";
335
    handler["default"]["zoomout"] = "ctrl+minus";
336
    handler["default"]["download"] = "download";
337
    handler["default"]["counterclockwise"] = "undefined";
338
    handler["default"]["clockwise"] = "undefined";
339
340
    // Handler for web pages.
341
    handler["palma-browser"] = {};
342
    handler["palma-browser"]["up"] = "Up";
343
    handler["palma-browser"]["down"] = "Down";
344
    handler["palma-browser"]["left"] = "Left";
345
    handler["palma-browser"]["right"] = "Right";
346
    handler["palma-browser"]["next"] = "Next";
347
    handler["palma-browser"]["prior"] = "Prior";
348
    handler["palma-browser"]["home"] = "Home";
349
    handler["palma-browser"]["end"] = "End";
350
    handler["palma-browser"]["zoomin"] = "ctrl+plus";
351
    handler["palma-browser"]["zoomout"] = "ctrl+minus";
352
    handler["palma-browser"]["download"] = "undefined";
353
    handler["palma-browser"]["counterclockwise"] = "undefined";
354
    handler["palma-browser"]["clockwise"] = "undefined";
355
356
    // Handler for images.
357
    handler["feh"] = {};
358
    handler["feh"]["up"] = "alt+Up";
359
    handler["feh"]["down"] = "alt+Down";
360
    handler["feh"]["left"] = "alt+Left";
361
    handler["feh"]["right"] = "alt+Right";
362
    handler["feh"]["next"] = "alt+Next";
363
    handler["feh"]["prior"] = "alt+Prior";
364
    handler["feh"]["home"] = "undefined";
365
    handler["feh"]["end"] = "undefined";
366
    handler["feh"]["zoomin"] = "KP_Add";
367
    handler["feh"]["zoomout"] = "KP_Subtract";
368
    handler["feh"]["download"] = "download";
369
    handler["feh"]["counterclockwise"] = "less";
370
    handler["feh"]["clockwise"] = "greater";
371
372
    // Controls in LibreOffice: no zoom in calc and writer, has to be activated first
373
    // by pressing <Ctrl+Shift+o> (switch view mode on/off) not implemented yet
374
    handler["libreoffice"] = {};
375
    handler["libreoffice"]["up"] = "Up";
376
    handler["libreoffice"]["down"] = "Down";
377
    handler["libreoffice"]["left"] = "Left";
378
    handler["libreoffice"]["right"] = "Right";
379
    handler["libreoffice"]["next"] = "Next";
380
    handler["libreoffice"]["prior"] = "Prior";
381
    handler["libreoffice"]["home"] = "undefined";
382
    handler["libreoffice"]["end"] = "undefined";
383
    handler["libreoffice"]["zoomin"] = "undefined";
384
    handler["libreoffice"]["zoomout"] = "undefined";
385
    handler["libreoffice"]["download"] = "download";
386
    handler["libreoffice"]["counterclockwise"] = "undefined";
387
    handler["libreoffice"]["clockwise"] = "undefined";
388
389
    // Handler for MS Excel and LibreOffice Calc documents.
390
    handler["libreoffice-calc"] = {};
391
    handler["libreoffice-calc"]["up"] = "Up";
392
    handler["libreoffice-calc"]["down"] = "Down";
393
    handler["libreoffice-calc"]["left"] = "Left";
394
    handler["libreoffice-calc"]["right"] = "Right";
395
    handler["libreoffice-calc"]["next"] = "Next";
396
    handler["libreoffice-calc"]["prior"] = "Prior";
397
    handler["libreoffice-calc"]["home"] = "Home";
398
    handler["libreoffice-calc"]["end"] = "End";
399
    handler["libreoffice-calc"]["zoomin"] = "undefined";
400
    handler["libreoffice-calc"]["zoomout"] = "undefined";
401
    handler["libreoffice-calc"]["download"] = "download";
402
    handler["libreoffice-calc"]["counterclockwise"] = "undefined";
403
    handler["libreoffice-calc"]["clockwise"] = "undefined";
404
405
    // Handler for MS Powerpoint and LibreOffice Impress documents.
406
    handler["libreoffice-impress"] = {};
407
    handler["libreoffice-impress"]["up"] = "Up";
408
    handler["libreoffice-impress"]["down"] = "Down";
409
    handler["libreoffice-impress"]["left"] = "Left";
410
    handler["libreoffice-impress"]["right"] = "Right";
411
    handler["libreoffice-impress"]["next"] = "Next";
412
    handler["libreoffice-impress"]["prior"] = "Prior";
413
    handler["libreoffice-impress"]["home"] = "Home";
414
    handler["libreoffice-impress"]["end"] = "End";
415
    handler["libreoffice-impress"]["zoomin"] = "plus";
416
    handler["libreoffice-impress"]["zoomout"] = "minus";
417
    handler["libreoffice-impress"]["download"] = "download";
418
    handler["libreoffice-impress"]["counterclockwise"] = "undefined";
419
    handler["libreoffice-impress"]["clockwise"] = "undefined";
420
421
    // Handler for MS Word and LibreOffice Writer documents.
422
    handler["libreoffice-writer"] = {};
423
    handler["libreoffice-writer"]["up"] = "Up";
424
    handler["libreoffice-writer"]["down"] = "Down";
425
    handler["libreoffice-writer"]["left"] = "Left";
426
    handler["libreoffice-writer"]["right"] = "Right";
427
    handler["libreoffice-writer"]["next"] = "Next";
428
    handler["libreoffice-writer"]["prior"] = "Prior";
429
    handler["libreoffice-writer"]["home"] = "undefined";
430
    handler["libreoffice-writer"]["end"] = "undefined";
431
    handler["libreoffice-writer"]["zoomin"] = "undefined";
432
    handler["libreoffice-writer"]["zoomout"] = "undefined";
433
    handler["libreoffice-writer"]["download"] = "download";
434
    handler["libreoffice-writer"]["counterclockwise"] = "undefined";
435
    handler["libreoffice-writer"]["clockwise"] = "undefined";
436
437
    // Handler for videos.
438
    handler["vlc"] = {};
439
    handler["vlc"]["up"] = "undefined";
440
    handler["vlc"]["down"] = "undefined";
441
    handler["vlc"]["left"] = "undefined";
442
    handler["vlc"]["right"] = "space";
443
    handler["vlc"]["next"] = "undefined";
444
    handler["vlc"]["prior"] = "undefined";
445
    handler["vlc"]["home"] = "undefined";
446
    handler["vlc"]["end"] = "undefined";
447
    handler["vlc"]["zoomin"] = "undefined";
448
    handler["vlc"]["zoomout"] = "undefined";
449
    handler["vlc"]["download"] = "undefined";
450
    handler["vlc"]["counterclockwise"] = "undefined";
451
    handler["vlc"]["clockwise"] = "undefined";
452
453
    // Handler for shared desktops (VNC).
454
    handler["vnc"] = {};
455
    handler["vnc"]["up"] = "Up";
456
    handler["vnc"]["down"] = "Down";
457
    handler["vnc"]["left"] = "Left";
458
    handler["vnc"]["right"] = "Right";
459
    handler["vnc"]["next"] = "undefined";
460
    handler["vnc"]["prior"] = "undefined";
461
    handler["vnc"]["home"] = "undefined";
462
    handler["vnc"]["end"] = "undefined";
463
    handler["vnc"]["zoomin"] = "plus";
464
    handler["vnc"]["zoomout"] = "minus";
465
    handler["vnc"]["download"] = "undefined";
466
    handler["vnc"]["counterclockwise"] = "undefined";
467
    handler["vnc"]["clockwise"] = "undefined";
468
469
    // Handler for PDF documents.
470
    handler["zathura"] = {};
471
    handler["zathura"]["up"] = "Up";
472
    handler["zathura"]["down"] = "Down";
473
    handler["zathura"]["left"] = "Left";
474
    handler["zathura"]["right"] = "Right";
475
    handler["zathura"]["next"] = "Next";
476
    handler["zathura"]["prior"] = "Prior";
477
    handler["zathura"]["home"] = "Home";
478
    handler["zathura"]["end"] = "End";
479
    handler["zathura"]["zoomin"] = "plus";
480
    handler["zathura"]["zoomout"] = "minus";
481
    handler["zathura"]["download"] = "download";
482
    handler["zathura"]["counterclockwise"] = "undefined";
483
    handler["zathura"]["clockwise"] = "r";
484
485
    var send_keys = handler["default"]["up"];
486
487
    if (typeof(handler[handle]) !== "undefined") {
488
        send_keys = handler[handle][task];
489
    }
490
491
    // console.log(send_keys);
492
493
    return send_keys;
494
}
495
496
Dropzone.options.palmaDropzone = {
497
    init: function() {
498
      this.on("complete", function() {
499
        if (this.getQueuedFiles().length == 0 && this.getUploadingFiles().length == 0) {
500
          // File finished uploading, and there aren't any left in the queue.
501
          // console.log("File(s) uploaded");
502
          setTimeout(function() {
503
             location.reload();
504
          }, 1);
505
          // location.reload(); // verlangt Eingabe von Enter zum wiederholten Schicken der Daten
506
        }
507
      });
508
    }
509
};
510
511
function updateUserList(address, user) {
512
    // Update the user list on screen from the table in the database.
513
514
    // Get the <tbody> element which contains the user entries.
515
    var list = document.getElementById('userlist');
516
517
    // First we remove all existing <tr> elements.
518
    while (list.firstChild) {
519
        list.removeChild(list.firstChild);
520
    }
521
522
    if (address.length > 0) {
523
        // Add an entry for each user. Iterate over addresses:
524
        // One user may be connected several times with different devices.
525
        // We don't expect more than one user from the same device.
526
        var m;
527
        for (m = 0; m < address.length; m++) {
528
            var n;
529
            for (n = 0; n < user.length; n++) {
530
                if (address[m].userid == user[n].userid) {
531
                    break;
532
                }
533
            }
534
            var device = address[m].device;
535
            var tr = document.createElement('tr');
536
            var td = document.createElement('td');
537
            var i = document.createElement('i');
538
            i.setAttribute('class', 'fa fa-fw fa-' + device);
539
            td.appendChild(i);
540
            td.appendChild(document.createTextNode(user[n].name));
541
            tr.appendChild(td);
542
            list.appendChild(tr);
543
        }
544
    } else {
545
<?php
546
if ($user) {
547
    ?>
548
        // All users were disconnected.
549
        alert("<?=addslashes(__('You were disconnected!'))?>");
550
        window.location = 'logout.php';
551
    <?php
552
} else {
553
    ?>
554
        // If there is no user, we display an empty entry.
555
        var tr = document.createElement('tr');
556
        var td = document.createElement('td');
557
        td.appendChild(document.createTextNode("\u00a0"));
558
        tr.appendChild(td);
559
        list.appendChild(tr);
560
    <?php
561
}
562
?>
563
    }
564
}
565
566
567
function addWindowPosition(layout, screensection) {
568
    var position = document.createElement("div");
569
    position.setAttribute("class", "position " + layout);
570
    position.setAttribute('title', '<?=addslashes(__("Select screen section for display"))?>');
571
572
    var s;
573
    var button;
574
    var icon;
575
    var br;
576
577
    switch (layout) {
578
        case 'g1x1':
579
            s = 1;
580
            break;
581
        case 'g1x2':
582
            s = 2;
583
            break;
584
        case 'g2x1':
585
            s = 2;
586
            break;
587
        case 'g1a2':
588
            s = 3;
589
            var layout_left = document.createElement('div');
590
            layout_left.setAttribute("class", "layout_left");
591
            var layout_right = document.createElement('div');
592
            layout_right.setAttribute("class", "layout_right");
593
            break;
594
        case 'g2x2':
595
            s = 4;
596
            break;
597
    }
598
599
    for (var n = 1; n <= s; n++) {
600
        br = '';
601
        button = document.createElement("button");
602
        button.setAttribute('value', n);
603
        if (n == screensection) {
604
            button.setAttribute("class", "selected");
605
        }
606
        button.setAttribute('onclick', "sendToNuc('switchWindows=TRUE&before=" + screensection + "&after='+(this.value))");
607
        icon = document.createElement("i");
608
        if (s == 1) {
609
            icon.setAttribute("class", "fa fa-desktop fa-2x");
610
        } else {
611
            icon.setAttribute("class", "fa fa-desktop fa-1x");
612
        }
613
        button.appendChild(icon);
614
615
        if ((layout == 'g1x2' && n == 1) || ((layout == 'g1a2' || layout == 'g2x2') && n == 2 )) {
616
            br = document.createElement("br");
617
        }
618
619
        if (layout == 'g1a2' && n == 1) {
620
            layout_left.appendChild(button);
621
        } else if (layout == 'g1a2' && n > 1) {
622
            layout_right.appendChild(button);
623
            if (br) {
624
                layout_right.appendChild(br);
625
            }
626
        } else {
627
            position.appendChild(button);
628
            if (br) {
629
                position.appendChild(br);
630
            }
631
        }
632
    }
633
634
    if (layout == 'g1a2') {
635
        position.appendChild(layout_left);
636
        position.appendChild(layout_right);
637
    }
638
    return position;
639
}
640
641
642
function addWindowControls(layout, controls, screensection, file, status) {
643
    var control = controls[screensection];
644
    if (typeof control == "undefined") {
645
    control = ["default", false, false, false, false,
646
               false, false, false, false, false, false, false];
647
    }
648
649
    // get handler
650
    var handler = control[0];
651
    // up down left right zoomin zoomout home end prior next download
652
    var up = control[1];
653
    var down = control[2];
654
    var left = control[3];
655
    var right = control[4];
656
    var zoomin = control[5];
657
    var zoomout = control[6];
658
    var home = control[7];
659
    var end = control[8];
660
    var prior = control[9];
661
    var next = control[10];
662
    var download = control[11];
663
    var counterclockwise = control[12];
664
    var clockwise = control[13];
665
666
    var windowcontrols = document.createElement("div");
667
    windowcontrols.setAttribute("class", "windowcontrols");
668
669
    var topbar = document.createElement("div");
670
    topbar.setAttribute("class", "topbar");
671
    var button = document.createElement('button');
672
    button.setAttribute("class", "toggle");
673
    icon = document.createElement('i');
674
    if (status == 'active') {
675
        icon.setAttribute("class", "fa fa-eye");
676
    } else {
677
        icon.setAttribute("class", "fa fa-eye-slash");
678
    }
679
    icon.setAttribute('id', 'status_' + screensection);
680
    button.setAttribute('title', '<?=addslashes(__("Toggle visibility"))?>');
681
    button.setAttribute('onclick', "sendToNuc('window=" + screensection + "&toggle=TRUE')");
682
    button.appendChild(icon);
683
    topbar.appendChild(button);
684
    topbar.appendChild(keyControl(screensection, 'fa fa-search-plus', 'zoomin', 'zoomin', handler, !zoomin, '<?=addslashes(__("Zoom in"))?>'));
685
    topbar.appendChild(keyControl(screensection, 'fa fa-search-minus', 'zoomout', 'zoomout', handler, !zoomout, '<?=addslashes(__("Zoom out"))?>'));
686
    topbar.appendChild(keyControl(screensection, 'fa fa-rotate-left', 'counterclockwise', 'counterclockwise', handler, !counterclockwise, '<?=addslashes(__("Rotate counterclockwise"))?>'));
687
    topbar.appendChild(keyControl(screensection, 'fa fa-rotate-right', 'clockwise', 'clockwise', handler, !clockwise, '<?=addslashes(__("Rotate clockwise"))?>'));
688
    var downloadbutton = keyControl(screensection, 'fa fa-download', 'download', 'download', handler, !download, '<?=addslashes(__("Download this item"))?>');
689
    if(download) {
690
      downloadbutton.setAttribute('onclick', 'downloadFile(' + screensection + ')');
691
    }
692
    topbar.appendChild(downloadbutton);
693
    button = document.createElement('button');
694
    button.setAttribute("class", "trash");
695
    button.setAttribute('onclick', "sendToNuc('window=" + screensection + "&delete=" + file + "')");
696
    button.setAttribute('title', '<?=addslashes(__("Remove this item"))?>');
697
    icon = document.createElement('i');
698
    icon.setAttribute("class", "fa fa-trash-o");
699
    button.appendChild(icon);
700
    topbar.appendChild(button);
701
702
    var movement = document.createElement("div");
703
    movement.setAttribute("class", "movement");
704
705
    var jump = document.createElement("div");
706
    jump.setAttribute("class", "jump");
707
    jump.appendChild(keyControl(screensection, 'fa fa-angle-double-up', 'jumpbeginning', 'home', handler, !home, '<?=addslashes(__("Jump to start"))?>'));
708
    jump.appendChild(keyControl(screensection, 'fa fa-angle-up', 'pageback', 'prior', handler, !prior, '<?=addslashes(__("Page up"))?>'));
709
    jump.appendChild(keyControl(screensection, 'fa fa-angle-down', 'pageforward', 'next', handler, !next, '<?=addslashes(__("Page down"))?>'));
710
    jump.appendChild(keyControl(screensection, 'fa fa-angle-double-down', 'jumpend', 'end', handler, !end, '<?=addslashes(__("Jump to end"))?>'));
711
712
    var arrows = document.createElement("div");
713
    arrows.setAttribute("class", "arrows");
714
    arrows.appendChild(keyControl(screensection, 'fa fa-toggle-up', 'arrowup', 'up', handler, !up, '<?=addslashes(__("Up"))?>'));
715
    arrows.appendChild(document.createElement("br"));
716
    arrows.appendChild(keyControl(screensection, 'fa fa-toggle-left', 'arrowleft', 'left', handler, !left, '<?=addslashes(__("Left"))?>'));
717
    arrows.appendChild(keyControl(screensection, 'fa fa-toggle-right', 'arrowright', 'right', handler, !right, '<?=addslashes(__("Right"))?>'));
718
    arrows.appendChild(document.createElement("br"));
719
    arrows.appendChild(keyControl(screensection, 'fa fa-toggle-down', 'arrowdown', 'down', handler, !down, '<?=addslashes(__("Down"))?>'));
720
721
    movement.appendChild(jump);
722
    movement.appendChild(arrows);
723
724
    var position = addWindowPosition(layout, screensection);
725
726
    // Putting it all together
727
    windowcontrols.appendChild(topbar);
728
    windowcontrols.appendChild(movement);
729
    windowcontrols.appendChild(position);
730
    return windowcontrols;
731
}
732
733
734
function updateWindowList(window){
735
    var windowlist = document.getElementById('windowlist');
736
    // remove old entries
737
    while (windowlist.firstChild) {
738
        windowlist.removeChild(windowlist.firstChild);
739
    }
740
741
    if (window.length == 0) {
742
        var entry = document.createElement('div');
743
        entry.setAttribute("class", "description");
744
        entry.appendChild(document.createTextNode('<?=addslashes(__('Welcome'))?>, <?=htmlspecialchars($username)?>!'));
745
        entry.appendChild(document.createElement("br"));
746
        entry.appendChild(document.createTextNode('<?=addslashes(__('There is no shared content yet. Click below to get started!'))?>'));
747
        var addbutton = document.createElement('button');
748
        addbutton.setAttribute("class", "splash_add pure-button");
749
        addbutton.setAttribute("onclick", "openTab(event, 'Add')");
750
        var addtext = (document.createTextNode('<?=addslashes(__("Add"))?>'));
751
        addbutton.appendChild(addtext);
752
        var addicon = document.createElement("i");
753
        addicon.setAttribute("class", "fa fa-plus");
754
        addbutton.appendChild(addicon);
755
        windowlist.appendChild(entry);
756
        windowlist.appendChild(addbutton);
757
        document.getElementById("closeWindows").style.display = "none";
758
        document.getElementById("Layout").style.display = "none";
759
        document.getElementById("controlbtn").className = "tablinks";
760
    } else {
761
        document.getElementById("closeWindows").style.display = "inline-block";
762
        document.getElementById("Layout").style.display = "block";
763
        document.getElementById("controlbtn").className = "tablinks active";
764
        // Add an entry for each window.
765
        var n;
766
        for (n = 0; n < window.length; n++) {
767
            var file = window[n].file;
768
            var handler = window[n].handler;
769
            var screensection = window[n].section;
770
            var entry = document.createElement('div');
771
            entry.setAttribute("class", "window_entry");
772
            var divID = 'file' + screensection;
773
            entry.setAttribute('id', divID);
774
775
            var button = document.createElement('button');
776
            button.setAttribute("class", "window_entry_button");
777
            button.setAttribute('onclick', "openAccordion('" + divID + "')");
778
            var icon = document.createElement('i');
779
            if (handler.indexOf("palma-browser") > -1) {
780
                icon.setAttribute("class", "fa fa-globe");
781
            } else if (handler.indexOf("vnc") > -1) {
782
                icon.setAttribute("class", "fa fa-video-camera");
783
            } else if (handler.indexOf("vlc") > -1) {
784
                icon.setAttribute("class", "fa fa-film");
785
            } else if (handler.indexOf("feh") > -1) {
786
                icon.setAttribute("class", "fa fa-picture-o");
787
            } else if (handler.indexOf("zathura") > -1) {
788
                icon.setAttribute("class", "fa fa-file-pdf-o");
789
            } else {
790
                icon.setAttribute("class", "fa fa-file");
791
            }
792
            button.appendChild(icon);
793
            var title = decodeURI(decodeURIComponent(file));
794
            // display only the last part of the URL or file name.
795
            // Long names are truncated, and the truncation is indicated.
796
            if (title.substring(0, 4) == 'http') {
797
                // Remove a terminating slash from an URL.
798
                // The full URL will be shown as a tooltip.
799
                title = title.replace(/\/$/, '');
800
                title = title.replace(/^.*\//, '');
801
                entry.setAttribute('title', file);
802
            } else {
803
                // For files only the full base name is shown as a tooltip.
804
                var fname = file;
805
                title = title.replace(/^.*\//, '');
806
                entry.setAttribute('title', fname);
807
            }
808
            if (title.length > 25) {
809
                title = title.substring(0, 25) + '...';
810
            }
811
            button.appendChild(document.createTextNode(title));
812
            var icon = document.createElement('i');
813
            icon.setAttribute("class", "fa fa-caret-down accordion-icon");
814
            button.appendChild(icon);
815
            entry.appendChild(button);
816
            windowlist.appendChild(entry);
817
        }
818
    }
819
}
820
821
function updateControlsBySection(window) {
822
823
    // get section and handler for each window
824
    var sectionControls = [];
825
826
    for (n = 0; n < window.length; n++) {
827
        var win_id = window[n].win_id;
828
        var section = window[n].section;
829
        var handler = window[n].handler;
830
831
        // alert("Section: " + section + " - Handler: " + handler);
832
833
        if (handler.indexOf("feh") > -1) {
834
            // up down left right zoomin zoomout home end prior next download rotateleft rotateright
835
            control = ["feh", true, true, true, true, true, true, false, false, false, false, true, true, true];
836
        } else if (handler.indexOf("libreoffice") > -1) {
837
            // Controls in LibreOffice: no zoom in calc and writer, has to be activated first
838
            // by pressing <Ctrl+Shift+o> (switch view mode on/off) not implemented yet
839
            control = ["libreoffice", true, true, true, true, false, false, false, false, true, true, true, false, false];
840
                if (handler.indexOf("--calc") > -1) {
841
                    control = ["libreoffice-calc", true, true, true, true, false, false, true, true, true, true, true, false, false];
842
                }
843
                if (handler.indexOf("--impress") > -1) {
844
                    control = ["libreoffice-impress", true, true, true, true, true, true, true, true, true, true, true, false, false];
845
                }
846
                if (handler.indexOf("--writer") > -1) {
847
                    control = ["libreoffice-writer", true, true, true, true, false, false, false, false, true, true, true, false, false];
848
                }
849
        } else if (handler.indexOf("palma-browser") > -1) {
850
            control = ["palma-browser", true, true, true, true, true, true, true, true, true, true, false, false, false];
851
        } else if (handler.indexOf("vlc") > -1) {
852
            control = ["vlc", false, false, false, true, false, false, false, false, false, false, false, false, false];
853
        } else if (handler.indexOf("vnc") > -1) {
854
            control = ["vnc", true, true, true, true, true, true, false, false, false, false, false, false, false];
855
        } else if (handler.indexOf("zathura") > -1) {
856
            control = ["zathura", true, true, true, true, true, true, true, true, true, true, true, false, true];
857
        } else {
858
            control = ["undefined", false, false, false, false, false, false, false, false, false, false, false, false, false];
859
        }
860
861
        sectionControls[section] = control;
862
    }
863
864
    // Fill empty sections with default values.
865
    for (i = sectionControls.length; i < 5; i++) {
866
        sectionControls[i] = ["default",
867
                              false, false, false, false,
868
                              false, false, false, false,
869
                              false, false, false, false, false];
870
    }
871
872
    return sectionControls;
873
}
874
875
function updateScreen() {
876
    sendToNuc('window=all&closeOrphans=true');
877
}
878
879
function clearURLField(defaultText) {
880
    var browseto = document.getElementById('url_field');
881
    browseto.setAttribute('value', 'https://');
882
}
883
884
// lastJSON is used to reduce the database polling rate.
885
var lastJSON = '';
886
887
function pollDatabase() {
888
    var xmlHttp = new XMLHttpRequest();
889
    if (xmlHttp) {
890
        xmlHttp.open("get", 'db.php?json=' + lastJSON, true);
891
        xmlHttp.onreadystatechange = function () {
892
            if (xmlHttp.readyState == 2) {
893
                // Data transferred to server.
894
            } else if (xmlHttp.readyState == 3) {
895
                // Server is answering.
896
            } else if (xmlHttp.readyState == 4) {
897
                // Received all data from server.
898
                var status = xmlHttp.status;
899
                if (status == 200) {
900
                    // Got valid response.
901
                    var text = xmlHttp.responseText;
902
                    lastJSON = text;
903
                    var db = JSON.parse(text);
904
                    if (db === null || Object.keys(db).length === 0) {
905
                        return;
906
                    }
907
                    var i;
908
                    var layout = '';
909
                    for (i = 0; i < db.setting.length; i++) {
910
                        if (db.setting[i].key == 'layout') {
911
                            layout = db.setting[i].value;
912
                            break;
913
                        }
914
                    }
915
                    var controls = updateControlsBySection(db.window);
916
                    // for (i = 0; i < controls.length; i++) {
917
                    //    console.log(i + ": " + controls[i]);
918
                    //    }
919
                    updateUserList(db.address, db.user);
920
                    updateWindowList(db.window);
921
                    showLayout(layout, controls, db.window);
922
                    // updateScreen(db.window);
923
                    setTimeout("pollDatabase()", 1);
924
                } else {
925
                    // Got error. TODO: handle it.
926
                }
927
            } else {
928
                // Got unexpected xmlHttp.readyState. TODO: handle it.
929
            }
930
        };
931
        xmlHttp.send(null);
932
    }
933
}
934
935
// Start polling the database.
936
pollDatabase();
937
938
939
function getOS() {
940
    var OSName="Unknown OS";
941
    if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
942
    if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
943
    if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
944
    if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
945
    if (navigator.userAgent.indexOf("Android")!=-1) OSName="Android";
946
    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) OSName="iOS";
947
    /* Source for Android and iOS:
948
    https://davidwalsh.name/detect-android
949
    https://davidwalsh.name/detect-iphone
950
    https://davidwalsh.name/detect-ipad */
951
    return OSName;
952
}
953
954
function getFilePathByOS() {
955
    var OSName = getOS();
956
    var windows = 'download-winvnc';
957
    var macOS = 'download-macvnc';
958
    var linux = 'download-linux';
959
    var download = '';
960
    switch(OSName) {
961
        case 'Windows': download = windows;
962
            break;
963
        case 'MacOS': download = macOS;
964
            break;
965
        case 'Linux': download = linux;
966
            break;
967
        case 'UNIX': download = linux;
968
            break;
969
        case 'Android':
970
        case 'iOS':
971
            document.getElementById("Screen").innerHTML = '<div class="description"><?=addslashes(__('Sorry! Screensharing for your device is currently not supported.'))?></div>';
972
            break;
973
        default: download = null;
974
    }
975
  document.getElementById(download).click();
976
}
977
978
function openTab(evt, tabName) {
979
    var i, tabcontent, tablinks;
980
    // Hide all elements with class="tabcontent"
981
    tabcontent = document.getElementsByClassName("tabcontent");
982
    for (i = 0; i < tabcontent.length; i++) {
983
        tabcontent[i].style.display = "none";
984
    }
985
    // Remove "active" class from all elements with class="tablinks"
986
    tablinks = document.getElementsByClassName("tablinks");
987
    for (i = 0; i < tablinks.length; i++) {
988
        tablinks[i].className = tablinks[i].className.replace(" active", "");
989
    }
990
991
    // Show current tab and add "active" class to the opening button
992
    document.getElementById(tabName).style.display = "block";
993
    evt.currentTarget.className += " active";
994
}
995
996
function openSubtab(evt, tabName, subtabName) {
997
    var i, tab, subtabcontent, subtablinks;
998
    // Hide all elements with class="subtabcontent"
999
    tab = document.getElementById(tabName);
1000
    subtabcontent = tab.getElementsByClassName("subtabcontent");
1001
    for (i = 0; i < subtabcontent.length; i++) {
1002
        subtabcontent[i].style.display = "none";
1003
    }
1004
1005
    // Remove "active" class from all elements with class="subtablinks"
1006
    subtablinks = tab.getElementsByClassName("subtablinks");
1007
    for (i = 0; i < subtablinks.length; i++) {
1008
        subtablinks[i].className = subtablinks[i].className.replace(" active", "");
1009
    }
1010
1011
    // Show current subtab and add "active" class to the opening button
1012
    document.getElementById(subtabName).style.display = "block";
1013
    evt.currentTarget.className += " active";
1014
}
1015
1016
function openAccordion(divID) {
1017
    var button = document.getElementById(divID).firstChild;
1018
    var windowcontrols = document.getElementById(divID).lastChild;
1019
    if (windowcontrols.style.display == "block") {
1020
        windowcontrols.style.display = "none";
1021
        button.setAttribute("class", "window_entry_button");
1022
    } else if (windowcontrols.style.display == "none") {
1023
        windowcontrols.style.display = "block";
1024
        button.setAttribute("class", "window_entry_button active");
1025
    } else {
1026
        windowcontrols.style.display = "block";
1027
        button.setAttribute("class", "window_entry_button active");
1028
    }
1029
}
1030
1031
function showDropdown() {
1032
    document.getElementById("languageSelection").classList.toggle("show");
1033
}
1034
// Close the dropdown menu if the user clicks outside of it
1035
// Must use some workaround to support IE.
1036
window.onclick = function(event) {
1037
  var classes = event.target.className.split(' ');
1038
  var found = false; var i = 0;
1039
  while (i < classes.length && !found) {
1040
      if (classes[i]=='dropbutton') found = true;
1041
      else ++i;
1042
  }
1043
  if (!found) {
1044
    var dropdowns = document.getElementsByClassName("dropdown-content");
1045
    var i;
1046
    for (i = 0; i < dropdowns.length; i++) {
1047
      var openDropdown = dropdowns[i];
1048
      if (openDropdown.classList.contains('show')) {
1049
        openDropdown.classList.remove('show');
1050
      }
1051
    }
1052
  }
1053
}
1054
</script>
1055
</head>
1056
1057
<body>
1058
1059
<!-- This formating is used to prevent empty textnodes that interfere with the design -->
1060
<div class="tab"
1061
    ><button class="tablinks" onclick="openTab(event, 'Add')"><?=addslashes(__('Add'))?><i class="fa fa-plus"></i></button
1062
    ><button class="tablinks" id="controlbtn" onclick="openTab(event, 'Control')"><?=addslashes(__('Control'))?><i class="fa fa-arrows"></i></button
1063
    ><button class="tablinks" onclick="openTab(event, 'Extras')"><?=addslashes(__('Extras'))?><i class="fa fa-info-circle"></i></button
1064
></div>
1065
1066
<div id="workbench">
1067
    <div id="Add" class="tabcontent">
1068
        <div class="subtab"
1069
        ><button class="subtablinks" onclick="openSubtab(event, 'Add', 'File')"><?=addslashes(__('File'))?><i class="fa fa-file"></i></button
1070
        ><button class="subtablinks" onclick="openSubtab(event, 'Add', 'URL')"><?=addslashes(__('URL'))?><i class="fa fa-globe"></i></button
1071
        ><button class="subtablinks" onclick="openSubtab(event, 'Add', 'Screen')"><?=addslashes(__('Screen'))?><i class="fa fa-video-camera"></i></button
1072
    ></div>
1073
        <div id="File" class="subtabcontent">
1074
            <div id="file_upload">
1075
                <form action="upload.php"
1076
                    class="dropzone"
1077
                    id="palma-dropzone"
1078
                    title="<?=addslashes(__('Drag and drop files or click here to upload.'))?>">
1079
                    <div class="dz-default dz-message">
1080
                        <?=__('Add file (click or drop here)')?>
1081
                        <i class="fa fa-file fa-2x"></i>
1082
                    </div>
1083
                </form>
1084
                <div class="dz-preview dz-file-preview">
1085
                    <div class="dz-details">
1086
                        <div class="dz-filename"><span data-dz-name></span></div>
1087
                        <div class="dz-size" data-dz-size></div>
1088
                        <img data-dz-thumbnail src="" alt="">
1089
                    </div>
1090
                  <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>
1091
                  <div class="dz-success-mark"><span> </span></div>
1092
                  <div class="dz-error-mark"><span> </span></div>
1093
                  <div class="dz-error-message"><span data-dz-errormessage></span></div>
1094
                </div>
1095
            </div>
1096
        </div>
1097
        <div id="URL" class="subtabcontent">
1098
            <div>
1099
                <input type="text" value="<?=addslashes(__('Add webpage'))?>"
1100
                    id="url_field" maxlength="256" size="46"
1101
                    onkeydown="if (event.keyCode == 13) document.getElementById('url_button').click()"
1102
                    onfocus="clearURLField('<?=addslashes(__('Enter URL'))?>')">
1103
                <button class="pure-button pure-button-primary pure-input-rounded"
1104
                    id="url_button"
1105
                    onClick="urlToNuc()" title="<?=addslashes(__('Click here to show the webpage on the screen.'))?>">
1106
                    <?=addslashes(__('Enter'))?><i class="fa fa-globe"></i>
1107
                </button>
1108
            </div>
1109
        </div>
1110
        <div id="Screen" class="subtabcontent">
1111
            <div id="vnc-button" onclick="javascript:getFilePathByOS()">
1112
                <div id="vnc-button-container">
1113
                    <div id="vnc-button-label"><?=addslashes(__('Add your screen'))?><i class="fa fa-video-camera fa-2x" aria-hidden="true"></i></div>
1114
                    <div id="vnc-button-label-subtext"><?=addslashes(__('Download screensharing tool'))?></div>
1115
                </div>
1116
                <a href="<?php echo $winvnc; ?>" download id="download-winvnc" hidden></a>
1117
                <a href="<?php echo $macvnc; ?>" download id="download-macvnc" hidden></a>
1118
                <a href="<?php echo $linuxsh; ?>" download id="download-linux" hidden></a>
1119
            </div>
1120
            <div class="description">
1121
            <?=addslashes(__('Download your screensharing tool (Windows, Mac and Linux only). Visit the help section for further information.'))?>
1122
            </div>
1123
        </div>
1124
    </div>
1125
    <div id="Control" class="tabcontent">
1126
        <div class="subtab"
1127
            ><button class="subtablinks" onclick="openSubtab(event, 'Control', 'Layout')"><?=addslashes(__('Layout'))?><i class="fa fa-desktop"></i></button
1128
            ><button class="subtablinks" onclick="openSubtab(event, 'Control', 'Navigate')"><?=addslashes(__('Navigate'))?><i class="fa fa-arrows"></i></button
1129
        ></div>
1130
        <div id="Layout" class="subtabcontent">
1131
            <div class="screenlayout">
1132
                <button class="pure-button pure-button-primary pure-input-rounded"
1133
                        id="g1x1" onclick="miniDisplaySelect(this)"
1134
                        title="<?=addslashes(__('Choose screen layout'))?>">
1135
                    <i alt="1" class="fa fa-desktop fa-2x" aria-hidden="true"></i>
1136
                </button>
1137
            </div
1138
            ><div class="screenlayout vertical">
1139
                <button class="pure-button pure-button-primary pure-input-rounded"
1140
                        id="g1x2" onclick="miniDisplaySelect(this)"
1141
                        title="<?=addslashes(__('Choose screen layout'))?>">
1142
                    <i alt="1" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1143
                    <i alt="2" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1144
                </button>
1145
            </div
1146
            ><div class="screenlayout">
1147
                <button class="pure-button pure-button-primary pure-input-rounded"
1148
                        id="g2x1" onclick="miniDisplaySelect(this)"
1149
                        title="<?=addslashes(__('Choose screen layout'))?>">
1150
                    <i alt="1" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1151
                    <i alt="2" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1152
                </button>
1153
            </div
1154
            ><div class="screenlayout">
1155
                <button class="pure-button pure-button-primary pure-input-rounded"
1156
                        id="g1a2" onclick="miniDisplaySelect(this)"
1157
                        title="<?=addslashes(__('Choose screen layout'))?>">
1158
                    <div class="layout_left">
1159
                    <i alt="1" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1160
                    </div>
1161
                    <div class="layout_right vertical">
1162
                    <i alt="2" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1163
                    <i alt="3" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1164
                    </div>
1165
                </button>
1166
            </div
1167
            ><div class="screenlayout">
1168
                <button class="pure-button pure-button-primary pure-input-rounded"
1169
                        id="g2x2" onclick="miniDisplaySelect(this)"
1170
                        title="<?=addslashes(__('Choose screen layout'))?>">
1171
                    <i alt="1" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1172
                    <i alt="2" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1173
                    <br />
1174
                    <i alt="3" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1175
                    <i alt="4" class="fa fa-desktop fa-1x" aria-hidden="true"></i>
1176
                </button>
1177
            </div>
1178
        </div>
1179
        <div id="Navigate" class="subtabcontent">
1180
            <div id="windowlist">
1181
            <!-- filled by updateWindowList and showLayout -->
1182
            </div>
1183
            <button id="closeWindows" class="pure-button pure-button-primary pure-input-rounded"
1184
                onClick="sendToNuc('closeAll=TRUE')"
1185
                title="<?=addslashes(__('Close all windows and remove uploaded files'))?>">
1186
                <?=addslashes(__('Delete all items'))?>
1187
            </button>
1188
        </div>
1189
    </div>
1190
    <div id="Extras" class="tabcontent">
1191
        <div class="subtab"
1192
            ><button class="subtablinks active" onclick="openSubtab(event, 'Extras', 'Help')"><?=addslashes(__('Help'))?><i class="fa fa-question-circle"></i></button
1193
            ><button class="subtablinks" onclick="openSubtab(event, 'Extras', 'Feedback')"><?=addslashes(__('Feedback'))?><i class="fa fa-thumbs-o-up"></i></button
1194
            ><button class="subtablinks" onclick="openSubtab(event, 'Extras', 'Users')"><?=addslashes(__('Users'))?><i class="fa fa-users"></i></button
1195
        ></div>
1196
        <div id="Help" class="subtabcontent">
1197
            <p><?=addslashes(__('With PalMA, you can share documents, websites and your desktop with your learning group.'))?>
1198
            <?=addslashes(__('The PalMA team monitor shows up to four contributions simultaneously.'))?></p>
1199
            <?php
1200
            if (CONFIG_INSTITUTION_URL) { ?>
1201
                <p><?=addslashes(__('For further information about PalMA in this institution'))?> <a href=<?=CONFIG_INSTITUTION_URL?> target="_blank"><?=__('see here.')?></a></p>
1202
                <?php
1203
            }
1204
            ?>
1205
            <h4><?=addslashes(__('Connect'))?><i class="fa fa-wifi"></i></h4>
1206
            <p><?=addslashes(__('Team members can join the session at any time with this URL or QR-Code:'))?></p>
1207
            <p class="url_hint"><?=htmlspecialchars($_SESSION['starturl'])?><br />
1208
            <?php
1209
            if (!empty($_SESSION['pin'])) {
1210
                echo addslashes(__('PIN: '));
1211
                echo htmlspecialchars($_SESSION['pin']);
1212
            }
1213
            ?>
1214
            </p>
1215
            <img class="qr-code" src="qrcode/php/qr_img.php?d=<?=htmlspecialchars($_SESSION['starturl'])?>?pin=<?=htmlspecialchars($_SESSION['pin'])?>" alt="QR Code">
1216
1217
            <h4><?=addslashes(__('Add'))?><i class="fa fa-plus"></i></h4>
1218
                <p><?=addslashes(__('Use the Add-Section to share content on the PalMA monitor.'))?></p>
1219
                <ul>
1220
                <li><i class="fa fa-file"></i> <?=addslashes(__('For PDF files, office files, images or videos use the file section.'))?></li>
1221
                <li><i class="fa fa-globe"></i> <?=addslashes(__('To display a website use the URL field.'))?></li>
1222
                <li><i class="fa fa-video-camera"></i> <?=addslashes(__('To share your desktop in real time download the VNC screen sharing software and'))?></li>
1223
                    <ul>
1224
                    <li><i class="fa fa-windows"></i> <?=addslashes(__('Windows:'))?></li>
1225
                        <ul>
1226
                        <li><?=addslashes(__('Run the downloaded file.'))?></li>
1227
                        <li><?=addslashes(__('Double-click the name of your PalMA station in the appearing list.'))?></li>
1228
                        </ul>
1229
                    <li><i class="fa fa-apple"> </i> <?=addslashes(__('Mac:'))?></li>
1230
                        <ul>
1231
                        <li><?=addslashes(__('CTRL + click the downloaded file and run it.'))?></li>
1232
                        <li><?=addslashes(__('A second window opens, in which you can start &quot;VineServer&quot;.'))?></li>
1233
                        <li><?=addslashes(__('In the upper left corner, click on &quot;VNC Server&quot;.'))?></li>
1234
                        <li><?=addslashes(__('Select &quot;Reverse Connection&quot;.'))?></li>
1235
                        <li><?=addslashes(__('Enter the URL of your PalMA station and click &quot;Connect&quot;.'))?></li>
1236
                        </ul>
1237
                    <li><i class="fa fa-linux"></i> <?=addslashes(__('Linux:'))?></li>
1238
                        <ul>
1239
                        <li><?=addslashes(__('Run the downloaded shell script.'))?></li>
1240
                        <li><?=addslashes(__('Or use this shell command:'))?> <code>x11vnc -connect <?=$_SERVER['HTTP_HOST']?></code></li>
1241
                        </ul>
1242
                    </ul>
1243
                </ul>
1244
            <h4><?=addslashes(__('Control'))?><i class="fa fa-arrows"></i></h4>
1245
            <p><?=addslashes(__('With the grey monitor buttons at the top you can choose how the shared content should be arranged on the PalMA monitor.'))?></p>
1246
            <p><?=addslashes(__('Below that you find the controls for each item:'))?></p>
1247
            <ul>
1248
            <li><?=addslashes(__('In the top bar you can'))?></li>
1249
            <ul>
1250
            <li><?=addslashes(__('Hide and show'))?><i class="fa fa-eye"></i>,</li>
1251
            <li><?=addslashes(__('Zoom in and out'))?><i class="fa fa-search-plus"></i><i class="fa fa-search-minus"></i>,</li>
1252
            <li><?=addslashes(__('Rotate'))?><i class="fa fa-rotate-left"></i><i class="fa fa-rotate-right"></i>,</li>
1253
            <li><?=addslashes(__('Download'))?><i class="fa fa-download"></i>,</li>
1254
            <li><?=addslashes(__('Delete the item'))?><i class="fa fa-trash-o"></i>.</li>
1255
            </ul>
1256
            <li><?=addslashes(__('Below you find the navigation controls.'))?></li>
1257
            <ul>
1258
            <li><?=addslashes(__('Buttons on the left jump to the top, to the end, a page up or a page down'))?><i class="fa fa-angle-double-up"></i><i class="fa fa-angle-up"></i><i class="fa fa-angle-down"></i><i class="fa fa-angle-double-up"></i>.</li>
1259
            <li><?=addslashes(__('Arrow buttons in the middle scroll gradually'))?><i class="fa fa-toggle-up"></i><i class="fa fa-toggle-down"></i><i class="fa fa-toggle-left"></i><i class="fa fa-toggle-right"></i>.</li>
1260
            </ul>
1261
            </li>
1262
            <li><?=addslashes(__('On the right you can choose the position on the PalMA monitor'))?><i class="fa fa-desktop"></i>.</li>
1263
            </ul>
1264
            <p><?=addslashes(__('Controls that are not available for certain kinds of content are marked grey.'))?></p>
1265
            <h4><?=addslashes(__('Extras'))?><i class="fa fa-info-circle"></i></h4>
1266
            <p><?=addslashes(__('Some additional features are:'))?></p>
1267
            <ul>
1268
            <li><i class="fa fa-question-circle"></i> <?=addslashes(__('This help,'))?></li>
1269
            <li><i class="fa fa-thumbs-o-up"></i> <?=addslashes(__('Your chance to recommend us or give us your thoughts in the &quot;Feedback&quot; section,'))?></li>
1270
            <li><i class="fa fa-users"></i> <?=addslashes(__('A list of all logged-in users as well as a button to disconnect everyone and therefore end the session.'))?></li>
1271
            </ul>
1272
        </div>
1273
        <div id="Feedback" class="subtabcontent">
1274
            <div id="recommendcontainer">
1275
                <h3>
1276
                    <?=addslashes(__('Recommend us'))?>
1277
                </h3>
1278
                <div>
1279
                    <p><?=addslashes(__('If you like PalMA, please recommend us by sharing in your social networks.<br />Enjoy PalMA!'))?></p>
1280
                    <!-- Social Media Button Integration, Source: http://sharingbuttons.io/ -->
1281
                    <?php $github_url = "https%3A%2F%2Fgithub.com/UB-Mannheim/PalMA/blob/master/README.md"; ?>
1282
1283
                    <!-- Sharingbutton Facebook -->
1284
                    <a class="resp-sharing-button__link" href="https://facebook.com/sharer/sharer.php?u=<?=$github_url?>" target="_blank" aria-label="">
1285
                      <div class="resp-sharing-button resp-sharing-button--facebook resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
1286
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.77 7.46H14.5v-1.9c0-.9.6-1.1 1-1.1h3V.5h-4.33C10.24.5 9.5 3.44 9.5 5.32v2.15h-3v4h3v12h5v-12h3.85l.42-4z"/></svg>
1287
                        </div>
1288
                      </div>
1289
                    </a>
1290
1291
                    <!-- Sharingbutton Twitter -->
1292
                    <a class="resp-sharing-button__link" href="https://twitter.com/intent/tweet/?text=Do%20you%20already%20know%20PalMA?%20Take%20a%20Look.&amp;url=<?=$github_url?>" target="_blank" aria-label="">
1293
                      <div class="resp-sharing-button resp-sharing-button--twitter resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
1294
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M23.44 4.83c-.8.37-1.5.38-2.22.02.93-.56.98-.96 1.32-2.02-.88.52-1.86.9-2.9 1.1-.82-.88-2-1.43-3.3-1.43-2.5 0-4.55 2.04-4.55 4.54 0 .36.03.7.1 1.04-3.77-.2-7.12-2-9.36-4.75-.4.67-.6 1.45-.6 2.3 0 1.56.8 2.95 2 3.77-.74-.03-1.44-.23-2.05-.57v.06c0 2.2 1.56 4.03 3.64 4.44-.67.2-1.37.2-2.06.08.58 1.8 2.26 3.12 4.25 3.16C5.78 18.1 3.37 18.74 1 18.46c2 1.3 4.4 2.04 6.97 2.04 8.35 0 12.92-6.92 12.92-12.93 0-.2 0-.4-.02-.6.9-.63 1.96-1.22 2.56-2.14z"/></svg>
1295
                        </div>
1296
                      </div>
1297
                    </a>
1298
1299
                    <!-- Sharingbutton E-Mail -->
1300
                    <a class="resp-sharing-button__link" href="mailto:?subject=Do%20you%20already%20know%20PalMA?%20Take%20a%20Look.&amp;body=<?=$github_url?>" target="_self" aria-label="">
1301
                      <div class="resp-sharing-button resp-sharing-button--email resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
1302
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 4H2C.9 4 0 4.9 0 6v12c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM7.25 14.43l-3.5 2c-.08.05-.17.07-.25.07-.17 0-.34-.1-.43-.25-.14-.24-.06-.55.18-.68l3.5-2c.24-.14.55-.06.68.18.14.24.06.55-.18.68zm4.75.07c-.1 0-.2-.03-.27-.08l-8.5-5.5c-.23-.15-.3-.46-.15-.7.15-.22.46-.3.7-.14L12 13.4l8.23-5.32c.23-.15.54-.08.7.15.14.23.07.54-.16.7l-8.5 5.5c-.08.04-.17.07-.27.07zm8.93 1.75c-.1.16-.26.25-.43.25-.08 0-.17-.02-.25-.07l-3.5-2c-.24-.13-.32-.44-.18-.68s.44-.32.68-.18l3.5 2c.24.13.32.44.18.68z"/></svg>
1303
                        </div>
1304
                      </div>
1305
                    </a>
1306
1307
                    <!-- Sharingbutton WhatsApp -->
1308
                    <a class="resp-sharing-button__link" href="whatsapp://send?text=Do%20you%20already%20know%20PalMA?%20Take%20a%20Look.%20<?=$github_url?>" target="_blank" aria-label="">
1309
                      <div class="resp-sharing-button resp-sharing-button--whatsapp resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
1310
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.1 3.9C17.9 1.7 15 .5 12 .5 5.8.5.7 5.6.7 11.9c0 2 .5 3.9 1.5 5.6L.6 23.4l6-1.6c1.6.9 3.5 1.3 5.4 1.3 6.3 0 11.4-5.1 11.4-11.4-.1-2.8-1.2-5.7-3.3-7.8zM12 21.4c-1.7 0-3.3-.5-4.8-1.3l-.4-.2-3.5 1 1-3.4L4 17c-1-1.5-1.4-3.2-1.4-5.1 0-5.2 4.2-9.4 9.4-9.4 2.5 0 4.9 1 6.7 2.8 1.8 1.8 2.8 4.2 2.8 6.7-.1 5.2-4.3 9.4-9.5 9.4zm5.1-7.1c-.3-.1-1.7-.9-1.9-1-.3-.1-.5-.1-.7.1-.2.3-.8 1-.9 1.1-.2.2-.3.2-.6.1s-1.2-.5-2.3-1.4c-.9-.8-1.4-1.7-1.6-2-.2-.3 0-.5.1-.6s.3-.3.4-.5c.2-.1.3-.3.4-.5.1-.2 0-.4 0-.5C10 9 9.3 7.6 9 7c-.1-.4-.4-.3-.5-.3h-.6s-.4.1-.7.3c-.3.3-1 1-1 2.4s1 2.8 1.1 3c.1.2 2 3.1 4.9 4.3.7.3 1.2.5 1.6.6.7.2 1.3.2 1.8.1.6-.1 1.7-.7 1.9-1.3.2-.7.2-1.2.2-1.3-.1-.3-.3-.4-.6-.5z"/></svg>
1311
                        </div>
1312
                      </div>
1313
                    </a>
1314
1315
                    <!-- Sharingbutton Telegram -->
1316
                    <a class="resp-sharing-button__link" href="https://telegram.me/share/url?text=Do%20you%20already%20know%20PalMA?%20Take%20a%20Look.&amp;url=<?=$github_url?>" target="_blank" aria-label="">
1317
                      <div class="resp-sharing-button resp-sharing-button--telegram resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
1318
                          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M.707 8.475C.275 8.64 0 9.508 0 9.508s.284.867.718 1.03l5.09 1.897 1.986 6.38a1.102 1.102 0 0 0 1.75.527l2.96-2.41a.405.405 0 0 1 .494-.013l5.34 3.87a1.1 1.1 0 0 0 1.046.135 1.1 1.1 0 0 0 .682-.803l3.91-18.795A1.102 1.102 0 0 0 22.5.075L.706 8.475z"/></svg>
1319
                        </div>
1320
                      </div>
1321
                    </a>
1322
                </div> <!-- Social media buttons and description -->
1323
            </div> <!-- recommendcontainer -->
1324
            <div id="contactcontainer">
1325
                <h3><?=addslashes(__('Tell us what you think'))?></h3>
1326
                <div>
1327
                    <p><?=addslashes(__('Please let us know about problems or ideas to improve PalMA. Help us directly by sending crash reports or contributing on '))?><a href="https://github.com/UB-Mannheim/PalMA" target="_blank">GitHub</a>.<br /><?=__('Thank you!')?></p>
1328
                </div>
1329
            </div> <!-- contactcontainer -->
1330
        </div> <!-- feedback -->
1331
        <div id="Users" class="subtabcontent">
1332
            <div class="dropdown">
1333
                <button onclick="showDropdown()" class="dropbutton pure-button pure-button-primary"><?=addslashes(__('Select language:'))?> <?=substr($locale, 0, 2)?><i class="fa fa-caret-down"></i></button>
1334
                <div id="languageSelection" class="dropdown-content">
1335
                <?php
1336
                $dirs = array_slice(scandir('locale'), 2);
1337
                $langs = [];
1338
                for ($n = 0; $n < count($dirs); $n++) {
1339
                    if (is_dir("locale/$dirs[$n]")) {
1340
                        array_push($langs, substr($dirs[$n], 0, 2));
1341
                    }
1342
                }
1343
                for ($i = 0; $i < count($langs); $i++) {
1344
                    echo "<a href=$_SERVER[PHP_SELF]?lang=$langs[$i]>$langs[$i]</a>";
1345
                }
1346
                ?>
1347
                </div>
1348
            </div>
1349
            <div class="list_container">
1350
                <table class="userlist" summary="<?=addslashes(__('User list'))?>" title="<?=__('List of connected users')?>">
1351
                    <tbody id="userlist">
1352
                        <tr><td><!-- filled by updateUserList() --></td></tr>
1353
                    </tbody>
1354
                </table>
1355
                <div class="description">
1356
                    <?=addslashes(__('New users can join at'))?><br /><?=htmlspecialchars($_SESSION['starturl'])?><br />
1357
                    <?php
1358
                    if (!empty($_SESSION['pin'])) {
1359
                        echo addslashes(__('PIN: '));
1360
                        echo htmlspecialchars($_SESSION['pin']);
1361
                    }
1362
                    ?>
1363
                    <img class="qr-code" src="qrcode/php/qr_img.php?d=<?=htmlspecialchars($_SESSION['starturl'])?>?pin=<?=htmlspecialchars($_SESSION['pin'])?>" alt="QR Code">
1364
                </div>
1365
                <button class="pure-button pure-button-primary pure-input-rounded"
1366
                        onClick="sendToNuc('logout=ALL')"
1367
                        title="<?=addslashes(__('Disconnect all users and end the session'))?>">
1368
                    <?=addslashes(__('End the session'))?>
1369
                </button>
1370
            </div>
1371
        </div>
1372
    </div>
1373
</div> <!-- workbench -->
1374
1375
<div id="footer">
1376
    <?php
1377
      # Show authorized user name (and address) and allow logout.
1378
    if ($user) {
1379
        echo("<a href=\"logout.php\" title=\"" .
1380
          addslashes(__('Disconnect the current user')) .
1381
          "\">" . addslashes(__('Log out')) . "<i class=\"fa fa-sign-out\"></i></a>");
1382
    }
1383
    ?>
1384
</div> <!-- Footer -->
1385
1386
</body>
1387
</html>
1388