Skip to content

Commit 896c472

Browse files
committed
Initial commit
1 parent d62c2f1 commit 896c472

11 files changed

+403
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.idea
2+
config.php

config.php.example

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
define('DB_HOST', 'localhost');
3+
define('DB_NAME', 'your_database_name');
4+
define('DB_USER', 'your_database_user');
5+
define('DB_PASSWORD', 'your_database_password');

getgyms.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
//Use same config as bot
3+
require_once("config.php");
4+
5+
// Establish mysql connection.
6+
$db = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
7+
$db->set_charset('utf8mb4');
8+
9+
// Error connecting to db.
10+
if ($db->connect_errno) {
11+
echo("Failed to connect to Database!\n");
12+
die("Connection Failed: " . $db->connect_error);
13+
}
14+
15+
$sql = "SELECT * FROM gyms";
16+
17+
$result = $db->query($sql);
18+
19+
if (!$result) {
20+
echo "An SQL error occured";
21+
exit;
22+
}
23+
24+
$rows = array();
25+
while($gyms = $result->fetch_assoc()) {
26+
$rows[] = $gyms;
27+
}
28+
29+
print json_encode($rows);
30+
31+
32+
?>

getraids.php

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
//Use same config as bot
3+
require_once("config.php");
4+
5+
// Establish mysql connection.
6+
$db = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
7+
$db->set_charset('utf8mb4');
8+
9+
// Error connecting to db.
10+
if ($db->connect_errno) {
11+
echo("Failed to connect to Database!\n");
12+
die("Connection Failed: " . $db->connect_error);
13+
}
14+
15+
$sql = "SELECT raids.*,
16+
UNIX_TIMESTAMP(raids.end_time) AS ts_end,
17+
UNIX_TIMESTAMP(raids.start_time) AS ts_start,
18+
UNIX_TIMESTAMP(raids.end_time)-UNIX_TIMESTAMP(NOW()) AS t_left,
19+
pokemon.raid_level,
20+
pokemon.pokedex_id,
21+
pokemon.pokemon_name,
22+
attendance.id AS interest,
23+
SUM(CASE WHEN attendance.cancel=FALSE AND attendance.raid_done=FALSE THEN 1 ELSE 0 END) AS count,
24+
SUM(CASE WHEN attendance.cancel=FALSE and attendance.raid_done=FALSE THEN attendance.extra_mystic ELSE 0 END) AS extra_mystic,
25+
SUM(CASE WHEN attendance.cancel=FALSE and attendance.raid_done=FALSE THEN attendance.extra_valor ELSE 0 END) AS extra_valor,
26+
SUM(CASE WHEN attendance.cancel=FALSE and attendance.raid_done=FALSE THEN attendance.extra_instinct ELSE 0 END) AS extra_instinct,
27+
SUM(CASE WHEN attendance.cancel=FALSE and attendance.raid_done=FALSE THEN (attendance.extra_mystic+attendance.extra_valor+attendance.extra_instinct) ELSE 0 END) AS total_extras
28+
FROM raids
29+
LEFT JOIN pokemon ON pokemon.pokedex_id=raids.pokemon
30+
LEFT JOIN attendance ON attendance.raid_id=raids.id
31+
WHERE raids.end_time > NOW()
32+
AND raids.end_time < NOW() + INTERVAL 96 hour
33+
GROUP BY raids.gym_name
34+
ORDER BY raids.end_time ASC";
35+
36+
$result = $db->query($sql);
37+
38+
if (!$result) {
39+
echo "An SQL error occured";
40+
exit;
41+
}
42+
43+
$rows = array();
44+
while($raid = $result->fetch_assoc()) {
45+
$rows[] = $raid;
46+
}
47+
48+
print json_encode($rows);
49+
50+
51+
?>

icons/egg_L1.png

8.02 KB
Loading

icons/egg_L2.png

8.22 KB
Loading

icons/egg_L3.png

8.59 KB
Loading

icons/egg_L4.png

8.54 KB
Loading

icons/egg_L5.png

10.1 KB
Loading

icons/level.png

2.26 KB
Loading

0 commit comments

Comments
 (0)