/[LeafOK_CVS]/fenglin/lib/passwd.inc.php
ViewVC logotype

Contents of /fenglin/lib/passwd.inc.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations)
Thu Oct 30 11:19:14 2025 UTC (4 months, 2 weeks ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +1 -1 lines
Refine

1 <?php
2 function verify_pass_complexity($password, $username, $min_len)
3 {
4 $num_count = 0;
5 $upper_case = 0;
6 $lower_case = 0;
7 $len = strlen($password);
8
9 if ($len < $min_len)
10 {
11 return false;
12 }
13
14 if (stristr($password, $username) !== false)
15 {
16 return false;
17 }
18
19 for ($i = 0; $i < $len; $i++)
20 {
21 $c = $password[$i];
22
23 if (ctype_digit($c))
24 {
25 $num_count++;
26 }
27
28 if (ctype_upper($c))
29 {
30 $upper_case++;
31 }
32
33 if (ctype_lower($c))
34 {
35 $lower_case++;
36 }
37 }
38
39 if ($upper_case == 0 || $lower_case == 0 || $num_count == 0)
40 {
41 return false;
42 }
43
44 return true;
45 }
46
47 function gen_passwd($len)
48 {
49 $str = "";
50
51 for ($i = 0; $i < $len; $i++)
52 {
53 mt_srand(intval(microtime(true) * 1000000));
54 $num = mt_rand(0, 61);
55 $str .= chr($num < 10 ? (ord("0") + $num) : ($num < 36 ? (ord("A") + $num - 10) : (ord("a") + $num - 36)));
56 }
57
58 return $str;
59 }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1