[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/includes/modules/pages/account_edit/ -> header_php.php (source)

   1  <?php
   2  /**

   3   * Header code file for the customer's Account-Edit page

   4   *

   5   * @package page

   6   * @copyright Copyright 2003-2006 Zen Cart Development Team

   7   * @copyright Portions Copyright 2003 osCommerce

   8   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   9   * @version $Id: header_php.php 4825 2006-10-23 22:25:11Z drbyte $

  10   */
  11  // This should be first line of the script:

  12  $zco_notifier->notify('NOTIFY_HEADER_START_ACCOUNT_EDIT');
  13  
  14  if (!$_SESSION['customer_id']) {
  15    $_SESSION['navigation']->set_snapshot();
  16    zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
  17  }
  18  
  19  require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
  20  if (isset($_POST['action']) && ($_POST['action'] == 'process')) {
  21    if (ACCOUNT_GENDER == 'true') $gender = zen_db_prepare_input($_POST['gender']);
  22    $firstname = zen_db_prepare_input($_POST['firstname']);
  23    $lastname = zen_db_prepare_input($_POST['lastname']);
  24    if (ACCOUNT_DOB == 'true') $dob = (empty($_POST['dob']) ? zen_db_prepare_input('0001-01-01 00:00:00') : zen_db_prepare_input($_POST['dob']));
  25    $email_address = zen_db_prepare_input($_POST['email_address']);
  26    $telephone = zen_db_prepare_input($_POST['telephone']);
  27    $fax = zen_db_prepare_input($_POST['fax']);
  28    $email_format = zen_db_prepare_input($_POST['email_format']);
  29  
  30    if (CUSTOMERS_REFERRAL_STATUS == '2' and $_POST['customers_referral'] != '') $customers_referral = zen_db_prepare_input($_POST['customers_referral']);
  31  
  32    $error = false;
  33  
  34    if (ACCOUNT_GENDER == 'true') {
  35      if ( ($gender != 'm') && ($gender != 'f') ) {
  36        $error = true;
  37        $messageStack->add('account_edit', ENTRY_GENDER_ERROR);
  38      }
  39    }
  40  
  41    if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
  42      $error = true;
  43      $messageStack->add('account_edit', ENTRY_FIRST_NAME_ERROR);
  44    }
  45  
  46    if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
  47      $error = true;
  48      $messageStack->add('account_edit', ENTRY_LAST_NAME_ERROR);
  49    }
  50  
  51    if (ACCOUNT_DOB == 'true') {
  52      if (ENTRY_DOB_MIN_LENGTH > 0 or !empty($_POST['dob'])) {
  53        if (substr_count($dob,'/') > 2 || checkdate((int)substr(zen_date_raw($dob), 4, 2), (int)substr(zen_date_raw($dob), 6, 2), (int)substr(zen_date_raw($dob), 0, 4)) == false) {
  54          $error = true;
  55          $messageStack->add('account_edit', ENTRY_DATE_OF_BIRTH_ERROR);
  56        }
  57      }
  58    }
  59  
  60    if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
  61      $error = true;
  62      $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_ERROR);
  63    }
  64  
  65    if (!zen_validate_email($email_address)) {
  66      $error = true;
  67      $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
  68    }
  69  
  70    $check_email_query = "SELECT count(*) AS total
  71                          FROM   " . TABLE_CUSTOMERS . "
  72                          WHERE  customers_email_address = :emailAddress
  73                          AND    customers_id != :customersID";
  74  
  75    $check_email_query = $db->bindVars($check_email_query, ':emailAddress', $email_address, 'string');
  76    $check_email_query = $db->bindVars($check_email_query, ':customersID', $_SESSION['customer_id'], 'integer');
  77    $check_email = $db->Execute($check_email_query);
  78  
  79    if ($check_email->fields['total'] > 0) {
  80      $error = true;
  81      $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
  82  
  83      // check phpBB for duplicate email address

  84      if ($phpBB->phpbb_check_for_duplicate_email(zen_db_input($email_address)) == 'already_exists' ) {
  85        $error = true;
  86        $messageStack->add('account_edit', 'phpBB-'.ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
  87      }
  88    }
  89  
  90  
  91    if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
  92      $error = true;
  93  
  94      $messageStack->add('account_edit', ENTRY_TELEPHONE_NUMBER_ERROR);
  95    }
  96  
  97    if ($error == false) {
  98      //update phpBB with new email address

  99      $old_addr_check=$db->Execute("select customers_email_address from ".TABLE_CUSTOMERS." where customers_id='".(int)$_SESSION['customer_id']."'");
 100      $phpBB->phpbb_change_email(zen_db_input($old_addr_check->fields['customers_email_address']),zen_db_input($email_address));
 101  
 102      $sql_data_array = array(array('fieldName'=>'customers_firstname', 'value'=>$firstname, 'type'=>'string'),
 103                              array('fieldName'=>'customers_lastname', 'value'=>$lastname, 'type'=>'string'),
 104                              array('fieldName'=>'customers_email_address', 'value'=>$email_address, 'type'=>'string'),
 105                              array('fieldName'=>'customers_telephone', 'value'=>$telephone, 'type'=>'string'),
 106                              array('fieldName'=>'customers_fax', 'value'=>$fax, 'type'=>'string'),
 107                              array('fieldName'=>'customers_email_format', 'value'=>$email_format, 'type'=>'string')
 108      );
 109  
 110      if ((CUSTOMERS_REFERRAL_STATUS == '2' and $customers_referral != '')) {
 111        $sql_data_array[] = array('fieldName'=>'customers_referral', 'value'=>$customers_referral, 'type'=>'string');
 112      }
 113      if (ACCOUNT_GENDER == 'true') {
 114        $sql_data_array[] = array('fieldName'=>'customers_gender', 'value'=>$gender, 'type'=>'string');
 115      }
 116      if (ACCOUNT_DOB == 'true') {
 117        if ($dob == '0001-01-01 00:00:00' or $_POST['dob'] == '') {
 118          $sql_data_array[] = array('fieldName'=>'customers_dob', 'value'=>'0001-01-01 00:00:00', 'type'=>'date');
 119        } else {
 120          $sql_data_array[] = array('fieldName'=>'customers_dob', 'value'=>zen_date_raw($_POST['dob']), 'type'=>'date');
 121        }
 122      }
 123  
 124      $where_clause = "customers_id = :customersID";
 125      $where_clause = $db->bindVars($where_clause, ':customersID', $_SESSION['customer_id'], 'integer');
 126      $db->perform(TABLE_CUSTOMERS, $sql_data_array, 'update', $where_clause);
 127  
 128      $sql = "UPDATE " . TABLE_CUSTOMERS_INFO . "
 129              SET    customers_info_date_account_last_modified = now()
 130              WHERE  customers_info_id = :customersID";
 131  
 132      $sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
 133  
 134      $db->Execute($sql);
 135  
 136      $where_clause = "customers_id = :customersID AND address_book_id = :customerDefaultAddressID";
 137      $where_clause = $db->bindVars($where_clause, ':customersID', $_SESSION['customer_id'], 'integer');
 138      $where_clause = $db->bindVars($where_clause, ':customerDefaultAddressID', $_SESSION['customer_default_address_id'], 'integer');
 139      $sql_data_array = array(array('fieldName'=>'entry_firstname', 'value'=>$firstname, 'type'=>'string'),
 140      array('fieldName'=>'entry_lastname', 'value'=>$lastname, 'type'=>'string'));
 141  
 142      $db->perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', $where_clause);
 143  
 144      $zco_notifier->notify('NOTIFY_HEADER_ACCOUNT_EDIT_UPDATES_COMPLETE');
 145  
 146      // reset the session variables

 147      $_SESSION['customer_first_name'] = $firstname;
 148  
 149      $messageStack->add_session('account', SUCCESS_ACCOUNT_UPDATED, 'success');
 150  
 151      zen_redirect(zen_href_link(FILENAME_ACCOUNT, '', 'SSL'));
 152    }
 153  }
 154  
 155  $account_query = "SELECT customers_gender, customers_firstname, customers_lastname,
 156                           customers_dob, customers_email_address, customers_telephone,
 157                           customers_fax, customers_email_format, customers_referral
 158                    FROM   " . TABLE_CUSTOMERS . "
 159                    WHERE  customers_id = :customersID";
 160  
 161  $account_query = $db->bindVars($account_query, ':customersID', $_SESSION['customer_id'], 'integer');
 162  $account = $db->Execute($account_query);
 163  if (ACCOUNT_GENDER == 'true') {
 164    if (isset($gender)) {
 165      $male = ($gender == 'm') ? true : false;
 166    } else {
 167      $male = ($account->fields['customers_gender'] == 'm') ? true : false;
 168    }
 169    $female = !$male;
 170  }
 171  
 172  // if DOB field has database default setting, show blank:

 173  $dob = ($dob == '0001-01-01 00:00:00') ? '' : $dob;
 174  
 175  $customers_referral = $account->fields['customers_referral'];
 176  
 177  if (isset($customers_email_format)) {
 178    $email_pref_html = (($customers_email_format == 'HTML') ? true : false);
 179    $email_pref_none = (($customers_email_format == 'NONE') ? true : false);
 180    $email_pref_optout = (($customers_email_format == 'OUT')  ? true : false);
 181    $email_pref_text = (($email_pref_html || $email_pref_none || $email_pref_out) ? false : true);  // if not in any of the others, assume TEXT

 182  } else {
 183    $email_pref_html = (($account->fields['customers_email_format'] == 'HTML') ? true : false);
 184    $email_pref_none = (($account->fields['customers_email_format'] == 'NONE') ? true : false);
 185    $email_pref_optout = (($account->fields['customers_email_format'] == 'OUT')  ? true : false);
 186    $email_pref_text = (($email_pref_html || $email_pref_none || $email_pref_out) ? false : true);  // if not in any of the others, assume TEXT

 187  }
 188  
 189  $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ACCOUNT, '', 'SSL'));
 190  $breadcrumb->add(NAVBAR_TITLE_2);
 191  
 192  // This should be last line of the script:

 193  $zco_notifier->notify('NOTIFY_HEADER_END_ACCOUNT_EDIT');
 194  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics