/**
  * Subscribes to Sendinblue list. Returns either "success" string or error message.
  * @return string
  */
 function subscribe_sendinblue($api_key, $email, $list_id, $name, $last_name = '')
 {
     if (!function_exists('curl_init')) {
         return __('curl_init is not defined ', 'rapidology');
     }
     if (!class_exists('Mailin')) {
         require_once RAD_RAPIDOLOGY_PLUGIN_DIR . 'subscription/sendinblue-v2.0/mailin.php';
     }
     $mailin = new Mailin('https://api.sendinblue.com/v2.0', $api_key);
     $user = $mailin->get_user($email);
     if ('failure' == $user['code']) {
         $attributes = array("NAME" => $name, "SURNAME" => $last_name);
         $blacklisted = 0;
         $listid = array($list_id);
         $listid_unlink = array();
         $blacklisted_sms = 0;
         $result = $mailin->create_update_user($email, $attributes, $blacklisted, $listid, $listid_unlink, $blacklisted_sms);
         if ('success' == $result['code']) {
             $error_message = 'success';
         } else {
             if (!empty($result['message'])) {
                 $error_message = $result['message'];
             } else {
                 $error_message = __('Unknown error', 'rapidology');
             }
         }
     } else {
         $error_message = __('Already subscribed', 'rapidology');
     }
     return $error_message;
 }
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <*****@*****.**>
* @copyright  2007-2013 PrestaShop SA
* @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../init.php';
include dirname(__FILE__) . '/mailin.php';
if (Tools::getValue('token') != Tools::encrypt(Configuration::get('PS_SHOP_NAME'))) {
    die('Error: Invalid Token');
}
$mailin = new Mailin();
$mailin->ajaxDisplayNewsletterEmail();
 /**
  * ajax module for validation of API access key
  *
  * @options :
  *  ws_main_option
  *  ws_token_store
  *  ws_error_type
  */
 public static function ajax_validation_process()
 {
     if (!class_exists('Mailin')) {
         require_once 'mailin.php';
     }
     $access_key = trim($_POST['access_key']);
     try {
         $mailin = new Mailin(self::sendinblue_api_url, $access_key);
     } catch (Exception $e) {
         if ($e->getMessage() == 'Mailin requires CURL module') {
             $ws_error_type = __('Please install curl on site to use sendinblue plugin.', 'wc_sendinblue');
         } else {
             $ws_error_type = __('Curl error.', 'wc_sendinblue');
         }
         $settings = array('error_type' => $ws_error_type);
         update_option('ws_error_type', $settings);
         die;
     }
     $response = $mailin->get_access_tokens();
     if (is_array($response)) {
         if ($response['code'] == 'success') {
             // store api info
             $settings = array('access_key' => $access_key);
             update_option('ws_main_option', $settings);
             // Create woocommerce attributes on SendinBlue
             $data = array("type" => "transactional", "data" => array('ORDER_ID' => 'ID', 'ORDER_DATE' => 'DATE', 'ORDER_PRICE' => 'NUMBER'));
             $mailin->create_attribute($data);
             $mailin->partnerWordpress();
             echo 'success';
         } else {
             $settings = array('error_type' => __('Please input correct information.', 'wc_sendinblue'));
             update_option('ws_error_type', $settings);
         }
     } else {
         echo 'fail';
     }
     die;
 }
Esempio n. 4
0
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <*****@*****.**>
* @copyright  2007-2013 PrestaShop SA
* @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/mailin.php';
if (Tools::getValue('token') != Tools::encrypt(Configuration::get('PS_SHOP_NAME'))) {
    die('Error: Invalid Token');
}
$mailin = new Mailin();
$mailin->updateNewsletterStatus();
 /**
  * Validation email
  */
 function validation_email($email, $list_id)
 {
     $general_settings = get_option('ws_main_option', array());
     if (!class_exists('Mailin')) {
         require_once 'mailin.php';
     }
     $mailin = new Mailin(WC_Sendinblue::sendinblue_api_url, $general_settings['access_key']);
     $data = array("email" => $email);
     $response = $mailin->get_user($data);
     if ($response['code'] == 'failure') {
         $ret = array('code' => 'success', 'listid' => array());
         return $ret;
     }
     $listid = $response['data']['listid'];
     if (!isset($listid) || !is_array($listid)) {
         $listid = array();
     }
     if ($response['data']['blacklisted'] == 1) {
         $ret = array('code' => 'update', 'listid' => $listid);
     } else {
         if (!in_array($list_id, $listid)) {
             $ret = array('code' => 'success', 'listid' => $listid);
         } else {
             $ret = array('code' => 'already_exist', 'listid' => $listid);
         }
     }
     return $ret;
 }
Esempio n. 6
0
function logincust_subscribe_widget()
{
    if (!empty($_POST["logincust_mail"])) {
        require LOGINCUST_FREE_PATH . 'mailin.php';
        $was_submited = get_option('logincust_mail_was_submited', false);
        $user_info = get_userdata(1);
        $mailin = new Mailin("https://api.sendinblue.com/v2.0", "cHW5sxZnzE7mhaYb");
        $data = array("email" => $_POST["logincust_mail"], "attributes" => array("NAME" => $user_info->first_name, "SURNAME" => $user_info->last_name), "blacklisted" => 0, "listid" => array(34), "blacklisted_sms" => 0);
        $status = $mailin->create_update_user($data);
        if ($status['code'] == 'success') {
            if (empty($was_submited)) {
                add_option('logincust_mail_was_submited', true);
            }
        }
    }
    $was_submited = get_option('logincust_mail_was_submited', false);
    if ($was_submited == false) {
        echo sprintf('<p> %s </p><form class="logincust-submit-mail" method="post"><input name="logincust_mail" type="email" class="wp-pointer-input" value="' . get_option('admin_email') . '" /><input class="button wp-pointer-submit" type="submit" value="Submit"></form>', esc_html__('Our free, 4-lesson course on how to make your WordPress site run incredibly fast is barely waiting for its students. Ready to learn how to reduce your loading times by half? Come and join the 1st lesson here!', LOGINCUST_TEXTDOMAIN));
    } else {
        echo sprintf('<p> %s </p>', esc_html__('Thank you for subscribing! You have been added to the mailing list and will receive the next email information in the coming weeks. If you ever wish to unsubscribe, simply use the “Unsubscribe� link included in each newsletter.', LOGINCUST_TEXTDOMAIN));
    }
}
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <*****@*****.**>
* @copyright  2007-2013 PrestaShop SA
* @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/mailin.php';
if (Tools::getValue('token') != Tools::encrypt(Configuration::get('PS_SHOP_NAME'))) {
    die('Error: Invalid Token');
}
$mailin = new Mailin();
Configuration::updateValue('Mailin_Api_Smtp_Status', Tools::getValue('smtptest'));
if (Tools::getValue('smtptest') == 1) {
    echo $mailin->postProcessConfiguration();
} else {
    $mailin->resetConfigMailinSmtp();
}
Esempio n. 8
0
<?php

require '../mailin.php';
/*
 * This will initiate the API with the endpoint and your access and secret key.
 *
 */
$mailin = new Mailin('https://api.sendinblue.com/v1.0', 'Your access key', 'Your secret key');
/** Prepare variables for easy use **/
$to = array("*****@*****.**" => "to whom!");
//mandatory
$subject = "My subject";
//mandatory
$from = array("*****@*****.**", "from email!");
//mandatory
$html = "This is the <h1>HTML</h1>";
//mandatory
$text = "This is the text";
$cc = array("*****@*****.**" => "cc whom!");
$bcc = array("*****@*****.**" => "bcc whom!");
$replyto = array("*****@*****.**", "reply to!");
$attachment = array();
//provide the absolute url of the attachment/s
$headers = array("Content-Type" => "text/html; charset=iso-8859-1", "X-Ewiufkdsjfhn" => "hello", "X-Custom" => "Custom");
var_dump($mailin->send_email($to, $subject, $from, $html, $text, $cc, $bcc, $replyto, $attachment, $headers));
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require 'Mailin.php';
require __DIR__ . '/../../vendor/autoload.php';
const STOP_SENDING = false;
use Firebase\Firebase;
$fb = Firebase::initialize("https://boiling-fire-2669.firebaseio.com/", "P5Ofkmp3suKfnJWbWOtQimj5SqzC0tuWBdSz9UQh");
// $userData = $fb->get("users/09a57e9a-6d0d-4587-8e2e-7867111a41a2");
$users = $fb->get("users");
$before = strtotime("-10 minutes");
$mailin = new Mailin('https://api.sendinblue.com/v2.0', 'RAKxVhObvYnN318W');
foreach ($users as $user_id => $userData) {
    if (isset($userData["cover_image"])) {
        $cover_image = $userData["cover_image"];
    } else {
        $cover_image = "https://firebasestorage.googleapis.com/v0/b/boiling-fire-2669.appspot.com/o/hdr-default.jpg?alt=media&token=1d041103-ab06-40d4-a80f-7630806af022";
    }
    if (is_array($userData["guests"])) {
        // echo $user_id;
        foreach ($userData["guests"] as $key => $guest) {
            // If has attending or not attending
            $hasAttending = isset($userData["attending"][$key]);
            $hasNotAttending = isset($userData["notattending"][$key]);
            $a_incron = "";
            $na_incron = "";
            if ($hasAttending || $hasNotAttending) {
                if ($hasAttending) {
                    $a_incron = $userData["attending"][$key]["date_created"] / 1000 > $before;
Esempio n. 10
0
<?php

require 'Mailin.php';
/*
 * This will initiate the API with the endpoint and your access key.
 *
 */
$mailin = new Mailin('https://api.sendinblue.com/v2.0', 'Your access key');
/*
 * This will send a transactional SMS
 *
 */
/** Prepare variables for easy use **/
$data = array("to" => "+331234567890", "from" => "From", "text" => "Good morning - test", "web_url" => "http://example.com", "tag" => "Tag1", "type" => "");
var_dump($mailin->send_sms($data));
Esempio n. 11
0
<?php

require 'Mailin.php';
/*
 * This will initiate the API with the endpoint and your access key.
 *
 */
$mailin = new Mailin('https://api.sendinblue.com/v2.0', 'Your access key');
/*
 * This will send a transactional email
 *
 */
/** Prepare variables for easy use **/
$data = array("to" => array("*****@*****.**" => "to whom!"), "cc" => array("*****@*****.**" => "cc whom!"), "bcc" => array("*****@*****.**" => "bcc whom!"), "from" => array("*****@*****.**", "from email!"), "replyto" => array("*****@*****.**", "reply to!"), "subject" => "My subject", "text" => "This is the text", "html" => "This is the <h1>HTML</h1><br/>\n\t\t\t\t\t   This is inline image 1.<br/>\n\t\t\t\t\t   <img src=\"{myinlineimage1.png}\" alt=\"image1\" border=\"0\"><br/>\n\t\t\t\t\t   Some text<br/>\n\t\t\t\t\t   This is inline image 2.<br/>\n\t\t\t\t\t   <img src=\"{myinlineimage2.jpg}\" alt=\"image2\" border=\"0\"><br/>\n\t\t\t\t\t   Some more text<br/>\n\t\t\t\t\t   Re-used inline image 1.<br/>\n\t\t\t\t\t   <img src=\"{myinlineimage1.png}\" alt=\"image3\" border=\"0\">", "attachment" => array(), "headers" => array("Content-Type" => "text/html; charset=iso-8859-1", "X-param1" => "value1", "X-param2" => "value2", "X-Mailin-custom" => "my custom value", "X-Mailin-IP" => "102.102.1.2", "X-Mailin-Tag" => "My tag"), "inline_image" => array('myinlineimage1.png' => "your_png_files_base64_encoded_chunk_data", 'myinlineimage2.jpg' => "your_jpg_files_base64_encoded_chunk_data"));
var_dump($mailin->send_email($data));
Esempio n. 12
0
<?php

require 'Mailin.php';
/*
 * This will initiate the API with the endpoint and your access key.
 *
 */
$mailin = new Mailin('https://api.sendinblue.com/v2.0', 'Your access key');
/*
 * This will get all your campaigns
 *
 */
/** Prepare variables for easy use **/
$data = array("type" => "classic", "status" => "queued", "page" => 1, "page_limit" => 10);
var_dump($mailin->get_campaigns_v2($data));
    /**
     * When a user places an order, the tracking code integrates in the order confirmation page.
     */
    public function hookOrderConfirmation($params)
    {
        if (!$this->checkModuleStatus()) {
            return false;
        }
        $customerid = isset($params['objOrder']->id_customer) ? $params['objOrder']->id_customer : '';
        $customer_result = Db::getInstance()->ExecuteS('SELECT id_gender, firstname, lastname, newsletter  FROM ' . _DB_PREFIX_ . 'customer WHERE `id_customer` = ' . (int) $customerid);
        $id_delivery = isset($params['objOrder']->id_address_delivery) ? $params['objOrder']->id_address_delivery : 0;
        $address_delivery = Db::getInstance()->ExecuteS('SELECT * FROM ' . _DB_PREFIX_ . 'address WHERE `id_address` = ' . (int) $id_delivery);
        if (version_compare(_PS_VERSION_, '1.5.0.0', '<')) {
            $ref_num = isset($params['objOrder']->id) ? $params['objOrder']->id : 0;
        } else {
            $ref_num = isset($params['objOrder']->reference) ? $params['objOrder']->reference : 0;
        }
        $total_to_pay = isset($params['total_to_pay']) ? $params['total_to_pay'] : 0;
        if (Configuration::get('Sendin_Api_Sms_Order_Status', '', $this->id_shop_group, $this->id_shop) && Configuration::get('Sendin_Sender_Order', '', $this->id_shop_group, $this->id_shop) && Configuration::get('Sendin_Sender_Order_Message', '', $this->id_shop_group, $this->id_shop)) {
            $data = array();
            if (isset($address_delivery[0]['phone_mobile']) && !empty($address_delivery[0]['phone_mobile'])) {
                $result_code = Db::getInstance()->getRow('SELECT `call_prefix` FROM ' . _DB_PREFIX_ . 'country
WHERE               `id_country` = \'' . pSQL($address_delivery[0]['id_country']) . '\'');
                $number = $this->checkMobileNumber($address_delivery[0]['phone_mobile'], $result_code['call_prefix']);
                $order_date = isset($params['objOrder']->date_upd) ? $params['objOrder']->date_upd : 0;
                if ($this->context->language->id == 1) {
                    $ord_date = date('m/d/Y', strtotime($order_date));
                } else {
                    $ord_date = date('d/m/Y', strtotime($order_date));
                }
                $firstname = isset($address_delivery[0]['firstname']) ? $address_delivery[0]['firstname'] : '';
                $lastname = isset($address_delivery[0]['lastname']) ? $address_delivery[0]['lastname'] : '';
                if (Tools::strtolower($firstname) === Tools::strtolower($customer_result[0]['firstname']) && Tools::strtolower($lastname) === Tools::strtolower($customer_result[0]['lastname'])) {
                    $civility_value = isset($this->context->customer->id_gender) ? $this->context->customer->id_gender : '';
                } else {
                    $civility_value = '';
                }
                if ($civility_value == 1) {
                    $civility = 'Mr.';
                } elseif ($civility_value == 2) {
                    $civility = 'Ms.';
                } elseif ($civility_value == 3) {
                    $civility = 'Miss.';
                } else {
                    $civility = '';
                }
                $total_pay = $total_to_pay . '' . $this->context->currency->iso_code;
                $msgbody = Configuration::get('Sendin_Sender_Order_Message', '', $this->id_shop_group, $this->id_shop);
                $civility_data = str_replace('{civility}', $civility, $msgbody);
                $fname = str_replace('{first_name}', $firstname, $civility_data);
                $lname = str_replace('{last_name}', $lastname . "\r\n", $fname);
                $product_price = str_replace('{order_price}', $total_pay, $lname);
                $order_date = str_replace('{order_date}', $ord_date . "\r\n", $product_price);
                $msgbody = str_replace('{order_reference}', $ref_num, $order_date);
                $data['from'] = Configuration::get('Sendin_Sender_Order', '', $this->id_shop_group, $this->id_shop);
                $data['text'] = $msgbody;
                $data['to'] = $number;
                $api_key = Configuration::get('Sendin_Api_Key', '', $this->id_shop_group, $this->id_shop);
                $mailin = new Mailin("https://api.sendinblue.com/v2.0", $api_key);
                $data_api = array("email" => $this->context->customer->email);
                $data_resp = $mailin->getUser($data_api);
                $order_status = '';
                if (!empty($data_resp['data']['transactional_attributes'])) {
                    $transactional_data = $data_resp['data']['transactional_attributes'];
                    foreach ($transactional_data as $data_chk) {
                        if ($data_chk['ORDER_ID'] == $ref_num) {
                            $order_status = $data_chk['ORDER_ID'];
                        }
                    }
                }
                if (empty($order_status)) {
                    $this->sendSmsApi($data);
                }
            }
        }
        if (Configuration::get('Sendin_Api_Key_Status', '', $this->id_shop_group, $this->id_shop) == 1 && Configuration::get('Sendin_Tracking_Status', '', $this->id_shop_group, $this->id_shop) == 1 && $customer_result[0]['newsletter'] == 1) {
            $this->tracking = $this->trackingResult();
            $date_value = $this->getApiConfigValue();
            if ($date_value->date_format == 'dd-mm-yyyy') {
                $date = date('d-m-Y');
            } else {
                $date = date('m-d-Y');
            }
            $list = str_replace('|', ',', Configuration::get('Sendin_Selected_List_Data', '', $this->id_shop_group, $this->id_shop));
            if (preg_match('/^[0-9,]+$/', $list)) {
                $list = $list;
            } else {
                $list = '';
            }
            $code = '<script type="text/javascript">
            /**Code for NB tracking*/
            function loadScript(url,callback){var script=document.createElement("script");script.type="text/javascript";if(script.readyState){script.onreadystatechange=function(){
            if(script.readyState=="loaded"||script.readyState=="complete"){script.onreadystatechange=null;callback(url)}}}else{
            script.onload=function(){callback(url)}}script.src=url;if(document.body){document.body.appendChild(script)}else{
            document.head.appendChild(script)}}
            var nbJsURL = (("https:" == document.location.protocol) ? "https://my-tracking-orders.googlecode.com/files" : "http://my-tracking-orders.googlecode.com/files");
            var nbBaseURL = "http://tracking.mailin.fr/";
            loadScript(nbJsURL+"/nbv2.js",
            function(){
            /*You can put your custom variables here as shown in example.*/
            try {
            var nbTracker = nb.getTracker(nbBaseURL , "' . Tools::safeOutput($this->tracking->result->tracking_data->site_id) . '");
            var list = [' . $list . '];
            var attributes = ["EMAIL","PRENOM","NOM","ORDER_ID","ORDER_DATE","ORDER_PRICE"];
            var values = ["' . $this->context->customer->email . '",
            "' . $this->context->customer->firstname . '",
            "' . $this->context->customer->lastname . '",
            "' . $ref_num . '",
            "' . $date . '",
            "' . Tools::safeOutput($total_to_pay) . '"];
            nbTracker.setListData(list);
            nbTracker.setTrackingData(attributes,values);
            nbTracker.trackPageView();
            } catch( err ) {}
            });
            </script>';
            echo html_entity_decode($code, ENT_COMPAT, 'UTF-8');
        }
    }
Esempio n. 14
0
 /**
  * Subscribes to Sendinblue list. Returns either "success" string or error message.
  * @return string
  */
 function subscribe_sendinblue($api_key, $email, $list_id, $name, $last_name = '')
 {
     if (!function_exists('curl_init')) {
         return __('curl_init is not defined ', 'bloom');
     }
     if (!class_exists('Mailin')) {
         require_once ET_BLOOM_PLUGIN_DIR . 'subscription/sendinblue-v2.0/mailin.php';
     }
     $mailin = new Mailin('https://api.sendinblue.com/v2.0', $api_key);
     $user = $mailin->get_user($email);
     //check whether current email subscribed to current list
     if (!empty($user['data']['listid'])) {
         foreach ($user['data']['listid'] as $single_list_id) {
             if ((int) $list_id === (int) $single_list_id) {
                 return __('Already subscribed', 'bloom');
             }
         }
     }
     // subscribe current email to current list if not subscribed yet
     $attributes = array("NAME" => $name, "SURNAME" => $last_name);
     $blacklisted = 0;
     $listid = array($list_id);
     $listid_unlink = array();
     $blacklisted_sms = 0;
     $result = $mailin->create_update_user($email, $attributes, $blacklisted, $listid, $listid_unlink, $blacklisted_sms);
     if ('success' == $result['code']) {
         $error_message = 'success';
     } else {
         if (!empty($result['message'])) {
             $error_message = $result['message'];
         } else {
             $error_message = __('Unknown error', 'bloom');
         }
     }
     return $error_message;
 }
Esempio n. 15
0
<?php

require '../mailin.php';
/*
 * This will initiate the API with the endpoint and your access and secret key.
 *
 */
$mailin = new Mailin('https://api.sendinblue.com/v1.0', 'Your access key', 'Your secret key');
/*
 * This will send an SMS
 *
 */
var_dump($mailin->send_sms("1231231313", "From!", "This is a test", "http://example.com", "tag1"));
Esempio n. 16
0
 /** ajax process when change template id */
 function ajax_change_template()
 {
     $template_id = $_POST['template_id'];
     $mailin = new Mailin('https://api.sendinblue.com/v1.0', SIB_Manager::$access_key, SIB_Manager::$secret_key);
     $response = $mailin->get_campaign($template_id);
     $ret_email = '-1';
     if ($response['code'] == 'success') {
         $from_email = $response['data'][$template_id]['from_email'];
         if ($from_email == '[DEFAULT_FROM_EMAIL]') {
             $ret_email = '-1';
         } else {
             $ret_email = $from_email;
         }
     }
     echo $ret_email;
     die;
 }
 /** ajax process when change template id */
 public static function ajax_change_template()
 {
     $template_id = $_POST['template_id'];
     $mailin = new Mailin(SIB_Manager::sendinblue_api_url, SIB_Manager::$access_key);
     $data = array('id' => $template_id);
     $response = $mailin->get_campaign_v2($data);
     $ret_email = '-1';
     if ($response['code'] == 'success') {
         $from_email = $response['data'][0]['from_email'];
         if ($from_email == '[DEFAULT_FROM_EMAIL]') {
             $ret_email = '-1';
         } else {
             $ret_email = $from_email;
         }
     }
     echo $ret_email;
     die;
 }
Esempio n. 18
0
<?php

require '../mailin.php';
/*
 * This will initiate the API with the endpoint and your access and secret key.
 *
 */
$mailin = new Mailin('https://api.sendinblue.com/v1.0', 'Your access key', 'Your secret key');
/*
 * This will get all your campaigns
 *
 */
var_dump($mailin->get_campaigns());
 /**
  * This method is called when the user send the campaign to only subscribed customers
  */
 public static function multipleChoiceSubCampaign($info)
 {
     $general_settings = get_option('ws_main_option', array());
     $sender_campaign = $info['from'];
     $sender_campaign_message = $info['text'];
     //Create a campaign
     $camp_name = 'SMS_' . date('Ymd');
     $first_name = '{NAME}';
     $last_name = '{SURNAME}';
     $fname = str_replace('{first_name}', $first_name, $sender_campaign_message);
     $content = str_replace('{last_name}', $last_name, $fname);
     $listid = array_keys(self::$lists);
     $data = array("name" => $camp_name, "sender" => $sender_campaign, "content" => $content, "listid" => $listid, "scheduled_date" => date('Y-m-d H:i:s', current_time('timestamp') + 60));
     if (!class_exists('Mailin')) {
         require_once 'mailin.php';
     }
     $mailin = new Mailin(WC_Sendinblue::sendinblue_api_url, $general_settings['access_key']);
     $result = $mailin->create_sms_campaign($data);
     delete_transient('wswcsbcredit_' . md5($general_settings['access_key']));
     return $result;
 }
Esempio n. 20
0
function pirate_forms_admin()
{
    global $current_user;
    $pirate_forms_options = get_option('pirate_forms_settings_array');
    $plugin_options = pirate_forms_plugin_options();
    ?>

	<div class="wrap">

		<h1><?php 
    esc_html_e('Pirate Forms', 'pirate-forms');
    ?>
</h1>


		<div class="pirate-options">
			<ul class="pirate-forms-nav-tabs" role="tablist">
				<li role="presentation" class="active"><a href="#0" aria-controls="how_to_use" role="tab" data-toggle="tab"><?php 
    esc_html_e('How to use', 'pirate-forms');
    ?>
</a></li>
				<li role="presentation"><a href="#1" aria-controls="options" role="tab" data-toggle="tab"><?php 
    esc_html_e('Options', 'pirate-forms');
    ?>
</a></li>
				<li role="presentation"><a href="#2" aria-controls="fields" role="tab" data-toggle="tab"><?php 
    esc_html_e('Fields Settings', 'pirate-forms');
    ?>
</a></li>
				<li role="presentation"><a href="#3" aria-controls="labels" role="tab" data-toggle="tab"><?php 
    esc_html_e('Fields Labels', 'pirate-forms');
    ?>
</a></li>
				<li role="presentation"><a href="#4" aria-controls="messages" role="tab" data-toggle="tab"><?php 
    esc_html_e('Alert Messages', 'pirate-forms');
    ?>
</a></li>
				<li role="presentation"><a href="#5" aria-controls="smtp" role="tab" data-toggle="tab"><?php 
    esc_html_e('SMTP', 'pirate-forms');
    ?>
</a></li>
			</ul>

			<div class="pirate-forms-tab-content">

				<div id="0" class="pirate-forms-tab-pane active">

					<h2 class="pirate_forms_welcome_text"><?php 
    esc_html_e('Welcome to Pirate Forms!', 'pirate-forms');
    ?>
</h2>
					<p class= "pirate_forms_subheading"><?php 
    esc_html_e('To get started, just ', 'pirate-forms');
    ?>
<b><?php 
    esc_html_e('configure all the options ', 'pirate-forms');
    ?>
</b><?php 
    esc_html_e('you need, hit save and start using the created form.', 'pirate-forms');
    ?>
</p>

					<hr>

					<p><?php 
    esc_html_e('There are 3 ways of using the newly created form:', 'pirate-forms');
    ?>
</p>
					<ol>
						<li><?php 
    esc_html_e('Add a ', 'pirate-forms');
    ?>
<strong><a href="<?php 
    echo admin_url('widgets.php');
    ?>
"><?php 
    esc_html_e('widget', 'pirate-forms');
    ?>
</a></strong></li>
						<li><?php 
    esc_html_e('Use the shortcode ', 'pirate-forms');
    ?>
<strong><code>[pirate_forms]</code></strong><?php 
    esc_html_e(' in any page or post.', 'pirate-forms');
    ?>
</li>
						<li><?php 
    esc_html_e('Use the shortcode ', 'pirate-forms');
    ?>
<strong><code>&lt;?php echo do_shortcode( '[pirate_forms]' ) ?&gt;</code></strong><?php 
    esc_html_e(' in the theme\'s files.', 'pirate-forms');
    ?>
</li>
					</ol>

					<hr>

					<div class="rate_plugin_invite">

						<h4><?php 
    esc_html_e('Are you enjoying Pirate Forms?', 'pirate-forms');
    ?>
</h4>

						<p class="review-link"><?php 
    echo sprintf(esc_html__('Rate our plugin on %sWordPress.org%s. We\'d really appreciate it!', 'pirate-forms'), '<a href="https://wordpress.org/support/view/plugin-reviews/pirate-forms" target="_blank" rel="nofollow"> ', '</a>');
    ?>
</p>

						<p><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span></p>

						<p><small><?php 
    echo sprintf(esc_html__('If you want a more complex Contact Form Plugin please check %sthis link%s.', 'pirate-forms'), '<a href="http://www.codeinwp.com/blog/best-contact-form-plugins-wordpress/" target="_blank" >', '</a>');
    ?>
</small></p>
					</div>


				</div>

				<?php 
    $pirate_forms_nr_tabs = 1;
    foreach ($plugin_options as $plugin_options_tab) {
        echo '<div id="' . $pirate_forms_nr_tabs . '" class="pirate-forms-tab-pane">';
        ?>
					<form method="post" class="pirate_forms_contact_settings">

						<?php 
        $pirate_forms_nr_tabs++;
        foreach ($plugin_options_tab as $key => $value) {
            /* Label */
            if (!empty($value[0])) {
                $opt_name = $value[0];
            }
            /* ID */
            $opt_id = $key;
            /* Description */
            if (!empty($value[1])) {
                $opt_desc = $value[1];
            } else {
                $opt_desc = '';
            }
            /* Input type */
            if (!empty($value[2])) {
                $opt_type = $value[2];
            } else {
                $opt_type = '';
            }
            /* Default value */
            if (!empty($value[3])) {
                $opt_default = $value[3];
            } else {
                $opt_default = '';
            }
            /* Value */
            $opt_val = isset($pirate_forms_options[$opt_id]) ? $pirate_forms_options[$opt_id] : $opt_default;
            /* Options if checkbox, select, or radio */
            $opt_options = empty($value[4]) ? array() : $value[4];
            switch ($opt_type) {
                case "title":
                    if (!empty($opt_name)) {
                        echo '<h3 class="title">' . $opt_name . '</h3><hr />';
                    }
                    break;
                case "text":
                    ?>

									<div class="pirate-forms-grouped">

										<label for="<?php 
                    echo $opt_id;
                    ?>
"><?php 
                    echo $opt_name;
                    if (!empty($opt_desc)) {
                        if ($opt_id == "pirateformsopt_email" || $opt_id == "pirateformsopt_email_recipients" || $opt_id == "pirateformsopt_confirm_email") {
                            echo '<span class="dashicons dashicons-editor-help"></span>';
                        }
                        echo '<div class="pirate_forms_option_description">' . $opt_desc . '</div>';
                    }
                    ?>

										</label>

										<input name="<?php 
                    echo $opt_id;
                    ?>
" id="<?php 
                    echo $opt_id;
                    ?>
" type="<?php 
                    echo $opt_type;
                    ?>
" value="<?php 
                    echo stripslashes($opt_val);
                    ?>
" class="widefat">
									</div>

									<?php 
                    break;
                case "textarea":
                    ?>

									<div class="pirate-forms-grouped">

										<label for="<?php 
                    echo $opt_id;
                    ?>
"><?php 
                    echo $opt_name;
                    if (!empty($opt_desc)) {
                        if ($opt_id == "pirateformsopt_confirm_email") {
                            echo '<span class="dashicons dashicons-editor-help"></span>';
                        }
                        echo '<div class="pirate_forms_option_description">' . $opt_desc . '</div>';
                    }
                    ?>

										</label>

										<textarea name="<?php 
                    echo $opt_id;
                    ?>
" id="<?php 
                    echo $opt_id;
                    ?>
" type="<?php 
                    echo $opt_type;
                    ?>
" value="<?php 
                    echo stripslashes($opt_val);
                    ?>
" rows="5" cols="30"></textarea>
									</div>

									<?php 
                    break;
                case "select":
                    ?>
									<div class="pirate-forms-grouped">

										<label for="<?php 
                    echo $opt_id;
                    ?>
"><?php 
                    echo $opt_name;
                    if (!empty($opt_desc)) {
                        echo '<div class="pirate_forms_option_description">' . $opt_desc . '</div>';
                    }
                    ?>

										</label>

										<select name="<?php 
                    echo $opt_id;
                    ?>
" id="<?php 
                    echo $opt_id;
                    ?>
">
											<?php 
                    foreach ($opt_options as $key => $val) {
                        $selected = '';
                        if ($opt_val == $key) {
                            $selected = 'selected';
                        }
                        ?>
												<option value="<?php 
                        echo $key;
                        ?>
" <?php 
                        echo $selected;
                        ?>
><?php 
                        echo $val;
                        ?>
</option>
											<?php 
                    }
                    ?>
										</select>


									</div>

								<?php 
                    break;
                case "checkbox":
                    ?>
									<div class="pirate-forms-grouped">

										<label for="<?php 
                    echo $opt_id;
                    ?>
"><?php 
                    echo $opt_name;
                    if (!empty($opt_desc)) {
                        if ($opt_id == "pirateformsopt_store" || $opt_id == "pirateformsopt_blacklist") {
                            echo '<span class="dashicons dashicons-editor-help"></span>';
                        }
                        echo '<div class="pirate_forms_option_description">' . $opt_desc . '</div>';
                    }
                    ?>

										</label>

										<?php 
                    $checked = '';
                    if (array_key_exists($opt_id, $pirate_forms_options)) {
                        $checked = 'checked';
                    }
                    ?>

											<input type="checkbox" value="yes" name="<?php 
                    echo $opt_id;
                    ?>
" id="<?php 
                    echo $opt_id;
                    ?>
" <?php 
                    echo $checked;
                    ?>
>Yes

									</div>


								<?php 
                    break;
            }
        }
        ?>
						<input name="save" type="submit" value="<?php 
        _e('Save changes', 'pirate-forms');
        ?>
" class="button-primary pirate-forms-save-button">
						<input type="hidden" name="action" value="save">
						<input type="hidden" name="proper_nonce" value="<?php 
        echo wp_create_nonce($current_user->user_email);
        ?>
">

					</form><!-- .pirate_forms_contact_settings -->
					<div class="ajaxAnimation"></div>
				</div><!-- .pirate-forms-tab-pane -->

				<?php 
    }
    ?>

			</div><!-- .pirate-forms-tab-content -->
		</div><!-- .pirate-options -->

		<div class="pirate-subscribe postbox card">
			<h3 class="title"><?php 
    esc_html_e('Get Our Free Email Course', 'islemag');
    ?>
</h3>
			<div class="pirate-forms-subscribe-content">
				<?php 
    if (!empty($_POST["pirate_forms_mail"])) {
        require PIRATE_FORMS_PATH . 'mailin.php';
        $user_info = get_userdata(1);
        $mailin = new Mailin("https://api.sendinblue.com/v2.0", "cHW5sxZnzE7mhaYb");
        $data = array("email" => $_POST["pirate_forms_mail"], "attributes" => array("NAME" => $user_info->first_name, "SURNAME" => $user_info->last_name), "blacklisted" => 0, "listid" => array(51), "blacklisted_sms" => 0);
        $status = $mailin->create_update_user($data);
        if ($status['code'] == 'success') {
            update_option('pirate_forms_subscribe', true);
        }
    }
    $was_submited = get_option('pirate_forms_subscribe', false);
    if ($was_submited == false) {
        echo sprintf('<p> %s </p><form class="pirate-forms-submit-mail" method="post"><input name="pirate_forms_mail" type="email" value="' . get_option('admin_email') . '" /><input class="button" type="submit" value="Submit"></form>', esc_html__('Ready to learn how to reduce your website loading times by half? Come and join the 1st lesson here!', 'pirate-forms'));
    } else {
        echo sprintf('<p> %s </p>', esc_html__('Thank you for subscribing! You have been added to the mailing list and will receive the next email information in the coming weeks. If you ever wish to unsubscribe, simply use the "Unsubscribe" link included in each newsletter.', 'pirate-forms'));
    }
    ?>
			</div>
		</div>



	</div><!-- .wrap -->

	<?php 
}
 /**
  * Get account info
  */
 static function update_account_info()
 {
     $access_key = SIB_Manager::$access_key;
     $mailin = new Mailin(SIB_Manager::sendinblue_api_url, $access_key);
     $response = $mailin->get_account();
     if (is_array($response) && $response['code'] == 'success') {
         $account_data = $response['data'];
         $count = count($account_data);
         SIB_Manager::$account_email = $account_data[$count - 1]['email'];
         SIB_Manager::$account_data = $account_data;
         SIB_Manager::$account_user_name = $account_data[$count - 1]['first_name'] . ' ' . $account_data[$count - 1]['last_name'];
         $account_settings = array('account_email' => SIB_Manager::$account_email, 'account_user_name' => SIB_Manager::$account_user_name, 'account_data' => SIB_Manager::$account_data);
         update_option(SIB_Manager::account_option_name, $account_settings);
     }
 }
Esempio n. 22
0
 /** update smtp details */
 public static function update_smtp_details()
 {
     $mailin = new Mailin('https://api.sendinblue.com/v1.0', SIB_Manager::$access_key, SIB_Manager::$secret_key);
     $response = $mailin->get_smtp_details();
     if ($response['code'] == 'success') {
         if ($response['data']['relay_data']['status'] == 'enabled') {
             self::$smtp_details = $response['data']['relay_data']['data'];
             update_option(self::attribute_smtp_name, self::$smtp_details);
             return true;
         } else {
             self::$smtp_details = array('relay' => false);
             update_option(self::attribute_smtp_name, self::$smtp_details);
             $home_settings = get_option(self::home_option_name, array());
             $home_settings['activate_email'] = 'no';
             update_option(SIB_Manager::home_option_name, $home_settings);
             return false;
         }
     }
     return false;
 }
Esempio n. 23
0
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <*****@*****.**>
* @copyright  2007-2013 PrestaShop SA
* @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../init.php';
include dirname(__FILE__) . '/mailin.php';
if (Tools::getValue('token') != Tools::encrypt(Configuration::get('PS_SHOP_NAME'))) {
    die('Error: Invalid Token');
}
$mailin = new Mailin();
$mailin->userStatus();
echo 'Cron executed successfully';