if($this->config->get('openbay_status') == 1 || $statusOverride == true) {
$this->lasterror = '';
$this->lastmsg = '';
if(!in_array($call, $this->noLog)) {
$this->log('call('.$call.') - Data: '. json_encode($post));
}
if(defined("HTTPS_CATALOG")) {
$domain = HTTPS_CATALOG;
}else{
$domain = HTTPS_SERVER;
}
$data = array(
'token' => $this->token,
'language' => $this->config->get('openbay_language'),
'secret' => $this->secret,
'server' => $this->server,
'domain' => $domain,
'openbay_version' => (int)$this->config->get('openbay_version'),
'data' => $post,
'content_type' => $content_type
);
$defaults = array(
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_URL => $this->url.$call,
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1",
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FORBID_REUSE => 1,
CURLOPT_TIMEOUT => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_POSTFIELDS => http_build_query($data, '', "&")
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
if( ! $result = curl_exec($ch)) {
$this->log('call() - Curl Failed '.curl_error($ch).' '.curl_errno($ch));
}
curl_close($ch);
if(!in_array($call, $this->noLog)) {
$this->log('call() - Result of : "'.$result.'"');
}
if($content_type == 'json') {
$encoding = mb_detect_encoding($result);
if($encoding == 'UTF-8') {
$result = preg_replace('/[^(\x20-\x7F)]*/','', $result);
}
$result = json_decode($result, 1);
$this->lasterror = $result['error'];
$this->lastmsg = $result['msg'];
if(!empty($result['data'])) {
return $result['data'];
}else{
return false;
}
}elseif($content_type == 'xml') {
$result = simplexml_load_string($result);
$this->lasterror = $result->error;
$this->lastmsg = $result->msg;
if(!empty($result->data)) {
return $result->data;
}else{
return false;
}
}
}else{
$this->log('call() - OpenBay Pro not active');
}