-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidator.php
More file actions
166 lines (98 loc) · 2.91 KB
/
Copy pathvalidator.php
File metadata and controls
166 lines (98 loc) · 2.91 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
<?php include('mysqlicon.php'); include('mylinks.php'); ?>
<?php
$defimg="images/img1.png";
$error="";
if (isset($_POST['signup'])) {
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$username=$_POST['username'];
$email=$_POST['email'];
$password=$_POST['password'];
$confirmpassword=$_POST['confirmpassword'];
$secretpassword=md5($password);
$currenttime=strtotime(date('Y-m-d H:i:s'));
$date=date('Y-m-d h:i:s', $currenttime);
$profilepic=$defimg;
$status="";
$sql="select * from tint where email='$email'";
$found=mysqli_query($con,$sql);
if ($password!=$confirmpassword) {
$error= "passwords do not match";
}
elseif ($password=='') {
echo "please enter a password";
}
elseif (strlen($password)<8 || strlen($password)>15) {
$error="password should be between 8 to 15 characters";
}
elseif (mysqli_num_rows($found)==1) {
$error="Email has been taken, please choose another email";
}
else{
$query="insert into tint values('','$firstname', '$lastname', '$username', '$email', '$secretpassword','$date','$profilepic','$status')";
$connect=mysqli_query($con,$query);
if ($connect) {
session_start();
$id=$_SESSION['id'];
header("location:index.php");
}
}
}
if (isset($_POST['login'])) {
$lemail=$_POST['lemail'];
$lpassword=md5($_POST['lpassword']);
$sql="select * from tint where email='$lemail' and password='$lpassword'";
$query=mysqli_query($con, $sql);
while ($row=mysqli_fetch_array($query)) {
$id=$row['id'];
$email=$row['email'];
$username=$row['username'];
$dp=$row['profilepic'];
}
if ($query->num_rows==0) {
$error="Incorrect email or password";
}
else{
$cookie=$_POST['rememberme'];
if ($cookie==1) {
setcookie("lusername",$username,time()+86400);
}
session_start();
$_SESSION['id']= $id;
$_SESSION['email']=$email;
$_SESSION['username']=$username;
$_SESSION['date']=$date;
$_SESSION['profilepic']=$dp;
$_SESSION['secretpassword']=$password;
header("location: index.php");
}
}
if (isset($_POST['post'])) {
session_start();
$set=$_POST['set'];
$date=date("d-m-y, h-m-s");
$userid=$_SESSION['id'];
$imgfolder="images/";
$imagepath=$imgfolder.basename($_FILES['addphoto']['name']);
$imgext=pathinfo($imagepath,PATHINFO_EXTENSION);
$imgsize=$_FILES['addphoto']['size'];
$imgtmpname=$_FILES['addphoto']['tmp_name'];
if ($imgext!="PNG" && $imgext!="JPG" && $imgext!="JPEG" && $imgext!="GIF") {
$ms="file type not supported";
}
elseif ($article='') {
$mss="article empty";
}
else{
$upload=move_uploaded_file($imgtmpname, $imagepath);
$db="insert into posts values('','$set','$userid','$imagepath','$date')";
$upd=mysqli_query($con, $db);
if ($upd) {
echo "<div class='bg-success text-light'>Post successful</div>";
}
else{
echo mysqli_error();
}
}
}
?>