-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookup.php
179 lines (129 loc) · 4.02 KB
/
bookup.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
<?php ob_start(); ?>
<?php
session_start();
$user_id = $_SESSION['user_id'];
?>
<?php
if(!$user_id){
header("location: index.php");
exit;
}
?>
<?php
//Initialize Values
$userid = $_SESSION['user_id'];
$src = NULL;
$ext = "";
//Based upon file, convert for use in database
if ($_FILES["file"]["type"] == "text/pdf")
{
$ext = "pdf";
$src = $_FILES['file']['tmp_name'];
}else if ($_FILES["file"]["type"] == "text/docx")
{
$ext = "docx";
$src = $_FILES['file']['tmp_name'];
}else if ($_FILES["file"]["type"] == "video/ogg")
{
$ext = "ogg";
$src = $_FILES['file']['tmp_name'];
}else if ($_FILES["file"]["type"] == "video/mpeg")
{
$ext = "mp4";
$src = $_FILES['file']['tmp_name'];
}
//Check image size
//Get pic info and upload pic to server
$RandoNum = "intllfd";
$RandomNum = rand(0, 9999999999);
$nameof = "$RandoNum-$RandomNum-$userid";
$nameofs = "$RandomNum-$userid";
$picid = $nameof;
$picturelocation = "userfiles/photos/$picid.pdf";
//move pic
move_uploaded_file($_FILES["file"]["tmp_name"],
"$picturelocation");
$content = $_POST['content'];
$content = $_POST['content'];
$typed = $_POST['type'];
$tribe = $_POST['tribe'];
$location = $_POST['location'];
$type = "Tribe";
$timestamp = time();
include "connect.php";
$exta ="pdf";
$gotosms = "SELECT post,user_id
FROM posts
WHERE post='$content'
";
$querym=mysqli_query($conn, $gotosms);
if(mysqli_num_rows($querym)<1){
if($picturelocation){
$sql="INSERT INTO posts(post,user_id,image,imageo,timestamp,type,location)
VALUES
('$content','$userid','$picturelocation','$picturelocations','$timestamp ','$exta','$location')";
$result=mysqli_query($conn, $sql) or die(mysql_error());
$yi= "UPDATE users
SET posts = posts + 1
WHERE id='$user_id'
";
$com=mysqli_query($conn, $yi) or die(mysql_error());
}
$strings =$_POST['content'];
$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());
}
}
}else{
header("location: home.php?duplicate=fail");
exit;
}
$gotosmss = "SELECT id,user_id
FROM posts
WHERE user_id='$user_id' ORDER BY timestamp DESC
";
$queryme=mysqli_query($conn, $gotosmss) or die(mysql_error());
$rowse = mysqli_fetch_assoc($queryme);
$pp = $rowse['id'];
if($com){
$success = 'success';
header("location: home.php?username=$name&success=$success&pull=$pp");
exit();
}else{
$success = 'success';
header("location: vupload.php?success=$success");
exit();
}
?><?php ob_end_flush();?>