From 2c4c12cb561ad8cf1ce3e6115c84be91e82e32e4 Mon Sep 17 00:00:00 2001 From: Erik Hommel Date: Thu, 20 Jul 2017 11:11:06 +0200 Subject: [PATCH] fix issues from testing with #12 --- proxy/proxy.php | 3 ++- proxy/rest.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/proxy/proxy.php b/proxy/proxy.php index b4cd504..e6bbee9 100644 --- a/proxy/proxy.php +++ b/proxy/proxy.php @@ -259,9 +259,10 @@ function civicrm_api3($entity, $action, $data) { * Function to get the valid rest_allowed_actions key * * @param $action + * @param $rest_allowed_actions * @return bool */ -function civiproxy_get_valid_allowed_actions_key($action) { +function civiproxy_get_valid_allowed_actions_key($action, $rest_allowed_actions) { $remote_addr = $_SERVER['REMOTE_ADDR']; // check IP specific whitelisting if specified for this address if (isset($rest_allowed_actions[$remote_addr])) { diff --git a/proxy/rest.php b/proxy/rest.php index 5a80389..e5b587b 100644 --- a/proxy/rest.php +++ b/proxy/rest.php @@ -51,7 +51,7 @@ if (!isset($action['version']) || $action['version'] != 3) { // the previous test is still used when no 'all' key is found in the array if (isset($rest_allowed_actions['all'])) { // get valid key for the rest_allowed_actions - $valid_allowed_key = civiproxy_get_valid_allowed_actions_key($action); + $valid_allowed_key = civiproxy_get_valid_allowed_actions_key($action, $rest_allowed_actions); if (isset($rest_allowed_actions[$valid_allowed_key][$action['entity']]) && isset($rest_allowed_actions[$valid_allowed_key][$action['entity']][$action['action']])) { $valid_parameters = $rest_allowed_actions[$valid_allowed_key][$action['entity']][$action['action']];