-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebhook.php
45 lines (34 loc) · 1.07 KB
/
webhook.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
$dbHost = 'your_mysql_host';
$dbUser = 'your_mysql_user';
$dbPassword = 'your_mysql_password';
$dbName = 'your_mysql_database';
$tokenwebhook = 'your_token_here';
$id = $_POST['id'] ?? null;
$newBalance = $_POST['new_balance'] ?? null;
$token = $_POST['token'] ?? null;
if($token!=$tokenwebhook){
http_response_code(400);
exit('Invalid token');
}
if (!$id || !$newBalance) {
http_response_code(400);
exit('Invalid payload');
}
$connection = new mysqli($dbHost, $dbUser, $dbPassword, $dbName);
if ($connection->connect_error) {
http_response_code(500);
exit('Database connection failed');
}
$id = $connection->real_escape_string($id);
$newBalance = $connection->real_escape_string($newBalance);
$updateQuery = "UPDATE users SET balance = '$newBalance' WHERE id = '$id'";
if ($connection->query($updateQuery) === true) {
http_response_code(200);
echo 'User balance updated successfully';
} else {
http_response_code(500);
echo 'Error updating user balance: ' . $connection->error;
}
// Close the database connection
$connection->close();