-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauth.php
249 lines (223 loc) · 6.97 KB
/
auth.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?php
session_start();
require "bd.php";
$login = $_POST['login'];
$pass = $_POST['pass'];
$email = $_POST['email'];
if(isset($_SESSION['user']))
{
echo "<script>location.href = '../'</script>";
}
if($_POST['submit_close'])
{
unset($_SESSION['user']);
}
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if(isset($_POST['forgot']))
{
if($_POST['forgot'])
{
if(!$_POST['email'] == "")
{
$email = $_POST['email'];
if ($result = mysqli_query($link, "SELECT id FROM users WHERE email='$email'"))
{
$row_cnt = $result->num_rows;
if($row_cnt > 0)
{
$result = mysqli_query($link, "SELECT * FROM users WHERE email='$email'");
while ($row = mysqli_fetch_row($result))
{
$login = "{$row[1]}";
$pass = "{$row[3]}";
include "mail/mail_forgot.php";
}
echo "<script>alert('Проверьте почту!')</script>";
echo "<script>location.href = '../'</script>";
}
else
{
echo "<script>alert('Email not found')</script>";
}
}
}
else
{
echo "<script>alert('Email no input')</script>";
}
}
}
if(isset($_POST['reg']))
{
if($_POST['reg'])
{
if(!$_POST['login'] == "" && !$_POST['email'] == "" && !$_POST['pass'] == "")
{
$login = $_POST['login'];
$email = $_POST['email'];
$pass = $_POST['pass'];
if ($id = mysqli_query($link, "SELECT id FROM users WHERE login='$login'"))
{
$id1 = mysqli_num_rows($id);
if ($id1 > 0)
{
echo "<script>alert('Пользователь с таким логином уже зарегистрирован!')</script>";
}
else
{
if ($id = mysqli_query($link, "SELECT `id` FROM `users` WHERE email = '$email'"))
{
$id2 = mysqli_num_rows($id);
if ($id2 > 0)
{
echo "<script>alert('Пользователь с такой почтой уже зарегистрирован!')</script>";
}
else
{
$query2 = mysqli_query($link, "INSERT INTO `users`(`login`, `email`, `pass`) VALUES ('$login','$email','$pass')");
if ($query2)
{
include "mail/mail_reg.php";
$_SESSION['user'] = $login;
echo "<script>location.href = '../'</script>";
}
else
{
echo "<script>alert('Не вносит в базу!')</script>";
}
}
}
}
}
}
else
{
echo "<script>alert('Ничего не введено!')</script>";
}
}
}
mysqli_close($link);
?>
<!DOCTYPE>
<html>
<head>
<link rel="shortcut icon" href="icon.png">
<title>Cash&Мир</title>
<LINK rel="icon" href="https://mospolytech.ru/favicon.ico" type="image/x-icon" />
<LINK rel="shortcut icon" href="https://mospolytech.ru/favicon.ico" type="image/x-icon" />
<script src="https://code.jquery.com/jquery.js"></script>
<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"></script>
<script src=\"https://rawgit.com/RobinHerbots/jquery.inputmask/3.x/dist/jquery.inputmask.bundle.js\"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="css/tabs.css" rel="stylesheet">
<link href="css/gs.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
</head>
<body>
<div class="tabs">
<input id="tab1" type="radio" name="tabs" checked="">
<label for="tab1" title="Вход">Вход</label>
<input id="tab2" type="radio" name="tabs">
<label for="tab2" title="Восстановить пароль">Восстановить пароль</label>
<input id="tab3" type="radio" name="tabs">
<label for="tab3" title="Регистрация">Регистрация</label>
<section id="content-tab1">
<p>
</p><left>
<?
if(isset($_POST['submit']))
{
if($_POST['submit'])
{
if(!$_POST['login'] == "" && !$_POST['pass'] == "")
{
$login = $_POST['login'];
$pass = $_POST['pass'];
if ($result = mysqli_query($link, "SELECT id FROM users WHERE BINARY login='$login' AND BINARY pass='$pass'"))
{
$row_cnt = $result->num_rows;
if($row_cnt > 0)
{
include "mail/mail_auth.php";
$_SESSION['user'] = $login;
echo "<script>location.href = '../'</script>";
}
else
{
echo "<script>alert('Login/Passwor not found')</script>";
}
}
else
{
echo "<script>alert('Хуйня какая-то!')</script>";
}
}
else
{
echo "<script>alert('Login/Password no input')</script>";
}
}
}
?>
<form method="post" action="" style=" margin-left: 30; margin-top: 20px;">
<table cellpadding="5">
<tbody><tr>
<td colspan="2">Вход:</td></tr>
<tr>
<td>Логин:</td>
<td><input type="text" name="login"></td></tr>
<tr>
<td>Пароль:</td>
<td><input type="password" name="pass"></td></tr>
<tr>
<td colspan="2" align="left">
<input type="submit" name="submit" value="Вход"></td></tr>
</tbody></table></form>
</left>
</section>
<section id="content-tab2">
<p>
</p><left> <form method="post" action="" style=" margin-left: 30; margin-top: 20px;">
<table cellpadding="5">
<tbody><tr>
<td colspan="2">Восстановить пароль</td></tr>
<tr>
<td>Email:</td>
<td><input type="email" name="email"></td></tr>
<tr>
<td colspan="2" align="left">
<input type="submit" name="forgot" value="Восстановить"></td></tr>
</tbody></table></form> </left>
</section>
<section id="content-tab3">
<p>
</p><left><form method="post" action="" style=" margin-left: 30; margin-top: 20px;">
<table cellpadding="5">
<tbody><tr><td colspan="2">Регистрация:</td></tr>
<tr><td>Логин:</td>
<td><input type="text" name="login" pattern ="[A-Za-z0-9]{1,}" id="login"></td></tr>
<tr>
<td>Email:</td>
<td><input type="email" name="email" id="email"></td></tr>
<tr>
<tr>
<td>Пароль:</td>
<td><input type="password" name="pass" id="pass"></td></tr>
<tr>
<td colspan="2" align="left">
<input type="submit" name="reg" id="reg" value="Зарегистрироваться"></td></tr>
</tbody></table></form></left>
</section>
</div>
<div id="footer">
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
</body>
</html>