-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPHPUXP
56 lines (52 loc) · 1.51 KB
/
PHPUXP
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
<?php
/**
* @copyright Copyright (c) 2022 Xii Group. (https://xiigroup.co.za)
* @author Sipho George Selabe <sg.selabe@xiigroup.co.za>
**/
class UXP{
public function __construct($domain, $username=null, $key=null){
$this->url = "https://$domain/api/index.php";
$this->payload = [];
$this->authentication = "$username:$key";
}
public function payload($payload){
$this->payload = $payload;
}
public function execute(){
$auth_header = [
"Content-Type"=>"application/x-www-form-urlencoded; charset=utf-8",
"Content-Length"=>strlen(http_build_query($this->payload))
];
if(function_exists('curl_init')){
$options = [
CURLOPT_URL => $this->url,
CURLOPT_HEADER => false,
CURLOPT_TIMEOUT => 60,
CURLOPT_CONNECTTIMEOUT => 60,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_VERBOSE => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => $auth_header,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $this->authentication
];
if(is_array($this->payload) && !empty($this->payload) && isset($this->payload)){
$options[CURLOPT_POSTFIELDS] = $this->payload;
}
$ch = curl_init();
curl_setopt_array($ch, $options);
$contents = curl_exec($ch);
$contents = json_decode($contents, true);
$header_size = curl_getinfo($ch);
if($errno = curl_errno($ch)) {
$contents = curl_strerror($errno);
}
curl_close($ch);
}
return $contents;
}
}
?>