-
Notifications
You must be signed in to change notification settings - Fork 0
/
like.php
86 lines (77 loc) · 2.23 KB
/
like.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
76
77
78
79
80
81
82
83
84
85
86
<?php ob_start(); ?>
<?php
session_start();
$user_id = $_SESSION['user_id'];
?>
<?php
if(!$user_id){
header("location: index.php");
exit;
}
?>
<?php
if($_GET['pid']){
$follow_userid = $_GET['key'];
$post_id = $_GET['pid'];
$post = $_GET['post'];
$user = $_GET['user'];
$reaction = $_GET['type'];
$timestamp = time();
$timestap = time();
include 'connect.php';
$query2w ="SELECT id
FROM likes
WHERE post_id='$post_id' AND user_id='$user_id'
";
$query2=mysqli_query($conn, $query2w) or die(mysql_error());
mysqli_close($conn);
if(!(mysqli_num_rows($query2)>=1)){
include 'connect.php';
$likes = likes + 1;
$content = "Reacted on your post";
$type = "like";
if($user_id==$follow_userid){
}else{
$not="INSERT INTO notifications(post_id,user_id,user2, timestamp,content,type)
VALUES ('$post_id','$user_id','$follow_userid','$timestap','$content','$type')
";
mysqli_query($conn, $not) or die(mysql_error());
}
$nots="INSERT INTO likes(post_id,user_id, timestamp,username)
VALUES ('$post_id','$user_id','$timestamp','$reaction')
";
mysqli_query($conn, $nots) or die(mysql_error());
$notsq="UPDATE posts
SET likes = likes + 1
WHERE id='$post_id'
";
mysqli_query($conn, $notsq) or die(mysql_error());
if($user){
if($user_id==$user){
}else{
$notv="INSERT INTO notifications(post_id,user_id,user2, timestamp,content,type)
VALUES ('$post_id','$user_id','$user','$timestap','$content','$type')
";
mysqli_query($conn, $notv) or die(mysql_error());
}
$notsv="INSERT INTO likes(post_id,user_id, timestamp)
VALUES ('$post','$user_id','$timestamp')
";
mysqli_query($conn, $notsv) or die(mysql_error());
$notsqv="UPDATE posts
SET likes = likes + 1
WHERE id='$post'
";
mysqli_query($conn, $notsqv) or die(mysql_error());
}
// mysql_query("UPDATE users
// SET followers = followers + 1
// WHERE id='$follow_userid'
// ");
mysqli_close($conn);
}
header("location: post.php?pid=$post_id");
}else{
header("location: index.php");
}
?><?php ob_end_flush();?>