<?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 gro�e 
  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
  
  -----------------------------------------------------------------------
  
 ##################################################################################

Captcha fuer Bigware 2.3 by Ede & Tigerstyle

*/
?>
<?php
 
  require('load_this/load_this_bigware_10.php'); 
  require(FOLDER_RELATIV_LANGUAGES . $language . '/' . $GLOBALS[CONFIG_NAME_FILE][main_bigware_10]); 
  if (isset($_GET['guest_member'])) $guest_member = true; 
  $process = false;
  
  //Captcha by Ede & Tigerstyle
	$sql=go_db_query('SELECT * FROM captcha_settings');
	$row=go_db_fetch_array($sql); 
	$captcha_enable_10 = $row['captcha_enable_10'];
    
  if (isset($_POST['action']) && ($_POST['action'] == 'process')) {
    $process = true; 
    if (isset($_POST['guest_member']) && ($_POST['guest_member'] == true)) {
      go_session_register('guest_member');
      global $guest_member;
      $guest_member = true;
    } 
    if (MEMBER_GENDER == 'true') {
      if (isset($_POST['gender'])) {
        $gender = go_db_producing_input($_POST['gender']);
      } else {
        $gender = false;
      }
    }
    $firstname = go_db_producing_input($_POST['firstname']);
    $lastname = go_db_producing_input($_POST['lastname']);
    if (MEMBER_DOB == 'true') $dob = go_db_producing_input($_POST['dob']);
    $email_address = go_db_producing_input($_POST['email_address']);
    if (MEMBER_EMAIL_VALIDATION == 'true'){
			$email_address2 = go_db_producing_input($_POST['email_address2']);
		}
    if (MEMBER_COMPANY == 'true') $company = go_db_producing_input($_POST['company']);
    $street_address = go_db_producing_input($_POST['street_address']);
    if (MEMBER_ADRESS2 == 'true'){
			$street_address2 = go_db_producing_input($_POST['street_address2']);
		}
    if (MEMBER_SUBURB == 'true') $suburb = go_db_producing_input($_POST['suburb']);
    $postcode = go_db_producing_input($_POST['postcode']);
    $city = go_db_producing_input($_POST['city']);
    if (MEMBER_STATE == 'true') {
      $state = go_db_producing_input($_POST['state']);
      if (isset($_POST['zone_id'])) {
        $zone_id = go_db_producing_input($_POST['zone_id']);
      } else {
        $zone_id = false;
      }
    }
    $land = go_db_producing_input($_POST['land']);
    if (MEMBER_TELE_FAX == 'true') {
    	$telephone = go_db_producing_input($_POST['telephone']);
    	$fax = go_db_producing_input($_POST['fax']);
    }
    if (isset($_POST['newsletter'])) {
      $newsletter = go_db_producing_input($_POST['newsletter']);
    } else {
      $newsletter = false;
    }
    $password = go_db_producing_input($_POST['password']);
    $confirmation = go_db_producing_input($_POST['confirmation']); 
     if ($guest_member) {
       $guest_pass = go_create_random_value(TYPE_IN_PASSWORD_MIN_LENGTH, 'mixed');
       $password = go_db_producing_input($guest_pass);
     } 
    $source = go_db_producing_input($_POST['source']);
    if (isset($_POST['source_other'])) $source_other = go_db_producing_input($_POST['source_other']);
    $error = false;
    if ((MEMBER_GENDER == 'true')&&(MEMBER_GENDER_REQ == 'true')) {
      if ( ($gender != 'm') && ($gender != 'f') ) {
        $error = true;
        $messageStack->add('create_member', TYPE_IN_GENDER_ERROR);
      }
    }
    if (strlen($firstname) < TYPE_IN_FIRST_NAME_MIN_LENGTH) {
      $error = true;
      $messageStack->add('create_member', TYPE_IN_FIRST_NAME_ERROR);
    }
    if (strlen($lastname) < TYPE_IN_LAST_NAME_MIN_LENGTH) {
      $error = true;
      $messageStack->add('create_member', TYPE_IN_LAST_NAME_ERROR);
    }
    if ((MEMBER_DOB == 'true')&&((MEMBER_DOB_REQ == 'true'))) {
      if (checkdate(substr(go_date_raw($dob), 4, 2), substr(go_date_raw($dob), 6, 2), substr(go_date_raw($dob), 0, 4)) == false) {
        $error = true;
        $messageStack->add('create_member', TYPE_IN_DATE_OF_BIRTH_ERROR);
      }
    }
    if (strlen($email_address) < TYPE_IN_EMAIL_ADDRESS_MIN_LENGTH) {
      $error = true;
      $messageStack->add('create_member', TYPE_IN_EMAIL_ADDRESS_ERROR);
    } elseif (go_validate_email($email_address) == false) {
      $error = true;
      $messageStack->add('create_member', TYPE_IN_EMAIL_ADDRESS_CHECK_ERROR);
    } elseif ( (MEMBER_EMAIL_VALIDATION == 'true') && ($email_address!=$email_address2) ){
		 $error = true;
		 $messageStack->add('create_member', TYPE_EMAIL_ADDRESS_CONFIRM_ERROR);
    } else { 
      $check_email_query = go_db_query("select count(*) as total from " . DB_TBL_ATTENDEES . " where attendees_email_address = '" . go_db_input($email_address) . "' and guest_flag != '1'");
      $check_email = go_db_fetch_array($check_email_query);
      if ($check_email['total'] > 0) {
        /*$error = true;
        $messageStack->add('create_member', TYPE_IN_EMAIL_ADDRESS_ERROR_EXISTS);*/
      }
    }
    if (strlen($street_address) < TYPE_IN_STREET_ADDRESS_MIN_LENGTH) {
      $error = true;
      $messageStack->add('create_member', TYPE_IN_STREET_ADDRESS_ERROR);
    }
    if (strlen($postcode) < TYPE_IN_POSTCODE_MIN_LENGTH) {
      $error = true;
      $messageStack->add('create_member', TYPE_IN_POST_CODE_ERROR);
    }
    if (strlen($city) < TYPE_IN_CITY_MIN_LENGTH) {
      $error = true;
      $messageStack->add('create_member', TYPE_IN_CITY_ERROR);
    }
    if (is_numeric($land) == false) {
      $error = true;
      $messageStack->add('create_member', TYPE_IN_LAND_ERROR);
    }
    if ((MEMBER_STATE == 'true')&&((MEMBER_STATE_REQ == 'true'))) {
      $zone_id = 0;
      $check_query = go_db_query("select count(*) as total from " . DB_TBL_ZONES . " where zone_land_id = '" . (int)$land . "'");
      $check = go_db_fetch_array($check_query);
      $entry_state_has_zones = ($check['total'] > 0);
      if ($entry_state_has_zones == true) {
        $zone_query = go_db_query("select distinct zone_id from " . DB_TBL_ZONES . " where zone_land_id = '" . (int)$land . "' and (zone_name like '" . go_db_input($state) . "%' or zone_code like '%" . go_db_input($state) . "%')");
        if (go_db_num_rows($zone_query) == 1) {
          $zone = go_db_fetch_array($zone_query);
          $zone_id = $zone['zone_id'];
        } else {
          $error = true;
          $messageStack->add('create_member', TYPE_IN_STATE_ERROR_SELECT);
        }
      } else {
        if (strlen($state) < TYPE_IN_STATE_MIN_LENGTH) {
          $error = true;
          $messageStack->add('create_member', TYPE_IN_STATE_ERROR);
        }
      }
    }
    if (MEMBER_TELE_FAX == 'true') {
	    if (MEMBER_TEL_REQ == 'true' && strlen($telephone) < TYPE_IN_TELEPHONE_MIN_LENGTH) {
	      $error = true;
	      $messageStack->add('create_member', TYPE_IN_TELEPHONE_NUMBER_ERROR);
	    }
  	}
 if (MEMBER == 'false'){ 
    if ($guest_member != true) {
      if (strlen($password) < TYPE_IN_PASSWORD_MIN_LENGTH) {
        $error = true;
        $messageStack->add('create_member', TYPE_IN_PASSWORD_ERROR);
      } elseif ($password != $confirmation) {
        $error = true;
        $messageStack->add('create_member', TYPE_IN_PASSWORD_ERROR_NOT_MATCHING);
      }
    } 
  }
    if ((REFERRAL_REQUIRED == 'true' && REFERRAL_REQUIRED_REQ == 'true') && (is_numeric($source) == false)) {
        $error = true;
        $messageStack->add('create_member', TYPE_IN_SOURCE_ERROR);
    }
    if ((REFERRAL_REQUIRED == 'true' && REFERRAL_REQUIRED_REQ == 'true') && (SHOW_REFERRAL_OTHER == 'true') && ($source == '9999') && (!go_not_null($source_other)) ) {
        $error = true;
        $messageStack->add('create_member', TYPE_IN_SOURCE_OTHER_ERROR);
    }

//captcha test, sets error message and error flag
	if ($captcha_enable_10 == "ja") {
	if( empty($captcha_code) || empty($_POST['captcha_code']) || go_urlsafe_b64encode(go_CAP_RC4($_POST['captcha_code'])) != $captcha_code ) {
      $error = true;
      $messageStack->add('create_member', CAPTCHA_INVALID_TEXT );
    }
    }
//END
//Captcha by Ede & Tigerstyle
if ($captcha_enable_10 == "ja") {
// captcha unregister here not needed anymore
      if ( go_session_is_registered('captcha_code') ) {
        go_session_unregister('captcha_code');
      }
      }
//END      
    if ($error == false) {
    
//Tigerstyle Grossbuchstaben
    function ucfirstPerWord($string) {
        $uc_char = array(' ', '-', ',', '(');
        $arr_ch = str_split($string);
        $upper = true;
        $result = '';
        foreach($arr_ch as $ch) {
            if(preg_match("/^[a-zA-Z]$/", $ch)) {
                if($upper) {
                    $ch = strtoupper($ch);
                    $upper = false;
                } else {
                    $ch = strtolower($ch);
                }
            } else {
                if(in_array($ch, $uc_char)) {
                    $upper = true;
                } else {
                    $upper = false;
                }
            }
            $result .= $ch;
        }
        return $result;
    }
    $firstname = ucfirstPerWord($firstname);
    $lastname = ucfirstPerWord($lastname);
    $street_address = ucfirstPerWord($street_address);
    $street_address2 = ucfirstPerWord($street_address2);
    $city = ucfirstPerWord($city);
    $suburb = ucfirstPerWord($suburb);

//END Tigerstyle Grossbuchstaben

      $sql_data_array = array('attendees_firstname' => $firstname,
                              'attendees_lastname' => $lastname,
                              'attendees_email_address' => $email_address,
                              'attendees_telephone' => $telephone,
                              'attendees_fax' => $fax,
                              'attendees_newsletter' => $newsletter,
                              'attendees_password_uncript' => $password,
                              'attendees_password' => go_encrypt_password($password));
      if (MEMBER_GENDER == 'true') $sql_data_array['attendees_gender'] = $gender;
      if (MEMBER_DOB == 'true') $sql_data_array['attendees_dob'] = go_date_raw($dob); 
    if ($guest_member) $sql_data_array['guest_flag'] = '1';	
    go_db_query("update " . DB_TBL_ATTENDEES . " set attendees_email_address = '@_" . $email_address . "' where attendees_email_address = '" . $email_address . "' and guest_flag = '1'");
    go_db_query("update " . DB_TBL_ATTENDEES . " set attendees_lastname = '@_" . $lastname . "' where attendees_email_address = '@_" . $email_address . "'"); 
      go_db_carry(DB_TBL_ATTENDEES, $sql_data_array);
      $attendee_id = go_db_insert_id();
      $sql_data_array = array('attendees_id' => $attendee_id,
                              'entry_firstname' => $firstname,
                              'entry_lastname' => $lastname,
                              'entry_street_address' => $street_address,
                              'entry_street_address2' => $street_address2,
                              'entry_postcode' => $postcode,
                              'entry_city' => $city,
                              'entry_land_id' => $land);
      if (MEMBER_GENDER == 'true') $sql_data_array['entry_gender'] = $gender;
      if (MEMBER_COMPANY == 'true') $sql_data_array['entry_company'] = $company;
      if (MEMBER_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb;
      if (MEMBER_STATE == 'true') {
        if ($zone_id > 0) {
          $sql_data_array['entry_zone_id'] = $zone_id;
          $sql_data_array['entry_state'] = '';
        } else {
          $sql_data_array['entry_zone_id'] = '0';
          $sql_data_array['entry_state'] = $state;
        }
      }
      go_db_carry(DB_TBL_DIRECTORY_TO_ADDRESS, $sql_data_array);
      $address_id = go_db_insert_id();
      go_db_query("update " . DB_TBL_ATTENDEES . " set attendees_default_address_id = '" . (int)$address_id . "' where attendees_id = '" . (int)$attendee_id . "'"); 
      if (!$guest_member) {
        go_db_query("insert into " . DB_TBL_ATTENDEES_INFO . " (attendees_info_id, attendees_info_number_of_logons, attendees_info_date_member_created, attendees_info_source_id) values ('" . go_db_input($attendee_id) . "', '0', now(), '". (int)$source . "')");
      } else {
        go_db_query("insert into " . DB_TBL_ATTENDEES_INFO . " (attendees_info_id, attendees_info_number_of_logons, attendees_info_date_member_created, attendees_info_source_id) values ('" . go_db_input($attendee_id) . "', '-1', now(), '". (int)$source . "')");
      } 
      if ($source == '9999') {
        go_db_carry(DB_TBL_SOURCES_OTHER, array('attendees_id' => (int)$attendee_id, 'sources_other_name' => go_db_input($source_other)));
      }
			if (MEMBER=='false'){
	      if (SESSION_RECREATE == 'True') {
	        go_session_recreate();
	      }
	      $attendee_first_name = $firstname;
	      $attendee_default_address_id = $address_id;
	      $attendee_land_id = $land;
	      $attendee_zone_id = $zone_id;
	      go_session_register('attendee_id');
	      go_session_register('attendee_first_name');
	      go_session_register('attendee_default_address_id');
	      go_session_register('attendee_land_id');
	      go_session_register('attendee_zone_id');
	      go_session_unregister('referral_id'); 
	      
				if (BASKET_DEL_IF_NEW_LOGIN == 'true'){ 	
	  				go_db_query("delete from " . DB_TBL_ATTENDEES_BASKET . " where attendees_id = '" . (int)$attendee_id . "'");
						go_db_query("delete from " . DB_TBL_ATTENDEES_BASKET_CHARACTERISTICS . " where attendees_id = '" . (int)$attendee_id . "'");
						go_db_query("delete from " . DB_TBL_ATTENDEES_BASKET_CHARACTERISTICS_CONF . " where attendees_id = '" . (int)$attendee_id . "'");       
	    	}
	      $cart->restore_contents();
			} 
      $name = $firstname . ' ' . $lastname;
      if (MEMBER_GENDER == 'true') {
         if ($gender == 'm') {
           $email_text = sprintf(EMAIL_GREET_MR, $lastname);
         } else {
           $email_text = sprintf(EMAIL_GREET_MS, $lastname);
         }
      } else {
        $email_text = sprintf(EMAIL_GREET_NONE, $firstname);
      } 
      if ($guest_member == true) {
        go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_66], '', 'SSL'));
      } else {
      	
			if (EMAIL_USE_HTML == 'true'){
		        $text_query = go_db_query("SELECT * FROM email_template_text where txt_html = 2 and language_id = '" . $languages_id . "' AND site_name = 'new_user'");
			}
			else{
			       $text_query = go_db_query("SELECT * FROM email_template_text where txt_html = 1 and language_id = '" . $languages_id . "' AND site_name = 'new_user'");
			}
       $werte = go_db_fetch_array($text_query);
       $text = $werte["email_text_one"];
      	
        //$email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;

				$text = preg_replace('/<-FIRST_NAME_CUSTOMER->|&lt;-FIRST_NAME_CUSTOMER-&gt;/', $firstname, $text);
				$text = preg_replace('/<-LAST_NAME_CUSTOMER->|&lt;-LAST_NAME_CUSTOMER-&gt;/', $lastname, $text);
				if (EMAIL_USE_HTML == 'true'){
					$text = preg_replace('/<-STREET_CUSTOMER->|&lt;-STREET_CUSTOMER-&gt;/', $street_address . "\n" . $street_address2, $text);
				}else{
					$text = preg_replace('/<-STREET_CUSTOMER->|&lt;-STREET_CUSTOMER-&gt;/', $street_address . "\n" . '<br>' . $street_address2, $text);
				}
				$text = preg_replace('/<-POSTCODE_CUSTOMER->|&lt;-POSTCODE_CUSTOMER-&gt;/', $postcode, $text);
				$text = preg_replace('/<-CITY_CUSTOMER->|&lt;-CITY_CUSTOMER-&gt;/', $city, $text);
				if (EMAIL_USE_HTML == 'true'){
					$text = preg_replace('/<-MY_LOGO->|&lt;-MY_LOGO-&gt;/', '<img border="0" src="' . HTTP_SERVER . FOLDER_RELATIV_HTTP_CATALOG . FOLDER_RELATIV_PICTURES . CHANGE_INVOICE_LOGO . '">', $text);
				}else{
					$text = preg_replace('/<-MY_LOGO->|&lt;-MY_LOGO-&gt;/', '', $text);
				}
				$text = preg_replace('/<-SHOP_NAME->|&lt;-SHOP_NAME-&gt;/', SHOP_NAME, $text);
				$text = preg_replace('/<-FIRMENANSCHRIFT->|&lt;-FIRMENANSCHRIFT-&gt;/', SHOP_NAME_ADDRESS, $text);
				$text = preg_replace('/<-FINANZAMT->|&lt;--&gt;/', OWNER_BANK_FA, $text);
				$text = preg_replace('/<-STEUERNUMMER->|&lt;-FINANZAMT-&gt;/', OWNER_BANK_TAX_NUMBER, $text);
				$text = preg_replace('/<-USTID->|&lt;-USTID-&gt;/', OWNER_BANK_UST_NUMBER, $text);
				$text = preg_replace('/<-BANKNAME->|&lt;-BANKNAME-&gt;/', OWNER_BANK_NAME, $text);
				$text = preg_replace('/<-KONTOINHABER->|&lt;-KONTOINHABER-&gt;/', OWNER_BANK_MEMBER, $text);
				$text = preg_replace('/<-BLZ->|&lt;-BLZ-&gt;/', SHOP_OWNER_BLZ, $text);
				$text = preg_replace('/<-KONTONUMMER->|&lt;-KONTONUMMER-&gt;/', OWNER_BANK, $text);
				$text = preg_replace('/<-SWIFT->|&lt;-SWIFT-&gt;/', OWNER_BANK_SWIFT, $text);
				$text = preg_replace('/<-IBAN->|&lt;-IBAN-&gt;/', OWNER_BANK_IBAN, $text);
				$text = preg_replace('/<-FAXVONKUNDE->|&lt;-FAXVONKUNDE-&gt;/', $fax, $text);
				$text = preg_replace('/<-TELEVONKUNDE->|&lt;-TELEVONKUNDE-&gt;/', $telephone, $text);
				$text = preg_replace('/<-KUNDENEMAIL->|&lt;-KUNDENEMAIL-&gt;/', $email_address, $text);   
  			$sql_give_back = go_db_query("SELECT Text FROM " . DB_TBL_INFO_GIVE_BACK . " where language_id='" . $languages_id . "'");
  			$give_back = go_db_fetch_array($sql_give_back); 
				$text = preg_replace('/<-WIDERUFSBELEHRUNG->|&lt;-WIDERUFSBELEHRUNG-&gt;/i', $give_back['Text'], $text);  
  			$sql_agb = go_db_query("SELECT Text FROM " . DB_TBL_INFO_CONDITIONS . " where language_id='" . $languages_id . "'");
  			$agb = go_db_fetch_array($sql_agb);
				$text = preg_replace('/<-AGB->|&lt;-AGB-&gt;/i', $agb['Text'], $text);
				

/////////////// Coupon und Gutschein //////////////////////
				  
			  if (NEW_SIGNUP_GIFT_VOUCHER_AMOUNT > 0) {
			    $coupon_code = create_coupon_code();
			    $insert_query = go_db_query("insert into " . DB_TBL_COUPONS . " (coupon_code, coupon_type, coupon_amount, date_created) values ('" . $coupon_code . "', 'G', '" . NEW_SIGNUP_GIFT_VOUCHER_AMOUNT . "', now())");
			    $insert_id = go_db_insert_id($insert_query);
			    $insert_query = go_db_query("insert into " . DB_TBL_COUPON_EMAIL_TRACK . " (coupon_id, attendee_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $insert_id ."', '0', 'Admin', '" . $email_address . "', now() )");

					$text = preg_replace('/<-IF_START VOUCHER->|&lt;-IF_START VOUCHER-&gt;/', '', $text);
					$text = preg_replace('/<-IF VOUCHER->|&lt;-IF VOUCHER-&gt;/', '', $text);
					$text = preg_replace('/<-IF_END VOUCHER->|&lt;-IF_END VOUCHER-&gt;/', '', $text);
					$text = preg_replace('/<-VOUCHER_COUNT->|&lt;-VOUCHER_COUNT-&gt;/', $currencies->format(NEW_SIGNUP_GIFT_VOUCHER_AMOUNT), $text);
					$text = preg_replace('/<-VOUCHER_CODE->|&lt;-VOUCHER_CODE-&gt;/', $coupon_code, $text);
					$text = preg_replace('/<-VOUCHER_INFO_SITE->|&lt;-VOUCHER_INFO_SITE-&gt;/', HTTP_SERVER . FOLDER_RELATIV_HTTP_CATALOG . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_27], 'gv_no=' . $coupon_code), $text);
			  }else{
					if (substr_count($text, '<-IF VOUCHER->') > '0'){
						for ($i = 0; $i <= substr_count($text, '<-IF VOUCHER->'); $i++) {
							$array_search = search_from_phrase_to_phrase('', '<-IF VOUCHER->', '', '', '<-IF_END VOUCHER->', $text);
							$text = easy_preg_replace($array_search[0][0], '', $text);
						}
					}
					elseif (substr_count($text, '&lt;-IF VOUCHER-&gt;') > '0'){
						for ($i = 0; $i <= substr_count($text, '&lt;-IF VOUCHER-&gt;'); $i++) {
							$array_search = search_from_phrase_to_phrase('', '&lt;-IF VOUCHER-&gt;', '', '', '&lt;-IF_END VOUCHER-&gt;', $text);
							$text = easy_preg_replace($array_search[0][0], '', $text);
						}
					}
					if (substr_count($text, '<-IF_START VOUCHER->') > '0'){
						for ($i = 0; $i <= substr_count($text, '<-IF_START VOUCHER->'); $i++) {
							$array_search = search_from_phrase_to_phrase('', '<-IF_START VOUCHER->', '', '', '<-IF_END VOUCHER->', $text);
							$text = easy_preg_replace($array_search[0][0], '', $text);
						}
					}
					elseif (substr_count($text, '&lt;-IF_START VOUCHER-&gt;') > '0'){
						for ($i = 0; $i <= substr_count($text, '&lt;-IF_START VOUCHER-&gt;'); $i++) {
							$array_search = search_from_phrase_to_phrase('', '&lt;-IF_START VOUCHER-&gt;', '', '', '&lt;-IF_END VOUCHER-&gt;', $text);
							$text = easy_preg_replace($array_search[0][0], '', $text);
						}
					}
				}

			  if (NEW_SIGNUP_DISCOUNT_COUPON != '') {
                  $coupon_code = NEW_SIGNUP_DISCOUNT_COUPON;
                  $create_new_signup_date = date("Y-m-d H:i:s");
                  $insert_query = go_db_query("insert into " . DB_TBL_COUPONS . " (coupon_code, coupon_type, coupon_amount, date_created) values ('" . $coupon_code . "', 'G', '" . NEW_SIGNUP_GIFT_VOUCHER_AMOUNT . "', '". $create_new_signup_date ."')");
                  $insert_id = go_db_insert_id($insert_query);
                  $coupon_query = go_db_query("select * from " . DB_TBL_COUPONS . " where coupon_code = '" . $coupon_code . "' and date_created = '". $create_new_signup_date ."'");
                  $coupon = go_db_fetch_array($coupon_query);
                  $coupon_id = $coupon['coupon_id'];
                  $coupon_desc_query = go_db_query("select * from " . DB_TBL_COUPONS_DESCRIPTION . " where coupon_id = '" . $coupon_id . "' and language_id = '" . (int)$languages_id . "'");
			      $coupon_desc = go_db_fetch_array($coupon_desc_query);
                  $insert_query = go_db_query("insert into " . DB_TBL_COUPON_EMAIL_TRACK . " (coupon_id, attendee_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $coupon_id ."', '0', 'Admin', '" . $email_address . "', now() )");
                  $text = preg_replace('/<-IF COUPON->|&lt;-IF COUPON-&gt;/', '', $text);
                  $text = preg_replace('/<-IF_START COUPON->|&lt;-IF_START COUPON-&gt;/', '', $text);
                  $text = preg_replace('/<-IF_END COUPON->|&lt;-IF_END COUPON-&gt;/', '', $text);
                  $text = preg_replace('/<-COUPON_CODE->|&lt;-COUPON_CODE-&gt;/', $coupon['coupon_code'], $text);
                  $text = preg_replace('/<-COUPON_INFO->|&lt;-COUPON_INFO-&gt;/', $coupon_desc['coupon_description'], $text);

			  }else{
					if (substr_count($text, '<-IF COUPON->') > '0'){
						for ($i = 0; $i <= substr_count($text, '<-IF COUPON->'); $i++) {
							$array_search = search_from_phrase_to_phrase('', '<-IF COUPON->', '', '', '<-IF_END COUPON->', $text);
							$text = easy_preg_replace($array_search[0][0], '', $text);
						}
					}
					elseif (substr_count($text, '&lt;-IF COUPON-&gt;') > '0'){
						for ($i = 0; $i <= substr_count($text, '&lt;-IF COUPON-&gt;'); $i++) {
							$array_search = search_from_phrase_to_phrase('', '&lt;-IF COUPON-&gt;', '', '', '&lt;-IF_END COUPON-&gt;', $text);
							$text = easy_preg_replace($array_search[0][0], '', $text);
						}
					}
					if (substr_count($text, '<-IF_START COUPON->') > '0'){
						for ($i = 0; $i <= substr_count($text, '<-IF_START COUPON->'); $i++) {
                            $array_search = search_from_phrase_to_phrase('', '<-IF_START COUPON->', '', '', '<-IF_END COUPON->', $text);
							$text = easy_preg_replace($array_search[0][0], '', $text);
						}
					}
					elseif (substr_count($text, '&lt;-IF_START COUPON-&gt;') > '0'){
						for ($i = 0; $i <= substr_count($text, '&lt;-IF_START COUPON-&gt;'); $i++) {
                            $array_search = search_from_phrase_to_phrase('', '&lt;-IF_START COUPON-&gt;', '', '', '&lt;-IF_END COUPON-&gt;', $text);
							$text = easy_preg_replace($array_search[0][0], '', $text);
						}
					}
				}
/////////////// Coupon und Gutschein ENDE //////////////////////    
			        
        go_mail($name, $email_address, EMAIL_SUBJECT, $text, SHOP_OWNER, SHOP_OWNER_EMAIL_ADDRESS);
				$former_email_text .= FORMER_EMAIL_WELCOME . '<br><br>' . FORMER_EMAIL_TEXT . '<br><br>' . $firstname . '<br>' . $lastname . '<br>' . $street_address. '<br>' . $postcode . ' ' . $city . '<br>' . $email_address . '<br><br>'. FORMER_EMAIL_TELEPHONE . $telephone . '<br>' . FORMER_EMAIL_FAX . $fax . '<br><br>'.'<br><br>'. EMAIL_WARNING . '<br>-------------------------<br>'; //Fred
    		go_mail(SHOP_OWNER, SHOP_OWNER_EMAIL_ADDRESS, FORMER_EMAIL_SUBJECT, nl2br($former_email_text) . $text, $name, $email_address, '');           
        go_forward(go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_12], '', 'SSL'));
      } 
    }
  }
  //Captcha by Ede & Tigerstyle	
   else {

    $_POST['email'] = "";
    $_POST['name'] = "";
    $_POST['captcha_code'] = "";

  }
//END
   
//Captcha by Ede & Tigerstyle
if ($captcha_enable_10 == "ja") {
// captcha generate a new captcha image and code, encoded and encrypt, register the code with session for testing $_POST
  $captcha_code = go_captcha_image();
    go_session_register('captcha_code');
  }
  //END
  $breadcrumb->add(NAVBAR_TITLE, go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_10], '', 'SSL'));
  $content = $GLOBALS[CONFIG_SHOW_FILE][main_bigware_10];
  $javascript = $GLOBALS[CONFIG_NAME_FILE][form_check_js];
  require(FOLDER_RELATIV_TEMPLATES . TEMPLATENAME_MAIN_PAGE);
  require(FOLDER_RELATIV_INCLUDES . 'load_this_bigware_3.php');
?>
