forked from pokepark/PokemonRaidBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_raid.php
77 lines (71 loc) · 3.09 KB
/
get_raid.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
<?php
/**
* Get raid data.
* @param $raid_id
* @return array
*/
function get_raid($raid_id)
{
global $dbh;
// Remove all non-numeric characters
$raidid = preg_replace( '/[^0-9]/', '', $raid_id );
$tz_diff = tz_diff();
// Get the raid data by id.
$rs = my_query(
'
SELECT IF (raids.pokemon = 0,
IF((SELECT count(*)
FROM raid_bosses
WHERE raid_level = raids.level
AND date_end != \'2038-01-19 03:14:07\'
AND convert_tz(raids.spawn,"+00:00","'.$tz_diff.'") BETWEEN date_start AND date_end) = 1,
(SELECT pokedex_id
FROM raid_bosses
WHERE raid_level = raids.level
AND convert_tz(raids.spawn,"+00:00","'.$tz_diff.'") BETWEEN date_start AND date_end),
(select concat(\'999\', raids.level) as pokemon)
)
,pokemon) as pokemon,
IF (raids.pokemon = 0,
IF((SELECT count(*) as count
FROM raid_bosses
WHERE raid_level = raids.level
AND date_end != \'2038-01-19 03:14:07\'
AND convert_tz(raids.spawn,"+00:00","'.$tz_diff.'") BETWEEN date_start AND date_end) = 1,
(SELECT pokemon_form_id
FROM raid_bosses
WHERE raid_level = raids.level
AND convert_tz(raids.spawn,"+00:00","'.$tz_diff.'") BETWEEN date_start AND date_end),
\'0\'
),
IF(raids.pokemon_form = 0,
(SELECT pokemon_form_id FROM pokemon
WHERE
pokedex_id = raids.pokemon AND
pokemon_form_name = \'normal\'
LIMIT 1), raids.pokemon_form)
) as pokemon_form,
raids.id, raids.user_id, raids.spawn, raids.start_time, raids.end_time, raids.gym_team, raids.gym_id, raids.level, raids.move1, raids.move2, raids.gender, raids.event, raids.event_note,
gyms.lat, gyms.lon, gyms.address, gyms.gym_name, gyms.ex_gym, gyms.gym_note,
users.name, users.trainername, users.nick,
events.name as event_name, events.description as event_description, events.vote_key_mode as event_vote_key_mode, events.time_slots as event_time_slots, events.raid_duration as event_raid_duration, events.hide_raid_picture as event_hide_raid_picture, events.poll_template as event_poll_template,
TIME_FORMAT(TIMEDIFF(end_time, UTC_TIMESTAMP()) + INTERVAL 1 MINUTE, \'%k:%i\') AS t_left
FROM raids
LEFT JOIN gyms
ON raids.gym_id = gyms.id
LEFT JOIN users
ON raids.user_id = users.user_id
LEFT JOIN events
ON events.id = raids.event
WHERE raids.id = '.$raid_id.'
LIMIT 1
'
);
// Get the row.
$raid = $rs->fetch();
// Check trainername
$raid = check_trainername($raid);
debug_log($raid);
return $raid;
}
?>