-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
190 lines (177 loc) · 7.43 KB
/
index.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
<?php
if(isset($_POST['generate'])):
require 'Password.php';
$data = $_POST;
//unset($data['generate']);
$s = $data['s'];
//unset($data['s']);
$s = str_replace( ' ', '', $s );
$special = str_split($s);
//print_r($s);
$pass = new Password( $data, $special );
$pw = $pass->generatePassword();
else:
$pw = '<< select options and submit';
$pass = FALSE;
endif;
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PHP Password Generator with full working example</title>
<meta name="description" content="PHP Password Generator with full working example">
<meta name="keywords" content="PHP,Password Generator,full working example">
<meta name="author" content="Michael M Chiwere">
<link type="text/css" rel="stylesheet" href="bootstrap.min.css">
<style type="text/css">
.form-control{float:left;}
</style>
</head>
<body>
<div class="container">
<div class="page-header" style="margin-top:20px;">
<h1>PHP Password Generator<br><small>with full working example</small></h1>
</div>
<div class="row">
<div class="col-xs-12 col-sm-7 col-md-6 col-lg-6 visible-xs">
<div class="well">
<h4>Your Password</h4>
<div class="row">
<pre class="col-xs-12 col-md-12 col-lg-12"
style="font-size:1.3em;padding:5px;background:#f9f2f4;color:#dc3e4e;"><?php echo $pw;?></pre>
</div>
<h4 class="hidden">Password Hash</h4>
<div class="row hidden">
<pre class="col-xs-12 col-md-12 col-lg-12"
style="font-size:1.3em;padding:5px;background:#f9f2f4;color:#dc3e4e;"><?php //echo md5($pw)?></pre>
</div>
<?php if($pass):
if($pass->get_error()):?>
<div class="alert alert-warning"><h4>Warning!</h4><?php echo $pass->get_error();?></div>
<?php endif;endif;?>
</div>
</div>
<div class="col-xs-12 col-sm-5 col-md-6 col-lg-6">
<div class="well">
<form method="POST" action="" class="form-horizontal">
<div class="form-group">
<label class="col-lg-4 control-label">Password Length</label>
<div class="col-lg-8">
<input class="form-control input-sm" type="text" name="length"
value="<?php if(isset($_POST['length'])) echo $_POST['length']; else echo 10;?>">
</div>
</div>
<div class="form-group">
<label class="col-lg-4 control-label">Allowed Characters <small color="green"></small></label>
<div class="col-lg-8">
<input class="form-control input-sm" type="text" name="s" class=""
value="<?php if(isset($_POST['s'])) echo $_POST['s'];
else echo '~ ! @ # $ % ^ & * ( ) - _ + = { } [ ] ; : ?';?>">
</div>
</div>
<div class="col-md-4 col-lg-3 col-lg-offset-3">
<div class="form-group">
<?php
if(isset($_POST['lower_case']))
$lc = $_POST['lower_case'];
else $lc = 1;
?>
<label class="control-label col-sm-12" style="text-align:center;">Lower Case</label><br>
<div class="col-sm-12">
<input type="range" name="lower_case" class="form-control input-sm" min="0" max="1" step="1"
placeholder="ON OFF" value="<?php echo $lc;?>">
<span class="pull-left">OFF</span> <span class="pull-right">ON</span>
</div>
</div>
</div>
<div class="col-md-4 col-lg-3">
<div class="form-group">
<?php if(isset($_POST['upper_case'])) $uc = $_POST['upper_case']; else $uc = 1;?>
<label class="control-label col-sm-12" style="text-align:center;">Upper Case</label><br>
<div class="col-sm-12">
<input type="range" name="upper_case" class="form-control input-sm" min="0" max="1" step="1"
placeholder="ON OFF" value="<?php echo $uc;?>">
<span class="pull-left">OFF</span> <span class="pull-right">ON</span>
</div>
</div>
</div>
<div class="col-md-4 col-lg-3">
<div class="form-group">
<?php if(isset($_POST['digits'])) $dg = $_POST['digits']; else $dg = 1;?>
<label class="control-label col-sm-12" style="text-align:center;">Digits</label>
<div class="col-sm-12">
<input type="range" name="digits" class="form-control input-sm" min="0" max="2" step="1"
placeholder="ON OFF" value="<?php echo $dg;?>">
<span class="col-xs-4 col-sm-4" style="padding:0;">OFF</span>
<span class="col-xs-4 col-sm-4" style="padding:0; text-align:center;">ON</span>
<span class="col-xs-4 col-sm-4" style="padding:0;text-align:right;">HEX</span>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4 col-lg-offset-3">
<div class="form-group">
<?php if(isset($_POST['special'])) $sc = $_POST['special']; else $sc = 0;?>
<label class="control-label col-sm-12" style="text-align:left;">Special Characters</label>
<div class="col-md-10 col-lg-9">
<input type="range" name="special" class="form-control input-sm" min="0" max="1" step="1"
placeholder="ON OFF" value="<?php echo $sc;?>">
<span class="pull-left">OFF</span> <span class="pull-right">ON</span>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="form-group">
<?php if(isset($_POST['unique'])) $uq = $_POST['unique']; else $uq = 0;?>
<label class="control-label col-sm-12" style="text-align:left;">Unique Characters</label>
<div class="col-md-10 col-lg-9">
<input type="range" name="unique" class="form-control input-sm" min="0" max="1" step="1"
placeholder="ON OFF" value="<?php echo $uq;?>">
<span class="pull-left">OFF</span> <span class="pull-right">ON</span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-4 col-lg-8">
<button type="submit" name="generate" value="1" class="btn btn-primary pull-right"
style="margin-right:10px;">Submit</button>
<a href="" class="btn btn-default pull-right" style="margin-right:10px;">Reset</a>
</div>
</div>
</form>
</div><!-- end of well -->
</div><!-- end of col-xs-12 col-md-6 col-lg-6 -->
<div class="col-xs-12 col-sm-7 col-md-6 col-lg-6 hidden-xs">
<div class="well">
<h4>Your Password</h4>
<div class="row">
<pre class="col-xs-12 col-md-12 col-lg-12"
style="font-size:1.3em;padding:5px;background:#f9f2f4;color:#dc3e4e;"><?php echo $pw;?></pre>
</div>
<h4 class="hidden">Password Hash</h4>
<div class="row hidden">
<pre class="col-xs-12 col-md-12 col-lg-12"
style="font-size:1.3em;padding:5px;background:#f9f2f4;color:#dc3e4e;"><?php //echo md5($pw)?></pre>
</div>
<?php if($pass):
if($pass->get_error()):?>
<div class="alert alert-warning"><h4>Warning!</h4><?php echo $pass->get_error();?></div>
<?php endif;endif;?>
</div>
<div class="well">
Thank you for using the PHP Password Generator. Please support one of our projects, zimall.co.zw<br><br>
<a class="btn btn-success btn-lg" href="https://www.zimall.co.zw" target="_blank">Visit Project</a><br><br>
<small>
© 2007-2009, Daniel Tlach,
Updated by Michael M Chiwere Feb 2014
</small><br>
<small>Version 1.1</small>
</div>
</div><!-- end of col-xs-12 col-md-6 col-lg-6 -->
</div><!-- end of row -->
<div class="well">
<div style="margin:0 auto; max-width:400px;">
<a href="php-password-generator.zip" class="btn btn-primary btn-block btn-lg">Download Script</a>
</div>
</div>
</div><!-- end of container -->
</body></html>