function setEmailAction()
 {
     $this->viewClass = "JsonView";
     if (!Config::get("newsletterEnabled")) {
         $this->return404();
     }
     $errorMessage = $this->newsletterEmail->validate($this->request);
     if ($errorMessage) {
         $this->set("status", "error");
         $this->set("message", _t($errorMessage));
         return;
     }
     if (!empty($this->request->addEmail)) {
         $newsletterEmail = $this->newsletterEmail->addEmail($this->request->email);
         if ($newsletterEmail) {
             $verification = $this->verification->addVerification($newsletterEmail->emailId, "newsletterEmailAdd");
             $confirmLink = Config::get("siteRootUrl") . $this->moduleLink("confirmNewsletterEmailAdd/" . $verification->code, false);
             Mailer::getInstance()->sendEmailConfirmation("newsletterEmailAdd", $this->request->email, $confirmLink);
         }
         $this->set("message", _t("Your email was added. Check your inbox to confirm it"));
     }
     if (!empty($this->request->deleteEmail)) {
         $verification = $this->verification->addVerification(null, "newsletterEmailDel", $this->request->email);
         $confirmLink = Config::get("siteRootUrl") . $this->moduleLink("confirmNewsletterEmailDel/" . $verification->code, false);
         Mailer::getInstance()->sendEmailConfirmation("newsletterEmailDel", $this->request->email, $confirmLink);
         $this->set("message", _t("Check your inbox and click on remove link"));
     }
     $this->set("status", "ok");
     $this->set("redirectUrl", Config::get("siteRootUrl"));
 }
Beispiel #2
0
 function lostPasswordAction()
 {
     if (empty($this->request->email)) {
         return;
     }
     $c = new Criteria();
     $c->add("email", $this->request->email);
     $c->add("role", "moderator");
     $user = $this->user->find($c);
     if (empty($user)) {
         return;
     }
     $newPassword = $user->generateNewPassword();
     Mailer::getInstance()->sendLostPassword($user->email, $newPassword);
     $this->redirect($this->moduleLink("logIn"));
 }
Beispiel #3
0
 /**
  * Update site state from waiting sites
  */
 function updateSiteStateAction()
 {
     //check that siteid is set and status is valid
     if (!empty($this->request->siteIds) && in_array($this->request->status, array("validated", "banned", "refused"))) {
         $siteIds = $this->request->siteIds;
         $status = $this->request->status;
         $mailer = Mailer::getInstance();
         //get sites which status code should be changed
         $c = new Criteria();
         $c->add("siteId", $siteIds, "IN");
         $sites = $this->site->findAll($c, "*", true);
         foreach ($sites as $site) {
             $site['status'] = $status;
             $customSubject = false;
             $customDescription = false;
             $siteId = $site['siteId'];
             //if admin select custom message copy it to mail message
             if ($this->request->emailType[$siteId] == "custom") {
                 $customSubject = $this->request->subject[$siteId];
                 $customDescription = $this->request->description[$siteId];
             }
             //send mail with state update
             if (Config::get("informWebmastersForAdminValidateDecision") && $status == "validated" || Config::get("informWebmastersForAdminBanDecision") && $status == "banned" || Config::get("informWebmastersForAdminRefuseDecision") && $status == "refused") {
                 $mailer->sendSiteStateUpdate($site['webmasterEmail'], $site, $customSubject, $customDescription);
             }
         }
         if ($status == "refused") {
             //delete site
             $this->site->del($c);
             //update refusing stats
             $this->refusal->updateRefusedSitesCount(0, count($sites));
         } else {
             //set page moderator id 0 = admin
             $this->site->update(array("status" => $status, "moderatorId" => 0, "_creationDate" => "NOW()"), $c);
         }
     }
     $this->redirect($this->moduleLink("waiting"));
 }
Beispiel #4
0
 public function saveCommentAction()
 {
     if (!Config::get('commentsEnabled')) {
         $this->return404();
     }
     $this->viewClass = "JsonView";
     $siteId = $this->request->itemId;
     $site = $this->site->findByPk($siteId);
     if (empty($site)) {
         return $this->return404();
     }
     $errorMessage = $this->comment->validate($this->request);
     if (Config::get('captchaEnabledOnComments') && !$errorMessage && !$this->captchaCode->validatePublicAndPrivateCodes($this->request)) {
         $errorMessage = 'You did not guess the security code.';
     }
     if (empty($errorMessage)) {
         $comment = new CommentRecord();
         $comment->fromArray($this->request->getArray(array("pseudo", "text", "rating")));
         $comment->siteId = $site->siteId;
         $comment->validated = Config::get("automaticCommentValidation") ? 1 : 0;
         $comment->remoteIp = $this->request->getIp();
         $comment->save();
         if (Config::get("sendEmailsOnComment")) {
             Mailer::getInstance()->sendNewCommentNotificationToAdmin($site);
         }
         $this->comment->setSiteCookie($site->siteId);
         $this->set("status", "ok");
         if (Config::get("automaticCommentValidation")) {
             $this->set("message", _t('Your comment was saved'));
         } else {
             $this->set("message", _t('Your comment was saved. He is awaiting moderation and will be published if it is useful for surfers'));
         }
     } else {
         $this->set("status", "error");
         $this->set("message", _t($errorMessage));
     }
 }
Beispiel #5
0
 public function __construct()
 {
     $this->_mailer = Mailer::getInstance();
 }
Beispiel #6
0
 /**
  * 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 = Mailer::getInstance();
                     $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;
 }
Beispiel #7
0
 function sendMessageToAdminAction()
 {
     $this->viewClass = "JsonView";
     $errorMessage = "";
     if (Config::get('captchaEnabledOnContactForm') && !$errorMessage && !$this->captchaCode->validatePublicAndPrivateCodes($this->request)) {
         $errorMessage = 'You did not guess the security code.';
     }
     if (empty($errorMessage)) {
         Mailer::getInstance()->sendEmail(Mailer::getInstance()->getAdminEmail(), $this->request->title, $this->request->description, $this->request->yourEmail);
         $this->set("status", "ok");
     } else {
         $this->set("status", "error");
         $this->set("message", _t($errorMessage));
     }
 }
Beispiel #8
0
 /**
  * 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))) !== false) {
             $mailer = Mailer::getInstance();
             if (isset($coupon[0]['value'])) {
                 $coupon[0]['value'] = Tax::getInstance()->priceFormat($coupon[0]['value']);
             }
             $data['storeURL'] = $this->config['storeURL'];
             if (($content = $mailer->loadContent('cart.gift_certificate', $this->_order_summary['lang'], array_merge($this->_order_summary, $data, $coupon[0]))) !== false) {
                 return $mailer->sendEmail($data['email'], $content);
             }
         }
     }
     return false;
 }
 /**
  * Get the mailer instance
  *
  * @return \MimeMailer\Mailer
  */
 public function getMailer()
 {
     return Mailer::getInstance();
 }
Beispiel #10
0
 /**
  * Test SMPT 
  *
  * @return data/false
  */
 public static function SMTPTest()
 {
     if (CC_IN_ADMIN) {
         @ob_start();
         $test_mailer = Mailer::getInstance();
         $test_mailer->SMTPDebug = 2;
         $test_mailer->Debugoutput = "html";
         $test_mailer->ClearAddresses();
         $test_mailer->Password = $GLOBALS['config']->get('config', 'email_smtp_password');
         $test_mailer->AddAddress($GLOBALS['config']->get('config', 'email_address'));
         $test_mailer->Subject = "Testing CubeCart";
         $test_mailer->Body = "Testing from CubeCart v" . CC_VERSION . " at " . CC_STORE_URL;
         $test_mailer->AltBody = "Testing from CubeCart v" . CC_VERSION . " at " . CC_STORE_URL;
         // Send email
         $email_test_send_result = $test_mailer->Send();
         $email_test_results = @ob_get_contents();
         @ob_end_clean();
         if (!empty($email_test_results)) {
             $email_test_results_data = array('request_url' => 'mailto:' . $GLOBALS['config']->get('config', 'email_address'), 'request' => 'Subject: Testing CubeCart', 'result' => $email_test_results, 'error' => $email_test_send_result ? null : "Mailer Failed");
             $GLOBALS['db']->insert('CubeCart_request_log', $email_test_results_data);
             $json = $email_test_results;
         } else {
             $json = "Test failed to execute.";
         }
         return $json;
     }
     return false;
 }
Beispiel #11
0
 function sendTestEmailAction($messageId)
 {
     $c = new Criteria();
     $c->addOrder("RAND()");
     $c->setLimit(1);
     $site = $this->site->find($c);
     if ($site) {
         $mailer = Mailer::getInstance();
         $adminEmail = $mailer->getAdminEmail();
         $confirmLink = Config::get("siteRootUrl") . $this->moduleLink("confirmSiteEmail/testcode", false);
         switch ($messageId) {
             case "submitSite":
                 $mailer->sendAdminNotification($site);
                 break;
             case "webmasterSubmitSite":
                 $mailer->sendWebmasterNotification($site, $adminEmail);
                 break;
             case "validateSite":
                 $site->status = "validated";
                 $mailer->sendSiteStateUpdate($adminEmail, $site);
                 break;
             case "refuseSite":
                 $site->status = "refused";
                 $mailer->sendSiteStateUpdate($adminEmail, $site);
                 break;
             case "newsletterEmailAdd":
             case "newsletterEmailDel":
             case "siteEmail":
             case "userEmail":
                 $mailer->sendEmailConfirmation($messageId, $adminEmail, $confirmLink);
                 break;
             default:
                 $message = $this->customMessage->findByPk($messageId);
                 if ($message) {
                     $site->status = "validated";
                     $mailer->sendSiteStateUpdate($adminEmail, $site, $message->title, $message->description);
                 }
         }
     }
     $this->redirect($this->moduleLink("email"));
 }
 protected function afterParsing()
 {
     Mailer::getInstance()->sendDuplicateContentTaskFinished();
 }
Beispiel #13
0
 /**
  * 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 = Mailer::getInstance();
                 $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;
 }
Beispiel #14
0
 function updateSiteStateAction()
 {
     if (!empty($this->request->siteIds) && in_array($this->request->status, array("validated", "banned", "refused"))) {
         $siteIds = $this->request->siteIds;
         $status = $this->request->status;
         $mailer = Mailer::getInstance();
         $c = new Criteria();
         $c->add("status", "waiting");
         $c->add("siteId", $siteIds, "IN");
         $sites = $this->site->findAll($c, "*", true);
         foreach ($sites as $site) {
             $site['status'] = $status;
             $customSubject = false;
             $customDescription = false;
             $siteId = $site['siteId'];
             if ($this->request->emailType[$siteId] == "custom") {
                 $customSubject = $this->request->subject[$siteId];
                 $customDescription = $this->request->description[$siteId];
             }
             $mailer->sendSiteStateUpdate($site['webmasterEmail'], $site, $customSubject, $customDescription);
         }
         if ($status == "refused") {
             $this->site->del($c);
             $this->refusal->updateRefusedSitesCount($this->userId, count($sites));
         } else {
             $this->site->update(array("status" => $status, "proposalForKeywords" => "", "proposalForCategory" => "", "moderatorId" => $this->userId, "_creationDate" => "NOW()"), $c);
         }
     }
     $this->redirect($this->moduleLink("waiting"));
 }
Beispiel #15
0
 /**
  * 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'])) {
         foreach ($GLOBALS['hooks']->load('class.cubecart.review') as $hook) {
             include $hook;
         }
         $error = false;
         $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 = Mailer::getInstance();
                 $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);
 }
Beispiel #16
0
 /**
  * Display lost password form and send it to user email
  */
 function lostPasswordAction()
 {
     //if no posta data only display form
     if (empty($this->request->email)) {
         return;
     }
     //search that email is correct
     $c = new Criteria();
     $c->add("email", $this->request->email);
     $c->add("role", "administrator");
     $user = $this->user->find($c);
     if (empty($user)) {
         return;
     }
     //generate and send new password
     $newPassword = $user->generateNewPassword();
     Mailer::getInstance()->sendLostPassword($user->email, $newPassword);
     $this->redirect($this->moduleLink("logIn"));
 }
 protected function afterParsing()
 {
     Mailer::getInstance()->sendNewsletterTaskFinished();
 }
 protected function afterParsing()
 {
     Mailer::getInstance()->sendSiteBacklinkTaskFinished();
 }
Beispiel #19
0
 function sendLostPasswordAction()
 {
     $this->viewClass = "JsonView";
     //get user which have this email and role webmaster
     $c = new Criteria();
     $c->add("email", $this->request->email);
     $c->add("role", "webmaster");
     $user = $this->user->find($c);
     if (empty($user)) {
         $errorMessage = "We haven't this email in database";
     }
     if (Config::get('captchaEnabledOnContactForm') && empty($errorMessage) && !$this->captchaCode->validatePublicAndPrivateCodes($this->request)) {
         $errorMessage = 'You did not guess the security code.';
     }
     if (empty($errorMessage)) {
         $newPassword = $user->generateNewPassword();
         Mailer::getInstance()->sendLostPassword($user->email, $newPassword);
         $this->set("status", "ok");
     } else {
         $this->set("status", "error");
         $this->set("message", _t($errorMessage));
     }
 }