-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths.php
136 lines (122 loc) · 3.77 KB
/
s.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
include('database.php');
include('function.php');
include('lib/BrowserDetection.php');
include('lib/Mobile_Detect.php');
if(isset($_GET['id']) && $_GET['id']>0){
$id=get_safe_value($_GET['id']);
$res=mysqli_query($con,"select added_by,link from qr_code where id='$id' and status='1'");
if(mysqli_num_rows($res)>0){
$row=mysqli_fetch_assoc($res);
$link=$row['link'];
$added_by=$row['added_by'];
$getUserInfo=getUserInfo($added_by);
if($getUserInfo['total_hit']!=0){
$totalUserQRHitListRes=getUserTotalQRHit($added_by);
if($getUserInfo['total_hit']<($totalUserQRHitListRes['total_hit']+1)){
die(showErrorAndRedirect('Invalid QR Code or QR Code is not active.', 'index.php'));
}
}
$device="";
$os="";
$detect=new Mobile_Detect();
$browserObj=new Wolfcast\BrowserDetection;
$browser=$browserObj->getName();
if($detect->isMobile()){
$device="Mobile";
}elseif($detect->isTablet()){
$device="Tablet";
}else{
$device="PC";
}
if($detect->isiOS()){
$os="iOS";
}elseif($detect->isAndroidOS()){
$os="Android";
}else{
$os="Window";
}
$ip_address = $_SERVER['REMOTE_ADDR'];
$api_url = "http://ip-api.com/json/" . $ip_address;
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result=curl_exec($ch);
curl_close($ch);
$result=json_decode($result,true);
$city=$result['city'];
$state=$result['regionName'];
$country=$result['country'];
$ip_address=$result['query'];
$added_on=date('Y-m-d h:i:s');
$added_on_str=date('Y-m-d');
mysqli_query($con,"insert into qr_traffic(qr_code_id,device,os,browser,city,state,country,added_on,ip_address,added_on_str) values('$id','$device','$os','$browser','$city','$state','$country','$added_on','$ip_address','$added_on_str')");
redirect($link);
}else{
die(showErrorAndRedirect('Invalid QR Code or QR Code is not active.', 'index.php'));
}
}
function showErrorAndRedirect($errorMessage, $redirectURL) {
echo '
<html>
<head>
<title>Error</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<style>
body {
background-color: #f8f8f8;
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
.container {
display: none;
background-color: #ffffff;
padding: 20px;
border-radius: 5px;
margin: 20px auto;
max-width: 500px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
h1 {
color: #003366;
margin-top: 0;
}
p {
color: #333333;
font-size: 16px;
}
.btn {
display: inline-block;
font-size: 16px;
padding: 10px 20px;
background-color: #3085d6;
color: #ffffff;
text-decoration: none;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container">
<h1>Error</h1>
<p>' . $errorMessage . '</p>
<a href="' . $redirectURL . '" class="btn">Back to Home</a>
</div>
<script>
Swal.fire({
icon: "error",
title: "Error",
text: "' . $errorMessage . '",
confirmButtonColor: "#3085d6",
confirmButtonText: "Back to Home"
}).then((result) => {
if (result.isConfirmed) {
window.location.href = "' . $redirectURL . '";
}
});
</script>
</body>
</html>';
}
?>