1
|
|
|
<?php |
2
|
|
|
$db_link = serverConnect(); |
3
|
|
|
require_once("config/carNames.php"); |
4
|
|
|
|
5
|
|
|
$max = 'LIMIT ' . ($pageNum - 1) * $_SESSION['items'] . ',' . $_SESSION['items']; |
6
|
|
|
|
7
|
|
View Code Duplication |
if (isset($search)) { |
|
|
|
|
8
|
|
|
logAction($_SESSION['user_name'], $lang['searched'] . ' (' . $search . ') ' . $lang['in'] . ' ' . $lang['vehicles'], 1); |
9
|
|
|
|
10
|
|
|
$sql = "SELECT `id` FROM `vehicles` INNER JOIN `players` ON vehicles.pid=players.$playerIdColumn WHERE `pid` LIKE '$search' OR `classname` LIKE '%$search%' OR `name` LIKE '%$search%' OR `plate` LIKE '$search' OR `inventory` LIKE '%$search%' OR `name` LIKE '%$search%';"; |
11
|
|
|
$result_of_query = $db_link->query($sql); |
12
|
|
|
$total_records = mysqli_num_rows($result_of_query); |
13
|
|
|
if ($pageNum > $total_records) $pageNum = $total_records; |
14
|
|
|
$sql = "SELECT vehicles.id,vehicles.pid,vehicles.classname,vehicles.active,vehicles.type,vehicles.plate,vehicles.alive,vehicles.active,players.name FROM `vehicles` INNER JOIN `players` ON vehicles.pid=players.$playerIdColumn WHERE `pid` LIKE '$search' OR vehicles.classname LIKE '%$search%' OR `name` LIKE '%$search%' OR vehicles.plate LIKE '$search' OR `inventory` LIKE '%$search%' OR `name` LIKE '%$search %' $max;"; |
15
|
|
|
} else { |
16
|
|
|
$sql = "SELECT `id` FROM `vehicles` INNER JOIN `players` ON vehicles.pid=players.$playerIdColumn;"; |
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 vehicles.id,vehicles.pid,vehicles.classname,vehicles.active,vehicles.type,vehicles.plate,vehicles.alive,vehicles.active,players.name FROM `vehicles` INNER JOIN `players` ON vehicles.pid=players.$playerIdColumn $max;"; |
21
|
|
|
} |
22
|
|
|
$result_of_query = $db_link->query($sql); |
23
|
|
|
if ($result_of_query->num_rows > 0) { ?> |
24
|
|
|
|
25
|
|
|
<div class="row"> |
26
|
|
|
<div class="col-lg-12"> |
27
|
|
|
<h1 class="page-header"> |
28
|
|
|
<?php echo $lang['vehicles']; ?> |
29
|
|
|
<small> <?php echo $lang['overview']; ?></small> |
30
|
|
|
</h1> |
31
|
|
|
</div> |
32
|
|
|
</div> |
33
|
|
|
|
34
|
|
|
<div class="content-panel"> |
35
|
|
|
<h4> |
36
|
|
|
<i class="fa fa-car"></i> |
37
|
|
|
<?php echo $lang['vehicles']; |
38
|
|
|
include("views/templates/search.php"); ?> |
39
|
|
|
</h4> |
40
|
|
|
<hr class="hidden-xs"> |
41
|
|
|
<table class="table table-striped table-advance table-hover"> |
42
|
|
|
<thead> |
43
|
|
|
<tr> |
44
|
|
|
<th><i class="fa fa-eye"></i> <?php echo $lang['owner'] ?></th> |
45
|
|
|
<th><i class="fa fa-car"></i> <?php echo $lang['class']; ?></th> |
46
|
|
|
<th class="hidden-xs"><i class="fa fa-car"></i> <?php echo $lang['type']; ?></th> |
47
|
|
|
<th class="hidden-xs"><i class="fa fa-car"></i> <?php echo $lang['plate']; ?></th> |
48
|
|
|
<th class="hidden-xs"><i class="fa fa-car"></i> <?php echo $lang['alive']; ?></th> |
49
|
|
|
<th class="hidden-xs"><i class="fa fa-info"></i> <?php echo $lang['active']; ?></th> |
50
|
|
View Code Duplication |
<?php if ($_SESSION['permissions']['edit']['vehicles']) { |
|
|
|
|
51
|
|
|
echo '<th><i class="fa fa-pencil"></i><span class="hidden-xs"> ' . $lang['edit'] . '</span></th>'; |
52
|
|
|
} |
53
|
|
|
?> |
54
|
|
|
</tr> |
55
|
|
|
</thead> |
56
|
|
|
<tbody> |
57
|
|
|
<?php |
58
|
|
View Code Duplication |
while ($row = mysqli_fetch_assoc($result_of_query)) { |
|
|
|
|
59
|
|
|
echo "<tr>"; |
60
|
|
|
echo "<td>" . $row["name"] . "</td>"; |
61
|
|
|
echo "<td>" . carName($row["classname"]) . "</td>"; |
62
|
|
|
echo "<td class='hidden-xs'> " . carType($row["type"], $lang) . "</td>"; |
63
|
|
|
echo "<td class='hidden-xs'> " . $row["plate"] . "</td>"; |
64
|
|
|
echo "<td class='hidden-xs'> " . yesNo($row["alive"], $lang) . "</td>"; |
65
|
|
|
echo "<td class='hidden-xs'> " . yesNo($row["active"], $lang) . "</td>"; |
66
|
|
|
if ($_SESSION['permissions']['edit']['vehicles']) { |
67
|
|
|
echo "<td><a class='btn btn-primary btn-xs' href='" . $settings['url'] . "editVeh/" . $row["id"] . "'>"; |
68
|
|
|
echo "<i class='fa fa-pencil'></i></a></td>"; |
69
|
|
|
} |
70
|
|
|
echo "</tr>"; |
71
|
|
|
} |
72
|
|
|
echo "</tbody></table>"; |
73
|
|
|
include("views/templates/page.php"); |
74
|
|
|
?> |
75
|
|
|
<br> |
76
|
|
|
</tbody> |
77
|
|
|
</table> |
78
|
|
|
</div> |
79
|
|
|
<?php |
80
|
|
|
} else echo errorMessage(32, $lang); |
|
|
|
|
81
|
|
|
|
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.