Quick Search:

View

Revision:

Diff

Diff from 182 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/trunk/oscommerce/includes/classes/account.php

Annotated File View

hpdl
176
1 <?php
2 /*
hpdl
182
3   $Id: account.php 182 2005-09-04 15:54:59Z hpdl $
hpdl
176
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2005 osCommerce
9
10   Released under the GNU General Public License
11 */
12
13   class osC_Account {
14
hpdl
179
15     function &getEntry() {
16       global $osC_Database, $osC_Customer;
17
18       $Qaccount = $osC_Database->query('select customers_gender, customers_firstname, customers_lastname, unix_timestamp(customers_dob) as customers_dob, customers_email_address from :table_customers where customers_id = :customers_id');
19       $Qaccount->bindTable(':table_customers', TABLE_CUSTOMERS);
20       $Qaccount->bindInt(':customers_id', $osC_Customer->id);
21       $Qaccount->execute();
22
23       return $Qaccount;
24     }
25
26     function getID($email_address) {
27       global $osC_Database;
28
29       $Quser = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address limit 1');
30       $Quser->bindTable(':table_customers', TABLE_CUSTOMERS);
31       $Quser->bindValue(':customers_email_address', $email_address);
32       $Quser->execute();
33
34       if ($Quser->numberOfRows() === 1) {
35         return $Quser->valueInt('customers_id');
36       }
37
38       return false;
39     }
40
hpdl
180
41     function saveEntry($data) {
42       global $osC_Database, $osC_Customer;
43
44       $Qcustomer = $osC_Database->query('update :table_customers set customers_gender = :customers_gender, customers_firstname = :customers_firstname, customers_lastname = :customers_lastname, customers_email_address = :customers_email_address, customers_dob = :customers_dob where customers_id = :customers_id');
45       $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
46       $Qcustomer->bindValue(':customers_gender', ((ACCOUNT_GENDER > -1) && isset($data['gender']) && (($data['gender'] == 'm') || ($data['gender'] == 'f'))) ? $data['gender'] : '');
47       $Qcustomer->bindValue(':customers_firstname', $data['firstname']);
48       $Qcustomer->bindValue(':customers_lastname', $data['lastname']);
49       $Qcustomer->bindValue(':customers_email_address', $data['email_address']);
50       $Qcustomer->bindValue(':customers_dob', (ACCOUNT_DATE_OF_BIRTH > -1) ? date('Ymd', $data['dob']) : '');
51       $Qcustomer->bindInt(':customers_id', $osC_Customer->id);
52       $Qcustomer->execute();
53
54       if ($Qcustomer->affectedRows() === 1) {
55         $Qupdate = $osC_Database->query('update :table_customers_info set customers_info_date_account_last_modified = now() where customers_info_id = :customers_info_id');
56         $Qupdate->bindTable(':table_customers_info', TABLE_CUSTOMERS_INFO);
57         $Qupdate->bindInt(':customers_info_id', $osC_Customer->id);
58         $Qupdate->execute();
59
60         return true;
61       }
62
63       return false;
64     }
65
hpdl
181
66     function savePassword($password) {
67       global $osC_Database, $osC_Customer;
68
69       $Qcustomer = $osC_Database->query('update :table_customers set customers_password = :customers_password where customers_id = :customers_id');
70       $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
71       $Qcustomer->bindValue(':customers_password', tep_encrypt_password($password));
72       $Qcustomer->bindInt(':customers_id', $osC_Customer->id);
73       $Qcustomer->execute();
74
75       if ($Qcustomer->affectedRows() === 1) {
76         $Qupdate = $osC_Database->query('update :table_customers_info set customers_info_date_account_last_modified = now() where customers_info_id = :customers_info_id');
77         $Qupdate->bindTable(':table_customers_info', TABLE_CUSTOMERS_INFO);
78         $Qupdate->bindInt(':customers_info_id', $osC_Customer->id);
79         $Qupdate->execute();
80
81         return true;
82       }
83
84       return false;
85     }
86
hpdl
176
87     function checkEntry($email_address) {
88       global $osC_Database;
89
90       $Qcheck = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address limit 1');
91       $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
92       $Qcheck->bindValue(':customers_email_address', $email_address);
93       $Qcheck->execute();
94
95       if ($Qcheck->numberOfRows() === 1) {
96         return true;
97       }
98
99       return false;
100     }
101
hpdl
181
102     function checkPassword($password, $email_address = null) {
103       global $osC_Database, $osC_Customer;
hpdl
176
104
hpdl
181
105       if ($email_address === null) {
106         $Qcheck = $osC_Database->query('select customers_password from :table_customers where customers_id = :customers_id');
107         $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
108         $Qcheck->bindInt(':customers_id', $osC_Customer->id);
109         $Qcheck->execute();
110       } else {
111         $Qcheck = $osC_Database->query('select customers_password from :table_customers where customers_email_address = :customers_email_address limit 1');
112         $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
113         $Qcheck->bindValue(':customers_email_address', $email_address);
114         $Qcheck->execute();
115       }
hpdl
176
116
117       if ($Qcheck->numberOfRows() === 1) {
118         if ( (strlen($password) > 0) && (strlen($Qcheck->value('customers_password')) > 0) ) {
119           $stack = explode(':', $Qcheck->value('customers_password'));
120
121           if (sizeof($stack) === 2) {
122             if (md5($stack[1] . $password) == $stack[0]) {
123               return true;
124             }
125           }
126         }
127       }
128
129       return false;
130     }
hpdl
180
131
132     function checkDuplicateEntry($email_address) {
133       global $osC_Database, $osC_Customer;
134
135       $Qcheck = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address and customers_id != :customers_id limit 1');
136       $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
137       $Qcheck->bindValue(':customers_email_address', $email_address);
138       $Qcheck->bindInt(':customers_id', $osC_Customer->id);
139       $Qcheck->execute();
140
141       if ($Qcheck->numberOfRows() === 1) {
142         return true;
143       }
144
145       return false;
146     }
hpdl
176
147   }
148 ?>