diff --git a/.gitignore b/.gitignore index ed11775..13fa6ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ **/*/logs upload.php config.php +.nova # Created by https://www.toptal.com/developers/gitignore/api/composer,macos # Edit at https://www.toptal.com/developers/gitignore?templates=composer,macos @@ -42,4 +43,4 @@ Network Trash Folder Temporary Items .apdisk -# End of https://www.toptal.com/developers/gitignore/api/composer,macos \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/composer,macos diff --git a/index.php b/index.php index 48c7c0d..33a7068 100644 --- a/index.php +++ b/index.php @@ -36,7 +36,7 @@ use PhotoPrismUpload\API\PhotoPrism; } - + login(); } catch (\Exception $e) { - die('Fehler: ' . $e->getMessage()); + die('Fehler: ' . $e->getMessage().''); } if (!isset($_POST['submit'])) { if (!isset($_GET['token'])) { - die('Sorry, kein Zugriff'); + die('Sorry, kein Zugriff'); } $token = $_GET['token']; $tokens = explode(',', $token); try { $albums = $api->getAlbumsByTokens($tokens); } catch (\Exception $e) { - die('Fehler: ' . $e->getMessage()); + die('Fehler: ' . $e->getMessage().''); } if (empty($albums) && (empty($config['noAlbumToken']) || !in_array($config['noAlbumToken'], $tokens))) { - die('Falscher Token'); + die('Falscher Token'); } ?> '); } try { $api->uploadPhotos($_POST['album']); } catch (\Exception $e) { - die('Fehler: ' . $e->getMessage()); + die('Fehler: ' . $e->getMessage().''); } ?> -Erfolg! Zurück \ No newline at end of file +Erfolg! Zurück + \ No newline at end of file diff --git a/src/API/PhotoPrism.php b/src/API/PhotoPrism.php index c810263..3d5ad3d 100644 --- a/src/API/PhotoPrism.php +++ b/src/API/PhotoPrism.php @@ -182,12 +182,13 @@ class PhotoPrism public function getAlbumsByTokens(array $tokens, int $count = 1000, int $offset = 0): array { + $this->logger->debug('getAlbumsByToken'); $albums = $this->getAlbums($count, 0); $visibleAlbums = []; foreach ($albums as $album) { $token = $this->getAlbumToken($album); $album->token = $token; - if (in_array($album->token, $tokens)) { + if ($token != null && in_array($album->token, $tokens)) { $visibleAlbums[] = $album; } else { $this->logger->debug('Skipping album without access: ' . $album->title); @@ -198,7 +199,7 @@ class PhotoPrism return $visibleAlbums; } - public function getAlbumToken($album): string + public function getAlbumToken($album): ?string { $uid = is_string($album) ? $album : $album->uid; $res = $this->makeRequest('GET', '/albums/' . $uid . '/links'); @@ -207,6 +208,9 @@ class PhotoPrism throw new NetworkException($response['error']); } $this->logger->debug('Token response: ' . $res); + if (!in_array('Token', $response)) { + return null; + } return $response['Token']; }