-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser_api1.php
More file actions
43 lines (32 loc) · 1.33 KB
/
parser_api1.php
File metadata and controls
43 lines (32 loc) · 1.33 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
<?php header('Content-Type: text/xml');
$whmusername = "";
$whmpassword = "";
$xmlapi_module = $_REQUEST['cpanel_xmlapi_module'];
$xmlapi_func = $_REQUEST['cpanel_xmlapi_func'];
$xmlapi_apiversion = "1";
$xmlapi_args = rawurlencode($_REQUEST['args']);
$query = "https://www.domain.com:2083/xml-api/cpanel?user=".$whmusername."&cpanel_xmlapi_module=". $xmlapi_module ."&cpanel_xmlapi_func=". $xmlapi_func ."&cpanel_xmlapi_apiversion=". $xmlapi_apiversion ."&arg-0=". $xmlapi_args;
$curl = curl_init();
# Create Curl Object
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
# Allow self-signed certs
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
# Allow certs that do not match the hostname
curl_setopt($curl, CURLOPT_HEADER,0);
# Do not include header in output
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
# Return contents of transfer on curl_exec
$header[0] = "Authorization: Basic " . base64_encode($whmusername.":".$whmpassword) . "\n\r";
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
# set the username and password
curl_setopt($curl, CURLOPT_URL, $query);
# execute the query
$result = curl_exec($curl);
if ($result == false) {
error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
# log error if curl exec fails
}
curl_close($curl);
$result = simplexml_load_string($result);
print $result->asXML();
?>