-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommentpost-audio.php
222 lines (164 loc) · 5.4 KB
/
commentpost-audio.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
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
<?php ob_start(); ?>
<?php
error_reporting(1);
session_start();
$user_id = $_SESSION['user_id'];
?>
<?php
if(!$user_id){
header("location: index.php");
exit;
}
?>
<?php
$userid = $_SESSION['user_id'];
$src = NULL;
$ext = "";
//Based upon file, convert for use in database
if ($_FILES["file"]["type"] == "audio/mp3")
{
$ext = "mp3";
$src = $_FILES['file']['tmp_name'];
}else if ($_FILES["file"]["type"] == "audio/mp3")
{
$ext = "mpeg";
$src = $_FILES['file']['tmp_name'];
}else if ($_FILES["file"]["type"] == "audio/mpeg")
{
$ext = "ogg";
$src = $_FILES['file']['tmp_name'];
}
//Make sure it was a valid file, if not complain.
if ((($ext == "mp3") ||($ext == "ogg") ||($ext == "mpeg") || ($ext == "gif")) && ($_FILES["file"]["size"] < 10000000))
{
//Check for errors, make sure upload worked
if ($_FILES["file"]["error"] > 0)
{
$post_wid =$_POST['post_id'];
$success = 'success';
header("location: post.php?pid=$post_wid&success=$success");
exit();
}
//Get pic info and upload pic to server
$RandoNum = "hbrd";
$RandomNum = rand(0, 999999999);
$nameof = " $RandoNum-$RandomNum-$userid";
$nameofa = "$RandomNum-hbrd";
$picid = $nameof;
$picturelocation = "userfiles/audio/$nameofa.$ext";
//move pic
move_uploaded_file($_FILES["file"]["tmp_name"],
"$picturelocation");
$content = $_POST['postcomment'];
$post_id =$_POST['post_id'];
$follow_userid =$_POST['user'];
$location =$_POST['location'];
$timestamp = time();
$type ="comment";
include "connect.php";
$e="INSERT INTO posts(post,user_id,timestamp,location,post_id,role,image,type)
VALUES
('$content','$userid','$timestamp ','$location','$post_id','$type','$picturelocation','$ext')";
$sql=mysqli_query($conn, $e) ;
$ie= "UPDATE posts
SET comments = comments + 1
WHERE id='$post_id'
";
$com=mysqli_query($conn, $ie) or die(mysql_error());
$comxc= "UPDATE users
SET posts = posts + 1
WHERE id='$user_id'
";
$gotor=mysqli_query($conn, $comxc) or die(mysql_error());
if($user_id==$follow_userid){
}else{
$ea="INSERT INTO notifications(post_id,user_id,user2, timestamp,content,type,content_id)
VALUES ('$post_id','$user_id','$follow_userid','$timestap','$contentr','$type','$post_id')
";
mysqli_query($conn, $ea) ;
}
//Get hashtags from user text
$strings = $_POST['postcomment'];
$result = explode('#',$strings);
array_shift($result);
//print_R($result);
//echo $cleantexts = implode($result, " ");
// foreach($result as $key => $resul) {
// $key = $result;
//echo "$key
// ";
$value0 = $result[0];
$value1 = $result[1];
$value2 = $result[2];
$value3 = $result[3];
if($value0){
$comie= "INSERT INTO tags(tag,user_id,timestamp,location)
VALUES ('#$value0','$user_id','$timestamp','$location')
";
$comi=mysqli_query($conn, $comie) or die(mysql_error());
if($value1){
$comie1="INSERT INTO tags(tag,user_id,timestamp,location)
VALUES ('#$value1','$user_id','$timestamp','$location')
";
$comi1=mysqli_query($conn, $comie1) or die(mysql_error());
}
if($value2){
$comie2= "INSERT INTO tags(tag,user_id,timestamp,location)
VALUES ('#$value2','$user_id','$timestamp','$location')
";
$comi2=mysqli_query($conn, $comie2) or die(mysql_error());
}
if($value3){
$comie3= "INSERT INTO tags(tag,user_id,timestamp,location)
VALUES ('#$value3','$user_id','$timestamp','$location')
";
$comi3=mysqli_query($conn, $comie3) or die(mysql_error());
}
}
$stringse = $_POST['content'];
$resulte = explode('@',$stringse);
array_shift($resulte);
//print_R($result);
//echo $cleantexts = implode($result, " ");
// foreach($result as $key => $resul) {
// $key = $result;
//echo "$key
// ";
$value0e = $resulte[0];
$value1e = $resulte[1];
$value2e = $resulte[2];
$value3e = $resulte[3];
$timestap = time();
$types = "mention";
$contenta = "Mentioned you on a post";
$gotosms = "SELECT id,username
FROM users
WHERE username='$value0e'
";
$querym=mysqli_query($conn, $gotosms) or die(mysql_error());
if(mysqli_num_rows($querym)>=1){
$rows = mysqli_fetch_assoc($querym);
$id = $rows['id'];
if($value0e){
$not="INSERT INTO notifications(user_id,user2, timestamp,content,type)
VALUES ('$user_id','$id','$timestap','$contenta','$types')
";
mysqli_query($conn, $not) or die(mysql_error());
// if($value1){
// $comie1="INSERT INTO tags(tag,user_id,timestamp,location)
// VALUES ('#$value1','$user_id','$timestamp','$location')
// ";
// $comi1=mysqli_query($conn, $comie1) or die(mysql_error());
// }
}
}
header("location: post.php?pid=$post_id");
}
else
{
$success = 'success';
header("location: post.php?pid=$post_id&success=$success");
exit();
}
header("location: post.php?pid=$post_id");
?><?php ob_end_flush();?>