2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 04/25/2004 *
4 * =================== Last change: 04/29/2004 *
6 * -------------------------------------------------------------------- *
7 * File : newsletter_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Functions for the HTML extension *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Funktionen fuer die HTML-Erweiterung *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
46 function insertNewsletterUrls ($text) {
49 // First replace URLs...
50 while (isInString('http://', $test)) {
51 $check = substr($test, strpos($test, 'http://')); $check2 = $check;
53 // See ext-html.php if you want to add more URL ends...
54 foreach ($GLOBALS['url_ends'] as $end) {
55 if (isInString($end, $check)) $check = substr($check, 0, strpos($check, $end));
58 // Now replace the URL against anchor container and pray...
59 $text = substr($text, 0, strpos($text, $check2)) . generateDerefererUrl($check) . substr($text, strpos($text, $check2) + strlen($check));
61 // Finally remove the url from testing string (or we have a loop and maybe server overload!)
62 $test = substr($test, strpos($test, $check) + strlen($check));
65 // Now do the (nearly) same thing with email addresses
66 // but now we have the problem that email addresses didn't have
67 // a start mark like http:// and our templates are lame didn't have
71 // ... what will the email address be out the @... ;-)
73 while (isInString('@', $test)) {
74 $pos = strpos($test, '@');
75 $test2 = substr($test, 0, $pos);
77 // First check backwards
80 $check = substr($test2, $idx, 1);
81 if (!in_array($check, $GLOBALS['valid_email_chars']))
83 // Char found so we end here
90 // Starting mark is found
91 $check2 = substr($test, 0, ($idx + 1));
92 $test = substr($test, ($idx + 1));
95 // And now go forward...
97 while ($idx < strlen($test)) {
98 $check = substr($test, $idx, 1);
99 if ((!in_array($check, $GLOBALS['valid_email_chars'])) && ($check != '@')) {
100 // Char found so end here again
107 // Maybe this is the email address?
108 $check = substr($test, 0, $idx);
111 // Now replace the email against anchor with mailto and pray...
112 $PARTS[] = $check2 . $check;
114 // Remove email from testing string (see above why...)
115 $test = substr($test, strlen($check));
118 // Now put all parts together
119 $text = ''; $PARTS[] = $test;
120 foreach ($PARTS as $part) {
124 // Pre-ompile possible own HTML tags out...
125 return preCompileCode($text);
128 // Wrapper for sending newsletter and wrapping URLs / HTML mail
129 function sendNewsletter ($to, $subject, $message, $mode) {
130 // Send mail away as HTML
131 if (postRequestParameter('auto_urls') == 'Y') {
132 // Automatically insert URLs into newsletter
133 if ((isExtensionActive('html_mail')) && ($mode == 'html')) {
135 sendEmail($to, $subject, insertUrlsIntoHtml($message), 'Y');
138 sendEmail($to, $subject, insertNewsletterUrls($message), 'N');
142 if ((isExtensionActive('html_mail')) && ($mode == 'html')) {
143 sendEmail($to, $subject, $message, 'Y');
145 sendEmail($to, $subject, $message, 'N');