included CURLOPT_INTERFACE option
This commit is contained in:
parent
8659e27503
commit
d1ceac5295
|
|
@ -38,6 +38,9 @@ $mail_subscription_user_key = NULL;
|
||||||
// CAREFUL: only enable temporarily on debug systems. Will log all queries to given PUBLIC file
|
// CAREFUL: only enable temporarily on debug systems. Will log all queries to given PUBLIC file
|
||||||
$debug = NULL; //'debug.log';
|
$debug = NULL; //'debug.log';
|
||||||
|
|
||||||
|
// Local network interface or IP to be used for the relayed query
|
||||||
|
// This is usefull in some VPN configurations (see CURLOPT_INTERFACE)
|
||||||
|
$target_interface = NULL;
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
** File Caching Options **
|
** File Caching Options **
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,9 @@ curl_setopt($curlSession, CURLOPT_HEADER, 1);
|
||||||
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1);
|
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1);
|
||||||
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
|
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
|
||||||
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 1);
|
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 1);
|
||||||
|
if (!empty($target_interface)) {
|
||||||
|
curl_setopt($curlSession, CURLOPT_INTERFACE, $target_interface);
|
||||||
|
}
|
||||||
if (file_exists(dirname(__FILE__).'/target.pem')) {
|
if (file_exists(dirname(__FILE__).'/target.pem')) {
|
||||||
curl_setopt($curlSession, CURLOPT_CAINFO, dirname(__FILE__).'/target.pem');
|
curl_setopt($curlSession, CURLOPT_CAINFO, dirname(__FILE__).'/target.pem');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
+---------------------------------------------------------*/
|
+---------------------------------------------------------*/
|
||||||
|
|
||||||
require_once "config.php";
|
require_once "config.php";
|
||||||
$civiproxy_version = '0.3.1';
|
$civiproxy_version = '0.3.2';
|
||||||
$civiproxy_logo = "<img src='{$proxy_base}/static/images/proxy-logo.png' alt='SYSTOPIA Organisationsberatung'></img>";
|
$civiproxy_logo = "<img src='{$proxy_base}/static/images/proxy-logo.png' alt='SYSTOPIA Organisationsberatung'></img>";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -21,6 +21,7 @@ $civiproxy_logo = "<img src='{$proxy_base}/static/images/proxy-logo.png' alt=
|
||||||
* where type can be 'int', 'string' (unchecked),
|
* where type can be 'int', 'string' (unchecked),
|
||||||
*/
|
*/
|
||||||
function civiproxy_redirect($url_requested, $parameters) {
|
function civiproxy_redirect($url_requested, $parameters) {
|
||||||
|
global $target_interface;
|
||||||
$url = $url_requested;
|
$url = $url_requested;
|
||||||
$curlSession = curl_init();
|
$curlSession = curl_init();
|
||||||
|
|
||||||
|
|
@ -49,6 +50,9 @@ function civiproxy_redirect($url_requested, $parameters) {
|
||||||
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1);
|
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1);
|
||||||
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
|
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
|
||||||
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 1);
|
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 1);
|
||||||
|
if (!empty($target_interface)) {
|
||||||
|
curl_setopt($curlSession, CURLOPT_INTERFACE, $target_interface);
|
||||||
|
}
|
||||||
if (file_exists(dirname(__FILE__).'/target.pem')) {
|
if (file_exists(dirname(__FILE__).'/target.pem')) {
|
||||||
curl_setopt($curlSession, CURLOPT_CAINFO, dirname(__FILE__).'/target.pem');
|
curl_setopt($curlSession, CURLOPT_CAINFO, dirname(__FILE__).'/target.pem');
|
||||||
}
|
}
|
||||||
|
|
@ -215,7 +219,7 @@ function civiproxy_http_error($message, $code = 404) {
|
||||||
* call the CiviCRM REST API via CURL
|
* call the CiviCRM REST API via CURL
|
||||||
*/
|
*/
|
||||||
function civicrm_api3($entity, $action, $data) {
|
function civicrm_api3($entity, $action, $data) {
|
||||||
global $target_rest, $sys_key_map;
|
global $target_rest, $sys_key_map, $target_interface;
|
||||||
|
|
||||||
// extract site key
|
// extract site key
|
||||||
$site_keys = array_values($sys_key_map);
|
$site_keys = array_values($sys_key_map);
|
||||||
|
|
@ -228,21 +232,24 @@ function civicrm_api3($entity, $action, $data) {
|
||||||
$query['entity'] = $entity;
|
$query['entity'] = $entity;
|
||||||
$query['action'] = $action;
|
$query['action'] = $action;
|
||||||
|
|
||||||
$curl = curl_init();
|
$curlSession = curl_init();
|
||||||
curl_setopt($curl, CURLOPT_POST, 1);
|
curl_setopt($curlSession, CURLOPT_POST, 1);
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $query);
|
curl_setopt($curlSession, CURLOPT_POSTFIELDS, $query);
|
||||||
curl_setopt($curl, CURLOPT_URL, $target_rest);
|
curl_setopt($curlSession, CURLOPT_URL, $target_rest);
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
|
||||||
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
|
if (!empty($target_interface)) {
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
|
curl_setopt($curlSession, CURLOPT_INTERFACE, $target_interface);
|
||||||
|
}
|
||||||
|
// curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, 1);
|
||||||
|
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 1);
|
||||||
if (file_exists(dirname(__FILE__).'/target.pem')) {
|
if (file_exists(dirname(__FILE__).'/target.pem')) {
|
||||||
curl_setopt($curlSession, CURLOPT_CAINFO, dirname(__FILE__).'/target.pem');
|
curl_setopt($curlSession, CURLOPT_CAINFO, dirname(__FILE__).'/target.pem');
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = curl_exec($curl);
|
$response = curl_exec($curlSession);
|
||||||
|
|
||||||
if (curl_error($curl)){
|
if (curl_error($curlSession)){
|
||||||
civiproxy_http_error(curl_error($curl));
|
civiproxy_http_error(curl_error($curlSession));
|
||||||
} else {
|
} else {
|
||||||
return json_decode($response, true);
|
return json_decode($response, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue