Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,7 @@
}

if (!isset($config['webserver']['ip'])) {
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
$protocol = 'https://';
} else {
$protocol = 'http://';
}
$config['webserver']['ip'] = str_replace($protocol, '', getPhotoboothUrl());
$config['webserver']['ip'] = getPhotoboothIp();
}

if (!isset($config['qr']['url'])) {
Expand Down
44 changes: 27 additions & 17 deletions lib/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@ function getrootpath($relative_path) {
return $rootpath;
}

function getPhotoboothIp() {
$os = DIRECTORY_SEPARATOR == '\\' || strtolower(substr(PHP_OS, 0, 3)) === 'win' ? 'windows' : 'linux';
if ($os == 'linux') {
$get_ip = shell_exec('hostname -I | cut -d " " -f 1');

if (!$get_ip) {
$ip = $_SERVER['HTTP_HOST'];
} else {
$ip = $get_ip;
}
} else {
$ip = $_SERVER['HTTP_HOST'];
}

return $ip;
}

function getPhotoboothFolder() {
$path = getrootpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
if ($path == $_SERVER['DOCUMENT_ROOT']) {
return false;
} else {
$folder = str_replace($_SERVER['DOCUMENT_ROOT'], '', $path);
return $folder;
}
}

function getPhotoboothUrl() {
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
$protocol = 'https';
Expand All @@ -27,23 +54,6 @@ function getPhotoboothUrl() {
return $url;
}

function getPhotoboothIp() {
$os = DIRECTORY_SEPARATOR == '\\' || strtolower(substr(PHP_OS, 0, 3)) === 'win' ? 'windows' : 'linux';
if ($os == 'linux') {
$get_ip = shell_exec('hostname -I | cut -d " " -f 1');

if (!$get_ip) {
$ip = $_SERVER['HTTP_HOST'];
} else {
$ip = $get_ip;
}
} else {
$ip = $_SERVER['HTTP_HOST'];
}

return $ip;
}

function testFile($file) {
$realPath = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $file);
if (is_dir($realPath)) {
Expand Down