Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?
2
	$self=basename($PHP_SELF);
3
	$DB="verteiler";
4
	define ("modul_name", "mail_verteiler");
5
	define ("tool_name", "versenden");
6
	require_once "../Online-Shop/connect2.php";
7
 
8
	if (!isset($user_rechte[mail_verteiler][versenden][html]))
9
	{
10
		header("Location: mailVerteilerSelect.php");
11
	}
12
 
13
	if ($action)
14
	{
15
 
16
		$query="SELECT * FROM Verteiler where ID = $Verteiler_NR";
17
		$result_Verteiler = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
18
		$Verteiler=mysql_fetch_array($result_Verteiler);
19
 
20
		$headers["From"]="From: $Verteiler[Absender]";
21
		//$headers["CC"]="";
22
		//$headers["BCC"]="";
23
 
24
		unset($text);
25
		$action="MIXED";
26
		switch ($action)
27
		{
28
			case "ATTACHMENTS":
29
				srand ((double)microtime()*1000000);
30
				$splitter = rand();
31
 
32
				$headers["Mime_header0"]="Mime-Version: 1.0";
33
				$headers["Mime_header1"]="Content-Type: multipart/mixed;";
34
				$headers["Mime_header2"]="\tboundary=\"----SPLITTER_".$splitter."_0\"";
35
				$headers["Mime_header3"]="This is a multi-part message in MIME format.";
36
				$headers=implode("\n",$headers);
37
 
38
				if ($attach)
39
				{
40
					foreach (array_keys($attach) as $elem)
41
					{
42
						if ($attach[$elem] != "none")
43
						{
44
							$filename = $attach[$elem];
45
							$fd = fopen ($filename, "r");
46
							$contents = fread ($fd, filesize ($filename));
47
							fclose ($fd);
48
 
49
							$daten = chunk_split (base64_encode($contents));
50
 
51
							$attach_text = array(
52
								"------SPLITTER_".$splitter."_0",
53
								"Content-Type: ".$attach_type[$elem].";",
54
								"\tname=\"".$attach_name[$elem]."\"",
55
								"Content-Transfer-Encoding: base64",
56
								"Content-Disposition: attachment;",
57
								"\tfilename=\"".$attach_name[$elem]."\"",
58
								"\n",
59
								$daten,
60
								"\n"
61
								);
62
							$attach_text = implode("\n",$attach_text);
63
							$attachments = $attachments.$attach_text;
64
						}
65
					}
66
				}
67
 
68
				$text = array(
69
					"------SPLITTER_".$splitter."_0",
70
					"Content-Type: multipart/alternative;",
71
					"\tboundary=\"----SPLITTER_".$splitter."_1\"\n\n",
72
					"------SPLITTER_".$splitter."_1",
73
					"Content-Type: text/plain;",
74
					"\tcharset=\"iso-8859-1\"",
75
					"Content-Transfer-Encoding: quoted-printable\n",
76
					$Verteiler[Begruessung],
77
					$message[PLAIN],
78
					$Verteiler[Schlusstext],
79
					"\n\n------SPLITTER_".$splitter."_1--",
80
					$attachments,
81
					"\n\n------SPLITTER_".$splitter."_0--"
82
					);
83
				$text = implode("\n",$text);
84
			break;
85
 
86
			case "MIXED":
87
				/* INIT $boundary */
88
				srand ((double)microtime()*1000000);
89
				$boundary="";
90
				for ($a=0; $a <= 15; $a++)
91
				{
92
					$boundary=$boundary.sprintf("%02X",rand(0,255));
93
				}
94
				$boundary="=_".$boundary;
95
 
96
				$headers["MIME-Version"]	=	"MIME-Version: 1.0";
97
				$headers["Content-Type"]	=	"Content-Type: multipart/alternative;";
98
				$headers["boundary"]		=	chr(9)."boundary=\"".$boundary."\"";
99
 
100
				$CONTENT_HEADERS=array
101
				(
102
					"PLAIN" => array(
103
					"--".$boundary,
104
					"Content-Type: text/plain; charset=\"ISO-8859-1\"",
105
					"Content-Transfer-Encoding: 7bit",
106
					"",""
107
					),
108
					"HTML" => array(
109
					"",
110
					"--".$boundary,
111
					"Content-Type: text/html; charset=\"ISO-8859-1\"",
112
					"Content-Transfer-Encoding: quoted-printable",
113
					"",""
114
					)
115
				);
116
 
117
				$message[HTML]=stripslashes(preg_replace ("/=/", "=3D", $message[HTML]."<br><br><a href=\"[logout_link]\">Newsletter abbestellen</a>"));
118
				$message[PLAIN]=$message[PLAIN]."\n\n[logout_link]";
119
 
120
				foreach(array_keys($CONTENT_HEADERS) as $elem)
121
				{
122
					$message[$elem]=join($CONTENT_HEADERS[$elem],"\n").$message[$elem];
123
				}
124
				$text=join($message,"\n")."\n--".$boundary."--\n";
125
			break;
126
 
127
			default:
128
				$text = array(
129
					$Verteiler[Begruessung],
130
					$message[PLAIN],
131
					$Verteiler[Schlusstext],
132
					"\n\n[logout_link]",
133
					);
134
				$text = implode("\n",$text);
135
			break;
136
		} // end of switch
137
 
138
		// Mailadressen filtern und formatieren
139
		preg_match_all("/[A-Za-z0-9-_.+]+\@[A-Za-z0-9-_.+]+\.[A-Za-z]+/", $To, $matches);
140
		$matches=$matches[0];
141
 
142
		foreach($matches as $mailadresse)
143
		{
144
			$logout_link = $web_rechte[mail_verteiler][verteiler][logout_link]."?m=".$mailadresse."&v=".$Verteiler[ID];
145
 
146
			$text2=preg_replace
147
			(
148
				"/\[logout_link\]/",
149
				stripslashes
150
				(
151
					preg_replace
152
					(
153
						"/=/",
154
						"=3D",
155
						$logout_link
156
					)
157
				),
158
				$text
159
			);
160
			// Mails verschicken wird überbewertet!
161
			//mail($mailadresse, $Verteiler[Betreff], $text2, implode("\n",$headers));
162
			// In den Mailspool packen
163
 
164
				$mail[webs_ID] = $webs[ID];
165
				$mail[to] = $mailadresse;
166
				$mail[cc] = '';
167
				$mail[bcc] = '';
168
				$mail[subject] = $Verteiler[Betreff];
169
				$mail[from] = $Verteiler[Absender];
170
				$mail[header_add] = implode("\n",$headers);
171
				$mail[text] = $text2;
172
				$mail[takeoff] = date("Y-m-d H:i:s"); // Takeoff ist immer NOW (Format: "2005-10-20 13:17:23"
173
				$mail[erstellt_von] = $PHP_AUTH_USER;
174
 
175
				$query_spool = "USE content_management";
176
				$result = mysql_query ($query_spool, $localhost_dbh) or die (mysql_errno().": ".mysql_error()."<hr>$query_spool<hr>");
177
 
178
				$query_spool = "
179
					INSERT INTO
180
						`mailspool_out`
181
					(
182
						`ID` ,
183
						`webs_ID` ,
184
						`to` ,
185
						`cc` ,
186
						`bcc` ,
187
						`subject` ,
188
						`from` ,
189
						`header_add` ,
190
						`text` ,
191
						`takeoff` ,
192
						`erstellt_am` ,
193
						`erstellt_von`
194
					)
195
					VALUES
196
					(
197
						'',
198
						'$mail[webs_ID]',
199
						'$mail[to]',
200
						'$mail[cc]' ,
201
						'$mail[bcc]' ,
202
						'$mail[subject]',
203
						'$mail[from]',
204
						'$mail[header_add]',
205
						'$mail[text]',
206
						'$mail[takeoff]',
207
						NOW(),
208
						'$mail[erstellt_von]'
209
					);
210
				";
211
				$result = mysql_query ($query_spool, $localhost_dbh) or die (mysql_errno().": ".mysql_error()."<hr>$query_spool<hr>");
212
 
213
 
214
 
215
		}
216
		header("Location: mailsent.php?count=".count($matches));
217
	} // end of if ($action)
218
 
219
	$Verteiler=array();
220
	$result = mysql_query ("SELECT * FROM Verteiler order by name") or die (mysql_errno().": ".mysql_error());
221
	while($zeile=mysql_fetch_array($result))
222
	{
223
		$Verteiler[$zeile[ID]]=$zeile;
224
	}
225
 
226
	if (!$Verteiler_NR)
227
	{
228
		$Verteiler_NR = array_keys($Verteiler);
229
		$Verteiler_NR = $Verteiler_NR[0];
230
	}
231
?>
232
<html>
233
<head>
234
<title>Mail versenden</title>
235
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
236
<meta name="author" content="Webagentur Niewerth - www.weban.de">
237
<meta name="revisit-after" content="30 days">
238
<meta name="language" content="deutsch, de">
239
<meta name="distribution" content="global">
240
<meta name="robots" content="all">
241
<link rel=stylesheet type="text/css" href="../buttons.css">
242
<style type="text/css">
243
<!--
244
a {  color: #<? echo $webs[font_color_rechts] ?>}
245
-->
246
</style>
247
<script type="text/javascript">
248
   _editor_url = "../htmlarea/";
249
   _editor_lang = "de";
250
</script>
251
<script type="text/javascript" src="../htmlarea/htmlarea.js"></script>
252
</head>
253
 
254
<body bgcolor="#<? echo $webs[bgcolor_seite] ?>" leftmargin="20" topmargin="10" marginwidth="20" marginheight="10" text="#<? echo $webs[font_color_rechts] ?>">
255
<font color="#FF0000" size="+1">Modul NICHT benutzen! "Bauarbeiten"!</font>
256
<form method="post" action="#" enctype="multipart/form-data">
257
  <table width="600" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
258
    <tr>
259
      <td bgcolor="#<? echo $webs[bgcolor_links] ?>" class="headline" colspan="2">Verteiler
260
        senden: <input type="hidden" name="Verteiler_NR" value="<?=$_REQUEST[Verteiler_NR];?>"></td>
261
    </tr>
262
    <tr>
263
      <td bgcolor="#<? echo $webs[bgcolor_links] ?>" class="headline" width="20%" valign="top">An:<? echo $web_rechte[mail_verteiler][versenden][grundfunktionen]; ?></td>
264
      <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
265
	  <?
266
		$to=array();
267
  		$query="
268
			SELECT DISTINCT
269
				Logins.E_Mail,
270
				MD5(Logins.E_Mail) as MD5
271
			FROM
272
				Logins,
273
				Logins_to_Verteiler
274
			WHERE
275
				Logins.ID = Logins_to_Verteiler.Logins
276
			AND
277
				Logins_to_Verteiler.Verteiler = '".$_REQUEST[Verteiler_NR]."'
278
			ORDER BY
279
				ID
280
		";
281
		$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
282
		$count = mysql_num_rows($result);
283
		while ($zeile=mysql_fetch_assoc($result))
284
		{
285
			if (preg_match("/^[A-Za-z0-9-_.+]+\@[A-Za-z0-9-_.+]+\.[A-Za-z]+$/", $zeile[E_Mail]) > 0)
286
			{
287
				$to[$zeile[MD5]]=$zeile[E_Mail];
288
			}
289
		}
290
	  ?>
291
	  <textarea name="To" cols="55" rows="10"><? echo implode(",\n",$to) ?></textarea>
292
	  <br>
293
	  Anzahl der ausgelesenen Empf&auml;nger:	  <?=count($to);?>
294
	  </td>
295
    </tr>
296
    <tr>
297
      <td bgcolor="#<? echo $webs[bgcolor_links] ?>" class="headline" width="20%" valign="top">Absender:</td>
298
      <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>"><? echo nl2br($Verteiler[$Verteiler_NR][Absender]) ?></td>
299
    </tr>
300
    <tr>
301
      <td bgcolor="#<? echo $webs[bgcolor_links] ?>" class="headline" width="20%" valign="top">Betreff:</td>
302
      <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>"><? echo nl2br($Verteiler[$Verteiler_NR][Betreff]) ?></td>
303
    </tr>
304
    <tr>
305
      <td bgcolor="#<? echo $webs[bgcolor_links] ?>" class="headline" width="20%" valign="top">Begr&uuml;ssung:</td>
306
      <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>"><? echo nl2br($Verteiler[$Verteiler_NR][Begruessung]) ?></td>
307
    </tr>
308
    <tr>
309
      <td bgcolor="#<? echo $webs[bgcolor_links] ?>" class="headline" width="20%" valign="top">Text:
310
        (Plain) </td>
311
      <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
312
        <textarea name="message[PLAIN]" cols="100" rows="10" wrap="OFF"></textarea>
313
      </td>
314
    </tr>
315
	<tr>
316
      <td bgcolor="#<? echo $webs[bgcolor_links] ?>" class="headline" width="20%" valign="top">Text:
317
        (HTML) </td>
318
      <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
319
        <textarea id=messageHTML name="message[HTML]" cols="100" rows="100" wrap="OFF">
320
<?
321
	if ($Verteiler[$_GET[Verteiler_NR]][Template_URL])
322
	{
323
?>
324
<p><?=nl2br($Verteiler[$Verteiler_NR][Begruessung])?></p>
325
<p></p>
326
<? readfile($Verteiler[$_GET[Verteiler_NR]][Template_URL]);?>
327
<p></p>
328
<p><?=nl2br($Verteiler[$Verteiler_NR][Schlusstext])?></p>
329
<?
330
	}
331
?>
332
		</textarea>
333
<script type="text/javascript">
334
	var config = new HTMLArea.Config();
335
	with (config)
336
	{
337
		width = '555';
338
		height = '500';
339
		statusBar=false;
340
		toolbar =
341
		[
342
			[
343
				"fontname", "space", "fontsize", "space", "formatblock", "space",
344
				"bold", "italic", "underline", "separator",
345
				"strikethrough", "subscript", "superscript", "separator",
346
				"copy", "cut", "paste", "separator", "undo", "redo"
347
			],
348
			[
349
				"justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
350
				"insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
351
				"forecolor", "hilitecolor", "textindicator", "separator",
352
				"inserthorizontalrule", "createlink", "insertimage", "htmlmode"
353
			]
354
		];
355
 
356
		/*
357
		toolbar =
358
		[
359
			[
360
				"fontname", "space", "fontsize", "space", "formatblock", "space",
361
				"bold", "italic", "underline", "separator",
362
				"strikethrough", "subscript", "superscript", "separator",
363
				"copy", "cut", "paste", "space", "undo", "redo",
364
				"separator",
365
				"justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
366
				"insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
367
				"forecolor", "hilitecolor", "textindicator", "separator",
368
				"inserthorizontalrule", "createlink", "insertimage", "htmlmode",
369
			]
370
		];
371
		*/
372
	}
373
	HTMLArea.replace("messageHTML",config);
374
</script>
375
      </td>
376
    </tr>
377
    <tr>
378
      <td bgcolor="#<? echo $webs[bgcolor_links] ?>" class="headline" width="20%" valign="top">Schlusstext:</td>
379
      <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>"><? echo nl2br($Verteiler[$Verteiler_NR][Schlusstext]) ?></td>
380
    </tr>
381
    <!--
382
    <tr>
383
      <td bgcolor="#<? echo $webs[bgcolor_links] ?>" class="headline" valign="top" width="20%">Attachments:</td>
384
      <td bgcolor="#<? echo $webs[bgcolor_rechts] ?>">
385
        <input type="file" name="attach[]">
386
        <br>
387
        <input type="file" name="attach[]">
388
        <br>
389
        <input type="file" name="attach[]">
390
        <br>
391
        <input type="file" name="attach[]">
392
        <br>
393
        <input type="file" name="attach[]">
394
      </td>
395
    </tr>
396
-->
397
    <tr align="right">
398
      <td bgcolor="#<? echo $webs[bgcolor_links] ?>" class="headline" colspan="2">
399
        <input type="submit" name="action" value="Abschicken">
400
        <input type="reset" value="Zur&uuml;cksetzen">
401
      </td>
402
    </tr>
403
  </table>
404
</form>
405
</body>
406
</html>