Exemplo n.º 1
0
 public static function l($string, $specific = false)
 {
     $module = new Mailjet();
     if ($string == $module->l($string, $specific)) {
         $trad_file = _PS_MODULE_DIR_ . 'mailjet/translations/' . Context::getContext()->language->iso_code . '.php';
         if (file_exists($trad_file)) {
             $_MODULE = array();
             @(include $trad_file);
             $key = '<{mailjet}prestashop>segmentation_' . md5(str_replace('\'', '\\\'', $string));
             /*
             if (!isset($_MODULE[$key]) && Context::getContext()->language->iso_code!='en')
             {
             	$f = fopen($trad_file,"a+");
             		fwrite($f, '$_MODULE[\''.$key.'\'] = \''.$string.'\';'.PHP_EOL);
             		fclose($f);
             }
             */
         }
         return isset($_MODULE[$key]) ? $_MODULE[$key] : $module->l($string, $specific);
     } else {
         return $module->l($string, $specific);
     }
 }
Exemplo n.º 2
0
* THE SOFTWARE.
*
*  @author Dream me up
*  @copyright  2011 Mailjet SAS
*  @license    hhttp://opensource.org/licenses/mit-license  MIT License
*  International Registred Trademark & Property of Mailjet SAS
*/
require '../../config/config.inc.php';
require 'mailjet.php';
if (Tools::getValue('token') == '' || Tools::getValue('token') != Configuration::get('MAILJET_AJAX_TOKEN')) {
    die('Invalid Token');
}
$obj_mailjet = new Mailjet();
$email_from = urldecode($_GET['email_from']);
try {
    $sujet = $obj_mailjet->l('Mailjet Test E-mail');
    $message = $obj_mailjet->l('Hello') . ",\r\n\r\n" . $obj_mailjet->l('This E-mail confirms you that Mailjet has successfully been installed on your shop.');
    $result = Mail::sendMailTest(true, "in.mailjet.com", $message, $sujet, "text/plain", $email_from, $email_from, $_GET['mailjet_api_key'], $_GET['mailjet_secret_key'], $smtpPort = 465, "tls");
    if ($result === true) {
        echo "true";
    } else {
        if ($result == 999) {
            $result = $obj_mailjet->l('The E-mail was not successfully sent');
        }
        echo "false|" . $result;
        reset_config_mailjet();
    }
} catch (Exception $e) {
    echo "false|" . $e->getMessage();
    reset_config_mailjet();
}
Exemplo n.º 3
0
    header('Pragma: no-cache');
    exit;
}
$post = trim(Tools::file_get_contents('php://input'));
/* mail("*****@*****.**", "callback ajax mailjet", $post.print_r($_POST, true).print_r($_GET, true)); */
/* die(); */
require_once _PS_ROOT_DIR_ . '/config/config.inc.php';
$method = Tools::getValue('method');
$back_office_method = Tools::getValue('back_office_method');
if (in_array($method, $back_office_method)) {
    define('_PS_ADMIN_DIR_', true);
}
require_once _PS_MODULE_DIR_ . 'mailjet/mailjet.php';
$method = Tools::isSubmit('method') ? Tools::getValue('method') : '';
$token = Tools::isSubmit('token') ? Tools::getValue('token') : '';
$mj = new Mailjet();
$result = array();
MailJetLog::write(MailJetLog::$file, 'New request sent');
if ($mj->getToken() != Tools::getValue('token')) {
    $result['error'] = $mj->l('Bad token sent');
} else {
    if (!method_exists($mj, $method)) {
        $result['error'] = $mj->l('Method requested doesn\'t exist:') . ' ' . $method;
    } else {
        $result = $mj->{$method}();
    }
}
$message = isset($result['error']) ? $result['error'] : 'Success with method: ' . $method;
MailJetLog::write(MailJetLog::$file, $message);
header('Content-Type: application/json');
die(Tools::jsonEncode($result));