public function addCustomer($data) { //2015-6-25 两值 不存在报错 zhouping if (!isset($data['city'])) { $data['city'] = ''; } if (!isset($data['zone_id'])) { $data['zone_id'] = 0; } if (isset($data['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($data['customer_group_id'], $this->config->get('config_customer_group_display'))) { $customer_group_id = $data['customer_group_id']; } else { $customer_group_id = $this->config->get('config_customer_group_id'); } $this->load->model('account/customer_group'); $customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id); $this->db->query("INSERT INTO " . DB_PREFIX . "customer SET store_id = '" . (int) $this->config->get('config_store_id') . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', salt = '" . $this->db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)) . "', password = '******'password'])))) . "', newsletter = '" . (isset($data['newsletter']) ? (int) $data['newsletter'] : 0) . "', customer_group_id = '" . (int) $customer_group_id . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', status = '1', approved = '" . (int) (!$customer_group_info['approval']) . "', date_added = NOW()"); $customer_id = $this->db->getLastId(); $this->db->query("INSERT INTO " . DB_PREFIX . "address SET customer_id = '" . (int) $customer_id . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', company = '" . $this->db->escape($data['company']) . "', company_id = '" . $this->db->escape($data['company_id']) . "', tax_id = '" . $this->db->escape($data['tax_id']) . "', batiment = '" . $this->db->escape($data['batiment']) . "', escalier = '" . $this->db->escape($data['escalier']) . "', interphone = '" . $this->db->escape($data['interphone']) . "', ascenceur = '" . $this->db->escape($data['ascenceur']) . "', digicode1 = '" . $this->db->escape($data['digicode1']) . "', digicode2 = '" . $this->db->escape($data['digicode2']) . "', etage = '" . $this->db->escape($data['etage']) . "', porte = '" . $this->db->escape($data['porte']) . "', address_1 = '" . $this->db->escape($data['address_1']) . "', address_2 = '" . $this->db->escape($data['address_2']) . "', city = '" . $this->db->escape(isset($data['city'])) . "', postcode = '" . $this->db->escape($data['postcode']) . "', country_id = '" . (int) $data['country_id'] . "', zone_id = '" . (int) $data['zone_id'] . "'"); $address_id = $this->db->getLastId(); $this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = '" . (int) $address_id . "' WHERE customer_id = '" . (int) $customer_id . "'"); $this->language->load('mail/customer'); $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name')); $message = sprintf($this->language->get('text_welcome'), $this->config->get('config_name')) . "\n\n"; if (!$customer_group_info['approval']) { $message .= $this->language->get('text_login') . "\n"; } else { $message .= $this->language->get('text_approval') . "\n"; } $message .= $this->url->link('account/login', '', 'SSL') . "\n\n"; $message .= $this->language->get('text_services') . "\n\n"; $message .= $this->language->get('text_thanks') . "\n"; $message .= $this->config->get('config_name'); $mail = new PHPMailer(); //建立邮件发送类 $mail->ClearAddresses(); //$mail->CharSet = "GB2312"; $mail->CharSet = "utf-8"; $mail->IsSMTP(); // 使用SMTP方式发送 $mail->Host = $this->config->get('config_smtp_host'); // 您的企业邮局域名 $mail->SMTPAuth = true; // 启用SMTP验证功能 $mail->Username = $this->config->get('config_smtp_username'); // 邮局用户名(请填写完整的email地址) $mail->Password = $this->config->get('config_smtp_password'); // 邮局密码 $mail->Port = $this->config->get('config_smtp_port'); $mail->From = "*****@*****.**"; //邮件发送者email地址 $mail->FromName = $this->config->get('config_title'); //发件人名称 $mail->AddAddress($this->config->get('config_mail_parameter'), "周树平"); //收件人地址,可以替换成任何想要接收邮件的email信箱,格式是AddAddress("收件人email","收件人姓名") // $mail->AddReplyTo("", ""); // echo $mail; // $mail->AddReplyTo("", ""); // $mail->AddAttachment("/var/tmp/file.tar.gz"); // 添加附件 $mail->IsHTML(true); // set email format to HTML //是否使用HTML格式 $mail->Subject = $subject; //邮件标题 $Body = html_entity_decode($message, ENT_QUOTES, 'UTF-8'); $mail->Body = $Body; //邮件内容 //$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //附加信息,可以省略 //$mail->Send(); /* $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($data['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($this->config->get('config_name')); $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8')); $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $mail->send();*/ // Send to main admin email if new account email is enabled if ($this->config->get('config_account_mail')) { $message = $this->language->get('text_signup') . "\n\n"; $message .= $this->language->get('text_website') . ' ' . $this->config->get('config_name') . "\n"; $message .= $this->language->get('text_firstname') . ' ' . $data['firstname'] . "\n"; $message .= $this->language->get('text_lastname') . ' ' . $data['lastname'] . "\n"; $message .= $this->language->get('text_customer_group') . ' ' . $customer_group_info['name'] . "\n"; if ($data['company']) { $message .= $this->language->get('text_company') . ' ' . $data['company'] . "\n"; } $message .= $this->language->get('text_email') . ' ' . $data['email'] . "\n"; $message .= $this->language->get('text_telephone') . ' ' . $data['telephone'] . "\n"; $mail->setTo($this->config->get('config_email')); $mail->setSubject(html_entity_decode($this->language->get('text_new_customer'), ENT_QUOTES, 'UTF-8')); $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $mail->send(); // Send to additional alert emails if new account email is enabled $emails = explode(',', $this->config->get('config_alert_emails')); foreach ($emails as $email) { if (strlen($email) > 0 && preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $email)) { $mail->setTo($email); $mail->send(); } } } }