Skip to content

Commit 712a8f4

Browse files
committed
Fixed: url encoding issue and added gitignore
1 parent fa3335c commit 712a8f4

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
.git

CPanel.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function call($module, $function, $args = array())
142142
$parameters = '';
143143
if ( count($args) > 0 ) {
144144
foreach( $args as $key => $value ) {
145-
$parameters .= '&' . $key . '=' . $value;
145+
$parameters .= '&' . $key . '=' . urlencode($value);
146146
}
147147
}
148148

@@ -167,30 +167,39 @@ public function call($module, $function, $args = array())
167167
CURLOPT_RETURNTRANSFER => true,
168168
CURLOPT_ENCODING => "",
169169
CURLOPT_MAXREDIRS => 10,
170-
CURLOPT_TIMEOUT => 30,
170+
CURLOPT_TIMEOUT => 100020,
171171
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
172172
CURLOPT_CUSTOMREQUEST => "GET",
173173
CURLOPT_POSTFIELDS => "",
174174
CURLOPT_HTTPHEADER => $headers,
175175
));
176176

177-
$response = curl_exec($curl);
177+
$curl_res = curl_exec($curl);
178178
$err = curl_error($curl);
179+
$err_no = curl_errno($curl);
180+
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
181+
$header = substr($curl_res, 0, $header_size);
182+
$body = substr($curl_res, $header_size);
179183

180184
curl_close($curl);
181185

182186

183-
if ($err) {
187+
$response['inputs']['url'] = $url;
188+
$response['data']['header_size'] = $header_size;
189+
$response['data']['header'] = $header;
190+
$response['data']['response'] = json_decode($curl_res);
191+
$response['data']['body'] = $body;
192+
$response['data']['error'] = $err;
193+
$response['data']['err_no'] = $err_no;
194+
195+
196+
if ($err || $err_no) {
184197

185198
$response['status'] = 'failed';
186199
$response['errors'] = $err;
187-
$response['inputs']['url'] = $url;
188200

189201
} else {
190202

191-
$res = json_decode($response);
192-
193-
$response = [];
194203
if(isset($res) && isset($res->status) && $res->status == 0)
195204
{
196205
$response['status'] = 'failed';
@@ -199,7 +208,6 @@ public function call($module, $function, $args = array())
199208
} else
200209
{
201210
$response['status'] = 'success';
202-
$response['data'] = $res;
203211
$response['inputs']['url'] = $url;
204212
}
205213
}

0 commit comments

Comments
 (0)