so on my website, I created donor.php to listen to webhook sent from a Donation Services called Saweria, here’s my php script
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Allow Saweria IP only
if ($_SERVER['REMOTE_ADDR'] != '159.65.8.77') {
exit;
}
// Get raw data
$raw_data = file_get_contents('php://input');
// Decode JSON
$data = json_decode($raw_data, true);
// Generate donation ID
$donationId = rand(0, 9999);
// Format amount
$amount = round($data['amount_raw'] / 1000);
// Create output
$output = ''.
''.
''.
'
ID
Amount
Name
Email
' . $donationId . '
' . $amount . '
' . $data['donator_name'] . '
' . $data['donator_email'] . '
';
// Read existing contents
$existing = file_get_contents('donations.html');
// Explode into array
$donations = explode('', $existing);
// Prepend new donation
array_unshift($donations, $output);
// Keep latest 5
$donations = array_slice($donations, 0, 5);
// Implode back to string
$donations = implode('', $donations);
// Write back to file
file_put_contents('donations.html', $donations);
?>
its a simple php script that listen to webhook then write it to donations.html on my folder directory, but I couldnt get the data on my donations.html. weirdly, it only occurs on InfinityFree, all hosting seems to be fine