-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
249 lines (244 loc) · 8.34 KB
/
index.php
File metadata and controls
249 lines (244 loc) · 8.34 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?php
include_once("design.php");
// Which map to load
if (isset($_GET["map"])) {
$map_id = intval($_GET["map"]);
} else {
$map_id = "1";
}
$get_map = mysqli_query($connection,"SELECT * FROM maps WHERE id='$map_id'");
$map = array("name"=>"Not found");
$buglist = array();
$history = array();
// Get bug list
if (mysqli_num_rows($get_map)==1) {
$map = mysqli_fetch_array($get_map);
$get_buglist = mysqli_query($connection,"SELECT id,bugs.user_id,ban,coords,type,state,register_date,description,media,priority,steam_persona,steam_avatar,steam_id FROM bugs JOIN users ON users.user_id=bugs.user_id WHERE map_id='$map[id]' AND ban=0 ORDER BY register_date DESC");
if (mysqli_num_rows($get_buglist)>0) {
while ($r=mysqli_fetch_assoc($get_buglist)) {
$buglist[] = $r;
$get_history = mysqli_query($connection,"SELECT steam_persona,steam_avatar,steam_id,action,message,time,bug_id FROM mod_log JOIN users ON users.user_id=mod_log.mod_user_id WHERE bug_id='$r[id]' ORDER BY bug_id ASC,time DESC");
if (mysqli_num_rows($get_history)>0) {
$rhistory = array();
while ($r2=mysqli_fetch_assoc($get_history)) {
$rhistory[] = $r2;
}
$history[$r["id"]]=$rhistory;
}
}
}
}
?>
<link href="css/bootstrap-sortable.min.css" rel="stylesheet">
<link href="css/bootstrap-multiselect.css" rel="stylesheet">
<script src="js/bootstrap-sortable.js"></script>
<script src="js/bootstrap-multiselect.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/map_bug.js?v=2"></script>
<div class='container' style='padding-bottom:100px;background-color:rgba(0,0,0,0.7);'>
<div class='row'>
<h2 class="text-center"><?php echo $map["name"];?></h2>
<div class='col-sm-10 col-sm-offset-1'>
<table style='width:100%;table-layout:fixed;'><tr>
<td>
<form class='form-inline'>
<label for='mapchange'>Select map:</label>
<div class='form-group'><select id='mapchange' class='form-control'>
<?php
// Get map list, except bottom nuke.
$select = mysqli_query($connection,"SELECT id,name FROM maps WHERE id!=2");
while ($r=mysqli_fetch_array($select))
{
echo "<option".(($map_id==$r["id"])?" selected='selected":"")." value='".$r["id"]."'>".$r["name"]."</option>";
}
?>
</select></div></form>
</td>
<?php
// It's only used for de_nuke.
if ($map_id==1) {
echo "<td><label>Map:</label>";
echo "<button disabled='disabled' type='button' class='btn btn-default'>Top</button>";
echo "<button type='button' class='btn-default btn btn:hover' onclick='changeMap(2)'>Bottom</button></td>";
} else if ($map_id==2) {
echo "<td><label>Map:</label>";
echo "<button type='button' class='btn-default btn btn:hover' onclick='changeMap(1)'>Top</button>";
echo "<button disabled='disabled' type='button' class='btn btn-default'>Bottom</button></td>";
}
?>
<td style='white-space:nowrap;'>
<form class='form-inline'>
<label for='filter_state'>State:</label>
<div id='filter_state_holder' class='form-group hidden'>
<select id='filter_state' multiple='multiple' class='form-control'></select>
</div>
</form>
</td>
<td style='white-space:nowrap;'>
<form class='form-inline'>
<label for='filter_type'>Type:</label>
<div id='filter_type_holder' class='form-group hidden'>
<select id='filter_type' multiple='multiple' class='form-control'></select>
</div>
</form>
</td>
</tr>
</table>
</div>
</div>
<div class='row'>
<div class='col-sm-12'>
<div class='text-center'>
<div id="map" style='display:inline-block;position:relative;'>
<img id="map_img">
</div><br>
<button class='btn btn-default' style='margin-top:3px;' type='button' onclick='show(-1)'>Show selected bugs</button>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-body">
<div id="modal-content">
<div class='row'>
<div class='col-lg-8 col-lg-offset-2 col-md-8 col-md-offset-2'>
<div id="warning-box" class="alert alert-danger dynamicboxes text-center" role="alert" style="display:none;"></div>
<div id="success-box" class="alert alert-success dynamicboxes text-center" role="alert" style="display:none;"></div>
</div>
</div>
<h3>Bug list</h3>
<table style='width:100%;' id="bug-table" class="table table-striped sortable">
<thead>
</tr><th>Type</th><th>Description</th><th>Media</th><th>Status</th><th>Posted by</th><th>Actions</th></tr>
</thead>
<tbody id="bug-table-body">
</tbody>
</table>
<div id='post_area'>
<h3>Post a bug</h3>
<?php
if ($logged) {
?>
<form class="form-inline">
<label for="type">Type:</label>
<div class='form-group'>
<select class='form-control' id="type">
</select>
<span style='font-style:italic;' id='type_tooltip'></span>
</div>
<br>
<label for="description">Description:</label>
<div class='form-group'>
<textarea maxlength='500' class='form-control' id='description'></textarea>
</div>
<br>
<label for="media">Imgur/Gyfcat/Youtube link:</label>
<div class='form-group'>
<input class='form-control' id='media'>
</div>
<br>
<input class='form-control' type='button' onclick='postBug(<?php echo $map["id"];?>)' value='Post'>
</form>
<?php
}
else {
echo "<h3 class='text-center'>You must be signed in through Steam to post bugs.</h3><div class='text-center'>";
steamlogin();
echo "</div>";
}
?>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script>
var map = <?php echo json_encode($map); ?>;
var buglist = <?php echo json_encode($buglist);?>;
var histories = <?php echo json_encode($history);?>;
var selected_coords = 0;
var coord_bugs = {};
function changeMap(id) {
var url = "index.php?map="+id;
if (url) {
window.location = url;
}
}
$("#mapchange").change(function() {
changeMap($(this).val());
});
$("#type").change(function() {
$("#type_tooltip").html(types_tooltip[$(this).val()]);
});
$("#filter_type" ).change(function() {
displayBugs();
});
$("#filter_state" ).change(function() {
displayBugs();
});
$("#bug-table").on('sorted',function() {
$(".history-table").remove();
});
$(document).on('change','.modifyChanger', function() {
if ($(this).val()!=-1) {
setStateBug($(this).attr('data-id'),$(this).val())
}
});
$( document ).ready(function() {
$.bootstrapSortable();
$("#type_tooltip").html(types_tooltip[0]);
for (i=0;i<types.length;i++) {
$("#filter_type").append("<option selected='selected' value='"+i+"'>"+types[i]+"</option>");
$("#type").append("<option value='"+i+"'>"+types[i]+"</option>");
}
for (i=0;i<states.length;i++) {
$("#filter_state").append("<option "+((i<2)?"selected='selected'":"")+" value='"+i+"'>"+states[i]+"</option>");
}
$('#filter_type').multiselect({includeSelectAllOption:true});
$("#filter_type_holder").removeClass("hidden");
$('#filter_state').multiselect({includeSelectAllOption:true});
$("#filter_state_holder").removeClass("hidden");
if (map!=null) {
if (map["id"]!=0) {
$("body").css("background-image", "url(images/maps/"+map["image_path"]+"_background.jpg)");
}
$("#map_img").attr("src","images/maps/"+map["image_path"]+".png");
var topa = 0;
var lefta = 0;
var owidth = parseInt(map["width"]);
var oheight = parseInt(map["height"]);
var grid_size = parseInt(map["grid_size"]);
var maxw = Math.floor(owidth/grid_size);
var maxh = Math.floor(oheight/grid_size);
var counter = 0;
// Build map grid
for (var s=0;s<maxh;s++) {
for (var i=0;i<maxw;i++) {
counter++;
$("#map").append("<div id="+counter+" onclick=show("+counter+") class=cube style='width:"+grid_size+"px;height:"+grid_size+"px;top:"+(topa)+"px;left:"+(lefta)+"px;'></div>");
lefta+=grid_size;
}
lefta=0;
topa+=grid_size;
}
// Overlay bug count
displayBugs();
}
});
</script>
<?php
if (!$logged) {
echo "<h3 class='text-center'>Sign in through Steam, to post bugs.</h3><div class='text-center'>";
steamlogin();
echo "</div>";
}
include_once("design2.php");
?>