-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.php
More file actions
492 lines (406 loc) · 18.9 KB
/
Copy pathview.php
File metadata and controls
492 lines (406 loc) · 18.9 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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
<?php include'config/config.php';?>
<?php include'lib/Database.php';?>
<?php include'lib/functions.php';?>
<?php include'helpers/format.php';?>
<?php
$cookie_name = "user";
if(!isset($_COOKIE[$cookie_name])) {
#__Cookies are not set
$cookie_value = substr(md5(mt_rand()), 0, 50);
setcookie($cookie_name, $cookie_value, time() +60*60*24*30);
header('Location: index.php');
}
$db = new Database();
$fm = new format();
if (isset($_GET['page_no']) && !empty($_GET['page_no'])) {
$page_no = (int)$_GET['page_no'];
} else {
$page_no = 1;
}
if(isset($_GET['search_topic']) && !empty($_GET['search_topic'])){
// $topic = $_GET['topic'];
// $result = $db->select("select * from vote where topic= '$topic'");
// $no_of_records_per_page = 10;
// $offset = ($page_no-1) * $no_of_records_per_page;
// $total_rows = $result->num_rows;
// $total_pages = ceil($total_rows / $no_of_records_per_page);
// $vote = $db->select("select * from vote where topic= '$topic' ORDER BY id DESC LIMIT $offset, $no_of_records_per_page");
if(isset($_GET['topic']) && !empty($_GET['topic'])){
if(isset($_GET['topic']) && $_GET['topic'] == 'bylike'){
echo"hi";
exit;
}else{
$topic = $_GET['topic'];
$result = $db->select("select * from vote where topic= '$topic'");
$no_of_records_per_page = 10;
$offset = ($page_no-1) * $no_of_records_per_page;
$total_rows = $result->num_rows;
$total_pages = ceil($total_rows / $no_of_records_per_page);
$vote = $db->select("select * from vote where topic= '$topic' ORDER BY id DESC LIMIT $offset, $no_of_records_per_page");
}
}else{
$result = $db->select('select * from vote');
$no_of_records_per_page = 10;
$offset = ($page_no-1) * $no_of_records_per_page;
$total_rows = $result->num_rows;
$total_pages = ceil($total_rows / $no_of_records_per_page);
$vote = $db->select("SELECT * FROM vote ORDER BY id DESC LIMIT $offset, $no_of_records_per_page");
}
}else{
$result = $db->select('select * from vote');
$no_of_records_per_page = 10;
$offset = ($page_no-1) * $no_of_records_per_page;
$total_rows = $result->num_rows;
$total_pages = ceil($total_rows / $no_of_records_per_page);
$vote = $db->select("SELECT * FROM vote ORDER BY id DESC LIMIT $offset, $no_of_records_per_page");
}
$email1 = $_POST['email1'];
if ($email1 != NULL)
{
if (filter_var($email1, FILTER_VALIDATE_EMAIL)) {
$db->insert("INSERT INTO `email` (`email`) VALUES ('$email1')");
?><script>
alert("অন্যান্য ধন্যবাদ । আমরা আপনাকে আপডেটেড রাখব । ");
</script><?php
} else {
?><script>
alert("Opps! Invalid email address.");
</script><?php
}
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css">
<title> View Total Vote </title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/bt_menu.css">
<link rel="stylesheet" href="/css/style_04.css">
<style type="text/css">
</style>
</head>
<body>
<input type="hidden" value="<?php if (isset($_GET['voteStatus'])){echo $_GET['voteStatus'];} ?>" id="voteStatus">
<!-- header
================================================== -->
<header class="s-header" style="background: #0C0C0C">
<div class="header-logo">
<a class="site-logo" href="/index.php">
<img src="/assets/img/amarVotebd.png" alt="Homepage">
</a>
</div>
<nav class="header-nav">
<a href="#0" class="header-nav__close" title="close"><span>Close</span></a>
<div class="header-nav__content">
<h3>Navigation</h3>
<ul class="header-nav__list">
<li><a href="#home" title="home">বাংলা ভার্শন</a></li>
<li><a href="/english.php" title="about">English Version</a></li>
<li><a class="smoothscroll" href="#about" title="about">About</a></li>
<li class="current"><a href="view.php" title="view">See Public Inputs</a></li>
<li><a href="/index.php#vote" title="Vote">Add Your Inputs</a></li>
</ul>
</div> <!-- end header-nav__content -->
</nav> <!-- end header-nav -->
<a class="header-menu-toggle" href="#0">
<span class="header-menu-text">Menu</span>
<span class="header-menu-icon"></span>
</a>
</header> <!-- end s-header -->
<style>
.from_border_r {
border-radius: .25rem 0 0 .25rem;
border-color: #28a745;
}
.from_border_l {
border-radius: 0 .25rem .25rem 0;
}
.sonar-wrapper {
position: relative;
z-index: 0;
/*overflow: hidden;*/
/*padding: 2rem 0;*/
}
/* The circle */
.sonar-emitter {
position: relative;
margin: 0 auto;
margin-right: 25px;
width: 130px;
height: 38px;
/*border-radius: 9999px;*/
background-color: rgb(11, 148, 68);
}
/* the 'wave', same shape and size as its parent */
.sonar-wave {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
/*border-radius: 9999px;*/
background-color: rgb(11, 148, 68);
opacity: 0;
z-index: -1;
pointer-events: none;
}
/*
Animate!
NOTE: add browser prefixes where needed.
*/
.sonar-wave {
animation: sonarWave 2s linear infinite;
}
@keyframes sonarWave {
from {
opacity: 0.4;
}
to {
transform: scale(3);
opacity: 0;
}
}
.uber_btn {
width: 130px;
color: #28a745;
background-color: transparent;
background-image: none;
border-color: #28a745;
border-radius: .25rem;
}
</style>
<div class="container-fluid">
<div class="row" style="margin-top: 96px;">
<div class="col-md-12 pl-0 pr-0">
<div class="card">
<div class="card-header alert-success">
<div class="row">
<div class="col-md-6 col-12">
<h4 class="pl-1 pt-3">তৈরি হচ্ছে জনতার ইশতিহার </h4>
</div>
<div class="col-md-6 col-12">
<form class="form-inline float-right custom-form pt-2" method="get">
<div class="form-group custom-form-group no-mr media-100">
<div class="sonar-wrapper">
<div class="sonar-emitter">
<a href="index.php#vote" type="button" class="btn btn-success uber_btn">Add Vote</a>
<div class="sonar-wave">
</div>
</div>
</div>
<button name="share" type="submit" value="submit" class="btn btn-outline-success mr-3"><i class="fas fa-share"></i> Share All</button>
</div>
</form>
</div>
<div class="col-md-12">
<form class="form-inline custom-form pt-2" method="get">
<label for="topic" class="mr-2">Filter Topic</label>
<div class="form-group no-mr media-100">
<select name="topic" class="form-control from_border_r" id="topic">
<option value=''> Select Filter Topic...</option>
<option value="bylike">Top supported</option>
<option value="Education">Education</option>
<option value="Health">Health</option>
<option value="Employment">Employment</option>
<option value="Youth">Youth</option>
<option value="Freedom of Speech">Freedom of Speech</option>
<option value="Women Issue">Women Issue</option>
<option value="Children Issue">Children Issue</option>
<option value="Liberation War">Liberation War</option>
<option value="Others">Others</option>
</select>
</div>
<button name="search_topic" type="submit" value="submit" class="btn btn-outline-success from_border_l filter_btn"><i class="fas fa-chart-line"></i> Filter</button>
</form>
</div>
</div>
</div>
</div>
<div class="container">
<div class="card-body pl-0 pr-0">
<?php
while($row = $vote->fetch_object()){ //var_dump($row); ?>
<div class="card mb-3">
<div class="card-body">
<p class="card-text"><?= $row->comment; ?></p>
<button id="<?= $row->id; ?>" class="btn btn-danger btn-sm mb-2 likeMe"><i class="far fa-thumbs-up"></i> Support</button>
<a href="#" class="btn btn-primary btn-sm mb-2"><i class="fab fa-facebook-f"></i> Share</a>
<a href="#" class="btn btn-info btn-sm mb-2"><i class="fas fa-box-open"></i> Total Votes: <span class="voteNo"><?= $row->like_count; ?></span></a>
<a href="#" class="btn btn-success btn-sm mb-2"><i class="fas fa-filter"></i><strong> Catagory: </strong><?= $row->topic; ?></a>
</div>
</div>
<?php } ?>
<?php
if (isset($_GET['topic'])) { $topic = $_GET['topic']; ?>
<nav aria-label="Page navigation example" class="pr-3">
<ul class="pagination justify-content-end">
<li class="page-item <?php if($page_no <= 1){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php echo"?topic=".$topic; if($page_no <= 1){ echo '#'; } else { echo "&page_no=".($page_no - 1); } ?>" tabindex="-1">Previous</a>
</li>
<?php
for($i=1; 5 >= $i; $i++){
echo'<li class="page-item"><a class="page-link" href="?topic='.$topic.'&page_no='.$i.'">'.$i.'</a></li>';
}
?>
<li class="page-item <?php if($page_no >= $total_pages){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php "?topic=".$topic; if($page_no >= $total_pages){ echo '#'; } else { echo "?page_no=".($page_no + 1); } ?>">Next</a>
</li>
</ul>
</nav>
<?php }else{ ?>
<nav aria-label="Page navigation example" class="pr-3">
<ul class="pagination justify-content-end">
<li class="page-item <?php if($page_no <= 1){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php if($page_no <= 1){ echo '#'; } else { echo "?page_no=".($page_no - 1); } ?>" tabindex="-1">Previous</a>
</li>
<?php
for($i = $page_no ; $i > $page_no -1 ; $i--){
if($i < $total_pages){
$n1 = $i-1;
$n2 = $i-2;
if($n2>0){
echo'<li class="page-item"><a class="page-link" href="?page_no='.$n2.'">'.$n2.'</a></li>';
}
if($n1 > 0 ){
echo'<li class="page-item"><a class="page-link" href="?page_no='.$n1.'">'.$n1.'</a></li>';
}
}
}
for($i = $page_no ; $i < $page_no +2 ; $i++){
if($i < $total_pages){
echo'<li class="page-item';
if($i == $page_no){
echo" active";
}
echo'"><a class="page-link" href="?page_no='.$i.'">'.$i.'</a></li>';
}
}
?>
<li class="page-item <?php if($page_no >= $total_pages){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php if($page_no >= $total_pages){ echo '#'; } else { echo "?page_no=".($page_no + 1); } ?>">Next</a>
</li>
</ul>
</nav>
<?php } ?>
</div>
</div>
</div>
</div>
<!--<div class="col-md-4">-->
<!-- <div class="card">-->
<!-- <div class="card-header text-center alert-success">-->
<!-- Smart Filter-->
<!-- </div>-->
<!-- <div class="card-body">-->
<!-- </div>-->
<!-- </div>-->
<!--</div>-->
</div>
<style>
footer{
background: #111111;
color:rgba(255, 255, 255, 0.3);
}
footer h4{
color: #FFF;
}
.footer-logo {
display: block;
margin: -.6rem 0 3.6rem 0;
padding: 0;
outline: 0;
border: none;
width: 240px;
height: 60px;
background: url(/assets/img/amarVotebd.png) no-repeat center;
background-size: 240px 60px;
font: 0/0 a;
text-shadow: none;
color: transparent;
-webkit-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
</style>
<!-- footer
================================================== -->
<footer class="col-md-12 pt-5 pb-5">
<div class="container">
<div class="row footer-main">
<div class="col-md-6 tab-full left footer-desc">
<div class="footer-logo"></div>
Amar.Vote is an open platform initiatied by Preneur Lab - Social Good Company. The aim is to empower and engage mass people, specially youth, in positive and constructive politicial process.
</div>
<div class="col-md-6 tab-full right footer-subscribe">
<h4>Get Notified</h4>
<p>More features and area-wise candidate list will be launched soon. Please subscribe to get more updates on National Elections 2018.</p>
<div class="subscribe-form">
<form id="mc-form" class="group" novalidate="true" action="index.php" method="post">
<input type="email" value="" name="email1" class="email" id="mc-email" placeholder="Email Address">
<input type="submit" name="subscri" value="Subscribe">
<label for="mc-email" class="subscribe-message"></label>
</form>
</div>
</div>
</div> <!-- end footer-main -->
<div class="row text-center mt-5">
<div class="col-md-12">
<div class="copyright">
<span>© Copyright 2018</span>
<span>Initiative of <a href="http://www.preneurlab.com/">Preneur Lab - Social Good Company</a></span>
</div>
</div>
</div> <!-- end footer-bottom -->
</div>
</footer> <!-- end footer -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="js/main.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var voteStatus = $('#voteStatus').val();
console.log(voteStatus);
if(voteStatus === 'already_done'){
swal("You have already support this topic", "", "error");
}else if(voteStatus === 'vot_submitted'){
}else if(voteStatus == ''){
}
});
</script>
<script>
$(document).ready(function(){
$('.likeMe').click(function(){
var data = $(this).attr("id");
var getparent = $(this).parent();
// AJAX code to send data to php file.
$.ajax({
type: "GET",
url: "support.php",
data: "likeMe=" + data,
dataType: "JSON",
success: function(data) {
console.log(data);
if(data === "already"){
swal('You have already support this topic', "", "error");
} else if (data.status === "success"){
swal('You have successfully supported this topic !', "", "success");
getparent.find('.voteNo').text(data.votes);
}else{
swal('wrong Something went wrong !', "", "error");
}
},
error: function(err) {
console.log(err);
}
});
});
});
</script>
</body>
</html>