Quick Search:

View

Revision:

Diff

Diff from 1843 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/oscommerce2/trunk/catalog/account_edit.php

Annotated File View

hpdl
477
1 <?php
2 /*
hpdl
1739
3   $Id: account_edit.php 1843 2008-12-12 13:32:10Z hpdl $
hpdl
477
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
1840
8   Copyright (c) 2008 osCommerce
hpdl
477
9
10   Released under the GNU General Public License
11 */
12
13   require('includes/application_top.php');
14
15   if (!tep_session_is_registered('customer_id')) {
16     $navigation->set_snapshot();
17     tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
18   }
19
20 // needs to be included earlier to set the success message in the messageStack
21   require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_EDIT);
22
hpdl
1843
23   if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
hpdl
477
24     if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
25     $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
26     $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
27     if (ACCOUNT_DOB == 'true') $dob = tep_db_prepare_input($HTTP_POST_VARS['dob']);
28     $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
29     $telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']);
30     $fax = tep_db_prepare_input($HTTP_POST_VARS['fax']);
31
32     $error = false;
33
34     if (ACCOUNT_GENDER == 'true') {
35       if ( ($gender != 'm') && ($gender != 'f') ) {
36         $error = true;
37
38         $messageStack->add('account_edit', ENTRY_GENDER_ERROR);
39       }
40     }
41
42     if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
43       $error = true;
44
45       $messageStack->add('account_edit', ENTRY_FIRST_NAME_ERROR);
46     }
47
48     if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
49       $error = true;
50
51       $messageStack->add('account_edit', ENTRY_LAST_NAME_ERROR);
52     }
53
54     if (ACCOUNT_DOB == 'true') {
hpdl
1840
55       if ((is_numeric(tep_date_raw($dob)) == false) || (@checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false)) {
hpdl
477
56         $error = true;
57
58         $messageStack->add('account_edit', ENTRY_DATE_OF_BIRTH_ERROR);
59       }
60     }
61
62     if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
63       $error = true;
64
65       $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_ERROR);
66     }
67
68     if (!tep_validate_email($email_address)) {
69       $error = true;
70
71       $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
72     }
73
74     $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' and customers_id != '" . (int)$customer_id . "'");
75     $check_email = tep_db_fetch_array($check_email_query);
76     if ($check_email['total'] > 0) {
77       $error = true;
78
79       $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
80     }
81
82     if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
83       $error = true;
84
85       $messageStack->add('account_edit', ENTRY_TELEPHONE_NUMBER_ERROR);
86     }
87
88     if ($error == false) {
89       $sql_data_array = array('customers_firstname' => $firstname,
90                               'customers_lastname' => $lastname,
91                               'customers_email_address' => $email_address,
92                               'customers_telephone' => $telephone,
93                               'customers_fax' => $fax);
94
95       if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
96       if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($dob);
97
98       tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'");
99
100       tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customer_id . "'");
101
102       $sql_data_array = array('entry_firstname' => $firstname,
103                               'entry_lastname' => $lastname);
104
105       tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$customer_default_address_id . "'");
106
107 // reset the session variables
108       $customer_first_name = $firstname;
109
110       $messageStack->add_session('account', SUCCESS_ACCOUNT_UPDATED, 'success');
111
112       tep_redirect(tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
113     }
114   }
115
116   $account_query = tep_db_query("select customers_gender, customers_firstname, customers_lastname, customers_dob, customers_email_address, customers_telephone, customers_fax from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
117   $account = tep_db_fetch_array($account_query);
118
119   $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
120   $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL'));
121 ?>
122 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
123 <html <?php echo HTML_PARAMS; ?>>
124 <head>
125 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
126 <title><?php echo TITLE; ?></title>
127 <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
128 <link rel="stylesheet" type="text/css" href="stylesheet.css">
129 <?php require('includes/form_check.js.php'); ?>
130 </head>
131 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
132 <!-- header //-->
133 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
134 <!-- header_eof //-->
135
136 <!-- body //-->
137 <table border="0" width="100%" cellspacing="3" cellpadding="3">
138   <tr>
139     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
140 <!-- left_navigation //-->
141 <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
142 <!-- left_navigation_eof //-->
143     </table></td>
144 <!-- body_text //-->
hpdl
1843
145     <td width="100%" valign="top"><?php echo tep_draw_form('account_edit', tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL'), 'post', 'onSubmit="return check_form(account_edit);"', true) . tep_draw_hidden_field('action', 'process'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
hpdl
477
146       <tr>
147         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
148           <tr>
149             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
150             <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
151           </tr>
152         </table></td>
153       </tr>
154       <tr>
155         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
156       </tr>
157 <?php
158   if ($messageStack->size('account_edit') > 0) {
159 ?>
160       <tr>
161         <td><?php echo $messageStack->output('account_edit'); ?></td>
162       </tr>
163       <tr>
164         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
165       </tr>
166 <?php
167   }
168 ?>
169       <tr>
170         <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
171           <tr>
172             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
173               <tr>
174                 <td class="main"><b><?php echo MY_ACCOUNT_TITLE; ?></b></td>
175                 <td class="inputRequirement" align="right"><?php echo FORM_REQUIRED_INFORMATION; ?></td>
176               </tr>
177             </table></td>
178           </tr>
179           <tr>
180             <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
181               <tr class="infoBoxContents">
182                 <td><table border="0" cellspacing="2" cellpadding="2">
183 <?php
184   if (ACCOUNT_GENDER == 'true') {
185     if (isset($gender)) {
186       $male = ($gender == 'm') ? true : false;
187     } else {
188       $male = ($account['customers_gender'] == 'm') ? true : false;
189     }
190     $female = !$male;
191 ?>
192                   <tr>
193                     <td class="main"><?php echo ENTRY_GENDER; ?></td>
194                     <td class="main"><?php echo tep_draw_radio_field('gender', 'm', $male) . '&nbsp;&nbsp;' . MALE . '&nbsp;&nbsp;' . tep_draw_radio_field('gender', 'f', $female) . '&nbsp;&nbsp;' . FEMALE . '&nbsp;' . (tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>': ''); ?></td>
195                   </tr>
196 <?php
197   }
198 ?>
199                   <tr>
200                     <td class="main"><?php echo ENTRY_FIRST_NAME; ?></td>
201                     <td class="main"><?php echo tep_draw_input_field('firstname', $account['customers_firstname']) . '&nbsp;' . (tep_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>': ''); ?></td>
202                   </tr>
203                   <tr>
204                     <td class="main"><?php echo ENTRY_LAST_NAME; ?></td>
205                     <td class="main"><?php echo tep_draw_input_field('lastname', $account['customers_lastname']) . '&nbsp;' . (tep_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_LAST_NAME_TEXT . '</span>': ''); ?></td>
206                   </tr>
207 <?php
208   if (ACCOUNT_DOB == 'true') {
209 ?>
210                   <tr>
211                     <td class="main"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>
212                     <td class="main"><?php echo tep_draw_input_field('dob', tep_date_short($account['customers_dob'])) . '&nbsp;' . (tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': ''); ?></td>
213                   </tr>
214 <?php
215   }
216 ?>
217                   <tr>
218                     <td class="main"><?php echo ENTRY_EMAIL_ADDRESS; ?></td>
219                     <td class="main"><?php echo tep_draw_input_field('email_address', $account['customers_email_address']) . '&nbsp;' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': ''); ?></td>
220                   </tr>
221                   <tr>
222                     <td class="main"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>
223                     <td class="main"><?php echo tep_draw_input_field('telephone', $account['customers_telephone']) . '&nbsp;' . (tep_not_null(ENTRY_TELEPHONE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_TELEPHONE_NUMBER_TEXT . '</span>': ''); ?></td>
224                   </tr>
225                   <tr>
226                     <td class="main"><?php echo ENTRY_FAX_NUMBER; ?></td>
227                     <td class="main"><?php echo tep_draw_input_field('fax', $account['customers_fax']) . '&nbsp;' . (tep_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?></td>
228                   </tr>
229                 </table></td>
230               </tr>
231             </table></td>
232           </tr>
233         </table></td>
234       </tr>
235       <tr>
236         <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
237       </tr>
238       <tr>
239         <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
240           <tr class="infoBoxContents">
241             <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
242               <tr>
243                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
244                 <td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
245                 <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
246                 <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
247               </tr>
248             </table></td>
249           </tr>
250         </table></td>
251       </tr>
252     </table></form></td>
253 <!-- body_text_eof //-->
254     <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
255 <!-- right_navigation //-->
256 <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
257 <!-- right_navigation_eof //-->
258     </table></td>
259   </tr>
260 </table>
261 <!-- body_eof //-->
262
263 <!-- footer //-->
264 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
265 <!-- footer_eof //-->
266 <br>
267 </body>
268 </html>
269 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>