From b378751c9e23854724a13e18f1e62295b0eb662b Mon Sep 17 00:00:00 2001 From: Michael Rasmussen Date: Wed, 24 Jun 2015 01:12:13 +0200 Subject: [PATCH] prepare for wblistadm server --- lib/utils.inc.php | 6 +++++- rest_client.php | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/utils.inc.php b/lib/utils.inc.php index e0ab45d..f32e209 100644 --- a/lib/utils.inc.php +++ b/lib/utils.inc.php @@ -384,7 +384,7 @@ class Utils { return $string; } - public function RESTCall($url, $data = null, $cookiesIn = '') { + public function RESTCall($url, $data = null, $cookiesIn = '', $headers = null) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => true, //return headers in addition to content @@ -405,6 +405,10 @@ class Utils { $options[CURLOPT_POSTFIELDS] = $data; } + if ($headers) { + $options[CURLOPT_HTTPHEADER] = $headers; + } + $ch = curl_init($url); curl_setopt_array($ch, $options); $rough_content = curl_exec($ch); diff --git a/rest_client.php b/rest_client.php index ed24278..e73a5d8 100644 --- a/rest_client.php +++ b/rest_client.php @@ -32,11 +32,12 @@ if (! isset($_SESSION['ticket'])) { $response = $util->RESTCall($CFG->wblistadm_url.'/ticket', $data, $cookiesIn = ''); if ($response['http_code'] >= 200 && $response['http_code'] <= 204) { $_SESSION['ticket'] = json_decode($response['content']); - $_SESSION['CSRFPreventionToken'] = 'CSRFPreventionToken='.$_SESSION['ticket']->data->CSRFPreventionToken; + $_SESSION['CSRFPreventionToken'] = array('CSRFPreventionToken' => $_SESSION['ticket']->data->CSRFPreventionToken); $_SESSION['cookies'] = $response['cookies']; } } else { - $response = $util->RESTCall($CFG->wblistadm_url.'/show', $_SESSION['CSRFPreventionToken'], $cookiesIn = $_SESSION['cookies']); + $response = $util->RESTCall($CFG->wblistadm_url.'/show', $_SESSION['CSRFPreventionToken'], + $cookiesIn = $_SESSION['cookies'], $_SESSION['CSRFPreventionToken']); if ($response['http_code'] >= 200 && $response['http_code'] <= 204) { $data = json_decode($response['content']); $_SESSION['cookies'] = $response['cookies']; -- 2.39.2