-
Notifications
You must be signed in to change notification settings - Fork 7
/
spotquest.php
144 lines (120 loc) · 3.74 KB
/
spotquest.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
137
138
139
140
141
142
143
144
<?php
$curl = curl_init();
ob_start();
require './config/config.php';
include'frontend/functions.php';
include("login/auth.php");
$quest = $conn->real_escape_string($_POST['quest']);
$reward = $conn->real_escape_string($_POST['reward']);
$sname = $conn->real_escape_string($_POST['sname']);
$sid = $conn->real_escape_string($_POST['sid']);
$reid = $conn->real_escape_string($_POST['reid']);
$qid = $conn->real_escape_string($_POST['qid']);
$spotter = $conn->real_escape_string($_SESSION['uname']);
if ($clock=="false"){
$qhour = date('g');
$qampm = date('A');
} else {
$qhour = date('H');
$qampm = '';
}
$qmin = date('i');
$sql1 = "UPDATE stops SET quested='1',actquest='$quest',actreward='$reward',hour='$qhour', min='$qmin',ampm='$qampm',questby='$spotter' WHERE sid='$sname'";
if(!mysqli_query($conn,$sql1))
{
echo 'Not Inserted';
}
else
{
echo 'Inserted';
}
$rewardquery = "SELECT rname FROM rewards WHERE reid='$reward'";
if(!mysqli_query($conn,$rewardquery))
{
echo 'Not Inserted';
}
else
{
echo 'Inserted';
}
$resultreward = $conn->query($rewardquery);
$rowreward = $resultreward->fetch_array(MYSQLI_NUM);
$rname = $rowreward[0];
$questquery = "SELECT qname FROM quests WHERE qid='$quest'";
if(!mysqli_query($conn,$questquery))
{
echo 'Not Inserted';
}
else
{
echo 'Inserted';
}
$resultquest = $conn->query($questquery);
$rowquest = $resultquest->fetch_array(MYSQLI_NUM);
$qname = $rowquest[0];
$pokestopquery = "SELECT sname,slatitude,slongitude FROM stops WHERE sid = '$sname'";
if(!mysqli_query($conn,$pokestopquery))
{
echo 'Not Inserted';
}
else
{
echo 'Inserted';
}
$resultpokestop = $conn->query($pokestopquery);
$row = $resultpokestop->fetch_array(MYSQLI_NUM);
$pokestopname = $row[0];
$slat = $row[1];
$slon = $row[2];
$siteurl = "[".$viewtitle."](".$viewurl."/?loc=$slat,$slon&zoom=19)";
if ($clock=="false"){
$date = date('g:i:s A');
} else {
$date = date('H:i:s');
}
$hookObject = json_encode([
"username" => "Quest Spotted!",
"tts" => false,
"avatar_url" => "$viewurl/static/stops/queststop.png",
"embeds" => [
[
"type" => "rich",
"description" => "$siteurl\n**Quest:** $qname\n**Reward:** $rname",
"color" => hexdec( "FFFFFF" ),
"footer" => [
"text" => "Spotted by $spotter at $date",
"icon_url" => "$viewurl/static/stops/queststop.png"
],
"image" => [
"url" => "http://staticmap.openstreetmap.de/staticmap.php?center=".$slat.",".$slon."&zoom=17&size=400x400&maptype=mapnik&markers=".$slat.",".$slon.",red-pushpin",
],
"thumbnail" => [
"url" => "$viewurl/static/stops/queststop.png",
],
"author" => [
"name" => "Quest spotted by $spotter",
],
"fields" => [
[
"name" => "Pokestop",
"value" => "$pokestopname",
"inline" => true
]
]
]
]
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
$ch = curl_init();
curl_setopt_array( $ch, [
CURLOPT_URL => $quest_webhook_url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $hookObject,
CURLOPT_HTTPHEADER => [
"Length" => strlen( $hookObject ),
"Content-Type" => "application/json"
]
]);
$response = curl_exec( $ch );
curl_close( $ch );
header('Location:index.php?loc='.$slat.','.$slon.'&zoom=19');
?>