@@ -5,10 +5,10 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | session_start(); |
| 7 | 7 | if (isset($_REQUEST['monitor'])) { |
| 8 | - $monitor = $_REQUEST['monitor']; |
|
| 9 | - $_SESSION['monitor'] = $monitor; |
|
| 8 | + $monitor = $_REQUEST['monitor']; |
|
| 9 | + $_SESSION['monitor'] = $monitor; |
|
| 10 | 10 | } elseif (!isset($_SESSION['monitor'])) { |
| 11 | - $_SESSION['monitor'] = '???'; |
|
| 11 | + $_SESSION['monitor'] = '???'; |
|
| 12 | 12 | } |
| 13 | 13 | $_SESSION['referer'] = 'index.php'; |
| 14 | 14 | require_once 'auth.php'; |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | $username = ''; |
| 26 | 26 | $address = ''; |
| 27 | 27 | if (isset($_SESSION['username'])) { |
| 28 | - # PHP session based authorization. |
|
| 29 | - $username = $_SESSION['username']; |
|
| 30 | - $address = $_SESSION['address']; |
|
| 31 | - $user = "$username@$address"; |
|
| 28 | + # PHP session based authorization. |
|
| 29 | + $username = $_SESSION['username']; |
|
| 30 | + $address = $_SESSION['address']; |
|
| 31 | + $user = "$username@$address"; |
|
| 32 | 32 | } elseif (isset($_SERVER['PHP_AUTH_USER'])) { |
| 33 | - # .htaccess basic authorization. |
|
| 34 | - $user = $_SERVER['PHP_AUTH_USER']; |
|
| 33 | + # .htaccess basic authorization. |
|
| 34 | + $user = $_SERVER['PHP_AUTH_USER']; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | require_once 'globals.php'; |
@@ -501,13 +501,13 @@ discard block |
||
| 501 | 501 | } |
| 502 | 502 | } else { |
| 503 | 503 | <?php |
| 504 | - if ($user) { |
|
| 504 | + if ($user) { |
|
| 505 | 505 | ?> |
| 506 | 506 | // All users were disconnected. |
| 507 | 507 | alert("<?=addslashes(__('You were disconnected!'))?>"); |
| 508 | 508 | window.location = 'logout.php'; |
| 509 | 509 | <?php |
| 510 | - } else { |
|
| 510 | + } else { |
|
| 511 | 511 | ?> |
| 512 | 512 | // If there is no user, we display an empty entry. |
| 513 | 513 | var tr = document.createElement('tr'); |
@@ -516,8 +516,8 @@ discard block |
||
| 516 | 516 | tr.appendChild(td); |
| 517 | 517 | list.appendChild(tr); |
| 518 | 518 | <?php |
| 519 | - } |
|
| 520 | - ?> |
|
| 519 | + } |
|
| 520 | + ?> |
|
| 521 | 521 | } |
| 522 | 522 | } |
| 523 | 523 | |
@@ -1190,8 +1190,8 @@ discard block |
||
| 1190 | 1190 | </div> |
| 1191 | 1191 | <div class="description"> |
| 1192 | 1192 | <?=addslashes(__('Download your screensharing tool' |
| 1193 | - . ' (Windows, Mac and Linux only).' |
|
| 1194 | - . ' Visit the help section for further information.'))?> |
|
| 1193 | + . ' (Windows, Mac and Linux only).' |
|
| 1194 | + . ' Visit the help section for further information.'))?> |
|
| 1195 | 1195 | </div> |
| 1196 | 1196 | </div> |
| 1197 | 1197 | </div> |
@@ -1285,20 +1285,20 @@ discard block |
||
| 1285 | 1285 | <div id="Help" class="subtabcontent"> |
| 1286 | 1286 | <p> |
| 1287 | 1287 | <?=addslashes(__('With PalMA, you can share documents, websites' |
| 1288 | - . ' and your desktop with your learning group.'))?> |
|
| 1288 | + . ' and your desktop with your learning group.'))?> |
|
| 1289 | 1289 | <?=addslashes(__('The PalMA team monitor shows up to four' |
| 1290 | - . ' contributions simultaneously.'))?> |
|
| 1290 | + . ' contributions simultaneously.'))?> |
|
| 1291 | 1291 | </p> |
| 1292 | 1292 | <?php |
| 1293 | - if (CONFIG_INSTITUTION_URL) { ?> |
|
| 1293 | + if (CONFIG_INSTITUTION_URL) { ?> |
|
| 1294 | 1294 | <p> |
| 1295 | 1295 | <?=addslashes(__('For further information about PalMA in this' |
| 1296 | - . ' institution'))?> |
|
| 1296 | + . ' institution'))?> |
|
| 1297 | 1297 | <a href=<?=CONFIG_INSTITUTION_URL?> target="_blank"><?=__('see here.')?></a> |
| 1298 | 1298 | </p> |
| 1299 | 1299 | <?php |
| 1300 | - } |
|
| 1301 | - ?> |
|
| 1300 | + } |
|
| 1301 | + ?> |
|
| 1302 | 1302 | <h4><?=addslashes(__('Connect'))?><i class="fa fa-wifi"></i></h4> |
| 1303 | 1303 | <p> |
| 1304 | 1304 | <?=addslashes(__('Team members can join the session at any time with this URL or QR-Code:'))?> |
@@ -1307,8 +1307,8 @@ discard block |
||
| 1307 | 1307 | <?=$starturl?><br /> |
| 1308 | 1308 | <?php |
| 1309 | 1309 | if (!empty($pin)) { |
| 1310 | - echo addslashes(__('PIN: ')); |
|
| 1311 | - echo $pin; |
|
| 1310 | + echo addslashes(__('PIN: ')); |
|
| 1311 | + echo $pin; |
|
| 1312 | 1312 | } |
| 1313 | 1313 | ?> |
| 1314 | 1314 | </p> |
@@ -1360,7 +1360,7 @@ discard block |
||
| 1360 | 1360 | </ul> |
| 1361 | 1361 | <h4><?=addslashes(__('Control'))?><i class="fa fa-arrows"></i></h4> |
| 1362 | 1362 | <p><?=addslashes(__('With the grey monitor buttons at the top you' |
| 1363 | - . ' can choose how the shared content should be arranged on the PalMA monitor.'))?></p> |
|
| 1363 | + . ' can choose how the shared content should be arranged on the PalMA monitor.'))?></p> |
|
| 1364 | 1364 | <p><?=addslashes(__('Below that you find the controls for each item:'))?></p> |
| 1365 | 1365 | <ul> |
| 1366 | 1366 | <li><?=addslashes(__('In the top bar you can'))?></li> |
@@ -1503,8 +1503,8 @@ discard block |
||
| 1503 | 1503 | <div> |
| 1504 | 1504 | <p> |
| 1505 | 1505 | <?=addslashes(__('Please let us know about problems or ideas' |
| 1506 | - . ' to improve PalMA. Help us directly by' |
|
| 1507 | - . ' sending crash reports or contributing on'))?> |
|
| 1506 | + . ' to improve PalMA. Help us directly by' |
|
| 1507 | + . ' sending crash reports or contributing on'))?> |
|
| 1508 | 1508 | <a href="https://github.com/UB-Mannheim/PalMA" target="_blank">GitHub</a>. |
| 1509 | 1509 | <br /> |
| 1510 | 1510 | <?=__('Thank you!')?> |
@@ -1520,17 +1520,17 @@ discard block |
||
| 1520 | 1520 | <i class="fa fa-caret-down"></i></button> |
| 1521 | 1521 | <div id="languageSelection" class="dropdown-content"> |
| 1522 | 1522 | <?php |
| 1523 | - $dirs = array_slice(scandir('locale'), 2); |
|
| 1524 | - $langs = []; |
|
| 1525 | - for ($n = 0; $n < count($dirs); $n++) { |
|
| 1523 | + $dirs = array_slice(scandir('locale'), 2); |
|
| 1524 | + $langs = []; |
|
| 1525 | + for ($n = 0; $n < count($dirs); $n++) { |
|
| 1526 | 1526 | if (is_dir("locale/$dirs[$n]")) { |
| 1527 | - array_push($langs, substr($dirs[$n], 0, 2)); |
|
| 1527 | + array_push($langs, substr($dirs[$n], 0, 2)); |
|
| 1528 | + } |
|
| 1528 | 1529 | } |
| 1529 | - } |
|
| 1530 | - for ($i = 0; $i < count($langs); $i++) { |
|
| 1530 | + for ($i = 0; $i < count($langs); $i++) { |
|
| 1531 | 1531 | echo "<a href=$_SERVER[PHP_SELF]?lang=$langs[$i]>$langs[$i]</a>"; |
| 1532 | - } |
|
| 1533 | - ?> |
|
| 1532 | + } |
|
| 1533 | + ?> |
|
| 1534 | 1534 | </div> |
| 1535 | 1535 | </div> |
| 1536 | 1536 | <div class="list_container"> |
@@ -1544,11 +1544,11 @@ discard block |
||
| 1544 | 1544 | <div class="description"> |
| 1545 | 1545 | <?=addslashes(__('New users can join at'))?><br /><?=$starturl?><br /> |
| 1546 | 1546 | <?php |
| 1547 | - if (!empty($pin)) { |
|
| 1547 | + if (!empty($pin)) { |
|
| 1548 | 1548 | echo addslashes(__('PIN: ')); |
| 1549 | 1549 | echo $pin; |
| 1550 | - } |
|
| 1551 | - ?> |
|
| 1550 | + } |
|
| 1551 | + ?> |
|
| 1552 | 1552 | <img class="qr-code" src="qrcode/php/qr_img.php?d=<?=$starturl?>?pin=<?=$pin?>" alt="QR Code"> |
| 1553 | 1553 | </div> |
| 1554 | 1554 | <button class="pure-button pure-button-primary pure-input-rounded" |
@@ -1563,13 +1563,13 @@ discard block |
||
| 1563 | 1563 | |
| 1564 | 1564 | <div id="footer"> |
| 1565 | 1565 | <?php |
| 1566 | - # Show authorized user name (and address) and allow logout. |
|
| 1567 | - if ($user) { |
|
| 1566 | + # Show authorized user name (and address) and allow logout. |
|
| 1567 | + if ($user) { |
|
| 1568 | 1568 | echo("<a href=\"logout.php\" title=\"" . |
| 1569 | - addslashes(__('Disconnect the current user')) . |
|
| 1570 | - "\">" . addslashes(__('Log out')) . "<i class=\"fa fa-sign-out\"></i></a>"); |
|
| 1571 | - } |
|
| 1572 | - ?> |
|
| 1569 | + addslashes(__('Disconnect the current user')) . |
|
| 1570 | + "\">" . addslashes(__('Log out')) . "<i class=\"fa fa-sign-out\"></i></a>"); |
|
| 1571 | + } |
|
| 1572 | + ?> |
|
| 1573 | 1573 | </div> <!-- Footer --> |
| 1574 | 1574 | |
| 1575 | 1575 | </body> |
@@ -8,80 +8,80 @@ |
||
| 8 | 8 | // The default translations are in locale/en_US.UTF-8/LC_MESSAGES/palma.mo. |
| 9 | 9 | $locale = ''; |
| 10 | 10 | if (isset($_REQUEST['lang'])) { |
| 11 | - // User requested language by URL parameter. |
|
| 12 | - $locale = $_REQUEST['lang']; |
|
| 13 | - $_SESSION['lang'] = $locale; |
|
| 11 | + // User requested language by URL parameter. |
|
| 12 | + $locale = $_REQUEST['lang']; |
|
| 13 | + $_SESSION['lang'] = $locale; |
|
| 14 | 14 | } elseif (isset($_SESSION['lang'])) { |
| 15 | - // Get language from session data. |
|
| 16 | - $locale = $_SESSION['lang']; |
|
| 15 | + // Get language from session data. |
|
| 16 | + $locale = $_SESSION['lang']; |
|
| 17 | 17 | } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
| 18 | - // Get language from browser settings. |
|
| 19 | - $locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']); |
|
| 18 | + // Get language from browser settings. |
|
| 19 | + $locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']); |
|
| 20 | 20 | } |
| 21 | 21 | switch (substr($locale, 0, 2)) { |
| 22 | - case 'al': |
|
| 22 | + case 'al': |
|
| 23 | 23 | // Albanian. |
| 24 | 24 | $locale = 'sq_AL.UTF-8'; |
| 25 | - break; |
|
| 26 | - case 'ar': |
|
| 25 | + break; |
|
| 26 | + case 'ar': |
|
| 27 | 27 | // Arabic. |
| 28 | 28 | $locale = 'ar.UTF-8'; |
| 29 | - break; |
|
| 30 | - case 'de': |
|
| 29 | + break; |
|
| 30 | + case 'de': |
|
| 31 | 31 | // German. |
| 32 | 32 | $locale = 'de_DE.UTF-8'; |
| 33 | - break; |
|
| 34 | - case 'el': |
|
| 33 | + break; |
|
| 34 | + case 'el': |
|
| 35 | 35 | // Greek. |
| 36 | 36 | $locale = 'el_GR.UTF-8'; |
| 37 | - break; |
|
| 38 | - case 'en': |
|
| 37 | + break; |
|
| 38 | + case 'en': |
|
| 39 | 39 | // English. |
| 40 | 40 | $locale = 'en_US.UTF-8'; |
| 41 | - break; |
|
| 42 | - case 'es': |
|
| 41 | + break; |
|
| 42 | + case 'es': |
|
| 43 | 43 | // Spanish. |
| 44 | 44 | $locale = 'es_ES.UTF-8'; |
| 45 | - break; |
|
| 46 | - case 'fr': |
|
| 45 | + break; |
|
| 46 | + case 'fr': |
|
| 47 | 47 | // French. |
| 48 | 48 | $locale = 'fr_FR.UTF-8'; |
| 49 | - break; |
|
| 50 | - case 'hi': |
|
| 49 | + break; |
|
| 50 | + case 'hi': |
|
| 51 | 51 | // Hindi. |
| 52 | 52 | $locale = 'hi_IN.UTF-8'; |
| 53 | - break; |
|
| 54 | - case 'it': |
|
| 53 | + break; |
|
| 54 | + case 'it': |
|
| 55 | 55 | // Italian. |
| 56 | 56 | $locale = 'it_IT.UTF-8'; |
| 57 | - break; |
|
| 58 | - case 'ja': |
|
| 57 | + break; |
|
| 58 | + case 'ja': |
|
| 59 | 59 | // Japanese. |
| 60 | 60 | $locale = 'ja.UTF-8'; |
| 61 | - break; |
|
| 62 | - case 'kg': |
|
| 61 | + break; |
|
| 62 | + case 'kg': |
|
| 63 | 63 | // Kyrgyz. |
| 64 | 64 | $locale = 'kg_KG.UTF-8'; |
| 65 | - break; |
|
| 66 | - case 'lv': |
|
| 65 | + break; |
|
| 66 | + case 'lv': |
|
| 67 | 67 | // Latvian. |
| 68 | 68 | $locale = 'lv_LV.UTF-8'; |
| 69 | - break; |
|
| 70 | - case 'ru': |
|
| 69 | + break; |
|
| 70 | + case 'ru': |
|
| 71 | 71 | // Russian. |
| 72 | 72 | $locale = 'ru_RU.UTF-8'; |
| 73 | - break; |
|
| 74 | - case 'ur': |
|
| 73 | + break; |
|
| 74 | + case 'ur': |
|
| 75 | 75 | // Urdu. |
| 76 | 76 | $locale = 'ur_PK.UTF-8'; |
| 77 | - break; |
|
| 78 | - case 'zh': |
|
| 77 | + break; |
|
| 78 | + case 'zh': |
|
| 79 | 79 | // Chinese. |
| 80 | 80 | $locale = 'zh_CN.UTF-8'; |
| 81 | - break; |
|
| 82 | - default: |
|
| 81 | + break; |
|
| 82 | + default: |
|
| 83 | 83 | $locale = 'en_US.UTF-8'; |
| 84 | - break; |
|
| 84 | + break; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | //~ error_log("setlocale $locale"); |
@@ -7,25 +7,25 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class SSVNCDaemon |
| 9 | 9 | { |
| 10 | - // all during session connected VNC Clients |
|
| 11 | - /** @var array<array<string>> */ |
|
| 12 | - private array $VNC_CLIENTS = array(); |
|
| 10 | + // all during session connected VNC Clients |
|
| 11 | + /** @var array<array<string>> */ |
|
| 12 | + private array $VNC_CLIENTS = array(); |
|
| 13 | 13 | |
| 14 | - // count of all connected clients |
|
| 15 | - // private $_VNC_CLIENT_COUNT; |
|
| 14 | + // count of all connected clients |
|
| 15 | + // private $_VNC_CLIENT_COUNT; |
|
| 16 | 16 | |
| 17 | - // active client count |
|
| 18 | - private int $CONNECTIONS = 0; |
|
| 17 | + // active client count |
|
| 18 | + private int $CONNECTIONS = 0; |
|
| 19 | 19 | |
| 20 | - // ignored VNC Clients |
|
| 21 | - // TODO: check if no more longer helpful, has to be cleaned |
|
| 22 | - ///** @var array<string> */ |
|
| 23 | - //private array $IGNORE_LIST = array(); |
|
| 20 | + // ignored VNC Clients |
|
| 21 | + // TODO: check if no more longer helpful, has to be cleaned |
|
| 22 | + ///** @var array<string> */ |
|
| 23 | + //private array $IGNORE_LIST = array(); |
|
| 24 | 24 | |
| 25 | - public DBConnector $db; |
|
| 25 | + public DBConnector $db; |
|
| 26 | 26 | |
| 27 | - public function __construct() |
|
| 28 | - { |
|
| 27 | + public function __construct() |
|
| 28 | + { |
|
| 29 | 29 | require_once 'DBConnector.class.php'; |
| 30 | 30 | $this->db = DBConnector::getInstance(); |
| 31 | 31 | |
@@ -34,156 +34,156 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | // Read log in loop |
| 36 | 36 | $this->readLog($handle); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - protected function start(): mixed |
|
| 40 | - { |
|
| 39 | + protected function start(): mixed |
|
| 40 | + { |
|
| 41 | 41 | // Startup ssvncviewer in multilisten mode |
| 42 | 42 | require_once 'globals.php'; |
| 43 | 43 | $cmd = "export DISPLAY=" . CONFIG_DISPLAY . |
| 44 | - "; killall -q ssvncviewer; ssvncviewer -viewonly -multilisten 0 2>&1"; |
|
| 44 | + "; killall -q ssvncviewer; ssvncviewer -viewonly -multilisten 0 2>&1"; |
|
| 45 | 45 | $handle = popen($cmd, 'r'); |
| 46 | 46 | trace("SSVNCDaemon::start: vnc_viewer started"); |
| 47 | 47 | |
| 48 | 48 | return $handle; |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function readLog(mixed $handle): void |
|
| 52 | - { |
|
| 51 | + protected function readLog(mixed $handle): void |
|
| 52 | + { |
|
| 53 | 53 | require_once 'globals.php'; |
| 54 | 54 | trace("SSVNCDaemon::readLog()"); |
| 55 | 55 | |
| 56 | 56 | // local SSVNC client info |
| 57 | 57 | $client = array( |
| 58 | - "ip" => "", |
|
| 59 | - "hostname" => "", |
|
| 60 | - "active" => 1, |
|
| 61 | - "exit" => 0 |
|
| 58 | + "ip" => "", |
|
| 59 | + "hostname" => "", |
|
| 60 | + "active" => 1, |
|
| 61 | + "exit" => 0 |
|
| 62 | 62 | ); |
| 63 | 63 | |
| 64 | 64 | // Read File continuously |
| 65 | 65 | while (!feof($handle)) { |
| 66 | - $buffer = fgets($handle); |
|
| 66 | + $buffer = fgets($handle); |
|
| 67 | 67 | |
| 68 | - if ($this->CONNECTIONS == 0) { |
|
| 68 | + if ($this->CONNECTIONS == 0) { |
|
| 69 | 69 | //debug("SSVNCDaemon::readLog: WAITING FOR NEW CONNECTIONS"); |
| 70 | - } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $ip = $this->parseIP($buffer); |
|
| 73 | - $hostname = $this->parseHostname($buffer); |
|
| 74 | - $exit = $this->parseExit($buffer); |
|
| 72 | + $ip = $this->parseIP($buffer); |
|
| 73 | + $hostname = $this->parseHostname($buffer); |
|
| 74 | + $exit = $this->parseExit($buffer); |
|
| 75 | 75 | |
| 76 | - if ($ip != "") { |
|
| 76 | + if ($ip != "") { |
|
| 77 | 77 | $client["ip"] = $ip; |
| 78 | - } |
|
| 79 | - if ($hostname != "") { |
|
| 78 | + } |
|
| 79 | + if ($hostname != "") { |
|
| 80 | 80 | $client["hostname"] = $hostname; |
| 81 | - } |
|
| 82 | - if ($exit != 0) { |
|
| 81 | + } |
|
| 82 | + if ($exit != 0) { |
|
| 83 | 83 | $client["exit"] = $exit; |
| 84 | - } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - if ( |
|
| 87 | - strstr($buffer, 'create_image') && $client["ip"] != "" && |
|
| 86 | + if ( |
|
| 87 | + strstr($buffer, 'create_image') && $client["ip"] != "" && |
|
| 88 | 88 | $client["hostname"] != "" |
| 89 | - ) { |
|
| 89 | + ) { |
|
| 90 | 90 | // add client |
| 91 | 91 | if ($client["hostname"] == "unknown") { |
| 92 | - $client["hostname"] = $client["ip"]; |
|
| 92 | + $client["hostname"] = $client["ip"]; |
|
| 93 | 93 | } |
| 94 | 94 | $this->addClient($client["ip"], $client["hostname"]); |
| 95 | 95 | |
| 96 | 96 | // reset local Client information after adding it |
| 97 | 97 | $client["ip"] = ""; |
| 98 | 98 | $client["hostname"] = ""; |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - if ($exit == 1) { |
|
| 101 | + if ($exit == 1) { |
|
| 102 | 102 | // decrease active client count |
| 103 | 103 | if ($this->CONNECTIONS > 0) { |
| 104 | - $this->CONNECTIONS--; |
|
| 105 | - $this->deleteInactiveVncWindow(); |
|
| 104 | + $this->CONNECTIONS--; |
|
| 105 | + $this->deleteInactiveVncWindow(); |
|
| 106 | + } |
|
| 106 | 107 | } |
| 107 | - } |
|
| 108 | 108 | |
| 109 | - $halt = $this->CONNECTIONS; |
|
| 109 | + $halt = $this->CONNECTIONS; |
|
| 110 | 110 | |
| 111 | - if ($halt == -1) { |
|
| 111 | + if ($halt == -1) { |
|
| 112 | 112 | exit(0); |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - flush(); |
|
| 115 | + flush(); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | pclose($handle); |
| 119 | - } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - protected function parseIP(string $buffer): string |
|
| 122 | - { |
|
| 121 | + protected function parseIP(string $buffer): string |
|
| 122 | + { |
|
| 123 | 123 | require_once 'globals.php'; |
| 124 | 124 | $ip = ""; |
| 125 | 125 | $line = $buffer; |
| 126 | 126 | if (strpos($line, "Reverse VNC connection from IP")) { |
| 127 | - $line = trim($line); |
|
| 128 | - $item = explode(":", $line); |
|
| 129 | - $ip = trim($item[1]); |
|
| 130 | - $ip = preg_replace('/\W\W\d{4}\/\d{2}\/\d{2} \d{2}/', '', $ip); |
|
| 127 | + $line = trim($line); |
|
| 128 | + $item = explode(":", $line); |
|
| 129 | + $ip = trim($item[1]); |
|
| 130 | + $ip = preg_replace('/\W\W\d{4}\/\d{2}\/\d{2} \d{2}/', '', $ip); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | if ($ip != "") { |
| 134 | - debug("SSVNCDaemon::parseIP(): " . $ip); |
|
| 134 | + debug("SSVNCDaemon::parseIP(): " . $ip); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | return $ip; |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - protected function parseHostname(string $buffer): string |
|
| 141 | - { |
|
| 140 | + protected function parseHostname(string $buffer): string |
|
| 141 | + { |
|
| 142 | 142 | require_once 'globals.php'; |
| 143 | 143 | $hostname = ""; |
| 144 | 144 | $line = $buffer; |
| 145 | 145 | if (strpos($line, "Hostname")) { |
| 146 | - $line = trim($line); |
|
| 147 | - $item = explode(":", $line); |
|
| 148 | - $hostname = trim($item[1]); |
|
| 149 | - $hostname = preg_replace('/\.uni\-mannheim\.de/', '', $hostname); |
|
| 146 | + $line = trim($line); |
|
| 147 | + $item = explode(":", $line); |
|
| 148 | + $hostname = trim($item[1]); |
|
| 149 | + $hostname = preg_replace('/\.uni\-mannheim\.de/', '', $hostname); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | if ($hostname != "") { |
| 153 | - debug("SSVNCDaemon::parseHostname(): " . $hostname); |
|
| 153 | + debug("SSVNCDaemon::parseHostname(): " . $hostname); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | return $hostname; |
| 157 | - } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - protected function parseExit(string $line): int |
|
| 160 | - { |
|
| 159 | + protected function parseExit(string $line): int |
|
| 160 | + { |
|
| 161 | 161 | require_once 'globals.php'; |
| 162 | 162 | $exit = 0; |
| 163 | 163 | if (strpos($line, "VNC Viewer exiting")) { |
| 164 | - $exit = 1; |
|
| 164 | + $exit = 1; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if ($exit != 0) { |
| 168 | - debug("SSVNCDaemon::parseExit: exit code " . $exit); |
|
| 168 | + debug("SSVNCDaemon::parseExit: exit code " . $exit); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | return $exit; |
| 172 | - } |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - protected function addClient(string $ip, string $hostname): void |
|
| 175 | - { |
|
| 174 | + protected function addClient(string $ip, string $hostname): void |
|
| 175 | + { |
|
| 176 | 176 | require_once 'globals.php'; |
| 177 | 177 | $vncclient = array( |
| 178 | - "ip" => $ip, |
|
| 179 | - "hostname" => $hostname, |
|
| 180 | - "active" => 1, |
|
| 181 | - "exit" => 0 |
|
| 178 | + "ip" => $ip, |
|
| 179 | + "hostname" => $hostname, |
|
| 180 | + "active" => 1, |
|
| 181 | + "exit" => 0 |
|
| 182 | 182 | ); |
| 183 | 183 | if (count($this->VNC_CLIENTS) == 0) { |
| 184 | - $id = 1; |
|
| 184 | + $id = 1; |
|
| 185 | 185 | } else { |
| 186 | - $id = count($this->VNC_CLIENTS) + 1; |
|
| 186 | + $id = count($this->VNC_CLIENTS) + 1; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $this->VNC_CLIENTS[$id] = $vncclient; |
@@ -196,13 +196,13 @@ discard block |
||
| 196 | 196 | $this->sendVncWindowToNuc($id, $vncclient); |
| 197 | 197 | |
| 198 | 198 | $this->CONNECTIONS++; |
| 199 | - } |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * @param array<string,string> $vncclient |
|
| 203 | - */ |
|
| 204 | - protected function sendVncWindowToNuc(int $id, array $vncclient): void |
|
| 205 | - { |
|
| 201 | + /** |
|
| 202 | + * @param array<string,string> $vncclient |
|
| 203 | + */ |
|
| 204 | + protected function sendVncWindowToNuc(int $id, array $vncclient): void |
|
| 205 | + { |
|
| 206 | 206 | require_once 'globals.php'; |
| 207 | 207 | debug("SSVNCDaemon::sendVncWindowToNuc()"); |
| 208 | 208 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $client_info = $this->db->getVNCClientInfo(); |
| 214 | 214 | |
| 215 | 215 | foreach ($client_info as $info) { |
| 216 | - $clients_in_db[] = $info["file"]; |
|
| 216 | + $clients_in_db[] = $info["file"]; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | $ip = $vncclient["ip"]; |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | // if vnc_id not in database create window and send to nuc |
| 236 | 236 | if (!(in_array($vnc_id, $clients_in_db))) { |
| 237 | - // print("\n[Daemon]: insert $vnc_id into db"); |
|
| 237 | + // print("\n[Daemon]: insert $vnc_id into db"); |
|
| 238 | 238 | |
| 239 | - $dt = new \DateTime(); |
|
| 240 | - $date = $dt->format('Y-m-d H:i:s'); |
|
| 239 | + $dt = new \DateTime(); |
|
| 240 | + $date = $dt->format('Y-m-d H:i:s'); |
|
| 241 | 241 | |
| 242 | - $window = array( |
|
| 242 | + $window = array( |
|
| 243 | 243 | "id" => "", |
| 244 | 244 | "win_id" => "", |
| 245 | 245 | "name" => "", |
@@ -248,33 +248,33 @@ discard block |
||
| 248 | 248 | "handler" => "vnc", |
| 249 | 249 | "userid" => $name, |
| 250 | 250 | "date" => $date |
| 251 | - ); |
|
| 251 | + ); |
|
| 252 | 252 | |
| 253 | - $serializedWindow = serialize($window); |
|
| 253 | + $serializedWindow = serialize($window); |
|
| 254 | 254 | |
| 255 | - require_once 'globals.php'; |
|
| 255 | + require_once 'globals.php'; |
|
| 256 | 256 | |
| 257 | - $sw = urlencode($serializedWindow); |
|
| 258 | - // Get cURL resource |
|
| 259 | - $curl = curl_init(); |
|
| 260 | - // Set some options - we are passing in a useragent too here |
|
| 261 | - curl_setopt_array($curl, array( |
|
| 257 | + $sw = urlencode($serializedWindow); |
|
| 258 | + // Get cURL resource |
|
| 259 | + $curl = curl_init(); |
|
| 260 | + // Set some options - we are passing in a useragent too here |
|
| 261 | + curl_setopt_array($curl, array( |
|
| 262 | 262 | CURLOPT_RETURNTRANSFER => 1, |
| 263 | 263 | CURLOPT_URL => CONFIG_CONTROL_FILE . '?newVncWindow=' . $sw, |
| 264 | 264 | CURLOPT_USERAGENT => 'PalMA cURL Request' |
| 265 | - )); |
|
| 266 | - // Send the request |
|
| 267 | - curl_exec($curl); |
|
| 268 | - // Close request to clear up some resources |
|
| 269 | - curl_close($curl); |
|
| 265 | + )); |
|
| 266 | + // Send the request |
|
| 267 | + curl_exec($curl); |
|
| 268 | + // Close request to clear up some resources |
|
| 269 | + curl_close($curl); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // add unique id to ignore list after sending to nuc |
| 273 | 273 | //array_push($this->IGNORE_LIST, $vnc_id); |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - protected function deleteInactiveVncWindow(): void |
|
| 277 | - { |
|
| 276 | + protected function deleteInactiveVncWindow(): void |
|
| 277 | + { |
|
| 278 | 278 | require_once 'globals.php'; |
| 279 | 279 | debug('SSVNCDaemon::deleteInactiveVncWindow()'); |
| 280 | 280 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $vnc_windows_in_db = array(); |
| 283 | 283 | $client_info = $this->db->getVNCClientInfo(); |
| 284 | 284 | foreach ($client_info as $info) { |
| 285 | - $vnc_windows_in_db[] = $info["win_id"]; |
|
| 285 | + $vnc_windows_in_db[] = $info["win_id"]; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | // window_ids on screen |
@@ -290,11 +290,11 @@ discard block |
||
| 290 | 290 | $windows = explode("\n", shell_exec('wmctrl -l')); |
| 291 | 291 | |
| 292 | 292 | foreach ($windows as $w) { |
| 293 | - $field = explode(' ', $w); |
|
| 294 | - $id = $field[0]; |
|
| 295 | - if ($id != '') { |
|
| 293 | + $field = explode(' ', $w); |
|
| 294 | + $id = $field[0]; |
|
| 295 | + if ($id != '') { |
|
| 296 | 296 | $windows_on_screen[] = $id; |
| 297 | - } |
|
| 297 | + } |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | debug(" clients in db = " . serialize($vnc_windows_in_db)); |
@@ -304,24 +304,24 @@ discard block |
||
| 304 | 304 | $inactive_vnc_window_ids = array_diff($vnc_windows_in_db, $windows_on_screen); |
| 305 | 305 | |
| 306 | 306 | foreach ($inactive_vnc_window_ids as $inactive_win_id) { |
| 307 | - // define vnc-id |
|
| 308 | - $inactive_vnc_id = $this->db->querySingle("SELECT file FROM window WHERE win_id='" . $inactive_win_id . "'"); |
|
| 307 | + // define vnc-id |
|
| 308 | + $inactive_vnc_id = $this->db->querySingle("SELECT file FROM window WHERE win_id='" . $inactive_win_id . "'"); |
|
| 309 | 309 | |
| 310 | - // delete from database (send to control.php) |
|
| 311 | - $curl = curl_init(); |
|
| 310 | + // delete from database (send to control.php) |
|
| 311 | + $curl = curl_init(); |
|
| 312 | 312 | |
| 313 | - require_once 'globals.php'; |
|
| 314 | - curl_setopt_array($curl, array( |
|
| 313 | + require_once 'globals.php'; |
|
| 314 | + curl_setopt_array($curl, array( |
|
| 315 | 315 | CURLOPT_RETURNTRANSFER => 1, |
| 316 | 316 | CURLOPT_URL => CONFIG_CONTROL_FILE . |
| 317 | - '?window=vncwin&delete=VNC&vncid=' . $inactive_win_id, |
|
| 317 | + '?window=vncwin&delete=VNC&vncid=' . $inactive_win_id, |
|
| 318 | 318 | CURLOPT_USERAGENT => 'PalMA cURL Request' |
| 319 | - )); |
|
| 319 | + )); |
|
| 320 | 320 | |
| 321 | - curl_exec($curl); |
|
| 322 | - curl_close($curl); |
|
| 321 | + curl_exec($curl); |
|
| 322 | + curl_close($curl); |
|
| 323 | 323 | |
| 324 | - // debug(" inactive vnc_id = $inactive_vnc_id >> add to list: " .serialize($this->IGNORE_LIST)); |
|
| 324 | + // debug(" inactive vnc_id = $inactive_vnc_id >> add to list: " .serialize($this->IGNORE_LIST)); |
|
| 325 | + } |
|
| 325 | 326 | } |
| 326 | - } |
|
| 327 | 327 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | if (count($this->VNC_CLIENTS) == 0) { |
| 184 | 184 | $id = 1; |
| 185 | 185 | } else { |
| 186 | - $id = count($this->VNC_CLIENTS) + 1; |
|
| 186 | + $id = count($this->VNC_CLIENTS)+1; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $this->VNC_CLIENTS[$id] = $vncclient; |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | debug("SSVNCDaemon::addClient: CLIENT OBJECT with ID " . $id . " CREATED : " |
| 192 | 192 | . $vncclient["ip"] . " | " . $vncclient["hostname"] . " | " |
| 193 | 193 | . $vncclient["active"] . " | " . $vncclient["exit"]); |
| 194 | - debug("SSVNCDaemon::addClient: " . ($this->CONNECTIONS + 1) . " CLIENT(S) CONNECTED ..."); |
|
| 194 | + debug("SSVNCDaemon::addClient: " . ($this->CONNECTIONS+1) . " CLIENT(S) CONNECTED ..."); |
|
| 195 | 195 | |
| 196 | 196 | $this->sendVncWindowToNuc($id, $vncclient); |
| 197 | 197 | |