Esempio n. 1
0
    if (!empty($contact_query['is_error'])) {
        // an error occured during contact generation/identification
        if ($contact_query['error_code'] == 'duplicate') {
            // there have been multiple duplicates found
            $contact_id = $contact_query['ids'][0];
        } else {
            civiproxy_http_error($contact_query['error_message'], 500);
        }
    } else {
        $contact_id = $contact_query['id'];
    }
    // then: subscribe
    $subscribe_query = civicrm_api3('MailingEventSubscribe', 'create', array('email' => $email, 'contact_id' => $contact_id, 'group_id' => $group_id, 'api_key' => $mail_subscription_user_key));
    if (!empty($subscribe_query['is_error'])) {
        // an error occured during the actual subscription
        civiproxy_http_error($subscribe_query['error_message'], 500);
    }
}
?>


<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8">
  <title>CiviProxy Version <?php 
echo $civiproxy_version;
?>
</title>
  <link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
  <style type="text/css">
Esempio n. 2
0
$valid_parameters = array('sid' => 'int', 'cid' => 'int', 'h' => 'hex');
$parameters = civiproxy_get_parameters($valid_parameters);
// check if parameters specified
if (empty($parameters['sid'])) {
    civiproxy_http_error("Missing/invalid parameter 'sid'.");
}
if (empty($parameters['cid'])) {
    civiproxy_http_error("Missing/invalid parameter 'cid'.");
}
if (empty($parameters['h'])) {
    civiproxy_http_error("Missing/invalid parameter 'h'.");
}
// PERFORM UNSUBSCRIBE
$group_query = civicrm_api3('MailingEventConfirm', 'create', array('subscribe_id' => $parameters['sid'], 'contact_id' => $parameters['cid'], 'hash' => $parameters['h'], 'api_key' => $mail_subscription_user_key));
if (!empty($group_query['is_error'])) {
    civiproxy_http_error($group_query['error_message'], 500);
}
?>


<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8">
  <title>CiviProxy Version <?php 
echo $civiproxy_version;
?>
</title>
  <link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
  <style type="text/css">
    body {
Esempio n. 3
0
<?php

/*--------------------------------------------------------+
| SYSTOPIA CiviProxy                                      |
|  a simple proxy solution for external access to CiviCRM |
| Copyright (C) 2015 SYSTOPIA                             |
| Author: B. Endres (endres -at- systopia.de)             |
| http://www.systopia.de/                                 |
+---------------------------------------------------------*/
require_once "config.php";
require_once "proxy.php";
// see if URL tracking is enabled
if (!$target_url) {
    civiproxy_http_error("Feature disabled", 405);
}
// basic check
civiproxy_security_check('url');
// basic restraints
$valid_parameters = array('u' => 'int', 'q' => 'int', 'qid' => 'int');
$parameters = civiproxy_get_parameters($valid_parameters);
civiproxy_redirect($target_url, $parameters);
Esempio n. 4
0
<?php

/*--------------------------------------------------------+
| SYSTOPIA CiviProxy                                      |
|  a simple proxy solution for external access to CiviCRM |
| Copyright (C) 2015 SYSTOPIA                             |
| Author: B. Endres (endres -at- systopia.de)             |
| http://www.systopia.de/                                 |
+---------------------------------------------------------*/
ini_set('include_path', dirname(dirname(__FILE__)));
require_once "proxy.php";
// see if mail open tracking is enabled
if (!$mail_subscription_user_key) {
    civiproxy_http_error("Feature disabled", 405);
}
// basic check
civiproxy_security_check('mail-optout');
civiproxy_http_error("Sorry, opt-out not yet implemented", 405);
Esempio n. 5
0
<?php

/*--------------------------------------------------------+
| SYSTOPIA CiviProxy                                      |
|  a simple proxy solution for external access to CiviCRM |
| Copyright (C) 2015 SYSTOPIA                             |
| Author: B. Endres (endres -at- systopia.de)             |
| http://www.systopia.de/                                 |
+---------------------------------------------------------*/
ini_set('include_path', dirname(dirname(__FILE__)));
require_once "proxy.php";
// see if mail open tracking is enabled
if (!$target_mail_view) {
    civiproxy_http_error("Feature disabled", 405);
}
// basic check
civiproxy_security_check('mail-view');
// basic restraints
$valid_parameters = array('id' => 'int');
$parameters = civiproxy_get_parameters($valid_parameters);
// check if id specified
if (empty($parameters['id'])) {
    civiproxy_http_error("Resource not found");
}
civiproxy_redirect($target_mail_view, $parameters);
Esempio n. 6
0
/**
 * call the CiviCRM REST API via CURL
 */
function civicrm_api3($entity, $action, $data)
{
    global $target_rest, $sys_key_map, $target_interface;
    // extract site key
    $site_keys = array_values($sys_key_map);
    if (empty($site_keys)) {
        civiproxy_http_error('No site key set.');
    }
    $query = $data;
    // array copy(!)
    $query['key'] = $site_keys[0];
    $query['json'] = 1;
    $query['version'] = 3;
    $query['entity'] = $entity;
    $query['action'] = $action;
    $curlSession = curl_init();
    curl_setopt($curlSession, CURLOPT_POST, 1);
    curl_setopt($curlSession, CURLOPT_POSTFIELDS, $query);
    curl_setopt($curlSession, CURLOPT_URL, $target_rest);
    curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
    if (!empty($target_interface)) {
        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')) {
        curl_setopt($curlSession, CURLOPT_CAINFO, dirname(__FILE__) . '/target.pem');
    }
    $response = curl_exec($curlSession);
    if (curl_error($curlSession)) {
        civiproxy_http_error(curl_error($curlSession));
    } else {
        return json_decode($response, true);
    }
}
Esempio n. 7
0
curl_setopt($curlSession, CURLOPT_HEADER, 1);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
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')) {
    curl_setopt($curlSession, CURLOPT_CAINFO, dirname(__FILE__) . '/target.pem');
}
//Send the request and store the result in an array
$response = curl_exec($curlSession);
// Check that a connection was made
if (curl_error($curlSession)) {
    error_log(curl_error($curlSession));
    civiproxy_http_error(curl_error($curlSession), curl_errno($curlSession));
}
// process the results
$content = explode("\r\n\r\n", $response, 2);
$header = $content[0];
$body = $content[1];
// extract headers
$header_lines = explode(chr(10), $header);
// store the information in the cache
$file_cache->save(json_encode($header_lines), $header_key);
$file_cache->save($body, $data_key);
// and reply
foreach ($header_lines as $header_line) {
    header($header_line);
}
print $body;