wachtwoord-generator
Code (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
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
<?php
$version = "20041107-a";
if (!isset($wwlen)) {
// first-time through
$wwlen = 8;
$checked1 = "checked";
$checked2 = "";
$checked3 = "";
$melding = "";
} else {
$checked1 = "";
$checked2 = "";
$checked3 = "";
if ($sterkte == "s1") {
$pattern = "[a-zA-Z0-9]";
$checked1 = "checked";
} elseif($sterkte == "s2") {
$pattern = "[a-zA-Z]";
$checked2 = "checked";
} else {
$pattern = "[abcdefghijklmnopqrstuvwxyz]";
$checked3 = "checked";
}
// validate
if ($wwlen < 1 or $wwlen > 16) {
$melding = "Wachtwoordlengte ligt buiten de toegestane waarde (1-16)";
} else {
// generate
$genpass = NULL;
for ($i=0; $i<$wwlen; $i++) {
$char = chr(rand(48,122));
while (!ereg($pattern, $char)) {
$char = chr(rand(48,122));
}
$genpass .= $char;
}
$melding = "WachtWoord: <input type='text' size='25' value='$genpass'>";
}
}
// # debug
// echo "<br>wwlen : $wwlen<br>
// sterkte: $sterkte<br>
// pattern: $pattern<br>
// checked1 $checked1<br>
// checked2 $checked2<br>
// checked3 $checked3<br>";
?>
<html>
<head>
<?php echo "<!versie=$version>" ?>
<script language=JavaScript>
<!--
function initialFocus(){document.myForm.wwlen.focus();}
// -->
</script>
<link rel='stylesheet' type='text/css' href='jtzondag.css'>
</head>
<body bgcolor='#000000' text='ffffff' onload='initialFocus()'>
<div align='center'>
<table border='0' width='760' cellspacing='0' cellpadding='0'><tr><td>
<h1>WachtWoord Generator</h1>
<p>Vul de gewenste lengte in, kies een sterkte en klik op Genereer.</p>
<?php
echo "<form name='myForm' method='POST' action='$PHP_SELF'>
<table border='0'>
<tr>
<td >WachtWoord lengte</td>
<td ><input type='text' name='wwlen' size='2' value='$wwlen' maxlength='2'></td>
</tr>
<tr>
<td ></td>
<td ></td>
</tr>
<tr>
<td >Sterk (a - z, A - Z en 0 - 9)</td>
<td ><input type='radio' name='sterkte' value='s1' $checked1></td>
</tr>
<tr>
<td >Middel (a - z en A - Z)</td>
<td ><input type='radio' name='sterkte' value='s2' $checked2></td>
</tr>
<tr>
<td >Zwak (a - z)</td>
<td ><input type='radio' name='sterkte' value='s3' $checked3></td>
</tr>
<tr>
<td ></td>
<td ></td>
</tr>
<tr>
<td ><input type='submit' value='Genereer' name='Button1'></td>
</tr>
</table>
</form>\n\n\n";
echo $melding;
echo "<br><br><br><font size=-3>Versie $version</font>";
echo "<p align='center' class='Footer'><u>(c) 2002-2004 John Zondag. Laatst gewijzigd:".date("d M Y", filemtime("wwgen.php"))."</u></p>";
?>
</td></tr></table></div>
</body>
</html>
$version = "20041107-a";
if (!isset($wwlen)) {
// first-time through
$wwlen = 8;
$checked1 = "checked";
$checked2 = "";
$checked3 = "";
$melding = "";
} else {
$checked1 = "";
$checked2 = "";
$checked3 = "";
if ($sterkte == "s1") {
$pattern = "[a-zA-Z0-9]";
$checked1 = "checked";
} elseif($sterkte == "s2") {
$pattern = "[a-zA-Z]";
$checked2 = "checked";
} else {
$pattern = "[abcdefghijklmnopqrstuvwxyz]";
$checked3 = "checked";
}
// validate
if ($wwlen < 1 or $wwlen > 16) {
$melding = "Wachtwoordlengte ligt buiten de toegestane waarde (1-16)";
} else {
// generate
$genpass = NULL;
for ($i=0; $i<$wwlen; $i++) {
$char = chr(rand(48,122));
while (!ereg($pattern, $char)) {
$char = chr(rand(48,122));
}
$genpass .= $char;
}
$melding = "WachtWoord: <input type='text' size='25' value='$genpass'>";
}
}
// # debug
// echo "<br>wwlen : $wwlen<br>
// sterkte: $sterkte<br>
// pattern: $pattern<br>
// checked1 $checked1<br>
// checked2 $checked2<br>
// checked3 $checked3<br>";
?>
<html>
<head>
<?php echo "<!versie=$version>" ?>
<script language=JavaScript>
<!--
function initialFocus(){document.myForm.wwlen.focus();}
// -->
</script>
<link rel='stylesheet' type='text/css' href='jtzondag.css'>
</head>
<body bgcolor='#000000' text='ffffff' onload='initialFocus()'>
<div align='center'>
<table border='0' width='760' cellspacing='0' cellpadding='0'><tr><td>
<h1>WachtWoord Generator</h1>
<p>Vul de gewenste lengte in, kies een sterkte en klik op Genereer.</p>
<?php
echo "<form name='myForm' method='POST' action='$PHP_SELF'>
<table border='0'>
<tr>
<td >WachtWoord lengte</td>
<td ><input type='text' name='wwlen' size='2' value='$wwlen' maxlength='2'></td>
</tr>
<tr>
<td ></td>
<td ></td>
</tr>
<tr>
<td >Sterk (a - z, A - Z en 0 - 9)</td>
<td ><input type='radio' name='sterkte' value='s1' $checked1></td>
</tr>
<tr>
<td >Middel (a - z en A - Z)</td>
<td ><input type='radio' name='sterkte' value='s2' $checked2></td>
</tr>
<tr>
<td >Zwak (a - z)</td>
<td ><input type='radio' name='sterkte' value='s3' $checked3></td>
</tr>
<tr>
<td ></td>
<td ></td>
</tr>
<tr>
<td ><input type='submit' value='Genereer' name='Button1'></td>
</tr>
</table>
</form>\n\n\n";
echo $melding;
echo "<br><br><br><font size=-3>Versie $version</font>";
echo "<p align='center' class='Footer'><u>(c) 2002-2004 John Zondag. Laatst gewijzigd:".date("d M Y", filemtime("wwgen.php"))."</u></p>";
?>
</td></tr></table></div>
</body>
</html>