-
-
Notifications
You must be signed in to change notification settings - Fork 98
/
search.php
63 lines (61 loc) · 1.89 KB
/
search.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
<?php
include('config/config.php');
global $map, $fork;
if ($noSearch === true) {
http_response_code(401);
die();
}
$useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if (preg_match("/curl|libcurl/", $useragent)) {
http_response_code(400);
die();
}
$data = array();
$term = ! empty($_POST['term']) ? $_POST['term'] : '';
$action = ! empty($_POST['action']) ? $_POST['action'] : '';
$lat = ! empty($_POST['lat']) ? $_POST['lat'] : '';
$lon = ! empty($_POST['lon']) ? $_POST['lon'] : '';
$quests_with_ar = (!empty($_POST['quests_with_ar']) && $_POST['quests_with_ar'] == "false") ? false : true;
$dbname = '';
if (strtolower($map) === "rdm") {
if ($action === "pokestops") {
$dbname = "pokestop";
} elseif ($action === "forts") {
$dbname = "gym";
}
$search = new \Search\RDM();
} elseif (strtolower($map) === "golbat") {
if ($action === "pokestops") {
$dbname = "pokestop";
} elseif ($action === "forts") {
$dbname = "gym";
}
$search = new \Search\Golbat();
} elseif (strtolower($map) === "rocketmap") {
if ($action === "pokestops") {
$dbname = "pokestop";
} elseif ($action === "forts") {
$dbname = "gym";
}
$search = new \Search\RocketMap_MAD();
}
if ($action === "pokemon") {
$data["pokemon"] = $search->search_pokemon($lat, $lon, $term);
}
if ($action === "reward") {
$data["reward"] = $search->search_reward($lat, $lon, $term, $quests_with_ar);
}
if ($action === "nests") {
$data["nests"] = $search->search_nests($lat, $lon, $term);
}
if ($action === "portals") {
$data["portals"] = $search->search_portals($lat, $lon, $term);
}
if ($action === "pokestops") {
$data["pokestops"] = $search->search($dbname, $lat, $lon, $term);
}
if ($action === "forts") {
$data["forts"] = $search->search($dbname, $lat, $lon, $term);
}
$jaysson = json_encode($data);
echo $jaysson;