|
1 | | -<?php |
2 | | -session_start(); |
3 | | - |
4 | | -define('NO_AUTH_REQUIRED',true); |
5 | | - |
6 | | -$TAB = 'RESET PASSWORD'; |
7 | | -// |
8 | | -include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); |
9 | | - |
10 | | - |
11 | | -if ((!empty($_POST['user'])) && (empty($_POST['code']))) { |
12 | | - $v_user = escapeshellarg($_POST['user']); |
13 | | - $user = $_POST['user']; |
14 | | - $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-list-user"; |
15 | | - exec ($cmd." ".$v_user." json", $output, $return_var); |
16 | | - if ( $return_var == 0 ) { |
17 | | - $data = json_decode(implode('', $output), true); |
18 | | - $rkey = $data[$user]['RKEY']; |
19 | | - $fname = $data[$user]['FNAME']; |
20 | | - $lname = $data[$user]['LNAME']; |
21 | | - $contact = $data[$user]['CONTACT']; |
22 | | - $to = $data[$user]['CONTACT']; |
23 | | - $subject = _('MAIL_RESET_SUBJECT',date("Y-m-d H:i:s")); |
24 | | - $hostname = exec('hostname'); |
25 | | - $from = _('MAIL_FROM',$hostname); |
26 | | - if (!empty($fname)) { |
27 | | - $mailtext = _('GREETINGS_GORDON_FREEMAN',$fname,$lname); |
28 | | - } else { |
29 | | - $mailtext = _('GREETINGS'); |
30 | | - } |
31 | | - $mailtext .= _('PASSWORD_RESET_REQUEST',$_SERVER['HTTP_HOST'],$user,$rkey,$_SERVER['HTTP_HOST'],$user,$rkey); |
32 | | - if (!empty($rkey)) send_email($to, $subject, $mailtext, $from); |
33 | | - unset($output); |
34 | | - } |
35 | | - |
36 | | - header("Location: /reset/?action=code&user=".$_POST['user']); |
37 | | - exit; |
38 | | -} |
39 | | - |
40 | | -if ((!empty($_POST['user'])) && (!empty($_POST['code'])) && (!empty($_POST['password'])) ) { |
41 | | - if ( $_POST['password'] == $_POST['password_confirm'] ) { |
42 | | - $v_user = escapeshellarg($_POST['user']); |
43 | | - $user = $_POST['user']; |
44 | | - $v_password = escapeshellarg($_POST['password']); |
45 | | - $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-list-user"; |
46 | | - exec ($cmd." ".$v_user." json", $output, $return_var); |
47 | | - if ( $return_var == 0 ) { |
48 | | - $data = json_decode(implode('', $output), true); |
49 | | - $rkey = $data[$user]['RKEY']; |
50 | | - if ($rkey == $_POST['code']) { |
51 | | - $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-change-user-password"; |
52 | | - exec ($cmd." ".$v_user." ".$v_password, $output, $return_var); |
53 | | - if ( $return_var > 0 ) { |
54 | | - $ERROR = "<a class=\"error\">"._('An internal error occurred')."</a>"; |
55 | | - } else { |
56 | | - $_SESSION['user'] = $_POST['user']; |
57 | | - header("Location: /"); |
58 | | - exit; |
59 | | - } |
60 | | - } else { |
61 | | - $ERROR = "<a class=\"error\">"._('ERROR: Invalid username or code')."</a>"; |
62 | | - } |
63 | | - } else { |
64 | | - $ERROR = "<a class=\"error\">"._('ERROR: Invalid username or code')."</a>"; |
65 | | - } |
66 | | - } else { |
67 | | - $ERROR = "<a class=\"error\">"._('ERROR: Passwords not match')."</a>"; |
68 | | - } |
69 | | -} |
70 | | - |
71 | | -require_once '../templates/header.html'; |
72 | | -if (empty($_GET['action'])) { |
73 | | - require_once '../templates/reset_1.html'; |
74 | | -} else { |
75 | | - if ($_GET['action'] == 'code' ) { |
76 | | - require_once '../templates/reset_2.html'; |
77 | | - } |
78 | | - if (($_GET['action'] == 'confirm' ) && (!empty($_GET['code']))) { |
79 | | - require_once '../templates/reset_3.html'; |
80 | | - } |
81 | | -} |
82 | | - |
83 | | -?> |
| 1 | +<?php |
| 2 | +session_start(); |
| 3 | + |
| 4 | +define('NO_AUTH_REQUIRED',true); |
| 5 | + |
| 6 | +$TAB = 'RESET PASSWORD'; |
| 7 | +// |
| 8 | +include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); |
| 9 | + |
| 10 | + |
| 11 | +if ((!empty($_POST['user'])) && (empty($_POST['code']))) { |
| 12 | + $v_user = escapeshellarg($_POST['user']); |
| 13 | + $user = $_POST['user']; |
| 14 | + $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-list-user"; |
| 15 | + exec ($cmd." ".$v_user." json", $output, $return_var); |
| 16 | + if ( $return_var == 0 ) { |
| 17 | + $data = json_decode(implode('', $output), true); |
| 18 | + $rkey = $data[$user]['RKEY']; |
| 19 | + $fname = $data[$user]['FNAME']; |
| 20 | + $lname = $data[$user]['LNAME']; |
| 21 | + $contact = $data[$user]['CONTACT']; |
| 22 | + $to = $data[$user]['CONTACT']; |
| 23 | + $subject = _('MAIL_RESET_SUBJECT',date("Y-m-d H:i:s")); |
| 24 | + $hostname = exec('hostname'); |
| 25 | + $from = _('MAIL_FROM',$hostname); |
| 26 | + if (!empty($fname)) { |
| 27 | + $mailtext = _('GREETINGS_GORDON_FREEMAN',$fname,$lname); |
| 28 | + } else { |
| 29 | + $mailtext = _('GREETINGS'); |
| 30 | + } |
| 31 | + $mailtext .= _('PASSWORD_RESET_REQUEST',$_SERVER['HTTP_HOST'],$user,$rkey,$_SERVER['HTTP_HOST'],$user,$rkey); |
| 32 | + if (!empty($rkey)) send_email($to, $subject, $mailtext, $from); |
| 33 | + unset($output); |
| 34 | + } |
| 35 | + |
| 36 | + header("Location: /reset/?action=code&user=".$_POST['user']); |
| 37 | + exit; |
| 38 | +} |
| 39 | + |
| 40 | +if ((!empty($_POST['user'])) && (!empty($_POST['code'])) && (!empty($_POST['password'])) ) { |
| 41 | + if ( $_POST['password'] == $_POST['password_confirm'] ) { |
| 42 | + $v_user = escapeshellarg($_POST['user']); |
| 43 | + $user = $_POST['user']; |
| 44 | + $v_password = escapeshellarg($_POST['password']); |
| 45 | + $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-list-user"; |
| 46 | + exec ($cmd." ".$v_user." json", $output, $return_var); |
| 47 | + if ( $return_var == 0 ) { |
| 48 | + $data = json_decode(implode('', $output), true); |
| 49 | + $rkey = $data[$user]['RKEY']; |
| 50 | + if ($rkey == $_POST['code']) { |
| 51 | + $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-change-user-password"; |
| 52 | + exec ($cmd." ".$v_user." ".$v_password, $output, $return_var); |
| 53 | + if ( $return_var > 0 ) { |
| 54 | + $ERROR = "<a class=\"error\">"._('An internal error occurred')."</a>"; |
| 55 | + } else { |
| 56 | + $_SESSION['user'] = $_POST['user']; |
| 57 | + header("Location: /"); |
| 58 | + exit; |
| 59 | + } |
| 60 | + } else { |
| 61 | + $ERROR = "<a class=\"error\">"._('ERROR: Invalid username or code')."</a>"; |
| 62 | + } |
| 63 | + } else { |
| 64 | + $ERROR = "<a class=\"error\">"._('ERROR: Invalid username or code')."</a>"; |
| 65 | + } |
| 66 | + } else { |
| 67 | + $ERROR = "<a class=\"error\">"._('ERROR: Passwords not match')."</a>"; |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +require_once '../templates/header.html'; |
| 72 | +if (empty($_GET['action'])) { |
| 73 | + require_once '../templates/reset_1.html'; |
| 74 | +} else { |
| 75 | + if ($_GET['action'] == 'code' ) { |
| 76 | + require_once '../templates/reset_2.html'; |
| 77 | + } |
| 78 | + if (($_GET['action'] == 'confirm' ) && (!empty($_GET['code']))) { |
| 79 | + require_once '../templates/reset_3.html'; |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +?> |
0 commit comments