Пример #1
0
/**
 * handler for dl requests
 */
function ProcessDlRequest()
{
    global $config;
    global $http_return_code;
    /* run this puppy through premailer */
    $premailer = Premailer::html($_POST["html"], true, "hpricot", $config[BASE_URL]);
    $html = $premailer["html"];
    /* create static versions of resized images */
    $matches = [];
    $num_full_pattern_matches = preg_match_all('#<img.*?src="([^"]*?\\/[^/]*\\.[^"]+)#i', $html, $matches);
    for ($i = 0; $i < $num_full_pattern_matches; $i++) {
        if (stripos($matches[1][$i], "/img?src=") !== FALSE) {
            $src_matches = [];
            if (preg_match('#/img\\?src=(.*)&amp;method=(.*)&amp;params=(.*)#i', $matches[1][$i], $src_matches) !== FALSE) {
                $file_name = urldecode($src_matches[1]);
                $file_name = substr($file_name, strlen($config[BASE_URL] . $config[UPLOADS_URL]));
                $method = urldecode($src_matches[2]);
                $params = urldecode($src_matches[3]);
                $params = explode(",", $params);
                $width = (int) $params[0];
                $height = (int) $params[1];
                $static_file_name = $method . "_" . $width . "x" . $height . "_" . $file_name;
                $html = str_ireplace($matches[1][$i], $config[BASE_URL] . $config[STATIC_URL] . urlencode($static_file_name), $html);
                $image = ResizeImage($file_name, $method, $width, $height);
                $image->writeImage($config[BASE_DIR] . $config[STATIC_DIR] . $static_file_name);
            }
        }
    }
    /* perform the requested action */
    switch ($_POST["action"]) {
        case "download":
            header("Content-Type: application/force-download");
            header("Content-Disposition: attachment; filename=\"" . $_POST["filename"] . "\"");
            header("Content-Length: " . strlen($html));
            echo $html;
            break;
        case "email":
            $to = $_POST["rcpt"];
            $subject = $_POST["subject"];
            $headers = array();
            $headers[] = "MIME-Version: 1.0";
            $headers[] = "Content-type: text/html; charset=iso-8859-1";
            $headers[] = "To: {$to}";
            $headers[] = "Subject: {$subject}";
            $headers = implode("\r\n", $headers);
            if (mail($to, $subject, $html, $headers) === FALSE) {
                $http_return_code = 500;
                return;
            }
            break;
    }
}
Пример #2
0
';
        $html .= '<div id="invoice" style="width: ' . $max_width . 'px; margin: 0 auto;">' . "\n" . $invoice . "\n</div>\n";
        $html .= '</body>' . "\n";
        // Remove all "\r" in emails to avoid double line breaks
        $html = str_replace("\r", '', $html);
        // Make email headers
        $headers = 'MIME-Version: 1.0' . "\n";
        $headers .= 'Content-type: text/html; charset="' . $charset . '"' . "\n";
        $headers .= "Return-Path: {$shop_email}" . "\n";
        $headers .= "Reply-To: {$shop_email}" . "\n";
        $headers .= "From: {$shop_name} <{$shop_email}>";
        // Premailer => bring css inline
        // @link http://premailer.dialect.ca/api
        // @link https://gist.github.com/barock19/1591053
        require_once 'library/premailer.php';
        $pre = Premailer::html($html);
        // $html  = $pre['html'];
        // $plain = $pre['plain'];
        // Send invoice email to customer
        if (mail($cust_email, $email_subject, $pre['html'], $headers)) {
            // On success increment email counter
            $database->query("UPDATE " . TABLE_PREFIX . "mod_bakery_customer SET sent_invoices = sent_invoices + '1' WHERE order_id = '{$order_id}'");
            // On success view confirmation
            $admin->print_success($MOD_BAKERY['TXT_INVOICE_HAS_BEEN_SENT_SUCCESSFULLY'], WB_URL . '/modules/bakery/modify_orders.php?page_id=' . $page_id);
        } else {
            $admin->print_error($database->get_error(), WB_URL . '/modules/bakery/modify_orders.php?page_id=' . $page_id);
        }
    }
}
// Print admin footer
$admin->print_footer();
Пример #3
0
<?php

chdir("..");
require "config.php";
require "dl/premailer.php";
/* run this puppy through premailer */
$base_url = (isset($_SERVER["HTTPS"]) ? "https" : "http") . "://" . $_SERVER["SERVER_NAME"] . dirname(dirname($_SERVER["PHP_SELF"])) . "/";
$premailer = Premailer::html($_POST["html"], true, "hpricot", $base_url);
$html = $premailer["html"];
/* create static versions of resized images */
$num_full_pattern_matches = preg_match_all('#<img.*?src="([^"]*?\\/[^/]*\\.[^"]+)#i', $html, $matches);
for ($i = 0; $i < $num_full_pattern_matches; $i++) {
    if (stripos($matches[1][$i], "/img?src=") !== FALSE) {
        if (preg_match('#/img\\?src=(.*)&amp;method=(.*)&amp;params=(.*)#i', $matches[1][$i], $src_matches) !== FALSE) {
            $file_name = urldecode($src_matches[1]);
            $file_name = substr($file_name, strlen($uploads_dir));
            $method = urldecode($src_matches[2]);
            $params = urldecode($src_matches[3]);
            $params = explode(",", $params);
            $width = (int) $params[0];
            $height = (int) $params[1];
            $static_file_name = $static_dir . $method . "_" . $width . "x" . $height . "_" . $file_name;
            $html = str_ireplace($matches[1][$i], $base_url . urlencode($static_file_name), $html);
            require "img/resize.php";
            $image->writeImage($static_file_name);
        }
    }
}
/* perform the requested action */
switch ($_POST["action"]) {
    case "download":