Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
98 lines (96 loc) · 2.81 KB
/
Copy pathindex.php
File metadata and controls
98 lines (96 loc) · 2.81 KB
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
<?php
require_once 'include/goPwd.php';
?>
<!DOCTYPE html>
<!-- Warning: this file is not properly written as it contains several security vulnerabilities. DO NOT USE in real practice. -->
<html>
<head>
<title>A simple password manager</title>
</head>
<body>
<?php
$email = get_email();
if ($email === '') {
//not logged in
?>
<a href="<?php echo get_auth_url();?>"> login </a>
<?php
} else {
init_generators();
//logged in, check available filters
echo "<p>Logged in as $email</p>\n";
if (isset($_GET['name']) && isset($_GET['generator'])) {
//process the query
switch($_GET['generator']){
case 'Saved':
if ($pwd = get_pwd($_GET['name'])){
echo "<p>Password for ".$_GET['name'].": $pwd</p>";
} else {
echo "<p>Error: No existing configs found.</p>";
}
break;
default:
$argv = array('generator' => $_GET['generator']);
foreach ($_GET as $rkey => $value) {
if (strncmp($rkey, 'conf_', 5) === 0) {
$key = substr($rkey, 5);
$argv[$key] = $value;
}
}
if ($pwd = get_pwd($_GET['name'], $argv)){
echo "<p>Password for ".$_GET['name'].": $pwd</p>";
} else {
echo "<p>Error.</p>";
}
break;
}
}
?>
<hr>
<form action="." method="get">
<p>
<input type="text" name="name" value="<?php if(isset($_GET['name'])) echo $_GET['name']; ?>">
<select id="gen-selector" name="generator">
<option selected>Saved</option>
</select>
</p>
<div id="user-argv">
</div>
<p><input type="submit" value="submit"></p>
</form>
<script type="text/javascript">
(function(){
var gendata = {<?php
foreach ($generators as $name => $value) {
echo "'$name' : {";
foreach ($generators[$name]['require'] as $key => $value) {
echo "'$key' : '$value',";
}
echo "},";
}
?>};
var sel = document.getElementById('gen-selector');
for (var key in gendata) {
var option = document.createElement('option');
option.innerHTML = key;
sel.appendChild(option);
}
sel.addEventListener('change', function() {
var container = document.getElementById('user-argv');
while (container.firstChild) {
container.removeChild(container.firstChild);
}
if (sel.value === 'Saved') return;
for (var key in gendata[sel.value]) {
var newfield = document.createElement("p");
container.appendChild(newfield);
newfield.innerHTML = key +
': <input type="text" name="conf_' + key + '" value="' +
gendata[sel.value][key] + '">';
}
});
})();
</script>
<?php } ?>
</body>
</html>