-
Notifications
You must be signed in to change notification settings - Fork 8
/
check.php
215 lines (209 loc) · 6.42 KB
/
check.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
<?php
declare(strict_types=1);
/**
* MCCodes v2 by Dabomstew & ColdBlooded
*
* Repository: https://github.com/davemacaulay/mccodesv2
* License: MIT License
*/
if (isset($_SERVER['REQUEST_METHOD']) && is_string($_SERVER['REQUEST_METHOD']))
{
if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST')
{
// Ignore a GET request
header('HTTP/1.1 400 Bad Request');
exit;
}
}
require_once('global_func.php');
if (!is_ajax())
{
header('HTTP/1.1 400 Bad Request');
exit;
}
if (!isset($_POST['password']))
{ // If they are trying to view this without ?password=password.
die('Whats this document for?'); // Lawl what is this document for anyway?
}
else
{ // ElseIf we cant to check the password's strength.
$PASS =
stripslashes(
strip_tags(
htmlentities($_POST['password'], ENT_QUOTES,
'ISO-8859-1'))); // Cleans all nasty input from the password.
$strength = 1; // Sets their default amount of points to 1.
if ($PASS != NULL)
{ // If the current password is not NULL (empty).
$numbers =
[ // Creates our array to store 1 - 9 in.
1 => '1', // 1.
2 => '2', // 2.
3 => '3', // 3.
4 => '4', // 4.
5 => '5', // 5.
6 => '6', // 6.
7 => '7', // 7.
8 => '8', // 8.
9 => '9', // 9.
0 => '0' // 0.
]; // Closes the Array.
$lowercase =
[ // Creates our array to store a - z in.
1 => 'a', // a.
2 => 'b', // b.
3 => 'c', // c.
4 => 'd', // d.
5 => 'e', // e.
6 => 'f', // f.
7 => 'g', // g.
8 => 'h', // h.
9 => 'i', // i.
10 => 'j', // j.
11 => 'k', // k.
12 => 'l', // l.
13 => 'm', // m.
14 => 'n', // n.
15 => 'o', // o.
16 => 'p', // p.
17 => 'q', // q.
18 => 'r', // r.
19 => 's', // s.
20 => 't', // t.
21 => 'u', // u.
22 => 'v', // v.
23 => 'w', // w.
24 => 'x', // x.
25 => 'y', // y.
26 => 'z' // z.
]; // Closes the Array.
$uppercase =
[ // Creates our array to store A - Z in.
1 => 'A', // A.
2 => 'B', // B.
3 => 'C', // C.
4 => 'D', // D.
5 => 'E', // E.
6 => 'F', // F.
7 => 'G', // G.
8 => 'H', // H.
9 => 'I', // I.
10 => 'J', // J.
11 => 'K', // K.
12 => 'L', // L.
13 => 'M', // M.
14 => 'N', // N.
15 => 'O', // O.
16 => 'P', // P.
17 => 'Q', // Q.
18 => 'R', // R.
19 => 'S', // S.
20 => 'T', // T.
21 => 'U', // U.
22 => 'V', // V.
23 => 'W', // W.
24 => 'X', // X.
25 => 'Y', // Y.
26 => 'Z' // Z.
]; // Closes the Array.
$symbs =
['\\', '/', '"', "'", '{', '}', ')', '(', '|', '?', '.',
',', '<', '>', '_', '-', '!', '#', "\$", '%', '^',
'&', '*'];
$strength = 0;
if (strlen($PASS) >= 7)
{
$strength += 3;
}
$nc = 0;
foreach ($numbers as $v)
{
if (strstr($PASS, $v))
{
$nc++;
}
}
if ($nc >= 2)
{
$strength += 1;
}
if ($nc >= 5)
{
$strength += 1;
}
$nc = 0;
foreach ($lowercase as $v)
{
if (strstr($PASS, $v))
{
$nc++;
}
}
if ($nc >= 2)
{
$strength += 1;
}
if ($nc >= 5)
{
$strength += 1;
}
$nc = 0;
foreach ($uppercase as $v)
{
if (strstr($PASS, $v))
{
$nc++;
}
}
if ($nc >= 2)
{
$strength += 1;
}
if ($nc >= 5)
{
$strength += 1;
}
$nc = 0;
foreach ($symbs as $v)
{
if (strstr($PASS, $v))
{
$nc++;
}
}
if ($nc >= 1)
{
$strength += 1;
}
if ($nc >= 2)
{
$strength += 1;
}
if ($nc >= 5)
{
$strength += 1;
}
$overall = '';
if ($strength <= 2)
{ // If there total points are equal or less than 5.
$overall = '<span style="color:#FF0000">Weak</span>'; // Eeek very week!
}
elseif ($strength <= 5)
{ // If there total points are equal or less than 8.
$overall = '<span style="color:#999900">Moderate</span>'; // Omg week.
}
elseif ($strength <= 10)
{ // If there total points are equal or less than 12.
$overall = '<span style="color:#008800">Good</span>'; // Meh Moderate.
}
elseif ($strength >= 12)
{ // If there total points are greater than 12.
$overall = '<span style="color:#0000ff">Excellent</span>'; // That's the way Superman.
} // End If.
echo 'Password strength: ' . $overall; // Tells them their passwords strength.
}
else
{ // ElseIf their password is NULL (empty).
echo ''; // Dont display anything.
} // End ElseIf.
} // End ElseIF.