Subversion-Projekte lars-tiefland.content-management

Revision

Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
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
    set_time_limit( 0 );
8
 
9
    if ( !isset( $user_rechte["mail_verteiler"]["versenden"]["html"] ) )
10
    {
11
        header( "Location: mailVerteilerSelect.php" );
12
    }
13
 
14
    function getVerteiler( $Verteiler_NR )
15
    {
16
        $query = "SELECT
17
                *
18
            FROM
19
                Verteiler
20
            WHERE
21
                ID = $Verteiler_NR
22
        ";
23
        $result_Verteiler = mysql_query( $query ) or die( mysql_errno() .
24
            ": " . mysql_error() . "<hr>$query<hr>" );
25
        return mysql_fetch_assoc( $result_Verteiler );
26
    }
27
 
28
    function boundary()
29
    {
30
        return md5( rand() );
31
    }
32
 
33
 
34
    function getShopsIdFromTemplateURL( $tplURL )
35
    {
36
        $shops_ID = null;
37
        $url = parse_url( $tplURL );
38
        $domain = str_replace( "www.", "", $url['host'] );
39
        $domain = str_replace( ".local", "", $domain );
40
 
41
        $sql = "SELECT
42
                ID
43
            FROM
44
                shops
45
            WHERE
46
                domain = '" . $domain . "'
47
        ";
48
        if ( $q = mysql_query( $sql ) )
49
        {
50
            if ( $r = mysql_fetch_assoc( $q ) )
51
            {
52
                $shops_ID = $r['ID'];
53
            }
54
        }
55
        return $shops_ID;
56
    }
57
 
58
 
59
    if ( $action )
60
    {
61
        $Verteiler = getVerteiler( $Verteiler_NR );
62
        $boundary = boundary();
63
        $msgBoundary = boundary();
64
 
65
 
66
        /* LOGOUT-LINK an eingegebene Nachrichten anhängen */
67
        if ( !empty( $web_rechte["mail_verteiler"]["verteiler"]["logout_link"] ) )
68
        {
69
            //$message[PLAIN] = $message[PLAIN] . "\n\n##logout_link##";
70
            $message["HTML"] = $message["HTML"] . "<br><br><a href=\"##logout_link##\">Newsletter abbestellen</a>";
71
        }
72
        else
73
        {
74
            //$message[PLAIN]=$message[PLAIN];
75
            //$message[HTML]=stripslashes(preg_replace ("/=/", "=3D", $message[HTML]));
76
        }
77
 
78
 
79
        /* ############################################################################################ */
80
        /* Headers zusammenstellen                                                                    */
81
        /* ############################################################################################ */
82
 
83
        $headers = array( "From: $Verteiler[Absender]", "MIME-Version: 1.0",
84
            "Content-Type: multipart/mixed;", "    boundary=\"" . $boundary .
85
            "\"" );
86
 
87
        /* ############################################################################################ */
88
        /* Nachricht zusammenstellen                                                                    */
89
        /* ############################################################################################ */
90
 
91
        /*
92
        $msg = array( // "alternative"-Header
93
        "--" . $boundary, "Content-Type: multipart/alternative;",
94
        "    boundary=\"" . $msgBoundary . "\"", "", // TEXT HEADER
95
        "--" . $msgBoundary, "Content-Type: text/plain; charset=\"ISO-8859-1\"",
96
        "Content-Transfer-Encoding: 7bit", "", $message["PLAIN"], "", "",
97
        // HTML HEADER
98
        "--" . $msgBoundary, "Content-Type: text/html; charset=\"ISO-8859-1\"",
99
        "Content-Transfer-Encoding: 7bit", "", $message["HTML"], "",
100
        "--" . $msgBoundary . "--", "" );
101
        */
102
        $msg = array( $message["PLAIN"], $message["HTML"] );
103
 
104
        if ( is_array( $_FILES["attach"]["error"] ) )
105
        {
106
            foreach ( array_keys( $_FILES["attach"]["error"] ) as $fileIndex =>
107
                $errorCode )
108
            {
109
                if ( $_FILES["attach"]["error"][$fileIndex] == 0 )
110
                {
111
                    $msg = array_merge( $msg, array( "--" . $boundary,
112
                        "Content-Type: " . $_FILES["attach"]["type"][$fileIndex] .
113
                        ";", "\tname=\"" . $_FILES["attach"]["name"][$fileIndex] .
114
                        "\"", "Content-Transfer-Encoding: base64",
115
                        "Content-Disposition: attachment;", "\tfilename=\"" .
116
                        $_FILES["attach"]["name"][$fileIndex] . "\"", "",
117
                        chunk_split( base64_encode( file_get_contents( $_FILES["attach"]["tmp_name"][$fileIndex] ) ) ),
118
                        "", "" ) );
119
                }
120
            }
121
        }
122
 
123
 
124
        //$textRaw = join( "\n", $msg ) . "\n\n--" . $boundary . "--\n\n";
125
        $textRaw = join( "\n", $msg );
126
 
127
        /* ############################################################################################ */
128
        /* Nachricht zusammenstellen ENDE                                                                */
129
        /* ############################################################################################ */
130
 
131
        $getValue = create_function( '$value,$key',
132
            'echo "zzz ".$key." zzz"; return $value[$key];' );
133
 
134
        $To = preg_replace( "/\|/", "", $To );
135
        $To = explode( "\n", trim( $To ) );
136
        //exit;
137
 
138
        if ( $_REQUEST["gutscheinvorlagenid"] )
139
        {
140
            $gs_vorlage = leseGutscheinvorlage( $_REQUEST["gutscheinvorlagenid"] );
141
        }
142
        foreach ( $To as $ToIndex => $ToValue )
143
        {
144
            $value = explode( ";", trim( $ToValue ) );
145
            $logout_link = ( !empty( $web_rechte["mail_verteiler"]["verteiler"]["logout_link"] ) ) ?
146
                $web_rechte["mail_verteiler"]["verteiler"]["logout_link"] .
147
                "?m=" . $value[0] . "&v=" . $Verteiler["ID"] : "";
148
 
149
 
150
            $value = array_merge( array( "logout_link" => $logout_link,
151
                "E_Mail" => $value[0], "" ), $value );
152
 
153
 
154
            $Betreff = $Verteiler["Betreff"];
155
            $text = $textRaw;
156
 
157
            // Platzhalter gegeb Inhalt tauschen
158
            // Änderung am 01.06.06
159
            // ersetze ##...##  und [...] Abgeschaltet da [weiter] als Schlüsselwort interpretiert wurde
160
            // Es wird nur noch ##...## ersetzt
161
            // "/#{2}$valueKey#{2}|\[$valueKey\]/",
162
            // "/#{2}\S*#{2}|\[\S*\]/"
163
 
164
            if ( !$_REQUEST['shops_ID'] )
165
            {
166
                $_REQUEST['shops_ID'] = 1;
167
            }
168
 
169
            if ( $gs_vorlage )
170
            {
171
                $gs = gen_gutschein( $gs_vorlage, $value[1], $_REQUEST["shops_ID"] );
172
                $text = str_replace( "##gutscheinname##", $gs["name"], $text );
173
                $wert = $gs["anfangswert"];
174
                if ( $wert < 0 )
175
                {
176
                    $wert = number_format( $wert * -1 ) . " %";
177
                }
178
                else
179
                {
180
                    $wert = number_format( $wert, 2, ',', '.' ) . " €";
181
                }
182
                $text = str_replace( "##gutscheinpreis1##", $wert, $text );
183
                $text = str_replace( "##gutscheinpreis2##", number_format( $gs["minbestwert"],
184
                    2, ',', '.' ) . " €", $text );
185
                $text = str_replace( "##gutscheincode##", $gs["code"], $text );
186
                $ablauf = date( "d.m.Y H:i", strtotime( $gs["gueltig_bis"] ) );
187
                $text = str_replace( "##gutscheinablauf##", $ablauf, $text );
188
            }
189
 
190
            foreach ( $value as $valueKey => $valueValue )
191
            {
192
                $Betreff = preg_replace( "/#{2}$valueKey#{2}/", $valueValue,
193
                    $Betreff );
194
 
195
                $text = preg_replace( "/#{2}$valueKey#{2}/", $valueValue, $text );
196
            }
197
 
198
            $Betreff = preg_replace( "/#{2}\S*#{2}/", "", $Betreff );
199
            $text = preg_replace( "/#{2}\S*#{2}/", "", $text );
200
 
201
            // In den Mailspool packen
202
            $mail = array( "shops_ID" => $_REQUEST['shops_ID'], "webs_ID" =>
203
                $webs["ID"], "to" => $value["E_Mail"], "cc" => '', "bcc" =>
204
                '', "subject" => $Betreff, "from" => $Verteiler["Absender"],
205
                "header_add" => implode( "\n", $headers ), "text" => $text,
206
                "erstellt_von" => $PHP_AUTH_USER, "smtp_server" => $_REQUEST['smtp_server'],
207
                "smtp_user" => $_REQUEST['smtp_user'], "smtp_pass" => $_REQUEST['smtp_pass'],
208
                "smtp_authed" => $_REQUEST['smtp_authed'] );
209
 
210
            list( $tag, $monat, $jahr, $stunde, $minute, $sekunde ) = sscanf( $_POST["takeoff"],
211
                "%d.%d.%d %d:%d:%d" );
212
            $mail["takeoff"] = "$jahr-$monat-$tag $stunde:$minute:$sekunde";
213
 
214
            if ( $MySQL_Host_write )
215
            {
216
                //echo "schreibe in Haupt-DB";
217
                $w_conn = @mysql_connect( $MySQL_Host_write, $MySQL_User, $MySQL_Passwd );
218
                if ( !$w_conn )
219
                {
220
                    $error = true;
221
                    $meld =
222
                        "Leider können keine Newsletter verschickt werden, da keine Verbindung zur Datenbank möglich ist.";
223
                }
224
                $r = @mysql_select_db( $database_name );
225
                if ( !$r )
226
                {
227
                    $meld =
228
                        "Leider können keine Newsletter verschickt werden, da keine Verbindung zur Datenbank möglich ist.";
229
                    $error = true;
230
                }
231
                if ( $meld )
232
                {
233
                    die( $meld );
234
                }
235
            }
236
            else
237
            {
238
                $w_conn = $localhost_dbh;
239
            }
240
            foreach ( $mail as $field => $value )
241
            {
242
                $mail[$field] = mysql_real_escape_string( $value );
243
            }
244
            $query_spool = "
245
                INSERT INTO
246
                    content_management.mailspool_out
247
                (
248
                    `shops_ID` ,
249
                    `webs_ID` ,
250
                    `to` ,
251
                    `cc` ,
252
                    `bcc` ,
253
                    `subject` ,
254
                    `from` ,
255
                    `header_add` ,
256
                    `text` ,
257
                    `takeoff` ,
258
                    `erstellt_am` ,
259
                    `erstellt_von`,
260
                    `smtp_server`,
261
                    `smtp_user`,
262
                    `smtp_pass`,
263
                    `smtp_authed`
264
                )
265
                VALUES
266
                (
267
                    " . $mail["shops_ID"] . ",
268
                    " . $mail["webs_ID"] . ",
269
                    '" . $mail["to"] . "',
270
                    '" . $mail["cc"] . "' ,
271
                    '" . $mail["bcc"] . "' ,
272
                    '" . $mail["subject"] . "',
273
                    '" . $mail["from"] . "',
274
                    '" . $mail["header_add"] . "',
275
                    '" . $mail['text'] . "',
276
                    '" . $mail["takeoff"] . "',
277
                    NOW(),
278
                    '" . $mail["erstellt_von"] . "',
279
                    '" . $mail["smtp_server"] . "',
280
                    '" . $mail["smtp_user"] . "',
281
                    '" . $mail["smtp_pass"] . "',
282
                    '" . $mail["smtp_authed"] . "'
283
                )
284
            ";
285
            $result = mysql_query( $query_spool, $w_conn ) or die( mysql_errno
286
                ( $w_conn ) . ": " . mysql_error( $w_conn ) . "<hr>$query_spool<hr>" );
287
        } // end of foreach($To as $ToIndex => $ToValue)
288
        header( "Location: mailsent.php?count=" . count( $To ) );
289
        exit;
290
    } // end of if ($action)
291
 
292
    $Verteiler = array();
293
    $result = mysql_query( "SELECT * FROM Verteiler order by name" ) or die( mysql_errno
294
        () . ": " . mysql_error() );
295
    while ( $zeile = mysql_fetch_array( $result ) )
296
    {
297
        $Verteiler[$zeile["ID"]] = $zeile;
298
    }
299
 
300
    if ( !$Verteiler_NR )
301
    {
302
        $Verteiler_NR = array_keys( $Verteiler );
303
        $Verteiler_NR = $Verteiler_NR[0];
304
    }
305
?>
306
<html>
307
<head>
308
<title>Mail versenden</title>
309
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
310
<meta name="author" content="Webagentur Niewerth - www.weban.de">
311
<meta name="revisit-after" content="30 days">
312
<meta name="language" content="deutsch, de">
313
<meta name="distribution" content="global">
314
<meta name="robots" content="all">
315
<link rel="stylesheet" type="text/css" href="../buttons.css">
316
<style type="text/css">
317
<!--
318
a {  color: #<?php echo $webs["font_color_rechts"]
319
?>}
320
-->
321
</style>
322
<script language="JavaScript" src="../checkDate.js"></script>
323
<script type="text/javascript" src="../whizzyRte/whizzywig.js"></script>
324
</head>
325
 
326
<body bgcolor="#<?php echo $webs["bgcolor_seite"]
327
?>" leftmargin="20" topmargin="10" marginwidth="20" marginheight="10" text="#<?php echo
328
    $webs["font_color_rechts"]
329
?>">
330
<form method="post" action="#" enctype="multipart/form-data">
331
  <table width="800" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
332
    <tr>
333
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
334
?>" colspan="2"><font color="#<?php echo $webs["font_color_links"]
335
?>">Verteiler
336
        senden: <input type="hidden" name="Verteiler_NR" value="<?= $_REQUEST["Verteiler_NR"];
337
?>"></td>
338
    </tr>
339
    <tr>
340
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
341
?>" class="headline" width="20%" valign="top"><font color="#<?php echo $webs["font_color_links"]
342
?>">An:</td>
343
      <td bgcolor="#<?php echo $webs["bgcolor_rechts"]
344
?>">
345
<?php
346
    $to = array();
347
    //Jenachdem was im Redaktionssystem angegeben ist, werden mehr Infos geholt und später mit in $to gepackt
348
    $grundfunktionen = explode( ";", $web_rechte["mail_verteiler"]["versenden"]["grundfunktionen"] );
349
    $zusatzfelder = '';
350
    foreach ( $grundfunktionen as $value )
351
    {
352
        if ( $value )
353
        {
354
            $zusatzfelder .= ", $value";
355
        }
356
    }
357
    $query = "SELECT DISTINCT
358
            Logins.E_Mail,
359
            MD5(Logins.E_Mail) as MD5
360
            $zusatzfelder
361
        FROM
362
            Logins,
363
            Logins_to_Verteiler
364
        WHERE
365
            Logins.ID = Logins_to_Verteiler.Logins
366
        AND
367
            Logins_to_Verteiler.Verteiler = '" . $_REQUEST["Verteiler_NR"] .
368
        "'
369
        ORDER BY
370
            ID
371
    ";
372
    $result = mysql_query( $query ) or die( mysql_errno() . ": " .
373
        mysql_error() . "<hr>$query<hr>" );
374
    $count = mysql_num_rows( $result );
375
    // Userdaten werden ins Array $to gepackt
376
    while ( $zeile = mysql_fetch_assoc( $result ) )
377
    {
378
        if ( preg_match( "/^[A-Za-z0-9-_.+]+\@[A-Za-z0-9-_.+]+\.[A-Za-z]+$/",
379
            $zeile["E_Mail"] ) > 0 )
380
        {
381
            $to[$zeile["MD5"]]["E_Mail"] = $zeile[E_Mail];
382
            //Jenachdem was im Redaktionssystem angegeben ist, werden mehr Infos geholt und später mit in $to gepackt
383
            foreach ( $grundfunktionen as $value )
384
            {
385
                $to[$zeile[MD5]][$value] = $zeile[$value];
386
            }
387
        }
388
    }
389
?>
390
<ul style="float:right; list-style-position: outside; list-style-type: none; padding-right:20px;">
391
    <li style="padding:3px">##1##</li>
392
    <li style="padding:3px">##2##</li>
393
    <li style="padding:3px">##3##</li>
394
    <li style="padding:3px">...</li>
395
</ul>
396
 
397
      <textarea name="To" cols="100" rows="10" style="float:left;"><?php
398
    foreach ( $to as $key => $value )
399
    {
400
        $ausgabe = '';
401
        foreach ( $value as $key2 => $value2 )
402
        {
403
            if ( $value2 )
404
            {
405
                $ausgabe .= "$value2;";
406
            }
407
        }
408
        $ausgabe = substr( $ausgabe, 0, strlen( $ausgabe ) - 1 ) . "|\n";
409
        echo $ausgabe;
410
    }
411
?></textarea>
412
      <br style="clear:both">
413
      Anzahl der ausgelesenen Empf&auml;nger:      <?= count( $to );
414
?>
415
      </td>
416
    </tr>
417
    <tr>
418
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
419
?>" class="headline" width="20%" valign="top"><font color="#<?php echo $webs["font_color_links"]
420
?>">Versenden am/ab:</td>
421
      <td bgcolor="#<?php echo $webs["bgcolor_rechts"]
422
?>">
423
        <input type="text" name="takeoff" size="30" value="<?= date( "d.m.Y H:i:s" );
424
?>" onFocus="current_value=this.value;if (this.value=='') {this.value=now2(uhrzeit());} this.select();" onChange="this.value=check_Date(this.value)">
425
    </td>
426
    </tr>
427
    <?php
428
    if ( isset( $user_rechte["mail_verteiler"]["versenden"]["gutscheinversand"] ) )
429
    {
430
?>
431
    <tr>
432
        <td bgcolor="#<?php echo $webs["bgcolor_links"]
433
?>" class="headline" width="20%" valign="top"><font color="#<?php echo $webs["font_color_links"]
434
?>">GutscheinvorlagenID:</td>
435
        <td bgcolor="#<?php echo $webs["bgcolor_rechts"]
436
?>">
437
            <input type="text" name="gutscheinvorlagenid">
438
        </td>
439
    </tr>
440
    <?php
441
    }
442
?>
443
    <tr>
444
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
445
?>" class="headline" width="20%" valign="top"><font color="#<?php echo $webs["font_color_links"]
446
?>">Absender:</td>
447
      <td bgcolor="#<?php echo $webs["bgcolor_rechts"]
448
?>"><?php echo nl2br( $Verteiler[$Verteiler_NR]["Absender"] )
449
?></td>
450
    </tr>
451
    <tr>
452
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
453
?>" class="headline" width="20%" valign="top"><font color="#<?php echo $webs["font_color_links"]
454
?>">Betreff:</td>
455
      <td bgcolor="#<?php echo $webs["bgcolor_rechts"]
456
?>"><?php echo nl2br( $Verteiler[$Verteiler_NR]["Betreff"] )
457
?></td>
458
    </tr>
459
<?php if ( !isset( $web_rechte[2]["versenden"]["html"] ) )
460
    {
461
?>
462
    <tr>
463
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
464
?>" class="headline" width="20%" valign="top"><font color="#<?php echo $webs["font_color_links"]
465
?>">Begr&uuml;ssung:</td>
466
      <td bgcolor="#<?php echo $webs["bgcolor_rechts"]
467
?>"><?php echo nl2br( $Verteiler[$Verteiler_NR]["Begruessung"] )
468
?></td>
469
    </tr>
470
<?php
471
    }
472
?>
473
    <tr>
474
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
475
?>" class="headline" width="20%" valign="top"><font color="#<?php echo $webs["font_color_links"]
476
?>">Text:
477
        (Plain) </td>
478
      <td bgcolor="#<?php echo $webs["bgcolor_rechts"]
479
?>">
480
        <textarea name="message[PLAIN]" cols="100" rows="10" wrap="OFF"></textarea>
481
      </td>
482
    </tr>
483
    <tr>
484
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
485
?>" class="headline" width="20%" valign="top"><font color="#<?php echo $webs["font_color_links"]
486
?>">Text:
487
        (HTML) </td>
488
      <td bgcolor="#<?php echo $webs["bgcolor_rechts"]
489
?>">
490
 
491
 
492
        <!--<textarea id="messageHTML" name="message[HTML]" cols="150" rows="100" wrap="OFF" height="200">-->
493
        <textarea id="messageHTML" name="message[HTML]" cols="150" rows="100">
494
 
495
        <?php
496
    if ( $Verteiler[$_GET["Verteiler_NR"]]["Template_URL"] )
497
    {
498
        echo $Verteiler[$Verteiler_NR]["Begruessung"];
499
        readfile( $Verteiler[$_GET["Verteiler_NR"]]["Template_URL"] );
500
        echo $Verteiler[$Verteiler_NR]["Schlusstext"];
501
    }
502
?>
503
        </textarea>
504
<!-- Einbindung TinyMCE -->
505
<script type="text/javascript" language="javascript" src="/js/jquery-1.4.4.min.js"></script>
506
<script type="text/javascript" src="../tiny_mce/tiny_mce.js"></script>
507
<script type="text/javascript">
508
tinyMCE.init({
509
    // General options
510
    apply_source_formatting : false,
511
    inline_styles : true,
512
    mode : "exact",
513
    elements: "messageHTML",
514
    theme : "advanced",
515
    verify_html : false,
516
    cleanup : false,
517
    extended_valid_elements : "style,head,body,html",
518
    language: "de",
519
    plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
520
 
521
    // Theme options
522
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
523
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
524
    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
525
    theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
526
    theme_advanced_toolbar_location : "top",
527
    theme_advanced_toolbar_align : "left",
528
    theme_advanced_statusbar_location : "bottom",
529
    theme_advanced_resizing : true,
530
 
531
    // Example content CSS (should be your site CSS)
532
    content_css : "css/example.css",
533
 
534
    // Drop lists for link/image/media/template dialogs
535
    template_external_list_url : "js/template_list.js",
536
    external_link_list_url : "js/link_list.js",
537
    external_image_list_url : "js/image_list.js",
538
    media_external_list_url : "js/media_list.js",
539
 
540
    // Replace values for the template plugin
541
    template_replace_values : {
542
        username : "Some User",
543
        staffid : "991234"
544
    }
545
});
546
</script>
547
        </td>
548
    </tr>
549
<?php if ( !isset( $web_rechte["mail_verteiler"]["versenden"]["html"] ) )
550
    {
551
?>
552
    <tr>
553
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
554
?>" class="headline" width="20%" valign="top"><font color="#<?php echo $webs["font_color_links"]
555
?>">Schlusstext:</td>
556
      <td bgcolor="#<?php echo $webs["bgcolor_rechts"]
557
?>"><?= nl2br( $Verteiler[$Verteiler_NR]["Schlusstext"] );
558
?></td>
559
    </tr>
560
<?php
561
    }
562
?>
563
<?php
564
    if ( isset( $user_rechte[modul_name][tool_name]["attachments"] ) )
565
    {
566
?>
567
<script language="javascript">
568
function addAttach()
569
{
570
    source=document.getElementById("attachment")
571
    clone=source.cloneNode(true);
572
    clone.removeAttribute("id");
573
 
574
    source.parentNode.appendChild(clone);
575
}
576
 
577
function removeAttach(obj)
578
{
579
    div = obj.parentNode;
580
    td = obj.parentNode.parentNode;
581
    if (!div.id)  { td.removeChild(div); }
582
}
583
</script>
584
    <tr>
585
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
586
?>" class="headline" valign="top" width="20%"><font color="#<?php echo $webs["font_color_links"]
587
?>">Dateianhänge:</td>
588
      <td bgcolor="#<?php echo $webs["bgcolor_rechts"]
589
?>">
590
        <div id="attachment">
591
 
592
            <input type="file" name="attach[]">
593
            <input type="button" value=" + " onClick="addAttach()">
594
            <input type="button" value=" - " onClick="removeAttach(this)">
595
        </div>
596
      </td>
597
    </tr>
598
<?php
599
    }
600
 
601
    $shops_ID = getShopsIdFromTemplateURL( $Verteiler[$_GET['Verteiler_NR']]['Template_URL'] );
602
?>
603
    <tr align="right">
604
      <td bgcolor="#<?php echo $webs["bgcolor_links"]
605
?>" class="headline" colspan="2">
606
        <input type="hidden" name="shops_ID" value="<?php echo $shops_ID;
607
?>">
608
        <input type="hidden" name="smtp_server" value="<?php echo $Verteiler[$_GET['Verteiler_NR']]['smtp_server'];
609
?>">
610
        <input type="hidden" name="smtp_user" value="<?php echo $Verteiler[$_GET['Verteiler_NR']]['smtp_user'];
611
?>">
612
        <input type="hidden" name="smtp_pass" value="<?php echo $Verteiler[$_GET['Verteiler_NR']]['smtp_pass'];
613
?>">
614
        <input type="hidden" name="smtp_authed" value="<?php echo $Verteiler[$_GET['Verteiler_NR']]['smtp_authed'];
615
?>">
616
        <input type="submit" name="action" value="Abschicken">
617
        <input type="reset" value="Zur&uuml;cksetzen">
618
      </td>
619
    </tr>
620
  </table>
621
</form>
622
</body>
623
</html>
624
 
625
<?php
626
    function leseGutscheinvorlage( $vorlagenID )
627
    {
628
        require_once
629
            "../Warenwirtschaft/includes/bestellungen/system/artikelDatabase.php";
630
        $table = "artikel";
631
        $sql = "SELECT
632
                kurzbezeichnung,
633
                short_line_1,
634
                short_line_2,
635
                preis1,
636
                preis2
637
            FROM
638
                $table
639
            WHERE
640
                ID=$vorlagenID
641
        ";
642
        //echo $sql;
643
        $res = mysql_query( $sql );
644
        $row = mysql_fetch_assoc( $res );
645
        return $row;
646
    }
647
    function gen_gutschein( $row, $empfaenger, $shopID )
648
    {
649
        define( "FROM_BESTELLUNG", true );
650
        require_once "../marketing/gutscheine.php";
651
        $_POST["gen_pdf"] = false;
652
        $_POST["gs_shop"] = 0;
653
        $_POST["gs_anfangswert"] = $row["preis1"];
654
        $_POST["gs_minbestwert"] = $row["preis2"];
655
        $_POST["gs_name"] = ( $row["short_line_1"] ) ? $row["short_line_1"] :
656
            $row["kurzbezeichnung"];
657
        $_POST["gs_empfaenger"] = $empfaenger;
658
        $_POST["gs_gueltig_von"] = date( "d.m.Y" );
659
        $_POST["gs_gueltig_bis"] = date( "d.m.Y", strtotime( $row["short_line_2"] .
660
            " days" ) );
661
        $_POST["gs_status"] = 1;
662
        $gs = insert_into_gutscheine();
663
        return $gs;
664
    }
665
?>