forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange_password.php
More file actions
58 lines (45 loc) · 1.44 KB
/
change_password.php
File metadata and controls
58 lines (45 loc) · 1.44 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
<?php
class ChangePassword
{
public function dispatch()
{
//print_r($_SERVER);
if (empty($_GET['v'])) {
return $this->renderError('General error');
}
$key = $_GET['v'];
$real_key = sha1($_SERVER['HTTP_USER_AGENT'].$_SERVER['REMOTE_ADDR']);
$key_sha1 = substr($key, 0, 10) . substr($key, 20, strlen($key));
$stamp = substr($key, 10, 10);
$allowed = time() - 60 * 5; // - 5 mins
if (strcmp($real_key, $key_sha1) != 0) {
return $this->renderError('Invalid keys');
}
/*if ($stamp < $allowed) {
return $this->renderError('Key is expired');
}*/
$this->showResetForm();
print $key_sha1 . "<br />" . $real_key;
}
public function showResetForm()
{
print <<<HTML
<form action="" >
<input type="hidden" name="action" value="change" />
<label>Enter secret code:</label>
<input type="text" name="secret_code" value="" />
<label>Enter new password:</label>
<input type="text" name="secret_code" value="" />
</form>
HTML;
}
public function renderError($message)
{
print <<<HTML
{$message}
HTML;
}
}
$changePassword = new ChangePassword();
$changePassword->dispatch();
?>