-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathactionr.php
75 lines (63 loc) · 2.58 KB
/
actionr.php
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
<?php
include'core/init.php';
protect_page();
session_start();
$action= $_GET['action'];
$user=$_GET['user'];//jiska username dala hai
$type=$_GET['type'];//jiska username dala hai
$id=$_GET['id'];//jiska username dala hai
$user2=$session_user_id;//jo loggedin hai
$votes=$_GET['votes'];//no. of votes
$ovotes=$_GET['ovotes'];//no. of votes
$user_data =user_data($user,'first_name','last_name','email','username','profile','enrollment_id','gender','age','type');
if($type=='reply'){
if($action=='upvote'){
if(user_reply_upvote_exists($user2,$id) === 1){
$con->query("DELETE FROM upvote_reply WHERE `who_id`='$user2' AND `reply_id`='$id' ");
$votes--;
$queryy="UPDATE `reply_comment` SET `upvotes`='$votes' WHERE `reply_id`='$id' ";
mysqli_query($con,$queryy);
}
else if(user_reply_downvote_exists($user2,$id) === 1){
$con->query("DELETE FROM downvote_reply WHERE `who_id`='$user2' AND `reply_id`='$id' ");
$con->query("INSERT INTO upvote_reply VALUES('','$user2','$id' )");
$votes++;
$ovotes--;
$queryy="UPDATE `reply_comment` SET `upvotes`='$votes' WHERE `reply_id`='$id' ";
mysqli_query($con,$queryy);
$queryz="UPDATE `reply_comment` SET `downvotes`='$ovotes' WHERE `reply_id`='$id' ";
mysqli_query($con,$queryz);
}
else{
$con->query("INSERT INTO upvote_reply VALUES('','$user2','$id' )");
$votes++;
$queryy="UPDATE `reply_comment` SET `upvotes`='$votes' WHERE `reply_id`='$id' ";
mysqli_query($con,$queryy);
}
}
else if($action=='downvote'){
if(user_reply_downvote_exists($user2,$id) === 1){
$con->query("DELETE FROM downvote_reply WHERE `who_id`='$user2' AND `reply_id`='$id' ");
$votes--;
$queryy="UPDATE `reply_comment` SET `downvotes`='$votes' WHERE `reply_id`='$id' ";
mysqli_query($con,$queryy);
}
else if(user_reply_upvote_exists($user2,$id) === 1){
$con->query("DELETE FROM upvote_reply WHERE `who_id`='$user2' AND `reply_id`='$id' ");
$con->query("INSERT INTO downvote_reply VALUES('','$user2','$id' )");
$votes++;
$ovotes--;
$queryy="UPDATE `reply_comment` SET `upvotes`='$ovotes' WHERE `reply_id`='$id' ";
mysqli_query($con,$queryy);
$queryz="UPDATE `reply_comment` SET `downvotes`='$votes' WHERE `reply_id`='$id' ";
mysqli_query($con,$queryz);
}
else{
$con->query("INSERT INTO downvote_reply VALUES('','$user2','$id' )");
$votes++;
$queryy="UPDATE `reply_comment` SET `downvotes`='$votes' WHERE `reply_id`='$id' ";
mysqli_query($con,$queryy);
}
}
header('location: profile.php?username='.$user_data['username']);
}?>