OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
firebase
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
π
..
-
05/09/2025 11:18:49 AM
rwxr-xr-x
π
app.js
1.07 KB
08/12/2024 10:32:50 AM
rw-r--r--
π
composer.json
66 bytes
08/12/2024 10:32:50 AM
rw-r--r--
π
composer.lock
93.17 KB
08/12/2024 10:32:50 AM
rw-r--r--
π
config
-
08/12/2024 10:32:51 AM
rwxr-xr-x
π
db.php
285 bytes
08/12/2024 10:32:50 AM
rw-r--r--
π
debug.log
0 bytes
08/12/2024 10:32:50 AM
rw-r--r--
π
firebase-messaging-sw.js
1.08 KB
08/12/2024 10:32:51 AM
rw-r--r--
π
index.php
2.03 KB
08/12/2024 10:32:51 AM
rw-r--r--
π
logo.png
49.4 KB
08/12/2024 10:32:51 AM
rw-r--r--
π
save-token.php
773 bytes
08/12/2024 10:32:51 AM
rw-r--r--
π
send-notification.php
1.5 KB
08/12/2024 10:32:51 AM
rw-r--r--
π
vendor
-
08/12/2024 10:33:06 AM
rwxr-xr-x
Editing: send-notification.php
Close
<?php // send-notification.php require 'vendor/autoload.php'; // Include Firebase Admin SDK (via Composer) use Kreait\Firebase\Factory; use Kreait\Firebase\Messaging\CloudMessage; use Kreait\Firebase\Messaging\Notification; use Kreait\Firebase\Messaging\MulticastSendReport; // Initialize Firebase Admin SDK $factory = (new Factory)->withServiceAccount(__DIR__ . '/config/serviceAccountKey.json'); $messaging = $factory->createMessaging(); // Include database connection include 'db.php'; // Retrieve tokens from the database $result = $conn->query("SELECT token FROM fcm_tokens"); $tokens = []; while ($row = $result->fetch_assoc()) { $tokens[] = $row['token']; } $conn->close(); if (empty($tokens)) { echo "No tokens found."; exit; } // Create the message $message = CloudMessage::new() ->withNotification(Notification::create('New Blog Post: Mastering SEO', 'Boost your websiteβs traffic with our latest tips on SEO.')) ->withWebPushConfig([ 'fcm_options' => [ 'link' => 'https://knoblycream.com/blog/mastering-seo' ] ]); // Send the message $response = $messaging->sendMulticast($message, $tokens); // Check the response if ($response->hasFailures()) { echo "Failed to send notifications."; foreach ($response->failures()->getItems() as $failure) { echo "Error sending to token {$failure->target()}: {$failure->error()->getMessage()}\n"; } } else { echo "Notifications sent successfully."; } ?>