1
|
|
|
<?php |
2
|
|
|
$db_link = serverConnect(); |
3
|
|
|
|
4
|
|
|
$max = 'LIMIT ' . ($pageNum - 1) * $_SESSION['items'] . ',' . $_SESSION['items']; |
5
|
|
|
|
6
|
|
|
if (isset($search)) { |
7
|
|
|
$sql = "SELECT `uid` FROM `players` WHERE `uid` LIKE '" . $search . "' OR `name` LIKE '%" . $search . "%' OR `playerid` LIKE '" . $search . "' AND `adminlevel` >= '1' ORDER BY `adminlevel` DESC;"; |
8
|
|
|
$result_of_query = $db_link->query($sql); |
9
|
|
|
$total_records = mysqli_num_rows($result_of_query); |
10
|
|
|
if ($pageNum > $total_records) $pageNum = $total_records; |
11
|
|
|
$sql = "SELECT `name`,`adminlevel`,`playerid`,`uid` FROM `players` WHERE `uid` LIKE '" . $search . "' OR `name` LIKE '%" . $search . "%' OR `playerid` LIKE '" . $search . "' AND `adminlevel` >= '1' ORDER BY `adminlevel` DESC " . $max . " ;"; |
12
|
|
|
logAction($_SESSION['user_name'], $lang['searched'] . ' (' . $search . ') ' . $lang['in'] . ' ' . $lang['players'], 1); |
13
|
|
|
} else { |
14
|
|
|
$sql = "SELECT `uid` FROM `players` WHERE `adminlevel` >= '1' ORDER BY `adminlevel` DESC;"; |
15
|
|
|
$result_of_query = $db_link->query($sql); |
16
|
|
|
$total_records = mysqli_num_rows($result_of_query); |
17
|
|
|
if ($pageNum > $total_records) $pageNum = $total_records; |
18
|
|
|
$sql = "SELECT `name`,`adminlevel`,`playerid`,`uid` FROM `players` WHERE `adminlevel` >= '1' ORDER BY `adminlevel` DESC " . $max . " ;"; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
$result_of_query = $db_link->query($sql); |
22
|
|
View Code Duplication |
if ($result_of_query->num_rows > 0) { |
|
|
|
|
23
|
|
|
while ($row = mysqli_fetch_assoc($result_of_query)) { |
24
|
|
|
$pids[] = $row['playerid']; |
25
|
|
|
} |
26
|
|
|
$pids = implode(',', $pids); |
27
|
|
|
if ($settings['steamAPI'] && $_SESSION['permissions']['view']['steam'] && !$settings['performance'] && $settings['vacTest']) { |
28
|
|
|
$api = "http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=" . $settings['steamAPI'] . "&steamids=" . $pids; |
29
|
|
|
$bans = get_object_vars(json_decode(file_get_contents($api))); |
30
|
|
|
$bans = $bans['players']; |
31
|
|
|
$steamPlayers = count($bans); |
32
|
|
|
} else { |
33
|
|
|
$steamPlayers = 0; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
$result_of_query = $db_link->query($sql); |
37
|
|
|
?> |
38
|
|
|
<h1 class="page-header"> |
39
|
|
|
<?php echo $lang['admin']; ?> |
40
|
|
|
<small><?php echo $lang['overview']; ?></small> |
41
|
|
|
</h1> |
42
|
|
|
<div class="content-panel"> |
43
|
|
|
<table class="table table-striped table-advance table-hover"> |
44
|
|
|
<h4> |
45
|
|
|
<i class="fa fa-user"></i> |
46
|
|
|
<?php echo $lang['admin']; |
47
|
|
|
include("views/templates/search.php"); ?> |
48
|
|
|
</h4> |
49
|
|
|
<hr class="hidden-xs"> |
50
|
|
|
<thead> |
51
|
|
|
<tr> |
52
|
|
|
<th><i class="fa fa-user"></i><?php echo $lang['name']; ?></th> |
53
|
|
|
<th><i class="fa fa-eye"></i><?php echo $lang['playerID']; ?></th> |
54
|
|
|
<th><i class="fa fa-user"></i><?php echo $lang['rank']; ?></th> |
55
|
|
|
<?php if ($_SESSION['permissions']['edit']['player']) { |
56
|
|
|
echo '<th><i class="fa fa-pencil"></i> ' . $lang['edit'] . '</th>'; |
57
|
|
|
} |
58
|
|
|
?> |
59
|
|
|
</tr> |
60
|
|
|
</thead> |
61
|
|
|
<tbody> |
62
|
|
|
<?php |
63
|
|
|
while ($row = mysqli_fetch_assoc($result_of_query)) { |
64
|
|
|
$playersID = $row["playerid"]; |
65
|
|
|
echo "<tr>"; |
66
|
|
|
echo "<td>" . $row["name"] . "</td>"; |
67
|
|
|
echo "<td>" . $row["playerid"] . "</td>"; |
68
|
|
|
echo "<td class='hidden-xs'>" . $row["adminlevel"] . "</td>"; |
69
|
|
|
if ($_SESSION['permissions']['edit']['player']) { |
70
|
|
|
echo "<td><a class='btn btn-primary btn-xs' href='" . $settings['url'] . "editPlayer/" . $row["uid"] . "'>"; |
71
|
|
|
echo "<i class='fa fa-pencil'></i></a></td>"; |
72
|
|
|
} else { |
73
|
|
|
echo "<td><a class='btn btn-primary btn-xs' href='" . $settings['url'] . "editPlayer/" . $row["uid"] . "'>"; |
74
|
|
|
echo "<i class='fa fa-eye'></i></a></td>"; |
75
|
|
|
} |
76
|
|
|
if ($_SESSION['permissions']['view']['steam'] && $steamPlayers > 0) { |
77
|
|
|
echo "<td><a href='http://steamcommunity.com/profiles/" . $row["playerid"] . "' "; |
78
|
|
|
for ($player = 0; $player <= $steamPlayers; $player++) { |
79
|
|
|
if ($bans[$player]->SteamId == $row['playerid']) { |
80
|
|
|
if ($bans[$player]->VACBanned == true) { |
81
|
|
|
echo "<td><a href='http://steamcommunity.com/profiles/" . $row["playerid"] . "' "; |
82
|
|
|
echo "class='btn btn-danger btn-xs hidden-xs' target='_blank'><i class='fa fa-steam'></i></a>"; |
83
|
|
|
|
84
|
|
|
} else { |
85
|
|
|
echo "<td><a href='http://steamcommunity.com/profiles/" . $row["playerid"] . "' "; |
86
|
|
|
echo "class='btn btn-primary btn-xs hidden-xs' target='_blank'><i class='fa fa-steam'></i></a>"; } |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
echo '</td>'; |
90
|
|
|
} |
91
|
|
|
echo "</tr>"; |
92
|
|
|
} |
93
|
|
|
echo "</tbody></table>"; |
94
|
|
|
include("views/templates/page.php"); |
95
|
|
|
?> |
96
|
|
|
</div> |
97
|
|
|
<?php |
98
|
|
|
} else echo '<h3>' . errorMessage(36, $lang) . '</h3>'; |
|
|
|
|
99
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.