コード例 #1
0
 /**
  * @param string $loginname
  * @param string $password
  * @return bool
  */
 public function login($loginname, $password)
 {
     $approved_only = '';
     if ($this->config->get('config_customer_approval')) {
         $approved_only = " AND approved = '1'";
     }
     $customer_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("customers") . "\n\t\t\t\t\t\t\t\t\t\t\tWHERE LOWER(loginname)  = LOWER('" . $this->db->escape($loginname) . "')\n\t\t\t\t\t\t\t\t\t\t\tAND password = '******'\n\t\t\t\t\t\t\t\t\t\t\tAND status = '1'" . $approved_only);
     if ($customer_query->num_rows) {
         $this->customer_id = $this->session->data['customer_id'] = $customer_query->row['customer_id'];
         //load customer saved cart and merge with session cart before login
         $cart = $this->getCustomerCart();
         $this->mergeCustomerCart($cart);
         //save merged cart
         $this->saveCustomerCart();
         $this->loginname = $loginname;
         $this->firstname = $customer_query->row['firstname'];
         $this->lastname = $customer_query->row['lastname'];
         if ($this->dcrypt->active) {
             $this->email = $this->dcrypt->decrypt_field($customer_query->row['email'], $customer_query->row['key_id']);
             $this->telephone = $this->dcrypt->decrypt_field($customer_query->row['telephone'], $customer_query->row['key_id']);
             $this->fax = $this->dcrypt->decrypt_field($customer_query->row['fax'], $customer_query->row['key_id']);
         } else {
             $this->email = $customer_query->row['email'];
             $this->telephone = $customer_query->row['telephone'];
             $this->fax = $customer_query->row['fax'];
         }
         $this->newsletter = $customer_query->row['newsletter'];
         $this->customer_group_id = $customer_query->row['customer_group_id'];
         $this->address_id = $customer_query->row['address_id'];
         $this->cache->delete('storefront_menu');
         //set cookie for unauthenticated user (expire in 1 year)
         $encryption = new AEncryption($this->config->get('encryption_key'));
         $cutomer_data = $encryption->encrypt(serialize(array('first_name' => $this->firstname, 'customer_id' => $this->customer_id, 'script_name' => $this->request->server['SCRIPT_NAME'])));
         setcookie('customer', $cutomer_data, time() + 60 * 60 * 24 * 365, '/', $this->request->server['HTTP_HOST']);
         return true;
     } else {
         return false;
     }
 }
コード例 #2
0
 /**
  * Usage of tables with unencrypted data
  * @param ADataEncryption $enc_data
  * @return array
  */
 private function _load_unencrypted_stats($enc_data)
 {
     $usage = array();
     $enc_config_tables = $enc_data->getEcryptedTables();
     foreach ($enc_config_tables as $table_name) {
         $row = array();
         $row['table'] = $table_name;
         //select total counts. Important to use non-encripted table. Do NOT use table function wrapper
         $query = $this->db->query("SELECT count(*) as total FROM " . DB_PREFIX . $table_name);
         $row['count'] = $query->row['total'];
         $usage[] = $row;
     }
     return $usage;
 }
コード例 #3
0
ファイル: customer.php プロジェクト: harshzalavadiya/fatak
 /**
  * @param string $loginname
  * @param string $password
  * @return bool
  */
 public function login($loginname, $password)
 {
     $approved_only = '';
     if ($this->config->get('config_customer_approval')) {
         $approved_only = " AND approved = '1'";
     }
     $customer_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("customers") . "\n\t\t\t\t\t\t\t\t\t\t\tWHERE loginname = '" . $this->db->escape($loginname) . "'\n\t\t\t\t\t\t\t\t\t\t\tAND password = '******'\n\t\t\t\t\t\t\t\t\t\t\tAND status = '1'" . $approved_only);
     if ($customer_query->num_rows) {
         $this->session->data['customer_id'] = $customer_query->row['customer_id'];
         if ($customer_query->row['cart'] && is_string($customer_query->row['cart'])) {
             $cart = unserialize($customer_query->row['cart']);
             foreach ($cart as $key => $value) {
                 if (!array_key_exists($key, $this->session->data['cart'])) {
                     $this->session->data['cart'][$key] = $value;
                 } else {
                     $this->session->data['cart'][$key]['qty'] += $value['qty'];
                 }
             }
         }
         $this->loginname = $loginname;
         $this->customer_id = $customer_query->row['customer_id'];
         $this->firstname = $customer_query->row['firstname'];
         $this->lastname = $customer_query->row['lastname'];
         if ($this->dcrypt->active) {
             $this->email = $this->dcrypt->decrypt_field($customer_query->row['email'], $customer_query->row['key_id']);
             $this->telephone = $this->dcrypt->decrypt_field($customer_query->row['telephone'], $customer_query->row['key_id']);
             $this->fax = $this->dcrypt->decrypt_field($customer_query->row['fax'], $customer_query->row['key_id']);
         } else {
             $this->email = $customer_query->row['email'];
             $this->telephone = $customer_query->row['telephone'];
             $this->fax = $customer_query->row['fax'];
         }
         $this->newsletter = $customer_query->row['newsletter'];
         $this->customer_group_id = $customer_query->row['customer_group_id'];
         $this->address_id = $customer_query->row['address_id'];
         $this->cache->delete('storefront_menu');
         return TRUE;
     } else {
         return FALSE;
     }
 }