forked from pokepark/PokemonBotMap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetquest.php
68 lines (50 loc) · 2.07 KB
/
getquest.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
<?php
//Use same config as bot
require_once("config.php");
// Establish mysql connection.
$dbh = new PDO("mysql:host=" . QUEST_DB_HOST . ";dbname=" . QUEST_DB_NAME . ";charset=utf8mb4", QUEST_DB_USER, QUEST_DB_PASSWORD, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$dbh->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING);
$sql = "
SELECT *
FROM quests
LEFT JOIN pokestops
ON quests.pokestop_id = pokestops.id
LEFT JOIN questlist
ON quests.quest_id = questlist.id
LEFT JOIN rewardlist
ON quests.reward_id = rewardlist.id
LEFT JOIN encounterlist
ON quests.quest_id = encounterlist.quest_id
LEFT JOIN pokemon
ON pokemon.pokedex_id = encounterlist.pokedex_ids
WHERE quest_date = CURDATE()
ORDER BY pokestops.pokestop_name
";
$rows = array();
try {
$result = $dbh->query($sql);
while($stops = $result->fetch(PDO::FETCH_ASSOC)) {
$rows[] = $stops;
}
}
catch (PDOException $exception) {
error_log($exception->getMessage());
$dbh = null;
exit;
}
$jsonaction = file_get_contents(LOCATION_QUEST_ACTION_JSON);
$translationsaction = json_decode($jsonaction,true);
$jsontype = file_get_contents(LOCATION_QUEST_TYPE_JSON);
$translationstype = json_decode($jsontype,true);
$jsonreward = file_get_contents(LOCATION_QUEST_REWARD_JSON);
$translationsreward = json_decode($jsonreward,true);
$jsonpokemon = file_get_contents(LOCATION_POKEMON_JSON);
$translationspokemon = json_decode($jsonpokemon,true);
$jsonpoketype = file_get_contents(LOCATION_POKETYPE_JSON);
$translationspoketype = json_decode($jsonpoketype,true);
$translations = array_merge($translationsaction, $translationstype, $translationsreward, $translationspokemon, $translationspoketype);
$data['translations'] = $translations;
$data['stops'] = $rows;
print json_encode($data);
$dbh = null;
?>