  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: account.php 184 2005-09-07 14:48:20Z hpdl $ |
| |
| 3 | + | $Id: account.php 206 2005-09-25 22:28:21Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
38 | 38 | | return false; |
| |
39 | 39 | | } |
| |
40 | 40 | | |
  |
| 41 | + | function createEntry($data) { |
| |
| 42 | + | global $osC_Database, $osC_Session, $osC_Customer, $osC_NavigationHistory; |
| |
| 43 | + | |
| |
| 44 | + | $osC_Database->startTransaction(); |
| |
| 45 | + | |
| |
| 46 | + | $Qcustomer = $osC_Database->query('insert into :table_customers (customers_firstname, customers_lastname, customers_email_address, customers_newsletter, customers_status, customers_ip_address, customers_password, customers_gender, customers_dob) values (:customers_firstname, :customers_lastname, :customers_email_address, :customers_newsletter, :customers_status, :customers_ip_address, :customers_password, :customers_gender, :customers_dob)'); |
| |
| 47 | + | $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS); |
| |
| 48 | + | $Qcustomer->bindValue(':customers_firstname', $data['firstname']); |
| |
| 49 | + | $Qcustomer->bindValue(':customers_lastname', $data['lastname']); |
| |
| 50 | + | $Qcustomer->bindValue(':customers_email_address', $data['email_address']); |
| |
| 51 | + | $Qcustomer->bindValue(':customers_newsletter', (isset($data['newsletter']) && ($data['newsletter'] == '1') ? '1' : '')); |
| |
| 52 | + | $Qcustomer->bindValue(':customers_status', '1'); |
| |
| 53 | + | $Qcustomer->bindValue(':customers_ip_address', tep_get_ip_address()); |
| |
| 54 | + | $Qcustomer->bindValue(':customers_password', tep_encrypt_password($data['password'])); |
| |
| 55 | + | $Qcustomer->bindValue(':customers_gender', (((ACCOUNT_GENDER > -1) && isset($data['gender']) && (($data['gender'] == 'm') || ($data['gender'] == 'f'))) ? $data['gender'] : '')); |
| |
| 56 | + | $Qcustomer->bindValue(':customers_dob', ((ACCOUNT_DATE_OF_BIRTH > -1) ? date('Ymd', $data['dob']) : '')); |
| |
| 57 | + | $Qcustomer->execute(); |
| |
| 58 | + | |
| |
| 59 | + | if ($Qcustomer->affectedRows() === 1) { |
| |
| 60 | + | $customer_id = $osC_Database->nextID(); |
| |
| 61 | + | |
| |
| 62 | + | $Qci = $osC_Database->query('insert into :table_customers_info (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values (:customers_info_id, :customers_info_number_of_logons, :customers_info_date_account_created)'); |
| |
| 63 | + | $Qci->bindTable(':table_customers_info', TABLE_CUSTOMERS_INFO); |
| |
| 64 | + | $Qci->bindInt(':customers_info_id', $customer_id); |
| |
| 65 | + | $Qci->bindInt(':customers_info_number_of_logons', 0); |
| |
| 66 | + | $Qci->bindRaw(':customers_info_date_account_created', 'now()'); |
| |
| 67 | + | $Qci->execute(); |
| |
| 68 | + | |
| |
| 69 | + | if ($Qci->affectedRows() === 1) { |
| |
| 70 | + | $osC_Database->commitTransaction(); |
| |
| 71 | + | |
| |
| 72 | + | if (SERVICE_SESSION_REGENERATE_ID == 'True') { |
| |
| 73 | + | $osC_Session->recreate(); |
| |
| 74 | + | } |
| |
| 75 | + | |
| |
| 76 | + | $osC_Customer->setCustomerData($customer_id); |
| |
| 77 | + | |
| |
| 78 | + | // restore cart contents |
| |
| 79 | + | $_SESSION['cart']->restore_contents(); |
| |
| 80 | + | |
| |
| 81 | + | $osC_NavigationHistory->removeCurrentPage(); |
| |
| 82 | + | |
| |
| 83 | + | // build the message content |
| |
| 84 | + | if ((ACCOUNT_GENDER > -1) && isset($data['gender'])) { |
| |
| 85 | + | if ($data['gender'] == 'm') { |
| |
| 86 | + | $email_text = sprintf(EMAIL_GREET_MR, $osC_Customer->getLastName()); |
| |
| 87 | + | } else { |
| |
| 88 | + | $email_text = sprintf(EMAIL_GREET_MS, $osC_Customer->getLastName()); |
| |
| 89 | + | } |
| |
| 90 | + | } else { |
| |
| 91 | + | $email_text = sprintf(EMAIL_GREET_NONE, $osC_Customer->getName()); |
| |
| 92 | + | } |
| |
| 93 | + | |
| |
| 94 | + | $email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING; |
| |
| 95 | + | tep_mail($osC_Customer->getName(), $osC_Customer->getEmailAddress(), EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); |
| |
| 96 | + | |
| |
| 97 | + | return true; |
| |
| 98 | + | } else { |
| |
| 99 | + | $osC_Database->rollbackTransaction(); |
| |
| 100 | + | } |
| |
| 101 | + | } else { |
| |
| 102 | + | $osC_Database->rollbackTransaction(); |
| |
| 103 | + | } |
| |
| 104 | + | |
| |
| 105 | + | return false; |
| |
| 106 | + | } |
| |
| 107 | + | |
  |
41 | 108 | | function saveEntry($data) { |
| |
42 | 109 | | global $osC_Database, $osC_Customer; |
| |
43 | 110 | | |