1
|
|
|
<?php |
2
|
|
|
$db_link = serverConnect(); |
3
|
|
|
|
4
|
|
|
$max = ' LIMIT ' . ($pageNum - 1) * $_SESSION['items'] . ',' . $_SESSION['items']; |
5
|
|
|
|
6
|
|
|
if (isset($search)) { |
7
|
|
|
logAction($_SESSION['user_name'], $lang['searched'] . ' (' . $search . ') ' . $lang['in'] . ' ' . $lang['gangs'], 1); |
8
|
|
|
$sql = "SELECT $playerIdColumn as playerid FROM `players` WHERE `name` LIKE '%" . $search . "%' "; |
9
|
|
|
$result_of_query = $db_link->query($sql); |
10
|
|
|
if ($result_of_query->num_rows > 0) { |
11
|
|
|
while ($row = mysqli_fetch_row($result_of_query)) { |
12
|
|
|
$samepID[] = $row; |
13
|
|
|
} |
14
|
|
|
$samepID = array_reduce($samepID, 'array_merge', array()); |
15
|
|
|
$samepID = implode(',', $samepID); |
16
|
|
|
$sql = "SELECT `id`,`name`,`owner`,`bank`,`members`,`maxmembers`,`active` FROM `gangs` WHERE `owner` IN ( " . $samepID . " ) OR `name` LIKE '%" . $search . "%' OR `id` = '" . $search . "' OR `owner` LIKE '" . $search . "' OR `members` LIKE '%" . $search . "%' ;"; |
17
|
|
|
$result_of_query = $db_link->query($sql); |
18
|
|
|
$total_records = mysqli_num_rows($result_of_query); |
19
|
|
|
if ($pageNum > $total_records) $pageNum = $total_records; |
20
|
|
|
$sql = "SELECT `id`,`name`,`owner`,`bank`,`members`,`maxmembers`,`active` FROM `gangs` WHERE `owner` IN ( " . $samepID . " ) OR `name` LIKE '%" . $search . "%' OR `id` = '" . $search . "' OR `owner` LIKE '" . $search . "' OR `members` LIKE '%" . $search . "%' " . $max . " ;"; |
21
|
|
|
} else { |
22
|
|
|
$sql = "SELECT `id` FROM `gangs` WHERE `name` LIKE '%" . $search . "%' OR `id` = '" . $search . "' OR `owner` LIKE '" . $search . "' OR `members` LIKE '%" . $search . "%' ;"; |
23
|
|
|
$result_of_query = $db_link->query($sql); |
24
|
|
|
$total_records = mysqli_num_rows($result_of_query); |
25
|
|
|
if ($pageNum > $total_records) $pageNum = $total_records; |
26
|
|
|
$sql = "SELECT `id`,`name`,`owner`,`bank`,`members`,`maxmembers`,`active` FROM `gangs` WHERE `name` LIKE '%" . $search . "%' OR `id` = '" . $search . "' OR `owner` LIKE '" . $search . "' OR `members` LIKE '%" . $search . "%' " . $max . " ;"; |
27
|
|
|
} |
28
|
|
|
} else { |
29
|
|
|
$sql = "SELECT `id` FROM `gangs`;"; |
30
|
|
|
$result_of_query = $db_link->query($sql); |
31
|
|
|
$total_records = mysqli_num_rows($result_of_query); |
32
|
|
|
if ($pageNum > $total_records) $pageNum = $total_records; |
33
|
|
|
$sql = "SELECT `id`,`name`,`owner`,`bank`,`members`,`maxmembers`,`active` FROM `gangs` " . $max . " ;"; |
34
|
|
|
} |
35
|
|
|
$result_of_query = $db_link->query($sql); |
36
|
|
|
if ($result_of_query->num_rows > 0) { |
37
|
|
|
?> |
38
|
|
|
|
39
|
|
|
<h1 class="page-header"> |
40
|
|
|
<?php echo $lang['gangs']; ?> |
41
|
|
|
<small> <?php echo $lang['overview']; ?></small> |
42
|
|
|
</h1> |
43
|
|
|
|
44
|
|
|
<div class="content-panel"> |
45
|
|
|
<table class="table table-striped table-advance table-hover"> |
46
|
|
|
<h4> |
47
|
|
|
<i class="fa fa-sitemap fa-fw"></i> |
48
|
|
|
<?php echo $lang['gangs']; |
49
|
|
|
include("views/templates/search.php"); ?> |
50
|
|
|
</h4> |
51
|
|
|
<hr class='hidden-xs'> |
52
|
|
|
<thead> |
53
|
|
|
<tr> |
54
|
|
|
<th class="hidden-xs"><i class="fa fa-eye"></i> <?php echo $lang['id']; ?></th> |
55
|
|
|
<th><i class="fa fa-user"></i> <?php echo $lang['gang'] . " " . $lang['name']; ?></th> |
56
|
|
|
<th class="hidden-xs"><i class="fa fa-user"></i> <?php echo $lang['owner']; ?></th> |
57
|
|
|
<th class="hidden-xs"><i class="fa fa-bank"></i> <?php echo $lang['bank']; ?></th> |
58
|
|
|
<?php if ($_SESSION['permissions']['edit']['gangs']) { |
59
|
|
|
echo '<th class="hidden-xs"><i class="fa fa-user"></i> ' . $lang['members'] . '</th>'; |
60
|
|
|
} else { |
61
|
|
|
echo '<th><i class="fa fa-user"></i> ' . $lang['members'] . '</th>'; |
62
|
|
|
}?> |
63
|
|
|
<th class="hidden-xs"><i class="fa fa-user"></i> <?php echo $lang['maxMembers']; ?></th> |
64
|
|
|
<th class="hidden-xs"><i class="fa fa-user"></i> <?php echo $lang['active']; ?></th> |
65
|
|
View Code Duplication |
<?php if ($_SESSION['permissions']['edit']['gangs']) { |
|
|
|
|
66
|
|
|
echo '<th><i class="fa fa-pencil"></i>' . $lang['edit'] . '</th>'; |
67
|
|
|
} |
68
|
|
|
?> |
69
|
|
|
</tr> |
70
|
|
|
</thead> |
71
|
|
|
<tbody> |
72
|
|
|
<?php |
73
|
|
|
while ($row = mysqli_fetch_assoc($result_of_query)) { |
74
|
|
|
echo "<tr>"; |
75
|
|
|
echo "<td class='hidden-xs'>" . $row["id"] . "</td>"; |
76
|
|
|
echo "<td>" . $row["name"] . "</td>"; |
77
|
|
|
echo "<td class='hidden-xs'>" . nameID($row["owner"], $db_link) . "</td>"; |
78
|
|
|
echo "<td class='hidden-xs'>" . $row["bank"] . "</td>"; |
79
|
|
|
$members = substr_count($row['members'], ","); |
80
|
|
|
$members++; |
81
|
|
View Code Duplication |
if ($_SESSION['permissions']['edit']['gangs']) { |
|
|
|
|
82
|
|
|
echo "<td class='hidden-xs'>" . $members . "</td>"; |
83
|
|
|
} else { |
84
|
|
|
echo "<td>" . $members . "</td>"; |
85
|
|
|
} |
86
|
|
|
echo "<td class='hidden-xs'>" . $row["maxmembers"] . "</td>"; |
87
|
|
|
echo "<td class='hidden-xs'>" . yesNo($row["active"], $lang) . "</td>"; |
88
|
|
|
if ($_SESSION['permissions']['edit']['gangs']) { |
89
|
|
|
echo "<td><a class='btn btn-primary btn-xs' href='" . $settings['url'] . "editGang/" . $row["id"] . "'>"; |
90
|
|
|
echo "<i class='fa fa-pencil'></i></a></td>"; |
91
|
|
|
} |
92
|
|
|
echo "</tr>"; |
93
|
|
|
} |
94
|
|
|
echo "</tbody></table>"; |
95
|
|
|
include("views/templates/page.php"); |
96
|
|
|
?> |
97
|
|
|
</tbody> |
98
|
|
|
<br> |
99
|
|
|
</table> |
100
|
|
|
</div> |
101
|
|
|
|
102
|
|
|
<?php |
103
|
|
|
} else echo errorMessage(3, $lang); |
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.