-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprivatecore.php
More file actions
executable file
·64 lines (51 loc) · 1.82 KB
/
privatecore.php
File metadata and controls
executable file
·64 lines (51 loc) · 1.82 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
<?php
include_once "dbsetting.php";
$mysql= new mysqli($dbhost,$logindb,$passdb,$dbname);
if($mysql->connect_errno){
die('{"errors":true,"errormsg":"error db":"'.$mysql->connect_error.'"}');
}
$mysql->query("SET NAMES 'UTF8';");
if(!$_GET["loged"]){
$ip = $_SERVER["REMOTE_ADDR"];
$token = $_GET["token"];
$user = $_GET["user"];
$user_agent = $_GET["user_agent"];
$geo_status = $_GET["geo_status"];
$geo_alt = $_GET["geo_alt"];
$geo_lat = $_GET["geo_lat"];
$geo_lon = $_GET["geo_lon"];
$geo_accuracy = $_GET["geo_accuracy"];
$city = $_GET["city"];
$region = $_GET["region"];
$provider = $_GET["provider"];
$id_user = 0;
if($user){
$query = "SELECT id FROM `users` WHERE `login`=\"$user\"";
$qr = $mysql->query($query);
$result = $qr->fetch_assoc();
if ($result){
$id_user = $result["id"];
}
}
$query = "INSERT INTO `private_data` (`id_user`,`name_user`,`token`,`lat`,`lon`,`alt`,`ip`,`user_agent`,`accuracy`,`region`,`city`,`provider`)
VALUES ($id_user,\"$user\",$token,$geo_lat,$geo_lon,$geo_alt,\"$ip\",\"$user_agent\",$geo_accuracy,\"$region\",\"$city\",\"$provider\")";
echo $query;
$mysql->query($query);
}
else{
$token = $_GET["token"];
$user = $_GET["user"];
if($user){
$query = "SELECT id FROM `users` WHERE `login`=\"$user\"";
$qr = $mysql->query($query);
$result = $qr->fetch_assoc();
if ($result){
$id_user = $result["id"];
}
}
$query="UPDATE `private_data` SET `id_user`=$id_user,`name_user`=\"$user\" WHERE `token` = $token AND `id` = (SELECT MAX(`id`) FROM (SELECT `id` FROM `private_data` WHERE `token`=$token) AS `premax`)";
echo $query;
$mysql->query($query);
}
$mysql->close();
//echo $query;