-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
114 lines (105 loc) · 4.33 KB
/
index.php
File metadata and controls
114 lines (105 loc) · 4.33 KB
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
<?php
$usrID = $_GET['id'] ?? '000000000';
$pokeJson = fopen("pokedex.json", "r") or die("Unable to open file!");
$pokemon = fread($pokeJson,filesize("pokedex.json"));
fclose($pokeJson);
$pokemon = json_decode($pokemon, true);
function cmp($a, $b){
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
$servername = "0.0.0.0";
$username = "Ed0ardo";
$password = "XXX";
$dbname = "pokedex";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pokédex Me</title>
<link rel="apple-touch-icon" type="image/png" sizes="192x192" href="favicon.png">
<link rel="icon" type="image/png" sizes="192x192" href="favicon.png">
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<script src='kofi.js'></script>
<script>
kofiWidgetOverlay.draw('ed0ardo', {
'type': 'floating-chat',
'floating-chat.donateButton.text': '',
'floating-chat.donateButton.background-color': '#323842',
'floating-chat.donateButton.text-color': '#fff'
});
</script>
<script>
function openPokemon(num) {
if(num){
window.open("https://www.pokemon.com/us/pokedex/" + num, '_blank').focus();
}
else{
window.open("https://t.me/PokedexMeBot", '_blank').focus();
}
}
</script>
<h1 class="pokeTitle" onclick="openPokemon();">PokédexMe</h1>
<div class="contenitor">
<input type="text" id="searchBar" onkeyup="searchPokemon()" placeholder="Search Pokémon...">
<ul class="results" id="ul">
<?php
if ($usrID) {
$sql = "SELECT pokemon FROM pokeball WHERE id = ".$usrID;
$r = $conn->query($sql);
echo '<p id="nPoke">'.$r->num_rows.'/'.count($pokemon).'</p>';
if ($r->num_rows > 0) {
$row = $r->fetch_all(MYSQLI_NUM);
usort($row, "cmp");
foreach($row as $num){
$li = '<li onclick="openPokemon(\''.$num[0].'\');" class="'.strtolower($pokemon[$num[0]]["types"][0]).'">
<div class="cont">
<figure>
<img src="'.$pokemon[$num[0]]["photo"].'">
</figure>
<div class="pokemon-info">
<p class="id">
<span class="number-prefix">#'.$num[0].'</span>
<img class="type" src="https://raw.githubusercontent.com/duiker101/pokemon-type-svg-icons/master/icons/'.strtolower($pokemon[$num[0]]["types"][0]).'.svg">
</p>
<h5>'.$pokemon[$num[0]]["name"].'</h5>
</div>
</div>
</li>';
echo $li;
}
}
}
echo '</ul>';
?>
</div>
<script>
function searchPokemon() {
var input, filter, ul, li, i, txtValue;
input = document.getElementById('searchBar');
filter = input.value.toUpperCase();
ul = document.getElementById("ul");
li = ul.getElementsByTagName('li');
for (i = 0; i < li.length; i++) {
txtValue = li[i].innerText
if (txtValue.toUpperCase().indexOf(filter) > -1) {
li[i].style.display = "";
} else {
li[i].style.display = "none";
}
}
}
</script>
</body>
</html>