🔃 Sync Hub v0.3

This commit is contained in:
jokob-sk
2024-06-03 23:06:25 +10:00
parent 8c96f61b54
commit 46e7e7bc01
4 changed files with 19 additions and 36 deletions

View File

@@ -1,5 +1,8 @@
<?php
// External files
require '/app/front/php/server/init.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Retrieve the authorization header
$headers = apache_request_headers();
@@ -10,6 +13,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($auth_header !== $expected_token) {
http_response_code(403);
echo 'Forbidden';
write_notification("[Plugin: Sync hub API] Incorrect API Token", "alert");
exit;
}
@@ -24,6 +28,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Create the storage directory if it doesn't exist
if (!is_dir($storage_path)) {
echo "Could not open folder: {$storage_path}";
write_notification("[Plugin: Sync hub API] Could not open folder: {$storage_path}", "alert");
http_response_code(500);
exit;
}
@@ -43,5 +48,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} else {
http_response_code(405);
echo 'Method Not Allowed';
write_notification("[Plugin: Sync hub API] Method Not Allowed", "alert");
}
?>