-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathcharacters.php
More file actions
112 lines (86 loc) · 3.11 KB
/
characters.php
File metadata and controls
112 lines (86 loc) · 3.11 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
<style>
td{border-right: 1px solid #dee2e6;text-align: center; vertical-align: middle !important;}
th{text-align: center !important;}
tr:nth-child(odd){background-color: #efefefa1;}
thead tr:first-child{background-color: #fff;}
</style>
<?php
$config = include 'config.php';
function getTitle()
{
return 'Karakterler';
}
$apiUrl = "https://www.potterapi.com/v1/characters?key={$config['api_key']}";
if (isset($_GET['house'])) {
$validHouses = $config['validHouses'];
if (!in_array($_GET['house'], $validHouses)) {
exit('Böyle bir bina yok');
}
$apiUrl .= ($_GET['house'] ? "&house=" . ucfirst($_GET['house']) : '');
}
$characters = file_get_contents($apiUrl);
$characterDetails = [];
$characters = json_decode($characters, true);
foreach ($characters as $character) {
$characterDetails[] = [
'_id' => $character['_id'],
'name' => $character['name'],
'house' => $character['house'] ?? null,
'role' => $character['role'] ?? null,
'bloodStatus' => $character['bloodStatus'] ?? null,
'species' => $character['species'] ?? null
];
}
?>
<?php
include 'header.php';
include 'navbar.php';
?>
<div class="pt-5">
<div class="container">
<section class="jumbotron text-center pt-5 mb-5 bg-white">
<div class="container">
<h1 class="jumbotron-heading"><?php echo getTitle(); ?></h1>
<?php if(isset($_GET['house'])): ?>
<img class="card-img-top" style="width: 5%" src="/assets/images/houses/<?php echo $_GET['house'] ?>.jpg" alt="<?php echo $_GET['house']; ?>">
<span><?php echo strtoupper($_GET['house']) ?></span>
<?php endif; ?>
</div>
</section>
<div class="bg-white p-5">
<table class="table">
<thead>
<tr>
<th scope="col" style="width: 15%">Avatar</th>
<th scope="col" style="width: 15%">Ad</th>
<th scope="col" style="width: 25%">Rol</th>
<th scope="col">Bina</th>
<th scope="col">Kan Durumu</th>
<th scope="col">Tür</th>
</tr>
</thead>
<tbody>
<?php
foreach ($characterDetails as $detail):
?>
<tr>
<td>
<img style=" width: 50%; height: auto;" alt="" class="card-img-top" src="assets/images/characters/<?php echo $detail['name']?>.jpg">
</td>
<td><?php echo $detail['name'];?></td>
<td><?php echo $detail['role'];?></td>
<td><?php echo $detail['house'];?></td>
<td><?php echo $detail['bloodStatus'];?></td>
<td><?php echo $detail['species'];?></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</div>
</div>
</div>
<?php
include 'footer.php';
?>