forked from PhotoboothProject/photobooth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwgetcaptureconfig.php
More file actions
60 lines (48 loc) · 1.88 KB
/
wgetcaptureconfig.php
File metadata and controls
60 lines (48 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/** @var array $config */
require_once '../lib/boot.php';
use Photobooth\Environment;
use Photobooth\Service\ConfigurationService;
use Photobooth\Service\LoggerService;
use Photobooth\Service\ProcessService;
use Photobooth\Utility\PathUtility;
// Login / Authentication check
if (!(
!$config['login']['enabled'] ||
(!$config['protect']['localhost_admin'] && isset($_SERVER['SERVER_ADDR']) && $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR']) ||
(isset($_SESSION['auth']) && $_SESSION['auth'] === true) || !$config['protect']['admin']
)) {
header('location: ' . PathUtility::getPublicPath('login'));
exit();
}
header('Content-Type: application/json');
$loggerService = LoggerService::getInstance();
$logger = $loggerService->getLogger('main');
$logger->debug(basename($_SERVER['PHP_SELF']));
$configurationService = ConfigurationService::getInstance();
$logger->debug('Saving Photobooth configuration for go2rtc...');
$config['commands']['preview'] = '';
$config['commands']['take_picture'] = 'wget -O %s http://' . Environment::getIp() . ':1984/api/frame.jpeg?src=photobooth';
$config['picture']['cheese_time'] = '0';
$config['preview']['mode'] = 'url';
$config['preview']['url'] = 'http://' . Environment::getIp() . ':1984/api/stream.mjpeg?src=photobooth';
$config['preview']['camTakesPic'] = false;
try {
$configurationService->update($config);
$logger->debug('New config saved.');
echo json_encode([
'status' => 'success',
'message' => 'New config saved.',
]);
} catch (\Exception $exception) {
$logger->error('ERROR: Config can not be saved!');
echo json_encode([
'status' => 'error',
'message' => $exception->getMessage(),
]);
}
// Kill service daemons after config has changed
ProcessService::getInstance()->shutdown();
// return to Adminpanel
header('location: ' . PathUtility::getPublicPath('admin'));
exit();