/** * Send gift certificate va email * * @param int $coupon_id * @param array $data * @return bool */ private function _sendCoupon($coupon_id, $data) { if (!empty($coupon_id)) { if (($coupon = $GLOBALS['db']->select('CubeCart_coupons', false, array('coupon_id' => (int) $coupon_id, 'email_sent' => 0))) !== false) { $mailer = new Mailer(); if (isset($coupon[0]['value'])) { $coupon[0]['value'] = Tax::getInstance()->priceFormat($coupon[0]['value']); } $data['storeURL'] = $GLOBALS['storeURL']; if (($content = $mailer->loadContent('cart.gift_certificate', $this->_order_summary['lang'], array_merge($this->_order_summary, $data, $coupon[0]))) !== false) { $GLOBALS['db']->update('CubeCart_coupons', array('email_sent' => 1), array('coupon_id' => (int) $coupon_id)); return $mailer->sendEmail($data['email'], $content); } } } return false; }
/** * Request password * * @param string $email * @return bool */ public function passwordRequest($email) { if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) { if (($check = $GLOBALS['db']->select('CubeCart_customer', false, array('email' => $email, 'type' => 1))) !== false) { // Generate validation key $validation = Password::getInstance()->createSalt(); if ($GLOBALS['db']->update('CubeCart_customer', array('verify' => $validation), array('customer_id' => (int) $check[0]['customer_id'])) !== false) { // Send email if (($user = $GLOBALS['db']->select('CubeCart_customer', false, array('customer_id' => (int) $check[0]['customer_id']))) !== false) { $mailer = new Mailer(); $link['reset_link'] = CC_STORE_URL . '/index.php?_a=recovery&validate=' . $validation; $data = array_merge($user[0], $link); $content = $mailer->loadContent('account.password_recovery', $GLOBALS['language']->current(), $data); $mailer->sendEmail($user[0]['email'], $content); return true; } } } } return false; }
/** * Products */ private function _product() { if (($product = $GLOBALS['catalogue']->getProductData($_GET['product_id'])) === false) { return; } if ($GLOBALS['config']->get('config', 'enable_reviews') && isset($_POST['review']) && is_array($_POST['review'])) { $error = false; foreach ($GLOBALS['hooks']->load('class.cubecart.review') as $hook) { include $hook; } $record = array_map('htmlspecialchars', $_POST['review']); if ($GLOBALS['user']->is()) { $record['name'] = $GLOBALS['user']->get('first_name') . ' ' . $GLOBALS['user']->get('last_name'); $record['email'] = $GLOBALS['user']->get('email'); $record['customer_id'] = $GLOBALS['user']->get('customer_id'); $record['anon'] = isset($record['anon']) ? 1 : 0; } else { $record['customer_id'] = 0; $record['email'] = $_POST['review']['email']; $record['anon'] = 0; if ($GLOBALS['config']->get('config', 'recaptcha') && !$GLOBALS['session']->isEmpty('error', 'recaptcha')) { $GLOBALS['gui']->setError($GLOBALS['session']->get('error', 'recaptcha')); $error = true; } } $record['rating'] = isset($_POST['rating']) ? $_POST['rating'] : 0; $record['product_id'] = (int) $_GET['product_id']; $record['ip_address'] = get_ip_address(); $record['time'] = time(); // Validate array $required = array('email', 'name', 'review', 'title'); foreach ($required as $req) { if (!isset($record[$req]) || empty($record[$req])) { $GLOBALS['gui']->setError($GLOBALS['language']->common['error_fields_required']); $error = true; break; } } if ($record['rating'] == 0) { $GLOBALS['gui']->setError($GLOBALS['language']->catalogue['error_rating_required']); $error = true; } if (!filter_var($record['email'], FILTER_VALIDATE_EMAIL)) { $GLOBALS['gui']->setError($GLOBALS['language']->common['error_email_invalid']); $error = true; } if (!$error) { if ($GLOBALS['db']->insert('CubeCart_reviews', $record) !== false) { foreach ($GLOBALS['hooks']->load('class.cubecart.review.insert') as $hook) { include $hook; } $GLOBALS['gui']->setNotify($GLOBALS['language']->catalogue['notify_review_submit']); $mail = new Mailer(); $record['link'] = $GLOBALS['storeURL'] . '/' . $GLOBALS['config']->get('config', 'adminFile') . '?_g=products&node=reviews&edit=' . $GLOBALS['db']->insertid(); $record['product_name'] = $product['name']; $content = $mail->loadContent('admin.review_added', $GLOBALS['language']->current(), $record); if (!empty($content)) { $mail->sendEmail($GLOBALS['config']->get('config', 'email_address'), $content); } } else { $GLOBALS['gui']->setError($GLOBALS['language']->catalogue['error_review_submit']); } httpredir(currentPage(null)); } else { foreach ($_POST['review'] as $key => $value) { $_POST['review'][$key] = htmlspecialchars($value); } $GLOBALS['smarty']->assign('WRITE', $_POST['review']); } } $this->_recaptcha(); /* Social Bookmarks */ $GLOBALS['smarty']->assign('SHARE', $this->_getSocial('product', 'getButtonHTML')); /* Social Comments */ $GLOBALS['smarty']->assign('COMMENTS', $this->_getSocial('product', 'getCommunityHTML')); $GLOBALS['catalogue']->displayProduct((int) $_GET['product_id'], true); }
/** * Request password * * @param string $username * @param string $email * @return bool */ public function passwordRequest($username, $email) { if (!empty($username) && !empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) { if (($check = $GLOBALS['db']->select('CubeCart_admin_users', array('admin_id', 'email', 'language', 'name'), array('username' => $username, 'email' => $email, 'status' => '1'))) !== false) { // Generate validation key $validation = randomString($this->_validate_key_len); if ($GLOBALS['db']->update('CubeCart_admin_users', array('verify' => $validation), array('admin_id' => (int) $check[0]['admin_id']))) { // Send email $mailer = new Mailer(); $data['link'] = $GLOBALS['storeURL'] . '/' . $GLOBALS['config']->get('config', 'adminFile') . '?_g=recovery&email=' . $check[0]['email'] . '&validate=' . $validation; $data['name'] = $check[0]['name']; $content = $mailer->loadContent('admin.password_recovery', $check[0]['language'], $data); if ($content) { $GLOBALS['smarty']->assign('DATA', $data); $GLOBALS['session']->set('recover_login', true); return $mailer->sendEmail($check[0]['email'], $content); } } } } return false; }