-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloader.php
42 lines (35 loc) · 1.17 KB
/
loader.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
<?php
require __DIR__ . '/app/vendor/autoload.php';
use SecureEnvPHP\SecureEnvPHP;
(new SecureEnvPHP())->parse('.env.enc', 'app/keys/.env.key');
$tracking_gps = ($_GET['GPS']);
header('Service-Worker-Allowed: *');
header("Content-Type: application/javascript");
//init javascript for subscription
echo "var ip = \"". $_SERVER['REMOTE_ADDR'] . "\";\r\n";
echo "var gps = \"". $tracking_gps . "\";\r\n";
echo file_get_contents("app/lib/detector.js");
echo file_get_contents("app/lib/subscriptionHandler.js");
echo 'subscriptionHandler.init();';
//insert load in db
$ip = '';
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$domain_url = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
$dbhost = getenv('DB_HOST');
$dbuser = getenv('DB_USER');
$dbpass = getenv('DB_PASS');
$dbname = getenv('DB_NAME');
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
$stmt = $conn->prepare("INSERT INTO `moon`.`loader_stats`
(`domain_url`,
`ip`)
VALUES (?, ?)");
$stmt->bind_param("ss",$domain_url, $ip);
$stmt->execute();
//}