Changeset 2666322
- Timestamp:
- 01/26/2022 07:57:56 PM (4 years ago)
- Location:
- whmcs-bridge/trunk
- Files:
-
- 2 edited
-
includes/request.class.php (modified) (8 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
whmcs-bridge/trunk/includes/request.class.php
r2659751 r2666322 116 116 } 117 117 } 118 if ($mime) return ';type='.$mime;118 if ($mime) return $mime; 119 119 else return ''; 120 120 } … … 188 188 $apost = []; 189 189 if (count($this->post) > 0) { 190 $this->debug(0, "HTTP POST 2");191 190 $post = ""; 192 191 $apost = array(); … … 222 221 global $wordpressPageName; 223 222 224 $newfiles =array();223 $newfiles = array(); 225 224 226 225 $url = str_replace('?m=DNSManagerII', '?m=DNSManager2', $url); … … 284 283 $_SESSION['cookieCach'] = $cookies; 285 284 286 /*if (count($_FILES) > 0) {285 if (count($_FILES) > 0) { 287 286 foreach ($_FILES as $name => $file) { 288 287 if (is_array($file['tmp_name']) && count($file['tmp_name']) > 0) { … … 291 290 if ($file['tmp_name'][$i]) { 292 291 $newfile = BLOGUPLOADDIR. $file['name'][$i]; 293 $newfiles[] = $newfile;294 292 copy($file['tmp_name'][$i], $newfile); 295 293 if (!file_exists($newfile)) { 296 cc_whmcs_log('Cant copy '.$file['tmp_name'][$i].' to '.$newfile);294 $this->debug(0, 'Cant copy '.$file['tmp_name'][$i].' to '.$newfile); 297 295 } else { 298 if (PHP_VERSION_ID >= 50500) { 299 $this->post[$name][$i] = new CurlFile($newfile, str_replace(';', '', $this->mimeType($newfile)), $newfile); 300 } else { 301 if ($file['tmp_name'][$i]) $this->post[$name][$i] = '@' . $newfile . $this->mimeType($newfile); 302 } 296 $newfiles[] = [ 297 'file' => $newfile, 298 'name' => $name.'['.$i.']' 299 ]; 303 300 } 304 301 } … … 306 303 } elseif ($file['tmp_name']) { 307 304 $newfile = BLOGUPLOADDIR. $file['name']; 308 $newfiles[] = $newfile;309 305 copy($file['tmp_name'], $newfile); 310 306 if (!file_exists($newfile)) { 311 cc_whmcs_log('Cant copy '.$file['tmp_name'][$i].' to '.$newfile);307 $this->debug(0, 'Cant copy '.$file['tmp_name'][$i].' to '.$newfile); 312 308 } else { 313 if (PHP_VERSION_ID >= 50500 && class_exists('CurlFile')) { 314 $this->post[$name] = new CurlFile($newfile, str_replace(';', '', $this->mimeType($newfile)), $newfile); 315 } else { 316 if ($file['tmp_name']) $this->post[$name] = '@' . $newfile . $this->mimeType($newfile); 317 } 309 $newfiles[] = [ 310 'file' => $newfile, 311 'name' => $name 312 ]; 318 313 } 319 314 } 320 315 } 321 cc_whmcs_log(0, 'There are files: '.json_encode($newfiles));322 } */316 $this->debug(0, 'There are files: '.json_encode($newfiles)); 317 } 323 318 324 319 $rawPost = file_get_contents('php://input'); 320 325 321 if (!empty($rawPost)) 326 $this->debug(0, "R AWdata: ".$rawPost);322 $this->debug(0, "Raw data: ".$rawPost); 327 323 328 324 $apost = $this->generatePostArray(); 329 325 330 if (!empty($apost)) { 326 $this->debug(0, "Post data: ".print_r($apost, true)); 327 328 if (!empty($newfiles)) { 329 $http_args['method'] = 'POST'; 330 $boundary = substr(md5(time()), -24); 331 $http_args['headers']['content-type'] = 'multipart/form-data; boundary='.$boundary; 332 $http_args['body'] = ''; 333 334 if (!empty($apost)) { 335 foreach ($apost as $k => $v) { 336 $http_args['body'] .= '--'.$boundary; 337 $http_args['body'] .= "\r\n"; 338 $http_args['body'] .= 'content-disposition: form-data; name="' . $k . 339 '"' . "\r\n\r\n"; 340 $http_args['body'] .= $v; 341 $http_args['body'] .= "\r\n"; 342 } 343 } 344 345 foreach ($newfiles as $file) { 346 $http_args['body'] .= '--' . $boundary; 347 $http_args['body'] .= "\r\n"; 348 $http_args['body'] .= 'content-disposition: form-data; name="' . $file['name'] . 349 '"; filename="' . basename( $file['file'] ) . '"' . "\r\n"; 350 $http_args['body'] .= 'content-type: '. $this->mimeType($file['file']) . "\r\n"; 351 $http_args['body'] .= "\r\n"; 352 $http_args['body'] .= file_get_contents( $file['file'] ); 353 $http_args['body'] .= "\r\n"; 354 } 355 $http_args['body'] .= '--' . $boundary . '--'; 356 357 $this->debug(0, 'Posting with file attachment '.json_encode($newfiles)); 358 359 } else if (!empty($apost)) { 331 360 $http_args['method'] = 'POST'; 332 361 … … 336 365 } 337 366 338 if (count($newfiles) > 0) { 339 $this->debug(0, 'Posting as [0]: ' . json_encode($apost)); 340 341 $http_args['body'] = $apost; 342 } else { 343 $pfields = $this->makeQueryString($apost); 344 $this->debug(0, 'Posting as [1]: ' . json_encode($pfields)); 345 346 $http_args['body'] = $pfields; 347 } 348 367 $pfields = $this->makeQueryString($apost); 368 $this->debug(0, 'Posting as: ' . json_encode($pfields)); 369 370 $http_args['body'] = $pfields; 349 371 } else if (!empty($rawPost)) { 350 372 $http_args['method'] = 'POST'; … … 377 399 } 378 400 379 $this->debug(0, "Posting to {$url} with : ".json_encode($http_args));401 $this->debug(0, "Posting to {$url} with headers: ".json_encode($http_args['headers'])); 380 402 381 403 $data = wp_remote_request($url, $http_args); -
whmcs-bridge/trunk/readme.txt
r2653261 r2666322 4 4 Tags: WHMCS, hosting, support, billing, integration 5 5 Requires at least: 5.0 6 Tested up to: 5. 8.26 Tested up to: 5.9 7 7 Stable tag: 6.4 8 8 License: GPLv3 … … 80 80 = 6.4 = 81 81 * Core updates 82 * Implementation of WP HTTP API 83 * Implementation of WP content wrappers 82 84 83 85 = 6.3 =
Note: See TracChangeset
for help on using the changeset viewer.