Skip to content

Commit 6c51114

Browse files
committed
Update package name
1 parent f0ffd99 commit 6c51114

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
2-
"name": "omines/directadmin",
2+
"name": "sidlegionair/directadmin",
33
"type": "library",
44
"description": "PHP client library to manage DirectAdmin control panel servers.",
55
"license": "MIT",
66
"keywords": [
77
"library", "php", "directadmin", "control panel", "api", "direct admin"
88
],
9-
"homepage": "https://github.com/omines/directadmin",
9+
"homepage": "https://github.com/sidlegionair/directadmin",
1010
"authors": [
1111
{
12-
"name": "Niels Keurentjes",
13-
"email": "niels.keurentjes@omines.com",
14-
"homepage": "https://www.omines.nl/"
12+
"name": "Floris Boers",
13+
"email": "floris@live-messenger.nl",
14+
"homepage": "https://github.com/sidlegionair"
1515
}
1616
],
1717
"support": {

src/DirectAdmin/Context/BaseContext.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,22 @@ protected function getConnection()
4949
* @param array $query Optional query parameters
5050
* @return array The parsed and validated response
5151
*/
52-
public function invokeApiGet($command, $query = [])
52+
public function invokeApiGet($command, $query = [], $allow_html_response = false)
5353
{
54-
return $this->connection->invokeApi('GET', $command, ['query' => $query]);
54+
return $this->connection->invokeApi('GET', $command, ['query' => $query], $allow_html_response);
5555
}
5656

5757
/**
5858
* Invokes the DirectAdmin API via HTTP POST.
5959
*
6060
* @param string $command DirectAdmin API command to invoke
6161
* @param array $postParameters Optional form parameters
62+
* @param boolean $allow_html_response Optional parameter to allow returning a response containing html instead of json
6263
* @return array The parsed and validated response
6364
*/
64-
public function invokeApiPost($command, $postParameters = [])
65+
public function invokeApiPost($command, $postParameters = [], $allow_html_response = false)
6566
{
66-
return $this->connection->invokeApi('POST', $command, ['form_params' => $postParameters]);
67+
return $this->connection->invokeApi('POST', $command, ['form_params' => $postParameters], $allow_html_response);
6768
}
6869

6970
/**

src/DirectAdmin/DirectAdmin.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,17 @@ public function getUsername()
124124
* @return array The unvalidated response
125125
* @throws DirectAdminException If anything went wrong on the network level
126126
*/
127-
public function invokeApi($method, $command, $options = [])
127+
public function invokeApi($method, $command, $options = [], $allow_html = false)
128128
{
129-
$result = $this->rawRequest($method, '/CMD_API_' . $command, $options);
129+
$result = $this->rawRequest($method, '/CMD_API_' . $command, $options, $allow_html);
130130
if (!empty($result['error'])) {
131131
throw new DirectAdminException("$method to $command failed: $result[details] ($result[text])");
132132
}
133-
return Conversion::sanitizeArray($result);
133+
if($allow_html == true) {
134+
return $result;
135+
} else {
136+
return Conversion::sanitizeArray($result);
137+
}
134138
}
135139

136140
/**
@@ -153,12 +157,14 @@ public function loginAs($username)
153157
* @param array $options
154158
* @return array
155159
*/
156-
public function rawRequest($method, $uri, $options)
160+
public function rawRequest($method, $uri, $options, $allow_html = false)
157161
{
158162
try {
159163
$response = $this->connection->request($method, $uri, $options);
160-
if ($response->getHeader('Content-Type')[0] == 'text/html') {
161-
throw new DirectAdminException(sprintf('DirectAdmin API returned text/html to %s %s containing "%s"', $method, $uri, strip_tags($response->getBody()->getContents())));
164+
if($allow_html == false) {
165+
if ($response->getHeader('Content-Type')[0] == 'text/html') {
166+
throw new DirectAdminException(sprintf('DirectAdmin API returned text/html to %s %s containing "%s"', $method, $uri, strip_tags($response->getBody()->getContents())));
167+
}
162168
}
163169
$body = $response->getBody()->getContents();
164170
return Conversion::responseToArray($body);

0 commit comments

Comments
 (0)