|
20 | 20 | $data = json_decode(implode('', $output), true); |
21 | 21 | if($email == $data[$user]['CONTACT']){ |
22 | 22 | //genrate new rkey |
23 | | - exec ("/usr/bin/sudo /usr/local/hestia/bin/v-change-user-rkey ".$v_user."", $output, $return_var); |
| 23 | + $rkey = substr( password_hash( 'hestiacp', PASSWORD_DEFAULT ), 5, 12 ); |
| 24 | + $hash = password_hash($rkey, PASSWORD_DEFAULT); |
| 25 | + $v_rkey = tempnam("/tmp","vst"); |
| 26 | + $fp = fopen($v_rkey, "w"); |
| 27 | + fwrite($fp, $hash."\n"); |
| 28 | + fclose($fp); |
| 29 | + exec ("/usr/bin/sudo /usr/local/hestia/bin/v-change-user-rkey ".$v_user." ".$v_rkey."", $output, $return_var); |
24 | 30 | unset($output); |
25 | 31 | exec ($cmd." ".$v_user." json", $output, $return_var); |
26 | 32 | $data = json_decode(implode('', $output), true); |
27 | | - $rkey = $data[$user]['RKEY']; |
28 | 33 | $name = $data[$user]['NAME']; |
29 | 34 | $contact = $data[$user]['CONTACT']; |
30 | 35 | $to = $data[$user]['CONTACT']; |
|
58 | 63 | if ( $return_var == 0 ) { |
59 | 64 | $data = json_decode(implode('', $output), true); |
60 | 65 | $rkey = $data[$user]['RKEY']; |
61 | | - if (hash_equals($rkey, $_POST['code'])) { |
| 66 | + if (password_verify($_POST['code'], $rkey)) { |
62 | 67 | unset($output); |
63 | 68 | exec("/usr/bin/sudo /usr/local/hestia/bin/v-get-user-value ".$v_user." RKEYEXP", $output,$return_var); |
64 | 69 | if($output[0] > time() - 900){ |
|
0 commit comments