-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.php
More file actions
307 lines (294 loc) · 13.5 KB
/
Copy pathevents.php
File metadata and controls
307 lines (294 loc) · 13.5 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<?php
include("header.php");
?>
<title>Events</title>
<link rel="stylesheet" href="css/events.css">
<link rel="stylesheet" href="css/footer2.css">
<style media="screen">
body {
background: #eee url(https://subtlepatterns.com/patterns/extra_clean_paper.png);
background-size: 100% 100%;
background-repeat: no-repeat;
padding-bottom: 0;
}
</style>
</head>
<body>
<?php
if (isset($_POST['host']) && !empty($_POST['host'])) {
if (!isset($_SESSION["user"]) || !$_SESSION["user"] || $_SESSION["user"] == null) {
header("Location:login.php");
}
$event_name = mysqli_real_escape_string($conn, $_POST['event-name']);
$type = mysqli_real_escape_string($conn, $_POST['type']);
$venue = mysqli_real_escape_string($conn, $_POST['venue']);
$city = mysqli_real_escape_string($conn, $_POST['city']);
$start_date = mysqli_real_escape_string($conn, $_POST['start-date']);
$end_date = mysqli_real_escape_string($conn, $_POST['end-date']);
$target_dir = "event-attachments/";
$target_file = $target_dir . basename($_FILES["description"]["name"]);
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
if (move_uploaded_file($_FILES["description"]["tmp_name"], $target_file)) {
// echo "The file ". basename( $_FILES["description"]["name"]). " has been uploaded.";
} else {
// echo "Sorry, there was an error uploading your file.";
}
$host = $_SESSION["user"];
$query = "Insert into `event` (`name`,`type`,`venue`,`city`,`start-date`,`end-date`,`registrations`,`active`,`host`,`description`) values('$event_name','$type','$venue','$city','$start_date','$end_date','0','0','$host','$target_file')";
$result = $db->insertQuery($query);
header("Location:events.php");
}
if (isset($_POST['register']) && !empty($_POST['register'])) {
if (!isset($_SESSION["user"]) || !$_SESSION["user"] || $_SESSION["user"] == null) {
header("Location:login.php");
}
$eid = $_POST['eventid'];
$uid = $_SESSION['user'];
$qur = "select * from registration where uid='$uid' && eid='$eid'";
$nums = $db->db_num($qur);
if ($nums > 0) {
// echo "Already Registered";
} else {
$revent = $db->SinglerunQuery("select * from event where evid='$eid'");
$newreg = $revent['registrations'] + 1;
$query = "Insert into `registration` (`uid`,`type`,`eid`) values('$uid','event',$eid)";
$result = $db->insertQuery($query);
$updatequery = "Update `event` set registrations='$newreg' where `evid`='$eid'";
$update = $db->updateQuery($updatequery);
header("Location:events.php");
}
}
?>
<div class="usercontainer">
<div class="modal fade" id="hostevent" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Host A New Event</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form class="form" method="post" action="events.php" enctype="multipart/form-data">
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label for="recipient-name" class="form-control-label">Event Name</label>
<input type="text" class="form-control" name="event-name" placeholder="Enter event name" required>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label for="recipient-name" class="form-control-label">Type</label>
<select class="form-control" name="type">
<option value="cleanliness">Cleanliness Drive</option>
<option value="tree-plantation">Tree plantation</option>
<option value="awareness">Awareness</option>
<option value="other">Other</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="recipient-name" class="form-control-label">Venue</label>
<input type="text" class="form-control" name="venue" placeholder="Enter Venue" required>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="recipient-name" class="form-control-label">City</label>
<input type="text" class="form-control" name="city" placeholder="Enter City" required>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="recipient-name" class="form-control-label">Start Date</label>
<input type="date" class="form-control" name="start-date" placeholder="Enter start date" required>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="recipient-name" class="form-control-label">End Date</label>
<input type="date" class="form-control" name="end-date" placeholder="Enter end date" required>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label for="recipient-name" class="form-control-label">Description</label><br>
<input type="file" name="description" placeholder="Enter Description" required>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" name="host" value="host" class="btn btn-secondary">Host!</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" id="more-info" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">More Info</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<object width="400" height="400" data="event-attachments/dashboard.txt"></object>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<!-- <button type="button" class="btn btn-primary">Send message</button> -->
</div>
</div>
</div>
</div>
<div class="modal fade" id="registration" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Confirm Registration</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p class="modalp">Are you sure you want to register for this event?</p>
<form method="post" action="events.php">
<input type="hidden" name="eventid">
<div class="float-right">
<button type="submit" name="register" value="register" class="btn btn-secondary">Yes</button>
<button data-dismiss="modal" class="btn btn-secondary">No</button>
</div>
</form>
</div>
</div>
</div>
</div>
<?php include 'topbar.php'; ?>
<div class="events-body">
<div class="new-event">
<button type="button" class="btn btn-success btn-lg float-right" data-toggle="modal" data-target="#hostevent">Host An Event!</button>
</div>
<br>
<br>
<div id="header">
<ul id="menu">
<li><a href="/"><span>Current Events</span></a></li>
</ul>
</div>
<br>
<br>
<br>
<div class="current_events">
<div class="row">
<?php
$query = "Select * from event where active=1";
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($result)) {
$uuid = $row['host'];
$hostdata = $db->SinglerunQuery("select * from user where uid='$uuid'");
echo '
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<strong class="d-inline-block mb-2 text-success" style="text-transform:uppercase;">' . $row["name"] . '</strong>';
$start = strtotime($row['start-date']);
$start = date('d-F-Y', $start);
$end = strtotime($row['end-date']);
$end = date('d-F-Y', $end);
echo '<div class="mb-1 text-mute small">' . $start . ' to ' . $end . '</div>
<img class="card-img-right flex-auto d-none d-lg-block" alt="Thumbnail [200x250]" src="//placeimg.com/250/250/nature" style="width: 100%; height: 100%;">
</div>
<div class="flip-card-back">
<h4><strong class="d-inline-block mb-2" style="text-transform:uppercase;">' . $row["name"] . '</strong></h4>
<p class="card-text mb-auto">Venue : ' . $row["venue"] . '</p>
<p class="card-text mb-auto">Host : ' . $hostdata["name"] . '</p>
<p class="card-text mb-auto">' . $row["registrations"] . ' Total Registrations</p>
<div class=""><br>
<button class="btn btn-success btn-sm" style="display:inline;" data-toggle="modal" data-target="#registration" data-evid=' . $row["evid"] . ' data-name=' . $row["name"] . '>Register</button>
<button type="button" class="btn btn-success btn-sm" style="display:inline;" data-toggle="modal" data-target="#more-info" data-evn=' . $row["name"] . ' data-description=' . $row["description"] . '>More Info</button>
</div>
</div>
</div>
</div>
';
}
?>
</div>
</div>
<br>
<div id="header">
<ul id="menu">
<li><a href="/"><span>Past Events</span></a></li>
</ul>
</div>
<br><br><br>
<div class="past_events">
<div class="row">
<?php
$query = "Select * from event where active=2";
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($result)) {
$uuid = $row['host'];
$hostdata = $db->SinglerunQuery("select * from user where uid='$uuid'");
echo '
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<strong class="d-inline-block mb-2 text-success" style="text-transform:uppercase;">' . $row["name"] . '</strong>
<img class="card-img-right flex-auto d-none d-lg-block" alt="Thumbnail [200x250]" src="//placeimg.com/250/250/nature" style="width: 100%; height: 100%;">
</div>
<div class="flip-card-back">
<h4><strong class="d-inline-block mb-2 " style="text-transform:uppercase;">' . $row["name"] . '</strong></h4>
<p class="card-text mb-auto">Venue : ' . $row["venue"] . '</p>
<p class="card-text mb-auto">Host : ' . $hostdata["name"] . '</p>
<p class="card-text mb-auto">' . $row["registrations"] . ' Total Participants</p>
<div class=""><br>
<a type="button" class="btn btn-success btn-sm" style="display:inline;" data-toggle="modal" data-target="#more-info" data-evn=' . $row["name"] . ' data-description=' . $row["description"] . '>More Info</a>
</div>
</div>
</div>
</div>
';
}
?>
</div>
</div>
</div>
<script type="text/javascript">
$('#more-info').on('show.bs.modal', function(event) {
var button = $(event.relatedTarget)
var name = button.data('evn')
var description = button.data('description')
var modal = $(this)
modal.find('.modal-title').text(name)
// modal.find('.modal-body object').data(description)
$("object").replaceWith('<object width="100%" height="400" data="' + description + '"></object>');
modal.find('.modal-body input').val(name)
})
$('#registration').on('show.bs.modal', function(event) {
var button = $(event.relatedTarget)
var evid = button.data('evid')
var name = button.data('name')
var modal = $(this)
modal.find('.modalp').text('Are you sure you want to register for the event - ' + name + ' ?')
modal.find('.modal-body input').val(evid)
})
</script>
</div>
<br><br>
<?php include('footer2.php') ?>