forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhestia.php
More file actions
73 lines (60 loc) · 2.16 KB
/
hestia.php
File metadata and controls
73 lines (60 loc) · 2.16 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Hestia Control Panel Password Driver
*
* @version 1.0
* @author HestiaCP <info@hestiacp.com>
*/
class rcube_hestia_password {
function save($curpass, $passwd)
{
$rcmail = rcmail::get_instance();
$hestia_host = $rcmail->config->get('password_hestia_host');
if (empty($hestia_host))
{
$hestia_host = 'localhost';
}
$hestia_port = $rcmail->config->get('password_hestia_port');
if (empty($hestia_port))
{
$hestia_port = '8083';
}
$postvars = array(
'email' => $_SESSION['username'],
'password' => $curpass,
'new' => $passwd
);
$postdata = http_build_query($postvars);
$send = 'POST /reset/mail/ HTTP/1.1' . PHP_EOL;
$send .= 'Host: ' . $hestia_host . PHP_EOL;
$send .= 'User-Agent: PHP Script' . PHP_EOL;
$send .= 'Content-length: ' . strlen($postdata) . PHP_EOL;
$send .= 'Content-type: application/x-www-form-urlencoded' . PHP_EOL;
$send .= 'Connection: close' . PHP_EOL;
$send .= PHP_EOL;
$send .= $postdata . PHP_EOL . PHP_EOL;
//$fp = fsockopen('ssl://' . $hestia_host, $hestia_port);
$errno = "";
$errstr = "";
$context = stream_context_create();
$result = stream_context_set_option($context, 'ssl', 'verify_peer', false);
$result = stream_context_set_option($context, 'ssl', 'verify_peer_name', false);
$result = stream_context_set_option($context, 'ssl', 'verify_host', false);
$result = stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
$fp = stream_socket_client('ssl://' . $hestia_host . ':'.$hestia_port, $errno, $errstr, 60, STREAM_CLIENT_CONNECT, $context);
fputs($fp, $send);
$result = fread($fp, 2048);
fclose($fp);
$fp = fopen("/tmp/roundcube.log", 'w');
fwrite($fp, "test ok");
fwrite($fp, "\n");
fclose($fp);
if(strpos($result, 'ok') && !strpos($result, 'error'))
{
return PASSWORD_SUCCESS;
}
else {
return PASSWORD_ERROR;
}
}
}