Fixed crash when no albums are available

This commit is contained in:
2021-11-26 17:44:38 +01:00
parent c65bc123d3
commit 56127a16a0
3 changed files with 17 additions and 11 deletions

View File

@ -36,7 +36,7 @@ use PhotoPrismUpload\API\PhotoPrism;
}
</style>
</head>
<body></body>
<body>
<?php
$config = require(__DIR__ . '/config.php');
@ -45,22 +45,22 @@ $albums = [];
try {
$api->login();
} catch (\Exception $e) {
die('Fehler: ' . $e->getMessage());
die('Fehler: ' . $e->getMessage().'</body></html>');
}
if (!isset($_POST['submit'])) {
if (!isset($_GET['token'])) {
die('Sorry, kein Zugriff');
die('Sorry, kein Zugriff</body></html>');
}
$token = $_GET['token'];
$tokens = explode(',', $token);
try {
$albums = $api->getAlbumsByTokens($tokens);
} catch (\Exception $e) {
die('Fehler: ' . $e->getMessage());
die('Fehler: ' . $e->getMessage().'</body></html>');
}
if (empty($albums) && (empty($config['noAlbumToken']) || !in_array($config['noAlbumToken'], $tokens))) {
die('Falscher Token');
die('Falscher Token</body></html>');
}
?>
<script>
@ -118,12 +118,13 @@ if (!isset($_POST['submit'])) {
});
</script>
<?php
die();
die('</body></html>');
}
try {
$api->uploadPhotos($_POST['album']);
} catch (\Exception $e) {
die('Fehler: ' . $e->getMessage());
die('Fehler: ' . $e->getMessage().'</body></html>');
}
?>
Erfolg! <a href=".">Zurück</a>
Erfolg! <a href=".">Zurück</a>
</body></html>