<?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');
  
  require(FOLDER_RELATIV_LANGUAGES . $language . '/' . NAME_OF_FILE_CREATE_MEMBER_PROCESS);  


if (!@$_POST['action']) {
   go_forward(go_href_link(NAME_OF_FILE_CREATE_MEMBER, '', 'NONSSL'));
 }
  $gender = go_db_producing_input($_POST['gender']);
  $firstname = go_db_producing_input($_POST['firstname']);
  $lastname = go_db_producing_input($_POST['lastname']);
  $dob = go_db_producing_input($_POST['dob']);
  $email_address = go_db_producing_input($_POST['email_address']);
  $telephone = go_db_producing_input($_POST['telephone']);
  $fax = go_db_producing_input($_POST['fax']);
  $newsletter = go_db_producing_input($_POST['newsletter']); 
  $confirmation = go_db_producing_input($_POST['confirmation']);
  $street_address = go_db_producing_input($_POST['street_address']);
  $company = go_db_producing_input($_POST['company']);
  $suburb = go_db_producing_input($_POST['suburb']);
  $postcode = go_db_producing_input($_POST['postcode']);
  $city = go_db_producing_input($_POST['city']);
  $zone_id = go_db_producing_input($_POST['zone_id']);
  $state = go_db_producing_input($_POST['state']);
  $land = go_db_producing_input($_POST['land']);
	$password = 'd1e167eec1f4a4dd7337f921fbd7b154:9f';
$password_nocrypt ='changeme';
  
  
  $error = false; 
  if (MEMBER_GENDER == 'true') {
    if (($gender == 'm') || ($gender == 'f')) {
      $entry_gender_error = false;
    } else {
      $error = true;
      $entry_gender_error = true;
    }
  }
  if (strlen($firstname) < TYPE_IN_FIRST_NAME_MIN_LENGTH) {
    $error = true;
    $entry_firstname_error = true;
  } else {
    $entry_firstname_error = false;
  }
  if (strlen($lastname) < TYPE_IN_LAST_NAME_MIN_LENGTH) {
    $error = true;
    $entry_lastname_error = true;
  } else {
    $entry_lastname_error = false;
  }
  if (MEMBER_DOB == 'true') {
    if (@checkdate(substr(go_date_raw($dob), 4, 2), substr(go_date_raw($dob), 6, 2), substr(go_date_raw($dob), 0, 4))) {
      $entry_date_of_birth_error = false;
    } else {
      $error = true;
      $entry_date_of_birth_error = true;
    }
  }
  if (strlen($email_address) < TYPE_IN_EMAIL_ADDRESS_MIN_LENGTH) {
    $error = true;
    $entry_email_address_error = true;
  } else {
    $entry_email_address_error = false;
  }
 if (!go_validate_email($email_address)) {
    $error = true;
    $entry_email_address_check_error = true;
  } else {
    $entry_email_address_check_error = false;
  }
  if (strlen($street_address) < TYPE_IN_STREET_ADDRESS_MIN_LENGTH) {
    $error = true;
    $entry_street_address_error = true;
  } else {
    $entry_street_address_error = false;
  }
  if (strlen($postcode) < TYPE_IN_POSTCODE_MIN_LENGTH) {
    $error = true;
    $entry_post_code_error = true;
  } else {
    $entry_post_code_error = false;
  }
  if (strlen($city) < TYPE_IN_CITY_MIN_LENGTH) {
    $error = true;
    $entry_city_error = true;
  } else {
    $entry_city_error = false;
  }
  if (!$land) {
    $error = true;
    $entry_land_error = true;
  } else {
    $entry_land_error = false;
  }
  if (MEMBER_STATE == 'true') {
    if ($entry_land_error) {
      $entry_state_error = true;
    } else {
      $zone_id = 0;
      $entry_state_error = false;
      $check_query = go_db_query("select count(*) as total from " . DB_TBL_ZONES . " where zone_land_id = '" . go_db_input($land) . "'");
      $check_value = go_db_fetch_array($check_query);
      $entry_state_has_zones = ($check_value['total'] > 0);
      if ($entry_state_has_zones) {
        $zone_query = go_db_query("select zone_id from " . DB_TBL_ZONES . " where zone_land_id = '" . go_db_input($land) . "' and zone_name = '" . go_db_input($state) . "'");
        if (go_db_num_rows($zone_query) == 1) {
          $zone_values = go_db_fetch_array($zone_query);
          $zone_id = $zone_values['zone_id'];
        } else {
          $zone_query = go_db_query("select zone_id from " . DB_TBL_ZONES . " where zone_land_id = '" . go_db_input($land) . "' and zone_code = '" . go_db_input($state) . "'");
          if (go_db_num_rows($zone_query) == 1) {
            $zone_values = go_db_fetch_array($zone_query);
            $zone_id = $zone_values['zone_id'];
          } else {
            $error = true;
            $entry_state_error = true;
          }
        }
      } else {
        if (!$state) {
          $error = true;
          $entry_state_error = true;
        }
      }
    }
  }
  if (strlen($telephone) < TYPE_IN_TELEPHONE_MIN_LENGTH) {
    $error = true;
    $entry_telephone_error = true;
  } else {
    $entry_telephone_error = false;
  }
 $check_email = go_db_query("select attendees_email_address from " . DB_TBL_ATTENDEES . " where attendees_email_address = '" . go_db_input($email_address) . "' and attendees_id <> '" . go_db_input($attendee_id) . "'");
  if (go_db_num_rows($check_email)) {
    $error = true;
    $entry_email_address_exists = true;
  } else {
    $entry_email_address_exists = false;
  }
  if ($error == true) {
    $processed = true;
?>
<!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>
<base href="<?php echo (getenv('HTTPS') == 'on' ? HTTPS_SERVER : HTTP_SERVER) . FOLDER_RELATIV_FORMER; ?>">
<link rel="stylesheet" type="text/css" href="load_this/style.css">
<script language="javascript" src="load_this/menu.js"></script>
<?php require('load_this/load_bigware_8.php'); ?>
</head>
<body 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"></td>
<!-- body_text //-->
    <td width="100%" valign="top"><form name="member_change" method="post" <?php echo 'action="' . go_href_link(NAME_OF_FILE_CREATE_MEMBER_PROCESS, '', 'SSL') . '"'; ?> onSubmit="return check_form();"><input type="hidden" name="action" value="process"><table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageGeneralsign"><?php echo ABOVE_TITLE; ?></td>
          </tr>
        </table></td>
      </tr>
<?php
  if (sizeof($navigation->snapshot) > 0) {
?>
      <tr>
        <td class="smallText"><br><?php echo sprintf(TEXT_ORIGIN_LOGIN, go_href_link(NAME_OF_FILE_LOGIN, go_get_all_get_parameter(), 'SSL')); ?></td>
      </tr>
<?php
  }
?>
      <tr>
        <td><?php echo go_fetch_dividing_up('tranparentes.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td>
<?php 
  $member['entry_land_id'] = SHOP_LAND;
  require(FOLDER_RELATIV_MODULES . 'member_details.php');
?>
        </td>
      </tr>
      <tr>
        <td align="right" class="main"><br><?php echo go_picture_submit('button_confirm.gif', PICTURE_BUTTON_CONTINUE); ?></td>
      </tr>
    </table></form></td>
<!-- body_text_eof //-->
    <td width="<?php echo FRAME_WIDTH; ?>" valign="top"><table border="0" width="<?php echo FRAME_WIDTH; ?>" cellspacing="0" cellpadding="2">
    </table></td>
  </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php include(FOLDER_RELATIV_INCLUDES . 'load_bigware_7.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php
  } else  {
    $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' => $password);
                              
        if (MEMBER_GENDER == 'true') $sql_data_array['attendees_gender'] = $gender;
      if (MEMBER_DOB == 'true') $sql_data_array['attendees_dob'] = go_date_raw($dob);
      go_db_carry(DB_TBL_ATTENDEES, $sql_data_array);
      $attendee_id = go_db_insert_id();
      var_dump($attendee_id);
      $sql_data_array = array('attendees_id' => $attendee_id,
                              'entry_firstname' => $firstname,
                              'entry_lastname' => $lastname,
                              'entry_street_address' => $street_address,
                              '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 . "'");
      go_db_query("insert into " . DB_TBL_ATTENDEES_INFO . " (attendees_info_id, attendees_info_number_of_logons, attendees_info_date_member_created) values ('" . (int)$attendee_id . "', '0', now())");
 
    $name = $firstname . " " . $lastname;
    if (MEMBER_GENDER == 'true') {
       if ($_POST['gender'] == 'm') {
         $email_text = EMAIL_GREET_MR;
       } else {
         $email_text = EMAIL_GREET_MS;
       }
    } else {
      $email_text = EMAIL_GREET_NONE;
    }
    $email_text .= EMAIL_WELCOME . EMAIL_PASS_1 . $password_nocrypt . EMAIL_PASS_2 . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;
    go_mail($name, $email_address, EMAIL_SUBJECT, nl2br($email_text), SHOP_OWNER, SHOP_OWNER_EMAIL_ADDRESS);
    go_forward(go_href_link(NAME_OF_FILE_CREATE_MEMBER_SUCCESS, '', 'SSL'));
  }
  require(FOLDER_RELATIV_INCLUDES . 'load_bigware_6.php');
?>