![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/fcm/ |
Upload File : |
<?php include_once "fcm_notification.php"; if (!isset($_POST['secret']) || $_POST['secret'] !== 'xJDDonkgbMOgIGtleSBiw60gbeG6rXQ=') { http_response_code(403); echo json_encode(['error' => 'Invalid or missing secret']); exit; } if (!isset($_POST['cmd'])) { http_response_code(400); echo json_encode(['error' => 'Missing cmd parameter']); exit; } $cmd = $_POST['cmd']; if ($cmd === 'sendNotificationToTopic') { if (!isset($_POST['topic'], $_POST['title'], $_POST['body'])) { http_response_code(400); echo json_encode(['error' => 'Missing required parameters']); exit; } $topic = $_POST['topic']; $title = $_POST['title']; $body = $_POST['body']; if (isset($_POST['data'])) { $data = json_decode($_POST['data'], true); if (json_last_error() !== JSON_ERROR_NONE) { $data = null; } } else { $data = null; } $image = isset($_POST['image']) ? $_POST['image'] : null; $badge = isset($_POST['badge']) ? (int)$_POST['badge'] : -1; $res = FCMNotification::sendNotificationToTopic([ 'topic' => $topic, 'title' => $title, 'body' => $body, 'data' => $data, 'image' => $image, 'badge' => $badge ]); echo json_encode($res); } else if ($cmd === 'sendNotificationToDevice') { if (!isset($_POST['userFCMToken'], $_POST['title'], $_POST['body'])) { http_response_code(400); echo json_encode(['error' => 'Missing required parameters']); exit; } $userFCMToken = $_POST['userFCMToken']; $title = $_POST['title']; $body = $_POST['body']; $image = isset($_POST['image']) ? $_POST['image'] : null; $badge = isset($_POST['badge']) ? (int)$_POST['badge'] : -1; if (isset($_POST['data'])) { $data = json_decode($_POST['data'], true); if (json_last_error() !== JSON_ERROR_NONE) { $data = null; } } else { $data = null; } $res = FCMNotification::sendNotificationToDevice([ 'userFCMToken' => $userFCMToken, 'title' => $title, 'body' => $body, 'data' => $data, 'image' => $image, 'badge' => $badge ]); echo json_encode($res); } else { http_response_code(400); echo json_encode(['error' => 'Unknown command']); }