Quick Search:

View

Revision:

Diff

Diff from 180 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 /*
3   $Id: address_book.php 166 2005-08-05 10:14:21 +0200 (Fr, 05 Aug 2005) hpdl $
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
176
66     function checkEntry($email_address) {
67       global $osC_Database;
68
69       $Qcheck = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address limit 1');
70       $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
71       $Qcheck->bindValue(':customers_email_address', $email_address);
72       $Qcheck->execute();
73
74       if ($Qcheck->numberOfRows() === 1) {
75         return true;
76       }
77
78       return false;
79     }
80
81     function checkPassword($email_address, $password) {
82       global $osC_Database;
83
84       $Qcheck = $osC_Database->query('select customers_password from :table_customers where customers_email_address = :customers_email_address limit 1');
85       $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
86       $Qcheck->bindValue(':customers_email_address', $email_address);
87       $Qcheck->execute();
88
89       if ($Qcheck->numberOfRows() === 1) {
90         if ( (strlen($password) > 0) && (strlen($Qcheck->value('customers_password')) > 0) ) {
91           $stack = explode(':', $Qcheck->value('customers_password'));
92
93           if (sizeof($stack) === 2) {
94             if (md5($stack[1] . $password) == $stack[0]) {
95               return true;
96             }
97           }
98         }
99       }
100
101       return false;
102     }
hpdl
180
103
104     function checkDuplicateEntry($email_address) {
105       global $osC_Database, $osC_Customer;
106
107       $Qcheck = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address and customers_id != :customers_id limit 1');
108       $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
109       $Qcheck->bindValue(':customers_email_address', $email_address);
110       $Qcheck->bindInt(':customers_id', $osC_Customer->id);
111       $Qcheck->execute();
112
113       if ($Qcheck->numberOfRows() === 1) {
114         return true;
115       }
116
117       return false;
118     }
hpdl
176
119   }
120 ?>