Exemple #1
0
/**
 * This function converts cid: url's into the ones that can be viewed in
 * the browser.
 *
 * @param  $message  the message object
 * @param  $id       the message id
 * @param  $cidurl   the cid: url.
 * @param  $mailbox  the message mailbox
 * @return           a string with a http-friendly url
 */
function sq_cid2http($message, $id, $cidurl, $mailbox)
{
    /**
     * Get rid of quotes.
     */
    $quotchar = substr($cidurl, 0, 1);
    if ($quotchar == '"' || $quotchar == "'") {
        $cidurl = str_replace($quotchar, "", $cidurl);
    } else {
        $quotchar = '';
    }
    $cidurl = substr(trim($cidurl), 4);
    $match_str = '/\\{.*?\\}\\//';
    $str_rep = '';
    $cidurl = preg_replace($match_str, $str_rep, $cidurl);
    $linkurl = find_ent_id($cidurl, $message);
    /* in case of non-safe cid links $httpurl should be replaced by a sort of
       unsafe link image */
    $httpurl = '';
    /**
     * This is part of a fix for Outlook Express 6.x generating
     * cid URLs without creating content-id headers. These images are
     * not part of the multipart/related html mail. The html contains
     * <img src="cid:{some_id}/image_filename.ext"> references to
     * attached images with as goal to render them inline although
     * the attachment disposition property is not inline.
     */
    if (empty($linkurl)) {
        if (preg_match('/{.*}\\//', $cidurl)) {
            $cidurl = preg_replace('/{.*}\\//', '', $cidurl);
            if (!empty($cidurl)) {
                $linkurl = find_ent_id($cidurl, $message);
            }
        }
    }
    if (!empty($linkurl)) {
        $httpurl = $quotchar . SM_PATH . 'src/download.php?absolute_dl=true&amp;' . "passed_id={$id}&amp;mailbox=" . urlencode($mailbox) . '&amp;ent_id=' . $linkurl . $quotchar;
    } else {
        /**
         * If we couldn't generate a proper img url, drop in a blank image
         * instead of sending back empty, otherwise it causes unusual behaviour
         */
        $httpurl = $quotchar . SM_PATH . 'images/blank.png' . $quotchar;
    }
    return $httpurl;
}
/**
 * This function converts cid: url's into the ones that can be viewed in
 * the browser.
 *
 * @param  $message  the message object
 * @param  $id       the message id
 * @param  $cidurl   the cid: url.
 * @param  $mailbox  the message mailbox
 * @return           a string with a http-friendly url
 */
function sq_cid2http($message, $id, $cidurl, $mailbox)
{
    /**
     * Get rid of quotes.
     */
    $quotchar = substr($cidurl, 0, 1);
    if ($quotchar == '"' || $quotchar == "'") {
        $cidurl = str_replace($quotchar, "", $cidurl);
    } else {
        $quotchar = '';
    }
    $cidurl = substr(trim($cidurl), 4);
    $linkurl = find_ent_id($cidurl, $message);
    /* in case of non-save cid links $httpurl should be replaced by a sort of
       unsave link image */
    $httpurl = '';
    if ($linkurl) {
        $httpurl = $quotchar . SM_PATH . 'src/download.php?absolute_dl=true&amp;' . "passed_id={$id}&amp;mailbox=" . urlencode($mailbox) . '&amp;ent_id=' . $linkurl . $quotchar;
    }
    return $httpurl;
}