-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocation.php
More file actions
66 lines (53 loc) · 1.62 KB
/
Copy pathlocation.php
File metadata and controls
66 lines (53 loc) · 1.62 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
require __DIR__ . '/vendor/autoload.php';
//load .env file
use Dotenv\Dotenv;$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$card_number = $_GET['id'];
$lat = $_GET['lat'];
$lon = $_GET['lon'];
//setup Ntfy server
use Ntfy\Server;
use Ntfy\Message;
use Ntfy\Client;
//setup mySQL connection
$conn = new mysqli($_ENV['mysql_servername'], $_ENV['mysql_username'], $_ENV['mysql_password'], $_ENV['mysql_dbname']);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//lookup the card number
$card_number = $_GET['id'];
if (empty($card_number)) {
}
$sql = "SELECT full_name FROM users WHERE id = ?;";
$stmt = $conn->prepare($sql);
if ($stmt === false) {
die("Prepare failed: " . $conn->error);
}
$stmt->bind_param("i", $card_number);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$card_name = $row['full_name'];
}
} else {
}
$stmt->close();
$server = new Server($_ENV['ntfy_server_url']);
//send notification to ntfy server
$url = "https://www.google.com/maps/search/?api=1&query=" . $lat . "," . $lon;
$action = new Ntfy\Action\View();
$action->label('View Location');
$action->url($url);
$message = new Message();
$message->topic($_ENV['ntfy_topic']);
$message->title($card_name . " Location Shared");
$message->body('Scanner location shared: ' . $lat . ', ' . $lon);
$message->clickAction($url);
$message->priority(Message::PRIORITY_MAX);
$message->action($action);
$client = new Client($server);
$client->send($message);
echo "<a href=\"" . $url . "\">" . $url . "</a>" ;
?>