Index: branches/5.2.x/core/units/helpers/curl_helper.php =================================================================== diff -u -N -r13840 -r14092 --- branches/5.2.x/core/units/helpers/curl_helper.php (.../curl_helper.php) (revision 13840) +++ branches/5.2.x/core/units/helpers/curl_helper.php (.../curl_helper.php) (revision 14092) @@ -1,6 +1,6 @@ debugMode = $this->Application->isDebugMode(false) && constOn('DBG_CURL'); + $this->debugMode = constOn('DBG_CURL'); } /** @@ -133,6 +133,10 @@ CURLOPT_RETURNTRANSFER => 1, CURLOPT_REFERER => PROTOCOL.SERVER_NAME, CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'], + + // don't verify SSL certificates + CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_HTTPHEADER => Array ('Expect:'), ); if ($this->requestHeaders) { @@ -174,6 +178,8 @@ function SetPostData($post_data) { if (is_array($post_data)) { + $post_data = $this->Application->HttpQuery->_transformArrays($post_data); + $params_str = ''; foreach ($post_data as $key => $value) { $params_str .= $key.'='.urlencode($value).'&'; @@ -208,14 +214,25 @@ return $ret; } - function Send($url, $close_connection = true) + function Send($url, $close_connection = true, $log_status = null) { + if (isset($log_status)) { + // override debug mode setting + $this->debugMode = $log_status; + } + $this->connectionID = curl_init($url); if ($this->debugMode) { safeDefine('DBG_CURL_LOGFILE', '/curl.log'); $this->logFilePointer = fopen(FULL_PATH.DBG_CURL_LOGFILE, 'a'); + $user_id = $this->Application->RecallVar('user_id'); + $data = $_SERVER['REMOTE_ADDR'] . ' - ['.adodb_date('D M d H:i:s Y').'] ' . $_SERVER['REQUEST_URI'] . '; user_id: '.$user_id.'; sid: '.$this->Application->GetSID(); + fwrite($this->logFilePointer, "\n\n" . str_repeat('=', strlen($data)) . "\n"); + fwrite($this->logFilePointer, $data); + fwrite($this->logFilePointer, "\n" . str_repeat('=', strlen($data)) . "\n"); + curl_setopt($this->connectionID, CURLOPT_FILE, $this->logFilePointer); curl_setopt($this->connectionID, CURLOPT_VERBOSE, true); curl_setopt($this->connectionID, CURLOPT_STDERR, $this->logFilePointer); @@ -251,20 +268,25 @@ $this->lastErrorMsg = curl_error($this->connectionID); $this->lastHTTPCode = curl_getinfo($this->connectionID, CURLINFO_HTTP_CODE); - if ($this->debugMode) { - fwrite($this->logFilePointer, "\n".$this->lastRespoce); - fclose($this->logFilePointer); - } - - $this->_resetSettings(); - if ($close_connection) { $this->CloseConnection(); } + + $this->_resetSettings(); } function CloseConnection() { curl_close($this->connectionID); + + if ($this->debugMode) { + // only close log after curl resource has been terminated + fwrite($this->logFilePointer, "\n" . 'LastHTTPCode: ' . $this->lastHTTPCode . '; LastError: #' . $this->lastErrorCode . ' (' . $this->lastErrorMsg . ')' . "\n"); + fwrite($this->logFilePointer, 'Respoce:' . "\n" . $this->lastRespoce); + fclose($this->logFilePointer); + } + + // restore debug mode setting + $this->debugMode = constOn('DBG_CURL'); } } \ No newline at end of file