@@ 810-865 (lines=56) @@ | ||
807 | /** |
|
808 | * Show confirmation of change password and actually change password |
|
809 | */ |
|
810 | public function doChangePassword($confirm, $msg = '') |
|
811 | { |
|
812 | $conf = $this->conf; |
|
813 | $misc = $this->misc; |
|
814 | $lang = $this->lang; |
|
815 | $data = $misc->getDatabaseAccessor(); |
|
816 | ||
817 | $server_info = $misc->getServerInfo(); |
|
818 | ||
819 | if ($confirm) { |
|
820 | $_REQUEST['rolename'] = $server_info['username']; |
|
821 | $this->printTrail('role'); |
|
822 | $this->printTitle($lang['strchangepassword'], 'pg.role.alter'); |
|
823 | $this->printMsg($msg); |
|
824 | ||
825 | if (!isset($_POST['password'])) { |
|
826 | $_POST['password'] = ''; |
|
827 | } |
|
828 | ||
829 | if (!isset($_POST['confirm'])) { |
|
830 | $_POST['confirm'] = ''; |
|
831 | } |
|
832 | ||
833 | echo '<form action="' . SUBFOLDER . "/src/views/roles.php\" method=\"post\">\n"; |
|
834 | echo "<table>\n"; |
|
835 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strpassword']}</th>\n"; |
|
836 | echo "\t\t<td><input type=\"password\" name=\"password\" size=\"32\" value=\"", |
|
837 | htmlspecialchars($_POST['password']), "\" /></td>\n\t</tr>\n"; |
|
838 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strconfirm']}</th>\n"; |
|
839 | echo "\t\t<td><input type=\"password\" name=\"confirm\" size=\"32\" value=\"\" /></td>\n\t</tr>\n"; |
|
840 | echo "</table>\n"; |
|
841 | echo "<p><input type=\"hidden\" name=\"action\" value=\"changepassword\" />\n"; |
|
842 | echo $misc->form; |
|
843 | echo "<input type=\"submit\" name=\"ok\" value=\"{$lang['strok']}\" />\n"; |
|
844 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; |
|
845 | echo "</p></form>\n"; |
|
846 | } else { |
|
847 | // Check that password is minimum length |
|
848 | if (strlen($_POST['password']) < $conf['min_password_length']) { |
|
849 | $this->doChangePassword(true, $lang['strpasswordshort']); |
|
850 | } |
|
851 | ||
852 | // Check that password matches confirmation password |
|
853 | elseif ($_POST['password'] != $_POST['confirm']) { |
|
854 | $this->doChangePassword(true, $lang['strpasswordconfirm']); |
|
855 | } else { |
|
856 | $status = $data->changePassword($server_info['username'], $_POST['password']); |
|
857 | if ($status == 0) { |
|
858 | $this->doAccount($lang['strpasswordchanged']); |
|
859 | } else { |
|
860 | $this->doAccount($lang['strpasswordchangedbad']); |
|
861 | } |
|
862 | } |
|
863 | } |
|
864 | } |
|
865 | } |
|
866 |
@@ 224-280 (lines=57) @@ | ||
221 | /** |
|
222 | * Show confirmation of change password and actually change password |
|
223 | */ |
|
224 | public function doChangePassword($confirm, $msg = '') |
|
225 | { |
|
226 | $conf = $this->conf; |
|
227 | $misc = $this->misc; |
|
228 | $lang = $this->lang; |
|
229 | $data = $misc->getDatabaseAccessor(); |
|
230 | ||
231 | $server_info = $misc->getServerInfo(); |
|
232 | ||
233 | if ($confirm) { |
|
234 | $_REQUEST['user'] = $server_info['username']; |
|
235 | $this->printTrail('user'); |
|
236 | $this->printTitle($lang['strchangepassword'], 'pg.user.alter'); |
|
237 | $this->printMsg($msg); |
|
238 | ||
239 | if (!isset($_POST['password'])) { |
|
240 | $_POST['password'] = ''; |
|
241 | } |
|
242 | ||
243 | if (!isset($_POST['confirm'])) { |
|
244 | $_POST['confirm'] = ''; |
|
245 | } |
|
246 | ||
247 | echo '<form action="' . SUBFOLDER . "/src/views/users.php\" method=\"post\">\n"; |
|
248 | echo "<table>\n"; |
|
249 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strpassword']}</th>\n"; |
|
250 | echo "\t\t<td><input type=\"password\" name=\"password\" size=\"32\" value=\"", |
|
251 | htmlspecialchars($_POST['password']), "\" /></td>\n\t</tr>\n"; |
|
252 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strconfirm']}</th>\n"; |
|
253 | echo "\t\t<td><input type=\"password\" name=\"confirm\" size=\"32\" value=\"\" /></td>\n\t</tr>\n"; |
|
254 | echo "</table>\n"; |
|
255 | echo "<p><input type=\"hidden\" name=\"action\" value=\"changepassword\" />\n"; |
|
256 | echo $misc->form; |
|
257 | echo "<input type=\"submit\" name=\"ok\" value=\"{$lang['strok']}\" />\n"; |
|
258 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; |
|
259 | echo "</p></form>\n"; |
|
260 | } else { |
|
261 | // Check that password is minimum length |
|
262 | if (strlen($_POST['password']) < $conf['min_password_length']) { |
|
263 | $this->doChangePassword(true, $lang['strpasswordshort']); |
|
264 | } |
|
265 | ||
266 | // Check that password matches confirmation password |
|
267 | elseif ($_POST['password'] != $_POST['confirm']) { |
|
268 | $this->doChangePassword(true, $lang['strpasswordconfirm']); |
|
269 | } else { |
|
270 | $status = $data->changePassword($server_info['username'], |
|
271 | $_POST['password']); |
|
272 | if ($status == 0) { |
|
273 | $this->doAccount($lang['strpasswordchanged']); |
|
274 | } else { |
|
275 | $this->doAccount($lang['strpasswordchangedbad']); |
|
276 | } |
|
277 | } |
|
278 | } |
|
279 | } |
|
280 | ||
281 | /** |
|
282 | * Function to allow editing of a user |
|
283 | */ |