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 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
45 function insertNewsletterUrls ($text) {
48 // First replace URLs...
49 while (ereg('http://', $test)) {
50 $check = substr($test, strpos($test, 'http://')); $check2 = $check;
52 // See ext-html.php if you want to add more URL ends...
53 foreach ($GLOBALS['url_ends'] as $end) {
54 if (ereg($end, $check)) $check = substr($check, 0, strpos($check, $end));
57 // Now replace the URL against anchor container and pray...
58 $text = substr($text, 0, strpos($text, $check2)) . generateDerefererUrl($check) . substr($text, strpos($text, $check2) + strlen($check));
60 // Finally remove the url from testing string (or we have a loop and maybe server overload!)
61 $test = substr($test, strpos($test, $check) + strlen($check));
64 // Now do the (nearly) same thing with email addresses
65 // but now we have the problem that email addresses didn't have
66 // a start mark like http:// and our templates are lame didn't have
70 // ... what will the email address be out the @... ;-)
72 while (ereg('@', $test)) {
73 $pos = strpos($test, '@');
74 $test2 = substr($test, 0, $pos);
76 // First check backwards
79 $check = substr($test2, $idx, 1);
80 if (!in_array($check, $GLOBALS['valid_email_chars']))
82 // Char found so we end here
89 // Starting mark is found
90 $check2 = substr($test, 0, ($idx + 1));
91 $test = substr($test, ($idx + 1));
94 // And now go forward...
96 while ($idx < strlen($test)) {
97 $check = substr($test, $idx, 1);
98 if ((!in_array($check, $GLOBALS['valid_email_chars'])) && ($check != '@')) {
99 // Char found so end here again
106 // Maybe this is the email address?
107 $check = substr($test, 0, $idx);
110 // Now replace the email against anchor with mailto and pray...
111 $PARTS[] = $check2 . $check;
113 // Remove email from testing string (see above why...)
114 $test = substr($test, strlen($check));
117 // Now put all parts together
118 $text = ''; $PARTS[] = $test;
119 foreach ($PARTS as $part) {
123 // Compile possible own HTML tags out...
124 return compileCode($text);
127 // Wrapper for sending newsletter and wrapping URLs / HTML mail
128 function sendNewsletter ($to, $subject, $message, $mode) {
129 // Send mail away as HTML
130 if (postRequestElement('auto_urls') == 'Y') {
131 // Automatically insert URLs into newsletter
132 if ((isExtensionActive('html_mail')) && ($mode == 'html')) {
134 sendEmail($to, $subject, insertUrlsIntoHtml($message), 'Y');
137 sendEmail($to, $subject, insertNewsletterUrls($message), 'N');
141 if ((isExtensionActive('html_mail')) && ($mode == 'html')) {
142 sendEmail($to, $subject, $message, 'Y');
144 sendEmail($to, $subject, $message, 'N');