config[modRestClient::OPT_PATH]; $purl['port'] = !empty($purl['port']) ? $purl['port'] : $this->config[modRestClient::OPT_PORT]; $sock = @fsockopen($purl['host'], $purl['port'],$errno,$errstr,30); /* setup params */ $q = http_build_query($params); if ($method == "GET") { $path .= "?" . $q; } $ip = $this->modx->request->getClientIp(); $ip = $ip['ip']; $out = $method." ".$purl['path']."/$path ".$_SERVER['SERVER_PROTOCOL']."\r\n" ."Host: $host\r\n" ."User-Agent: ".$this->config[modRestClient::OPT_USERAGENT]."\r\n" ."Content-type: text/xml; charset=UTF-8\r\n" ."Accept: */*\r\n" ."Accept-Language: en-us,en;q=0.5\r\n" ."Accept-Charset: utf-8;q=0.7,*;q=0.7\r\n" ."Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" /*."Keep-Alive: 300\r\n" */ ."Referer: ".$ip."\r\n" ."Connection: Close\r\n\r\n"; fwrite($sock,$out); if ($method == 'POST') { fwrite($sock, "Content-length: ".strlen($q)."\r\n"); fwrite($sock, $q); } $response = ''; $i = 0; while ($line = fread($sock, 4096)) { if ($i > 20) break; $response .= $line; $i++; } fclose($sock); list($header,$response) = explode(''))); /* commented out for debugging */ //echo ''; die(); //echo '
'.htmlentities($xml->asXml()).''; die(); return $response; } }