Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Photobooth Updater #285

Merged
merged 14 commits into from
Aug 24, 2021
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
24 changes: 24 additions & 0 deletions api/checkConnection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
header('Content-Type: application/json');

function is_connected() {
$connected = @fsockopen('www.startpage.com', 80);
if ($connected) {
$is_conn = true;
fclose($connected);
} else {
$is_conn = false;
}

return $is_conn;
}

if (is_connected()) {
echo json_encode([
'connected' => true,
]);
} else {
echo json_encode([
'connected' => false,
]);
}
8 changes: 8 additions & 0 deletions api/checkOS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
header('Content-Type: application/json');

$operating_system = DIRECTORY_SEPARATOR == '\\' || strtolower(substr(PHP_OS, 0, 3)) === 'win' ? 'windows' : 'linux';

echo json_encode([
'os' => $operating_system,
]);
62 changes: 62 additions & 0 deletions api/update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
header('Content-Type: application/json');

require_once '../lib/config.php';

$ghscript = __DIR__ . DIRECTORY_SEPARATOR . '../resources/sh/check-github.sh';
$commitscript = __DIR__ . DIRECTORY_SEPARATOR . '../resources/sh/commit.sh';
$upddev = __DIR__ . DIRECTORY_SEPARATOR . '../resources/sh/update-dev.sh';
$updstable = __DIR__ . DIRECTORY_SEPARATOR . '../resources/sh/update-stable.sh';
$checkdeps = __DIR__ . DIRECTORY_SEPARATOR . '../resources/sh/check-dependencies.sh';

$mode = $_POST['mode'];

switch ($mode) {
case 'check-git':
$cmd = sprintf($ghscript);
break;
case 'commit':
$cmd = sprintf($commitscript);
break;
case 'update-dev':
$cmd = sprintf($upddev);
break;
case 'update-stable':
$cmd = sprintf($updstable);
break;
case 'check-deps':
$cmd = sprintf($checkdeps);
break;
default:
$cmd = 'echo "Error!"';
break;
}

$success = exec('bash ' . $cmd, $output, $retval);

if (isset($success)) {
switch ($retval) {
case 127:
$output = 'Command not found';
$success = false;
break;
case 0:
$success = true;
break;
default:
$success = 'unknown';
break;
}

echo json_encode([
'success' => $success,
'output' => $output,
'retval' => $retval,
'command' => $cmd,
]);
} else {
echo json_encode([
'success' => 'false',
'command' => $cmd,
]);
}
2 changes: 2 additions & 0 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@
$config['login']['password'] = NULL;
$config['protect']['admin'] = true;
$config['protect']['localhost_admin'] = true;
$config['protect']['update'] = true;
$config['protect']['localhost_update'] = true;
$config['protect']['index'] = false;
$config['protect']['localhost_index'] = false;
$config['protect']['manual'] = false;
Expand Down
76 changes: 76 additions & 0 deletions dependencies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
session_start();

require_once('lib/config.php');

// Login / Authentication check
if (
!$config['login']['enabled'] ||
(!$config['protect']['localhost_admin'] && $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR']) ||
(isset($_SESSION['auth']) && $_SESSION['auth'] === true) ||
!$config['protect']['admin']
) {
// nothing to do for now

} else {
header('location: login');
exit();
}
?>
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
<meta name="msapplication-TileColor" content="<?=$config['colors']['primary']?>">
<meta name="theme-color" content="<?=$config['colors']['primary']?>">

<title><?=$config['ui']['branding']?></title>

<!-- Favicon + Android/iPhone Icons -->
<link rel="apple-touch-icon" sizes="180x180" href="resources/img/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="resources/img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="resources/img/favicon-16x16.png">
<link rel="manifest" href="resources/img/site.webmanifest">
<link rel="mask-icon" href="resources/img/safari-pinned-tab.svg" color="#5bbad5">

<!-- Fullscreen Mode on old iOS-Devices when starting photobooth from homescreen -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />

<link rel="stylesheet" href="node_modules/normalize.css/normalize.css" />
<link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.css" />
<link rel="stylesheet" href="resources/css/<?php echo $config['ui']['style']; ?>_style.css" />
<link rel="stylesheet" href="resources/css/update.css" />
<?php if ($config['ui']['rounded_corners'] && $config['ui']['style'] === 'classic'): ?>
<link rel="stylesheet" href="resources/css/rounded.css" />
<?php endif; ?>
<?php if (is_file("private/overrides.css")): ?>
<link rel="stylesheet" href="private/overrides.css" />
<?php endif; ?>
</head>

<body class="updatewrapper">

<div class="white-box" id="white-box">
<h2><?=$config['ui']['branding']?> dependencies check</h2>
<p><span data-i18n="os_check"></span></p>
</div>

<div>
<a href="./" class="btn"><i class="fa fa-home"></i> <span data-i18n="home"></span></a>

<a href="admin" class="btn"><i class="fa fa-cog"></i> <span data-i18n="admin_panel"></span></a>
</div>

<script type="text/javascript" src="node_modules/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="api/config.php"></script>
<script type="text/javascript" src="resources/js/theme.js"></script>
<script type="text/javascript" src="resources/js/dependencies.js"></script>
<script src="node_modules/whatwg-fetch/dist/fetch.umd.js"></script>
<script src="node_modules/@andreasremdt/simple-translator/dist/umd/translator.min.js"></script>
<script type="text/javascript" src="resources/js/i18n.js"></script>

</body>
</html>
26 changes: 26 additions & 0 deletions lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@
'name' => 'DISKUSAGEBUTTON',
'value' => 'diskusage-btn',
],
'dependencies_button' => [
'view' => 'basic',
'type' => 'button',
'placeholder' => 'dependencies_check',
'name' => 'DEPENDENCIESBUTTON',
'value' => 'dependencies-btn',
],
],
'frontpage' => [
'view' => 'basic',
Expand Down Expand Up @@ -1552,6 +1559,18 @@
'name' => 'protect[localhost_admin]',
'value' => $config['protect']['localhost_admin'],
],
'protect_update' => [
'view' => 'advanced',
'type' => 'checkbox',
'name' => 'protect[update]',
'value' => $config['protect']['update'],
],
'protect_localhost_update' => [
'view' => 'expert',
'type' => 'checkbox',
'name' => 'protect[localhost_update]',
'value' => $config['protect']['localhost_update'],
],
'protect_index' => [
'view' => 'advanced',
'type' => 'checkbox',
Expand Down Expand Up @@ -1979,5 +1998,12 @@
'name' => 'CHECKVERSIONBUTTON',
'value' => 'checkversion-btn',
],
'updater_button' => [
'view' => 'basic',
'type' => 'button',
'placeholder' => 'updater',
'name' => 'UPDATERBUTTON',
'value' => 'updater-btn',
],
],
];
4 changes: 4 additions & 0 deletions login/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
<?php endif; ?>
<?php if(!$config['protect']['admin'] || (!$config['protect']['localhost_admin'] && $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR']) || !$config['login']['enabled'] || (isset($_SESSION['auth']) && $_SESSION['auth'] === true)): ?>
<p><a href="../admin" class="btn btn--login"><i class="fa fa-cog"></i> <span data-i18n="admin_panel"></span></a></p>
<p><a href="../dependencies.php" class="btn btn--login"><i class="fa fa-list-ul"></i> <span data-i18n="dependencies_check"></span></a></p>
<?php endif; ?>
<?php if(!$config['protect']['update'] || (!$config['protect']['localhost_update'] && $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR']) || !$config['login']['enabled'] || (isset($_SESSION['auth']) && $_SESSION['auth'] === true)): ?>
<p><a href="../update.php" class="btn btn--login"><i class="fa fa-tasks"></i> <span data-i18n="updater"></span></a></p>
<?php endif; ?>
<p><a href="../gallery.php" class="btn btn--login"><i class="fa fa-th"></i> <span data-i18n="gallery"></span></a></p>
<p><a href="../slideshow" class="btn btn--login"><i class="fa fa-play"></i> <span data-i18n="slideshow"></span></a></p>
Expand Down
29 changes: 29 additions & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
"authentication:protect_localhost_admin": "Protect admin panel on localhost access",
"authentication:protect_localhost_index": "Protect start screen on localhost access",
"authentication:protect_localhost_manual": "Protect manual & FAQ on localhost access",
"authentication:protect_localhost_update": "Protect updater on localhost access",
"authentication:protect_manual": "Protect manual & FAQ",
"authentication:protect_update": "Protect updater",
"auto_reload": "Photobooth reloads automatically...",
"available_version": "Available:",
"bootconfig": "config.txt",
"busy": "Processing ...",
"busyCollage": "Processing Collage ...",
"cameralog": "Camera log",
"check_connection": "Checking connection...",
"check_dependencies": "Checking installed dependencies...",
"check_version": "Check online",
"cheese": "Cheeeeeeeese!",
"cheeseCollage": "Cheeeeeeeese Collageeeeeeeeeee!",
Expand Down Expand Up @@ -66,6 +70,7 @@
"debugpanel:autorefresh": "Auto-Refresh",
"degrees": "°",
"delete": "Delete",
"dependencies_check": "Installed dependencies",
"dev_debugpanel": "Debug panel",
"disk_usage": "Disk Usage",
"dot": ".",
Expand Down Expand Up @@ -123,6 +128,7 @@
"general:database_file": "Database file name",
"general:database_rebuild": "Rebuild image database",
"general:delete_no_request": "Delete images without confirm request",
"general:dependencies_button": "Check installed dependencies",
"general:dev_debugpanel": "Debug Panel",
"general:dev_demo_images": "Use Demo Images",
"general:dev_enabled": "Dev-Mode",
Expand Down Expand Up @@ -189,7 +195,9 @@
"manual:authentication:protect_localhost_admin": "If disabled, admin panel can be accessed without username and password from localhost.",
"manual:authentication:protect_localhost_index": "If disabled, start screen can be accessed without username and password from localhost.",
"manual:authentication:protect_localhost_manual": "If disabled, manual and FAQ can be accessed without username and password from localhost.",
"manual:authentication:protect_localhost_update": "If disabled, updater can be accessed without username and password from localhost.",
"manual:authentication:protect_manual": "If enabled, manual and FAQ can only be accessed if a username and password is entered.",
"manual:authentication:protect_update": "If enabled, updater can only be accessed if a username and password is entered.",
"manual:collage:collage_cntdwn_time": "Set your countdown time between pictures while taking a collage.",
"manual:collage:collage_continuous": "Take collage without interrupption.",
"manual:collage:collage_continuous_time": "Controll the time a picture is visible on continuous collage before the next picture is taken.",
Expand Down Expand Up @@ -266,6 +274,7 @@
"manual:general:database_file": "Name of the database file.",
"manual:general:database_rebuild": "Rebuild the images database. Normally not required but can be used to fix a corrupted database file.",
"manual:general:delete_no_request": "If enabled, images will be deleted without a confirm request. Delete of images can't be undone!",
"manual:general:dependencies_button": "This will check if needed dependencies are installed.",
"manual:general:dev_debugpanel": "Opens the debug panel in a separate window. Make sure you have Dev-Mode enabled for more information.",
"manual:general:dev_demo_images": "If enabled, sample pictures will be used instead taking a picture.",
"manual:general:dev_enabled": "Enables development mode with advanced logging.",
Expand Down Expand Up @@ -407,11 +416,15 @@
"manual:userinterface:ui_rounded_corners": "If enabled, the Photobooth UI uses smooth rounded edges.",
"manual:userinterface:ui_style": "Choose a start page styling. To use custom styling please create and use \"/template/custom.template.php\" and \"/resources/css/custom_style.css\", if one of these files is not readable we will fallback to default theme.",
"manual:version:check_version": "This will check online against the Github repository for the latest Photobooth version.",
"manual:version:updater_button": "This will check if Photobooth can be updated and perform the update. Only works on Linux if Photobooth was installed via git.",
"milliseconds": "ms",
"myconfig": "My Config",
"newCollage": "New Collage",
"newPhoto": "New Picture",
"nextPhoto": "Next Picture",
"no_connection": "Not internect connection!",
"ok": "ok",
"os_check": "Checking OS...",
"path": "Path:",
"percent": "%",
"pictures": "Pictures",
Expand Down Expand Up @@ -535,7 +548,22 @@
"telegram": "Community @ Telegram",
"test_update_available": "There is a test update available.",
"toggleFullscreen": "Toggle Fullscreen",
"unsupported_os": "Unsupported OS!",
"update_available": "There is an update available.",
"update_check_git": "Checking git repository...",
"update_commit_backup": "Commit & backup your changes to update!",
"update_committing": "Committing your changes...",
"update_done": "Updated!",
"update_error": "Something went wrong!",
"update_fail": "Failed! Check console log for more informations!",
"update_git_commit": "Commit & Backup",
"update_git_commited": "Changes committed!",
"update_no_git": "Not a git repo! Automated update not possible!",
"update_ready": "Ready to update!",
"update_running": "Updating... Please be patient! Update might take a while! ...",
"update_to_dev": "Update to latest development Version",
"update_to_stable": "Update to latest Stable v3",
"updater": "Updater",
"use_button": "Use Buzzer to take a Picture",
"userinterface": "User interface",
"userinterface:background_admin": "Admin panel background image path",
Expand Down Expand Up @@ -564,5 +592,6 @@
"using_latest_version": "You are using the latest version of photobooth.",
"version": "Version",
"version:check_version": "Photobooth version",
"version:updater_button": "Update Photobooth (git)",
"wait_message": "Please wait..."
}
Loading