-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.php
More file actions
170 lines (129 loc) · 3.75 KB
/
comment.php
File metadata and controls
170 lines (129 loc) · 3.75 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
<div id="post" style="background-color: #eee;">
<div>
<?php
$image = "img/user_male.jpg";
if($ROW_USER['gender'] == 'Female')
{
$image = "img/user_female.jpg";
}
if(file_exists($ROW_USER['profile_image']))
{
$image = $image_class->get_thumb_profile($ROW_USER['profile_image']);
}
?>
<img src="<?php echo $image ?>" style="width: 50px; height: 50px; margin-right: 4px; border-radius: 50%;">
</div>
<div style="width:100%; ">
<div style="font-weight: bold;color: #405d9b; width:100%; ">
<?php
echo "<a style='text-decoration: none;'' href='profile.php?id=$COMMENT[userid]'>";
echo htmlspecialchars( $ROW_USER['first_name']) . " " . htmlspecialchars( $ROW_USER['last_name'] );
echo "</a>";
if($COMMENT['is_profile_image'])
{
$pronoun = "his";
if($ROW_USER['gender'] == 'Female')
{
$pronoun = "her";
}
echo "<span style='font-weight: normal; color: #aaa;'> updated $pronoun profile image</span>";
}
if($COMMENT['is_cover_image'])
{
$pronoun = "his";
if($ROW_USER['gender'] == 'Female')
{
$pronoun = "her";
}
echo "<span style='font-weight: normal; color: #aaa;'> updated $pronoun cover image</span>";
}?><br><br>
<span style="font-weight: normal; color: #aaa;"><?php
echo $COMMENT['date']
?></span><br><br>
</div>
<?php echo check_tags($COMMENT['post']) ?>
<br><br>
<?php
if(file_exists($COMMENT['image']))
{
$post_image = $image_class->get_thumb_post($COMMENT['image']);
echo "<img src='$post_image' style = 'width: 80%;' />";
}
?>
<br/><br/>
<?php
$likes = "";
$likes = ($COMMENT['likes'] > 0) ? "(" . $COMMENT['likes']. ")" : "" ;
?>
<a href="like.php?type=post&id=<?php echo $COMMENT['postid'] ?>"> Like <?php echo $likes ?></a> .
<a href="single_post.php?id=<?php echo $COMMENT['postid'] ?>">Reply</a> .
<span style="color: #999" >
<?php
echo $COMMENT['date']
?>
</span>
<?php
if($COMMENT['has_image']){
echo "<a href='image_view.php?id=$COMMENT[postid]' >";
echo ". View Full Image . ";
echo "</a>";
}
?>
<span style="color: #999; float: right;" >
<?php
$post = new Post();
if($post->i_own_post($COMMENT['postid'],$_SESSION['socialsite_userid'])){
echo "<a href='edit.php?id=$COMMENT[postid]'>
Edit
</a> . ";
}
if(i_own_content($COMMENT)){
echo "<a href='delete.php?id=$COMMENT[postid] ' >
Delete
</a>";
}
?>
</span>
<?php
$i_liked = false;
if(isset($_SESSION['socialsite_userid']))
{
$DB = new Database();
$sql = "select likes from likes where type = 'post' && contentid = '$COMMENT[postid]' limit 1";
$result = $DB->read($sql);
if(is_array($result))
{
$likes = json_decode($result[0]['likes'],true);
$user_ids = array_column($likes, "userid");
if(in_array($_SESSION['socialsite_userid'], $user_ids)){
$i_liked = true;
}
}
}
if($COMMENT['likes']>0){
echo "<br/>";
echo "<a href='likes.php?type=post&id=$COMMENT[postid]'>";
if($COMMENT['likes'] == 1){
if($i_liked){
echo "<div style='text-align: left;'>You liked this comment </div>";
}else
{
echo "<div style='text-align: left;'>1 person liked this comment </div>";
}
}else
{
if($i_liked){
$text ="others";
if($COMMENT['likes']-1 == 1){
$text = "other";
}
echo "<div style='text-align: left;'>You and " . ($COMMENT['likes']-1) . " $text liked this comment </div>";
}else{
echo "<div style='text-align: left;'>" . $COMMENT['likes'] . " other liked this comment </div>";
}
}
echo "</a>";
}
?>
</div>
</div>