<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/
?>
<?php
  require('load_this/load_bigware_11.php');
  $action = (isset($_GET['action']) ? $_GET['action'] : '');
  if ( ($action == 'send_email_to_user') && isset($_POST['attendees_email_address']) && !isset($_POST['back_x']) ) {
    switch ($_POST['attendees_email_address']) {
      case '***':
        $mail_query = go_db_query("select attendees_firstname, attendees_lastname, attendees_email_address, attendees_password_uncript from " . DB_TBL_ATTENDEES);
        $mail_sent_to = TEXT_ALL_ATTENDEES;
        break;
      case '**D':
        $mail_query = go_db_query("select attendees_firstname, attendees_lastname, attendees_email_address, attendees_password_uncript from " . DB_TBL_ATTENDEES . " where attendees_newsletter = '1'");
        $mail_sent_to = TEXT_NEWSLETTER_ATTENDEES;
        break; 
	  case 'group':
	  	$attendees_group_query2 = go_db_query("select distinct attendees_group_name, attendees_group_id from ". DB_TBL_ATTENDEES_GROUPS ." where attendees_group_id != '" . 0 . "' order by attendees_group_id");
		while ($attendees_group2 = go_db_fetch_array($attendees_group_query2)) {
			if (go_db_num_rows($attendees_group_query2) > 0) { 
				$mail_query = go_db_query("select attendees_firstname, attendees_lastname, attendees_email_address, attendees_group_id from " . DB_TBL_ATTENDEES . " where attendees_group_id = '" . go_get_attendees_group('$attendee_group_id') ."'");
				$mail_sent_to = go_get_attendees_group();
			}
		}
		break; 
      default:
        $attendees_email_address = go_db_producing_input($_POST['attendees_email_address']);
        $mail_query = go_db_query("select attendees_firstname, attendees_lastname, attendees_email_address, attendees_password_uncript from " . DB_TBL_ATTENDEES . " where attendees_email_address = '" . go_db_input($attendees_email_address) . "'");
        $mail_sent_to = $_POST['attendees_email_address'];
        break;
    }
    $from = go_db_producing_input($_POST['from']);
    $subject = go_db_producing_input($_POST['subject']);

    
    $message = go_db_producing_input($_POST['message']); 
    while ($mail = go_db_fetch_array($mail_query)) {
      $mimemessage = new email(array('X-Mailer: bigware'));
      
      $subject_new=str_replace('<--Vorname-->',$mail['attendees_firstname'],$subject);
      $subject_new=str_replace('<--Nachname-->',$mail['attendees_lastname'],$subject_new);
      $subject_new=str_replace('&lt;--Vorname--&gt;',$mail['attendees_firstname'],$subject_new);
      $subject_new=str_replace('&lt;--Nachname--&gt;',$mail['attendees_lastname'],$subject_new);
      $subject_new=str_replace('<--E-Mail-->',$mail['attendees_email_address'],$subject_new);
      $subject_new=str_replace('<--Passwort-->',$mail['attendees_password_uncript'],$subject_new);
      $subject_new=str_replace('&lt;--E-Mail--&gt;',$mail['attendees_email_address'],$subject_new);
      $subject_new=str_replace('&lt;--Passwort--&gt;',$mail['attendees_password_uncript'],$subject_new);     
      
      $message_new=str_replace('<--Vorname-->',$mail['attendees_firstname'],$message);
      $message_new=str_replace('<--Nachname-->',$mail['attendees_lastname'],$message_new);
      $message_new=str_replace('&lt;--Vorname--&gt;',$mail['attendees_firstname'],$message_new);
      $message_new=str_replace('&lt;--Nachname--&gt;',$mail['attendees_lastname'],$message_new);
      $message_new=str_replace('<--E-Mail-->',$mail['attendees_email_address'],$message_new);
      $message_new=str_replace('<--Passwort-->',$mail['attendees_password_uncript'],$message_new);
      $message_new=str_replace('&lt;--E-Mail--&gt;',$mail['attendees_email_address'],$message_new);
      $message_new=str_replace('&lt;--Passwort--&gt;',$mail['attendees_password_uncript'],$message_new);
      

      $mimemessage->add_html($message_new);
      $mimemessage->build_message();
      $mimemessage->send($mail['attendees_firstname'] . ' ' . $mail['attendees_lastname'], $mail['attendees_email_address'], '', $from, $subject_new);
    } 
    
    
 go_forward(go_href_link(NAME_OF_FILE_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to)));
  }
  if ( ($action == 'preview') && !isset($_POST['attendees_email_address']) ) {
    $messageStack->add(ERROR_NO_ATTENDEE_SELECTED, 'error');
  }
  if (isset($_GET['mail_sent_to'])) {
    $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $_GET['mail_sent_to']), 'success');
  }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="load_this/style.css">
       <script language="JavaScript">
<!-- Begin
       function init() {
define('attendees_email_address', 'string', 'Customer or Newsletter Group');
} 
// --></script>
<script language="javascript" src="tiny_mce/tiny_mce.js"></script>
<script language="javascript" src="tiny_mce/tiny_mce_init.js"></script>
</head>
<body OnLoad="init()" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_9.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td width="<?php echo FRAME_WIDTH; ?>" valign="top">
<!-- left_navigation //-->
<!-- left_navigation_eof //-->
</td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageGeneralsign"><?php echo ABOVE_TITLE; ?></td>
            <td class="pageGeneralsign" align="right"><?php echo go_fetch_dividing_up('tranparentes.gif', ABOVE_PICTURE_WIDTH, ABOVE_PICTURE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
  if ( ($action == 'preview') && isset($_POST['attendees_email_address']) ) {
    switch ($_POST['attendees_email_address']) {
      case '***':
        $mail_sent_to = TEXT_ALL_ATTENDEES;
        break;
      case '**D':
        $mail_sent_to = TEXT_NEWSLETTER_ATTENDEES;
        break; 
	  case 'group':
	    $mail_sent_to = $attendees_group2['attendees_group_name']; 
      default:
        $mail_sent_to = $_POST['attendees_email_address'];
        break;
    }
?>
          <tr><?php echo go_fetch_form('mail', NAME_OF_FILE_MAIL, 'action=send_email_to_user'); ?>
            <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
              <tr>
                <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="smallText"><b><?php echo TEXT_ATTENDEE; ?></b><br><?php echo $mail_sent_to; ?></td>
              </tr>
              <tr>
                <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="smallText"><b><?php echo TEXT_FROM; ?></b><br><?php echo isohtmlspecialchars(stripslashes($_POST['from'])); ?></td>
              </tr>
              <tr>
                <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b><br><?php echo isohtmlspecialchars(stripslashes($_POST['subject'])); ?></td>
              </tr>
              <tr>
                <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="smallText"><b><?php echo TEXT_MESSAGE; ?></b><br><?php echo stripslashes($_POST['message']); ?></td>
              <!-- nl2br() macht aus zeilenumbrüche <br> -->
              
              </tr>
              <tr>
                <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td>
<?php
 reset($_POST);
    while (list($key, $value) = each($_POST)) {
      if (!is_array($_POST[$key])) {
        echo go_fetch_hidden_field($key, isohtmlspecialchars(stripslashes($value)));
      }
    }
?>
                <table border="0" width="100%" cellpadding="0" cellspacing="2">
                  <tr>
                    <td align="right"><?php echo '<a href="' . go_href_link(NAME_OF_FILE_MAIL) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a> ' . go_picture_submit('button_send_mail.gif', PICTURE_SEND_EMAIL); ?></td>
                    </tr>
                    <td class="smallText">
                <?php echo(TEXT_EMAIL_BUTTON_TEXT); ?>
                    </td>
                  </tr>
                </table></td>
             </tr>
            </table></td>
          </form></tr>
<?php
  } else {
?>
          <tr><?php echo go_fetch_form('mail', NAME_OF_FILE_MAIL, 'action=preview'); ?>
            <td><table border="0" cellpadding="0" cellspacing="2">
              <tr>
                <td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
              </tr>
<?php
    $attendees = array();
    $attendees[] = array('id' => '', 'text' => TEXT_SELECT_ATTENDEE);
    $attendees[] = array('id' => '***', 'text' => TEXT_ALL_ATTENDEES);
    $attendees[] = array('id' => '**D', 'text' => TEXT_NEWSLETTER_ATTENDEES); 
	$attendees[] = array('id' => 'group', 'text' => $attendees_group2['attendees_group_name']); 
    $mail_query = go_db_query("select attendees_email_address, attendees_firstname, attendees_lastname from " . DB_TBL_ATTENDEES . " order by attendees_lastname");
    while($attendees_values = go_db_fetch_array($mail_query)) {
      $attendees[] = array('id' => $attendees_values['attendees_email_address'],
                           'text' => $attendees_values['attendees_lastname'] . ', ' . $attendees_values['attendees_firstname'] . ' (' . $attendees_values['attendees_email_address'] . ')');
    }
?>
              <tr>
                <td class="main"><?php echo TEXT_ATTENDEE; ?></td>
                <td><?php echo go_fetch_pull_down_menu('attendees_email_address', $attendees, (isset($_GET['attendee']) ? $_GET['attendee'] : ''));?></td>
              </tr>
              <tr>
                <td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="main"><?php echo TEXT_FROM; ?></td>
                <td><?php echo go_fetch_inputfeld('from', EMAIL_FROM); ?></td>
              </tr>
              <tr>
                <td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="main" valign="top"><?php echo TEXT_SUBJECT; ?></td>
                <td class="main">
        <?php echo TEXT_PLACEHOLDER_REGARD_INDEX ?><br>  
	<?php echo TEXT_FIRST_NAME ?><br> 
	<?php echo TEXT_LAST_NAME ?><br> 
	<?php echo TEXT_E_MAIL ?><br> 
	<?php echo TEXT_PASSWORD ?><br> <br>
	
	<?php echo go_fetch_inputfeld('subject'); ?>
               
                </td>
              </tr>
              <tr>
                <td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
              </tr>
              <tr>
<td valign="top" class="main"><?php echo TEXT_MESSAGE; ?></td>
                <td class="main">
                
        <?php echo TEXT_PLACEHOLDER_TEXT_INDEX ?><br>  
	<?php echo TEXT_FIRST_NAME ?><br> 
	<?php echo TEXT_LAST_NAME ?><br> 
	<?php echo TEXT_E_MAIL ?><br> 
	<?php echo TEXT_PASSWORD ?><br> <br>             
  
  
<?php 
echo '<textarea class="mce" name="message"></textarea></br>';
?>      
                
               </td>

          </script>
              </tr>
              <tr>
                <td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td colspan="2" align="right">
                 <?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Enable'){ echo go_picture_submit('button_send_mail.gif', PICTURE_SEND_EMAIL, 'onClick="validate();return returnVal;"');
                   } else {
                echo go_picture_submit('button_send_mail.gif', PICTURE_SEND_EMAIL); }?>
                </td>
              </tr>
            </table></td>
          </form></tr>
<?php
  }
?>
<!-- body_text_eof //-->
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_7.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_6.php'); ?>
