mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-03-12 17:05:16 +00:00
Update index.php
This commit is contained in:
parent
9786bb2d9d
commit
b824fce0ed
38
index.php
38
index.php
|
@ -246,6 +246,34 @@ function relay_mysql_query($params, $mysqli) {
|
|||
);
|
||||
}
|
||||
|
||||
function relay_sendmail($params) {
|
||||
$to = $params['to'];
|
||||
$from = $params['from'];
|
||||
$subject = $params['subject'];
|
||||
$message = $params['message'];
|
||||
$headers = 'From: ' . $from . "\r\n" .
|
||||
'X-Mailer: php-httpproxy/' . PHP_HTTPPROXY_VERSION . ' (Server; PHP ' . phpversion() . ')';
|
||||
$sent = mail($to, $subject, $message, $headers);
|
||||
if (!$sent) {
|
||||
$e = error_get_last();
|
||||
return array(
|
||||
"success" => false,
|
||||
"error" => array(
|
||||
"status" => 500,
|
||||
"code" => $e['type'],
|
||||
"message" => $e['message']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
"success" => true,
|
||||
"result" => array(
|
||||
"status" => 200
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function relay_get_version() {
|
||||
return array("version" => PHP_HTTPPROXY_VERSION);
|
||||
}
|
||||
|
@ -300,6 +328,15 @@ if ($context['jsonrpc'] == "2.0") {
|
|||
}
|
||||
break;
|
||||
|
||||
case "relay_sendmail":
|
||||
$result = relay_sendmail($context['params']);
|
||||
if ($result['success']) {
|
||||
echo jsonrpc2_result_encode($result['result'], $context['id']);
|
||||
} else {
|
||||
echo jsonrpc2_error_encode($result['error'], $context['id']);
|
||||
}
|
||||
break;
|
||||
|
||||
case "relay_get_version":
|
||||
echo jsonrpc2_result_encode(relay_get_version(), $context['id']);
|
||||
break;
|
||||
|
@ -312,6 +349,7 @@ if ($context['jsonrpc'] == "2.0") {
|
|||
echo jsonrpc2_result_encode(relay_get_loaded_extensions(), $context['id']);
|
||||
break;
|
||||
|
||||
|
||||
case "get_client_address":
|
||||
echo jsonrpc2_result_encode(get_client_address(), $context['id']);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue
Block a user