-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
53 lines (38 loc) · 1.4 KB
/
index.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
46
47
48
49
50
51
52
53
<?php
require 'config.php';
require 'functions.php';
/**
* Test
* echo ip_user();
* echo "<br/>";
* echo browser_user();
* echo "<br/>";
* echo os_user();
*/
// GET data user yang sudah mengakses website kita
$ip = ip_user();
$browser = browser_user();
$os = os_user();
// USE API TO GET VISITOR DATA
$queryapi=@unserialize(file_get_contents('http:https://ip-api.com/php/'.$ip));
if($queryapi && $queryapi['status'] == 'success') {
$isp = $queryapi['isp'];
$country = $queryapi['country'];
$region = $queryapi['regionName'];
$city = $queryapi['city'];
$latitude = $queryapi['lat'];
$longitude = $queryapi['lon'];
$timezone = $queryapi['timezone'];
// Check bila sebelumnya data pengunjung sudah terekam
if (! isset($_COOKIE['VISITOR'])) {
// Cookie disimpan selama 24 jam
$duration = time()+60*60*24;
// simpan kedalam cookie browser
setcookie('VISITOR',$browser,$duration);
// SQL Command atau perintah SQL INSERT
$sql = "INSERT INTO statistik_api (ip, os, browser, isp, country, region, city, latitude, longitude, timezone) VALUES ('$ip', '$os', '$browser', '$isp', '$country', '$region', '$city', '$latitude', '$longitude', '$timezone')";
$query = $db->query($sql);
}
}
echo "<p>Untuk Melihat siapa saja yang telah mengakses website ini, silahkan buka pada <a href=\"admin.php\"/>Halaman Admin</a></p>";
?>