Issues (25)

index.php (1 issue)

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
$winvnc = CONFIG_START_URL . "theme/" . CONFIG_THEME . "/winvnc-palma.exe";
84
$macvnc = CONFIG_START_URL . "theme/" . CONFIG_THEME . "/osx-vnc.dmg";
85
$linuxsh = CONFIG_START_URL . "theme/" . CONFIG_THEME . "/x11.sh";
86
87
?>
88
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
89
       "http://www.w3.org/TR/html4/strict.dtd">
90
91
<html>
92
93
<head>
94
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
95
<meta name="viewport" content="width=device-width, initial-scale=1">
96
<title>PalMA</title>
97
98
<link rel="icon" href="theme/<?=CONFIG_THEME?>/favicon.ico" type="image/x-icon">
99
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
100
<link rel="stylesheet" href="pure-min.css">
101
<link rel="stylesheet" href="palma.css" type="text/css">
102
103
<script type="text/javascript" src="jquery.min.js"></script>
104
105
<script src="dropzone.min.js"></script>
106
<link
107
  rel="stylesheet"
108
  href="dropzone.min.css"
109
  type="text/css"
110
/>
111
112
<script type="text/javascript">
113
114
// Screen section which responds to keyboard input.
115
var focus_section = '1';
116
117
function sendToNuc(command) {
118
  var xmlHttp = new XMLHttpRequest();
119
  if (!xmlHttp) {
120
    // TODO
121
    alert('XMLHttpRequest failed!');
122
    return;
123
  }
124
  var url = 'control.php?' + command;
125
  var response = "";
126
  xmlHttp.open("get", url, true);
127
  xmlHttp.onreadystatechange = function () {
128
      if (xmlHttp.readyState == 1) {
129
          // Server connection established (IE only).
130
      } else if (xmlHttp.readyState == 2) {
131
          // Data transferred to server.
132
      } else if (xmlHttp.readyState == 3) {
133
          // Server is answering.
134
      } else if (xmlHttp.readyState == 4) {
135
          // Received all data from server.
136
          return xmlHttp.responseText;
137
      } else {
138
          alert("Got xmlHttp.readyState " + xmlHttp.readyState);
139
      }
140
  };
141
  xmlHttp.send(null);
142
  //~ alert("sendToNuc " + url);
143
}
144
145
function keyControl(number, image, controlClass, key, handler, disabled, title) {
146
    // "number" refers to the slected screensection
147
148
  var keyHandler = getHandlerCommand(handler, key);
149
  if ( (keyHandler == "") || (keyHandler == null) ) {
150
    keyHandler = "default";
151
  }
152
  var button = document.createElement('button');
153
  var icon = document.createElement('i');
154
  if (!disabled) {
155
    icon.setAttribute('class', image);
156
    button.appendChild(icon);
157
    button.setAttribute('class', controlClass);
158
    button.setAttribute('onmousedown',
159
                     'sendToNuc("window=' + number + '&keydown=' + encodeURIComponent(keyHandler) + '")');
160
    button.setAttribute('onmouseup',
161
                     'sendToNuc("window=' + number + '&keyup=' + encodeURIComponent(keyHandler) + '")');
162
    button.setAttribute('title', title);
163
  } else {
164
    icon.setAttribute('class', image + " unavailable");
165
    button.appendChild(icon);
166
    button.setAttribute("class", "unavailable");
167
    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

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