1 | <?php␊ |
2 | /*␊ |
3 | Copyright (C) 2013-2014 Grégory Soutadé␊ |
4 | ␊ |
5 | This file is part of gPass.␊ |
6 | ␊ |
7 | gPass is free software: you can redistribute it and/or modify␊ |
8 | it under the terms of the GNU General Public License as published by␊ |
9 | the Free Software Foundation, either version 3 of the License, or␊ |
10 | (at your option) any later version.␊ |
11 | ␊ |
12 | gPass is distributed in the hope that it will be useful,␊ |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of␊ |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the␊ |
15 | GNU General Public License for more details.␊ |
16 | ␊ |
17 | You should have received a copy of the GNU General Public License␊ |
18 | along with gPass. If not, see <http://www.gnu.org/licenses/>.␊ |
19 | */␊ |
20 | ␊ |
21 | include('functions.php');␊ |
22 | ␊ |
23 | include('conf.php');␊ |
24 | ␊ |
25 | session_start();␊ |
26 | ␊ |
27 | $user = "";␊ |
28 | ␊ |
29 | if ($ADMIN_MODE && isset($_POST['create_user']))␊ |
30 | {␊ |
31 | if (create_user($_POST['user']))␊ |
32 | $user = $_POST['user'];␊ |
33 | }␊ |
34 | else␊ |
35 | {␊ |
36 | if (isset($_POST['get_passwords']) && isset($_POST['user']))␊ |
37 | return list_entries($_POST['user']);␊ |
38 | ␊ |
39 | if (isset($_POST['add_entry']) && isset($_POST['user']) && ␊ |
40 | isset($_POST['login']) && isset($_POST['password']))␊ |
41 | return add_entry($_POST['user'], $_POST['login'], $_POST['password']);␊ |
42 | ␊ |
43 | if (isset($_POST['delete_entry']) && isset($_POST['user']) && ␊ |
44 | isset($_POST['login']))␊ |
45 | return delete_entry($_POST['user'], $_POST['login']);␊ |
46 | }␊ |
47 | ␊ |
48 | ?>␊ |
49 | <!DOCTYPE html> ␊ |
50 | <html>␊ |
51 | <head>␊ |
52 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >␊ |
53 | <link rel="icon" type="image/png" href="ressources/favicon.png" />␊ |
54 | <link rel="stylesheet" type="text/css" href="ressources/gpass.css" />␊ |
55 | <script language="javascript">␊ |
56 | <?php␊ |
57 | echo "pkdbf2_level=$PKDBF2_LEVEL;\n";␊ |
58 | ?>␊ |
59 | </script>␊ |
60 | <script src="ressources/jsaes.js"></script>␊ |
61 | <script src="ressources/jssha256.js"></script>␊ |
62 | <script src="ressources/hmac.js"></script>␊ |
63 | <script src="ressources/pkdbf2.js"></script>␊ |
64 | <script src="ressources/gpass.js"></script>␊ |
65 | <script src="ressources/pwdmeter.js"></script>␊ |
66 | <title>gPass : global Password</title>␊ |
67 | </head>␊ |
68 | <body onload="start();">␊ |
69 | <div id="logo">␊ |
70 | <a href="http://indefero.soutade.fr/p/gpass"><img src="ressources/gpass.png" alt="logo"/></a>␊ |
71 | </div>␊ |
72 | ␊ |
73 | <div id="admin" <?php if (!$ADMIN_MODE) echo "style=\"display:none\"";?> >␊ |
74 | <form method="post">␊ |
75 | ␉<input type="text" name="user"/> <input type="submit" name="create_user" value="Create user" onclick="return confirm('Are you sure want to create this user ?');"/>␊ |
76 | </form>␊ |
77 | </div>␊ |
78 | <div id="user">␊ |
79 | <?php␊ |
80 | global $user;␊ |
81 | $users = scandir("./users/");␊ |
82 | $count = 0;␊ |
83 | foreach($users as $u)␊ |
84 | {␊ |
85 | if (is_dir("./users/" . $u) && $u[0] != '_' && $u[0] != '.')␊ |
86 | $count++;␊ |
87 | }␊ |
88 | ␊ |
89 | if ($count == 0)␊ |
90 | echo "<b>No user found</b><br/>\n";␊ |
91 | else␊ |
92 | {␊ |
93 | echo "<b>User</b> <select id=\"selected_user\" name=\"user\" onchange=\"document.getElementById('master_key').value = '';update_master_key(false);\">" . "\n";␊ |
94 | foreach($users as $u)␊ |
95 | {␊ |
96 | if (is_dir("./users/" . $u) && $u[0] != '_' && $u[0] != '.')␊ |
97 | {␊ |
98 | if ($user == "") $user = $u;␊ |
99 | if ($user == $u)␊ |
100 | echo "<option value=\"$u\" selected=\"1\"/>$u</option>";␊ |
101 | else␊ |
102 | echo "<option value=\"$u\"/>$u</option>";␊ |
103 | }␊ |
104 | }␊ |
105 | echo "</select>\n";␊ |
106 | echo ' <b>Master key </b> <input id="master_key" type="password" onkeypress="if (event.keyCode == 13) update_master_key(true);"/>';␊ |
107 | echo "<input type=\"button\" value=\"See\" onclick=\"update_master_key(true);\" />" . "\n";␊ |
108 | ␊ |
109 | if (!isset($_SERVER['HTTPS']))␊ |
110 | echo "<div id=\"addon_address\">Current addon address is : http://" . $_SERVER['SERVER_NAME'] . "/" . $user . "</div>\n";␊ |
111 | else␊ |
112 | echo "<div id=\"addon_address\">Current addon address is : https://" . $_SERVER['SERVER_NAME'] . "/" . $user . "</div>\n";␊ |
113 | }␊ |
114 | ?>␊ |
115 | <div id="passwords">␊ |
116 | </div>␊ |
117 | <div id="add_new_password">␊ |
118 | <?php␊ |
119 | global $user;␊ |
120 | ␊ |
121 | if ($user != "")␊ |
122 | {␊ |
123 | echo "<b>Add a new password</b><br/>\n";␊ |
124 | ␊ |
125 | echo 'URL <input type="text" name="url"/>';␊ |
126 | echo 'login <input type="text" name="login" />';␊ |
127 | echo 'password <input id="new_password" type="text" name="password"/>';␊ |
128 | echo 'master key <input type="text" name="mkey" onkeypress="if (event.keyCode == 13) add_password();" onkeyup="chkPass(this.value);"/>';␊ |
129 | echo '<input type="button" value="Generate password" onClick="generate_password();"/>';␊ |
130 | echo "<input type=\"button\" name=\"add\" value=\"Add\" onclick=\"add_password();\"/>";␊ |
131 | echo "<br />";␊ |
132 | echo '<div><a href="http://en.wikipedia.org/wiki/Password_strength">Master key strength</a><div id="scorebarBorder"><div id="score">0%</div><div id="scorebar"> </div></div></div>';␊ |
133 | }␊ |
134 | ?>␊ |
135 | </div>␊ |
136 | </div>␊ |
137 | </body>␊ |
138 | </html>␊ |