Exemple #1
0
 /**
  * 
  * @param string $key 配置key
  * @param string $to 收件人
  * @param string $subject 主题
  * @param string $body 内容
  */
 public static function normal_send($key, $to, $subject, $body, $toname = '')
 {
     $pzarr = Conf::$email[$key];
     if ($pzarr['protocol'] == 'smtp') {
         $mail = new Mailer();
         $mail->IsSMTP();
         $mail->Host = $pzarr['smtp_host'];
         // SMTP server
         $mail->SMTPDebug = 2;
         // enables SMTP debug information (for testing)
         $mail->SMTPAuth = true;
         // enable SMTP authentication
         $mail->Port = isset($pzarr['smtp_port']) ? $pzarr['smtp_port'] : 25;
         // set the SMTP port for the GMAIL server
         $mail->Username = $pzarr['smtp_user'];
         // SMTP account username
         $mail->Password = $pzarr['smtp_pass'];
         // SMTP account password
         $mail->AddReplyTo($pzarr['from'][0], $pzarr['from'][1]);
         $mail->SetFrom($pzarr['from'][0], $pzarr['from'][1]);
         $mail->AddAddress($to, $toname);
         $mail->Subject = $subject;
         $mail->Body = $body;
         $mail->IsHTML();
         $mail->Send();
     }
 }
 public function index()
 {
     $this->load->library('url');
     $this->document->title = $this->language->get('heading_title');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->load->library('email/mailer');
         $mailer = new Mailer();
         $subject = "Sugerencias NecoTienda";
         $message .= "<p>Dominio:<b>" . $this->request->post['domain'] . "</b></p><br />";
         $message .= "<p>IP Browser:<b>" . $this->request->post['remote_ip'] . "</b></p><br />";
         $message .= "<p>IP Server:<b>" . $this->request->post['server_ip'] . "</b></p><br />";
         $message .= "<p>Cliente ID:<b>" . C_CODE . "</b></p><br />";
         $message .= "<p>Sugerencia:<b>" . HTTP_HOME . "</b></p><br />";
         $message .= "<p>" . $this->request->post['feedback'] . "</p>";
         $message .= "<hr />";
         $message .= "Server Vars:" . serialize($_SERVER);
         if ($this->config->get('config_smtp_method') == 'smtp') {
             $mailer->IsSMTP();
             $mailer->Host = $this->config->get('config_smtp_host');
             $mailer->Username = $this->config->get('config_smtp_username');
             $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
             $mailer->Port = $this->config->get('config_smtp_port');
             $mailer->Timeout = $this->config->get('config_smtp_timeout');
             $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
             $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
         } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
             $mailer->IsSendmail();
         } else {
             $mailer->IsMail();
         }
         $mailer->IsHTML();
         $mailer->AddAddress("*****@*****.**", "Support NecoTienda");
         $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
         $mailer->Subject = $subject;
         $mailer->Body = $message;
         $mailer->Send();
     }
     $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
 }
 protected function notifyReview($page_id)
 {
     if (!$page_id) {
         return false;
     }
     $this->load->auto('email/mailer');
     $this->load->auto('content/page');
     $this->load->auto('store/review');
     $this->load->auto('marketing/newsletter');
     $page_info = $this->modelPage->getById($page_id);
     if ($page_info) {
         $page = $this->modelNewsletter->getById($this->config->get('marketing_email_new_comment'));
         $subject = $page['title'];
         $message = str_replace("{%page_url%}", Url::createUrl('content/page', array('page_id' => $page_id)), $page['description']);
         $message = str_replace("{%page_name%}", $page_info['title'], $message);
         $mailer = new Mailer();
         $reps = $this->modelReview->getCustomersReviewsByPageId($page_id);
         foreach ($reps as $k => $v) {
             $mailer->AddBCC($v['email'], $v['author']);
         }
         $mailer->AddBCC($this->config->get('config_email'), $this->config->get('config_name'));
         if ($this->config->get('config_smtp_method') == 'smtp') {
             $mailer->IsSMTP();
             $mailer->Host = $this->config->get('config_smtp_host');
             $mailer->Username = $this->config->get('config_smtp_username');
             $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
             $mailer->Port = $this->config->get('config_smtp_port');
             $mailer->Timeout = $this->config->get('config_smtp_timeout');
             $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
             $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
         } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
             $mailer->IsSendmail();
         } else {
             $mailer->IsMail();
         }
         $mailer->IsHTML();
         $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
         $mailer->Subject = $subject;
         $mailer->Body = $message;
         $mailer->Send();
     }
 }
 public function index()
 {
     $this->language->load('page/contact');
     $this->document->title = $this->language->get('heading_title');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->load->library('email/mailer');
         $mailer = new Mailer();
         if ($this->config->get('config_smtp_method') == 'smtp') {
             $mailer->IsSMTP();
             $mailer->Host = $this->config->get('config_smtp_host');
             $mailer->Username = $this->config->get('config_smtp_username');
             $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
             $mailer->Port = $this->config->get('config_smtp_port');
             $mailer->Timeout = $this->config->get('config_smtp_timeout');
             $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
             $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
         } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
             $mailer->IsSendmail();
         } else {
             $mailer->IsMail();
         }
         $mailer->IsHTML(false);
         $mailer->AddAddress($this->config->get('config_email'), $this->config->get('config_name'));
         $mailer->SetFrom($this->request->post['email'], $this->request->post['name']);
         $mailer->Subject = $this->config->get('config_name') . " - Contacto";
         $mailer->Body = strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8'));
         $mailer->Send();
         if ($this->request->hasPost('newsletter')) {
             $this->load->model('marketing/contact');
             $this->modelContact->add($this->request->post);
         }
         $this->data['success'] = $this->language->get('text_success');
         $this->request->post = array();
         unset($this->request->server['REQUEST_METHOD']);
     }
     $this->document->breadcrumbs = array();
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("common/home"), 'text' => $this->language->get('text_home'), 'separator' => false);
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("page/contact"), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator'));
     $this->data['breadcrumbs'] = $this->document->breadcrumbs;
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['error_name'] = isset($this->error['name']) ? $this->error['name'] : '';
     $this->data['error_email'] = isset($this->error['email']) ? $this->error['email'] : '';
     $this->data['error_enquiry'] = isset($this->error['enquiry']) ? $this->error['enquiry'] : '';
     $this->data['error_name'] = isset($this->error['name']) ? $this->error['name'] : '';
     $this->data['error_name'] = isset($this->error['name']) ? $this->error['name'] : '';
     $this->data['action'] = Url::createUrl("page/contact");
     $this->data['store'] = $this->config->get('config_name');
     $this->data['address'] = nl2br($this->config->get('config_address'));
     $this->data['telephone'] = $this->config->get('config_telephone');
     $this->setvar('name');
     $this->setvar('email');
     $this->setvar('enquiry');
     if ($this->config->get('marketing_page_contact_id')) {
         $this->load->model('content/page');
         $contact_page = $this->modelPage->getById($this->config->get('marketing_page_contact_id'));
         $this->data['contact_page'] = html_entity_decode($contact_page['description']);
     }
     // style files
     $csspath = defined("CDN_CSS") ? CDN_CSS : HTTP_CSS;
     $styles[] = array('media' => 'all', 'href' => $csspath . 'neco.form.css');
     $this->styles = array_merge($styles, $this->styles);
     // javascript files
     $jspath = defined("CDN_JS") ? CDN_JS : HTTP_JS;
     $javascripts[] = $jspath . "vendor/jquery-ui.min.js";
     $javascripts[] = $jspath . "necojs/neco.form.js";
     $this->javascripts = array_merge($this->javascripts, $javascripts);
     // SCRIPTS
     $scripts[] = array('id' => 'contact', 'method' => 'ready', 'script' => "\$('#contact').ntForm();");
     $this->loadWidgets();
     $this->scripts = array_merge($this->scripts, $scripts);
     $this->children[] = 'common/column_left';
     $this->children[] = 'common/column_right';
     $this->children[] = 'common/nav';
     $this->children[] = 'common/header';
     $this->children[] = 'common/footer';
     $template = $this->config->get('default_view_contact') ? $this->config->get('default_view_contact') : 'page/contact.tpl';
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/' . $template)) {
         $this->template = $this->config->get('config_template') . '/' . $template;
     } else {
         $this->template = 'choroni/' . $template;
     }
     $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
 }
 public function recover()
 {
     $this->load->language('common/login');
     $this->data['error_warning'] = '';
     $this->document->title = $this->language->get('heading_recover_title');
     if ($this->user->isLogged() && isset($this->request->get['token']) && $this->request->get['token'] == $this->session->get('ukey')) {
         $this->redirect(Url::createAdminUrl('common/home'));
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validateRecover()) {
         $result = $this->db->query("SELECT * FROM " . DB_PREFIX . "user WHERE username = '******'username') . "' AND email = '" . $this->request->getPost('email') . "'");
         if ($result->num_rows) {
             $password = substr(md5(rand()), 0, 7);
             $this->db->query("UPDATE " . DB_PREFIX . "user SET \r\n                `password` = '" . md5($password) . "' \r\n                WHERE username = '******'username') . "' \r\n                AND email = '" . $this->request->getPost('email') . "'");
             $this->user->registerActivity($result->row['user_id'], 'user', 'Solicitud de generación de contraseña nueva', 'update');
             $this->load->auto('email/mailer');
             $mailer = new Mailer();
             $message = "<h1>Hola " . $this->request->getPost('username') . ",</h1>\n\n";
             $message .= "<p>Tu nueva contrase&ntilde;a es:</p>\n";
             $message .= "<h1>" . $password . "</h1>\n";
             if ($this->config->get('config_smtp_method') == 'smtp') {
                 $mailer->IsSMTP();
                 $mailer->Host = $this->config->get('config_smtp_host');
                 $mailer->Username = $this->config->get('config_smtp_username');
                 $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
                 $mailer->Port = $this->config->get('config_smtp_port');
                 $mailer->Timeout = $this->config->get('config_smtp_timeout');
                 $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
                 $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
             } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
                 $mailer->IsSendmail();
             } else {
                 $mailer->IsMail();
             }
             $mailer->IsHTML();
             $mailer->AddAddress($this->request->getPost('email'), $this->request->getPost('username'));
             $mailer->SetFrom('*****@*****.**', 'NecoTienda');
             $mailer->Subject = 'Recuperacion de Contrasena';
             $mailer->Body = $message;
             $mailer->Send();
             $this->redirect(Url::createUrl('common/login'));
         } else {
             $this->user->registerActivity($result->row['user_id'], 'user', 'Intento fallido de solicitud de generación de contraseña nueva', 'update');
             $this->data['error_warning'] = $this->language->get('error_user_unknown');
         }
     }
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     }
     $this->data['action'] = Url::createAdminUrl('common/login/recover');
     $this->setvar('username');
     $this->setvar('email');
     $scripts[] = array('id' => 'login', 'method' => 'ready', 'script' => "\$('#form input').keydown(function(e) {\r\n        \t\tif (e.keyCode == 13) {\r\n                    \$('#form').submit();\r\n        \t\t}\r\n        \t});");
     $this->scripts = array_merge($scripts, $this->scripts);
     $this->template = 'common/recover.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
 }
Exemple #6
0
 /**
  * Display contact page
  */
 private function _contact()
 {
     // Contact Form
     $contact = $GLOBALS['config']->get('Contact_Form');
     if ($contact && $contact['status']) {
         $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->documents['document_contact'], currentPage());
         if (isset($_POST['contact'])) {
             $error = false;
             $required = array('email', 'name', 'subject', 'enquiry');
             foreach ($GLOBALS['hooks']->load('class.cubecart.contact') as $hook) {
                 include $hook;
             }
             $GLOBALS['smarty']->assign('MESSAGE', $_POST['contact']);
             // Validation
             foreach ($_POST['contact'] as $key => $value) {
                 if (in_array($key, $required) && empty($value)) {
                     $GLOBALS['gui']->setError($GLOBALS['language']->common['error_fields_required']);
                     $error = true;
                     break;
                 }
             }
             if (!filter_var($_POST['contact']['email'], FILTER_VALIDATE_EMAIL)) {
                 $GLOBALS['gui']->setError($GLOBALS['language']->common['error_email_invalid']);
                 $error = true;
             }
             // reCAPTCHA, if enabled
             if ($GLOBALS['config']->get('config', 'recaptcha') && !$GLOBALS['session']->get('confirmed', 'recaptcha')) {
                 if (($message = $GLOBALS['session']->get('error', 'recaptcha')) === false) {
                     //If the error message from recaptcha fails for some reason:
                     $GLOBALS['gui']->setError($GLOBALS['language']->form['verify_human_fail']);
                 } else {
                     $GLOBALS['gui']->setError($GLOBALS['session']->get('error', 'recaptcha'));
                 }
                 $error['recaptcha'] = true;
             }
             if (!$error) {
                 $email = isset($contact['email']) && filter_var($contact['email'], FILTER_VALIDATE_EMAIL) ? $contact['email'] : $GLOBALS['config']->get('config', 'email_address');
                 // Send email to correct department
                 $mailer = new Mailer();
                 $department = '';
                 if (isset($_POST['contact']['dept']) && is_array($contact['department'])) {
                     $key = (int) $_POST['contact']['dept'];
                     $department = $contact['department'][$key]['name'];
                     $email = !empty($contact['department'][$key]['email']) ? $contact['department'][$key]['email'] : $email;
                     $mailer->AddAddress($email, $department);
                 }
                 // Load content, assign variables
                 $mailer->IsHTML(false);
                 $mailer->AddAddress($email, $department);
                 if (isset($_POST['contact']['cc'])) {
                     $mailer->AddAddress($_POST['contact']['email'], strip_tags($_POST['contact']['name']));
                 }
                 $mailer->addReplyTo($_POST['contact']['email'], strip_tags($_POST['contact']['name']));
                 $mailer->Subject = strip_tags($_POST['contact']['subject']);
                 $mailer->Body = sprintf($GLOBALS['language']->contact['email_content'], $_POST['contact']['name'], $_POST['contact']['email'], $department, strip_tags($_POST['contact']['enquiry']));
                 foreach ($GLOBALS['hooks']->load('class.cubecart.contact.mailer') as $hook) {
                     include $hook;
                 }
                 // Send
                 if ($mailer->Send()) {
                     $GLOBALS['gui']->setNotify($GLOBALS['language']->documents['notify_document_contact']);
                     httpredir('index.php');
                 } else {
                     $GLOBALS['gui']->setError($GLOBALS['language']->documents['error_document_contact']);
                 }
             }
         }
         // Display form
         $contact['description'] = base64_decode($contact['description']);
         $GLOBALS['smarty']->assign('CONTACT', $contact);
         if (isset($contact['department']) && is_array($contact['department'])) {
             foreach ($contact['department'] as $key => $dept) {
                 $dept['key'] = $key;
                 $dept['selected'] = isset($_POST['contact']['dept']) && $_POST['contact']['dept'] == $key ? ' selected="selected"' : '';
                 $vars['departments'][] = $dept;
             }
             $GLOBALS['smarty']->assign('DEPARTMENTS', $vars['departments']);
         }
         if ($GLOBALS['config']->get('config', 'recaptcha') && !$GLOBALS['session']->get('confirmed', 'recaptcha')) {
             $recaptcha = $GLOBALS['config']->get('config', 'recaptcha');
             if ($recaptcha == 2) {
                 $GLOBALS['smarty']->assign('RECAPTCHA', $recaptcha);
             } else {
                 $GLOBALS['smarty']->assign('LANG_RECAPTCHA', array('reload_words' => sprintf($GLOBALS['language']->recaptcha['reload_words'], 'javascript:Recaptcha.reload()', "javascript:Recaptcha.switch_type('audio')"), 'reload_numbers' => sprintf($GLOBALS['language']->recaptcha['reload_numbers'], 'javascript:Recaptcha.reload()', "javascript:Recaptcha.switch_type('image')")));
                 $GLOBALS['smarty']->assign('DISPLAY_RECAPTCHA', recaptcha_get_html($GLOBALS['recaptcha_keys']['captcha_public'], $GLOBALS['session']->get('error', 'recaptcha'), CC_SSL));
                 $GLOBALS['smarty']->assign('RECAPTCHA', true);
             }
         }
         foreach ($GLOBALS['hooks']->load('class.cubecart.contact.display') as $hook) {
             include $hook;
         }
         $content = $GLOBALS['smarty']->fetch('templates/content.contact.php');
         $GLOBALS['smarty']->assign('PAGE_CONTENT', $content);
     } else {
         httpredir('index.php');
     }
 }
Exemple #7
0
 if (count($sendTo)) {
     $replyTo = array();
     if ($mailform['replyto']) {
         foreach ($submission as $field) {
             if ($field['type'] == 'email') {
                 $replyTo[] = $field['value'];
             }
         }
     }
     $mm = new Pagemill();
     $mm->setVariable('submission', $submission);
     $mm->setVariable('referrer', $log['referrer']);
     $body = $mm->writeString('<pm:include template="/mailform/submission.eml" />', true);
     $mail = new Mailer();
     $mail->Configure();
     $mail->IsHTML(true);
     foreach ($sendTo as $s) {
         $mail->AddAddress($s['email'], $s['name']);
     }
     foreach ($replyTo as $r) {
         $mail->AddReplyTo($r);
     }
     $attachmentSize = 0;
     foreach ($submission as $field) {
         if ($field['type'] == 'file' || $field['type'] == 'image') {
             $fullname = TYPEF_DIR . '/files/public/mailform/' . $field['value'];
             $attachmentSize += filesize($fullname);
             if ($attachmentSize <= MAILFORM_MAX_ATTACHMENT_SIZE) {
                 $mail->AddAttachment($fullname);
             }
         }
 public function addHistory($order_id, $data)
 {
     $this->db->query("UPDATE `" . DB_PREFIX . "order` SET \r\n        order_status_id = '" . (int) $data['order_status_id'] . "', \r\n        date_modified = NOW() \r\n        WHERE order_id = '" . (int) $order_id . "'");
     if ($data['append']) {
         $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET \r\n              order_id = '" . (int) $order_id . "', \r\n              order_status_id = '" . (int) $data['order_status_id'] . "', \r\n              notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "', \r\n              comment = '" . $this->db->escape(strip_tags($data['comment'])) . "', \r\n              date_added = NOW()");
     }
     if ($data['notify']) {
         $order_query = $this->db->query("SELECT *, os.name AS status \r\n            FROM `" . DB_PREFIX . "order` o \r\n            LEFT JOIN " . DB_PREFIX . "order_status os ON (o.order_status_id = os.order_status_id AND os.language_id = o.language_id) \r\n            LEFT JOIN " . DB_PREFIX . "language l ON (o.language_id = l.language_id) \r\n            WHERE o.order_id = '" . (int) $order_id . "'");
         if ($order_query->num_rows) {
             $language = new Language($order_query->row['directory']);
             $language->load($order_query->row['filename']);
             //$language->load('mail/order');
             //TODO: cargar la plantilla de email asociada con esta accion
             $subject = sprintf($language->get('text_subject'), $order_query->row['store_name'], $order_id);
             $message = "<p><b>" . $language->get('text_order') . ' ' . $order_id . "</b></p>";
             $message .= "<p>" . $language->get('text_date_added') . ' ' . date('d-m-Y', strtotime($order_query->row['date_added'])) . "</p>";
             $message .= "<p>" . $language->get('text_order_status') . '&nbsp;<b>' . $order_query->row['status'] . "</b></p>";
             $message .= "<p>" . $language->get('text_invoice') . "</p>";
             $message .= "<a href=\"" . html_entity_decode($order_query->row['store_url'] . 'index.php?r=account/invoice&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\">Ver Pedido</a>";
             if ($data['comment']) {
                 $message .= "<br /><p>" . $language->get('text_comment') . "</p>";
                 $message .= "<br /><p>" . strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "</p>";
             }
             $message .= $language->get('text_footer');
             $this->load->library('email/mailer');
             $mailer = new Mailer();
             if ($this->config->get('config_smtp_method') == 'smtp') {
                 $mailer->IsSMTP();
                 $mailer->Host = $this->config->get('config_smtp_host');
                 $mailer->Username = $this->config->get('config_smtp_username');
                 $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
                 $mailer->Port = $this->config->get('config_smtp_port');
                 $mailer->Timeout = $this->config->get('config_smtp_timeout');
                 $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
                 $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
             } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
                 $mailer->IsSendmail();
             } else {
                 $mailer->IsMail();
             }
             $mailer->IsHTML();
             $mailer->AddAddress($order_query->row['email'], $order_query->row['payment_firstname']);
             $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
             $mailer->Subject = $subject;
             $mailer->Body = $message;
             $mailer->Send();
         }
     }
 }
 public function index()
 {
     $Url = new Url($this->registry);
     if ($this->config->get('config_store_mode') != 'store') {
         $this->redirect(HTTP_HOME);
     }
     $this->language->load('checkout/success');
     $this->load->auto('account/address');
     $address = $this->modelAddress->getAddress($this->customer->getAddressId());
     $method_data = array();
     $results = $this->modelExtension->getExtensions('payment');
     foreach ($results as $result) {
         $this->load->model('payment/' . $result['key']);
         $this->language->load('payment/' . $result['key']);
         $method = $this->{'model_payment_' . $result['key']}->getMethod($address);
         if ($method) {
             $method_data[$result['key']] = $method;
         }
     }
     $sort_order = array();
     foreach ($method_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $method_data);
     $this->data['payment_methods'] = $method_data;
     foreach ($method_data as $key => $value) {
         $this->children[$key] = 'payment/' . $key;
     }
     $order_id = 0;
     if ($this->session->has('order_id')) {
         $order_id = $this->session->get('order_id');
     } elseif ($this->request->hasPost('order_id')) {
         $order_id = $this->request->getPost('order_id');
     } elseif ($this->request->hasQuery('order_id')) {
         $order_id = $this->request->getQuery('order_id');
     }
     $this->data['order_id'] = $order_id;
     if ($order_id) {
         if ($this->config->get('marketing_email_new_order')) {
             $this->load->model('account/order');
             $this->load->model('account/payment');
             $this->load->model("marketing/newsletter");
             $this->load->library('email/mailer');
             $this->load->library('BarcodeQR');
             $this->load->library('Barcode39');
             $this->load->library('tcpdf/config/lang/spa');
             $this->load->library('tcpdf/tcpdf');
             $mailer = new Mailer();
             $qr = new BarcodeQR();
             $barcode = new Barcode39(C_CODE);
             $this->data['Currency'] = $this->currency;
             $this->data['order'] = $order = $this->modelOrder->getOrder($order_id);
             $this->data['products'] = $products = $this->modelOrder->getOrderProducts($order_id);
             $this->data['totals'] = $totals = $this->modelOrder->getOrderTotals($order_id);
             $this->data['payments'] = $payments = $this->modelPayment->getPayments(array('order_id' => $order_id, 'order_payment_status_id' => $this->config->get('order_payment_status_approved')));
             $shipping_address = $order['shipping_address_1'] . ", " . $order['shipping_city'] . ". " . $order['shipping_zone'] . " - " . $order['shipping_country'] . ". CP " . $order['shipping_zone_code'];
             $payment_address = $order['payment_address_1'] . ", " . $order['payment_city'] . ". " . $order['payment_zone'] . " - " . $order['payment_country'] . ". CP " . $order['payment_zone_code'];
             $text = $this->config->get('config_owner') . "\n";
             $text .= "Pedido ID: " . $order_id . "\n";
             $text .= "Fecha Emision: " . date('d-m-Y h:i A', strtotime($order['date_added'])) . "\n";
             $text .= "Cliente: " . $this->customer->getCompany() . "\n";
             $text .= "RIF: " . $this->customer->getRif() . "\n";
             $text .= "Direccion IP: " . $order['ip'] . "\n";
             $text .= "Productos (" . count($products) . ")\n";
             $text .= "Modelo\tCant.\tTotal\n";
             foreach ($products as $key => $product) {
                 $text .= $product['model'] . "\t" . $product['quantity'] . "\t" . $this->currency->format($product['total'], $order['currency'], $order['value']) . "\n";
             }
             $qrStore = "cache/" . str_replace(".", "_", $this->config->get('config_owner')) . '.jpg';
             $qrOrder = "cache/" . str_replace(" ", "_", $this->config->get('config_owner') . "_qr_code_order_" . $order_id) . '.jpg';
             $eanStore = "cache/" . str_replace(" ", "_", $this->config->get('config_owner') . "_barcode_39_order_id_" . $order_id) . '.gif';
             $qr->text($text);
             $qr->draw(150, DIR_IMAGE . $qrOrder);
             $qr->url(HTTP_HOME);
             $qr->draw(150, DIR_IMAGE . $qrStore);
             $barcode->draw(DIR_IMAGE . $eanStore);
             $product_html = "<table><thead><tr style=\"background:#ccc;color:#666;\"><th>Item</th><th>" . $this->language->get('column_description') . "</th><th>" . $this->language->get('column_model') . "</th><th>" . $this->language->get('column_quantity') . "</th><th>" . $this->language->get('column_price') . "</th><th>" . $this->language->get('column_total') . "</th></tr></thead><tbody>";
             foreach ($products as $key => $product) {
                 $options = $this->modelOrder->getOrderOptions($order_id, $product['order_product_id']);
                 $option_data = "";
                 foreach ($options as $option) {
                     $option_data .= "&nbsp;&nbsp;&nbsp;&nbsp;- " . $option['name'] . "<br />";
                 }
                 $product_html .= "<tr>";
                 $product_html .= "<td style=\"width:5%\">" . (int) ($key + 1) . "</td>";
                 $product_html .= "<td style=\"width:45%\">" . $product['name'] . "<br />" . $option_data . "</td>";
                 $product_html .= "<td style=\"width:20%\">" . $product['model'] . "</td>";
                 $product_html .= "<td style=\"width:10%\">" . $product['quantity'] . "</td>";
                 $product_html .= "<td style=\"width:10%\">" . $this->currency->format($product['price'], $order['currency'], $order['value']) . "</td>";
                 $product_html .= "<td style=\"width:10%\">" . $this->currency->format($product['total'], $order['currency'], $order['value']) . "</td>";
                 $product_html .= "</tr>";
             }
             $product_html .= "</tbody></table>";
             $total_html = "<div class=\"clear:both;float:none;\"></div><br /><table style=\"float:right;\">";
             foreach ($totals as $total) {
                 $total_html .= "<tr>";
                 $total_html .= "<td style=\"text-align:right;\">" . $total['title'] . "</td>";
                 $total_html .= "<td style=\"text-align:right;\">" . $total['text'] . "</td>";
                 $total_html .= "</tr>";
             }
             $total_html .= "</table>";
             $result = $this->modelNewsletter->getById($this->config->get('marketing_email_new_order'));
             $message = $result['htmlbody'];
             $message = str_replace("{%title%}", 'Pedido N&deg; ' . $order_id . " - " . $this->config->get('config_name'), $message);
             $message = str_replace("{%store_logo%}", '<img src="' . HTTP_IMAGE . $this->config->get('config_logo') . '" alt="' . $this->config->get('config_name') . '" />', $message);
             $message = str_replace("{%store_url%}", HTTP_HOME, $message);
             $message = str_replace("{%store_owner%}", $this->config->get('config_owner'), $message);
             $message = str_replace("{%store_name%}", $this->config->get('config_name'), $message);
             $message = str_replace("{%store_rif%}", $this->config->get('config_rif'), $message);
             $message = str_replace("{%store_email%}", $this->config->get('config_email'), $message);
             $message = str_replace("{%store_telephone%}", $this->config->get('config_telephone'), $message);
             $message = str_replace("{%store_address%}", $this->config->get('config_address'), $message);
             $message = str_replace("{%products%}", $product_html, $message);
             $message = str_replace("{%totals%}", $total_html, $message);
             $message = str_replace("{%order_id%}", $this->config->get('config_invoice_prefix') . $order_id, $message);
             $message = str_replace("{%invoice_id%}", $this->config->get('config_invoice_prefix') . $invoice_id, $message);
             $message = str_replace("{%rif%}", $this->customer->getRif(), $message);
             $message = str_replace("{%fullname%}", $this->customer->getFirstName() . " " . $this->customer->getFirstName(), $message);
             $message = str_replace("{%company%}", $this->customer->getCompany(), $message);
             $message = str_replace("{%email%}", $this->customer->getEmail(), $message);
             $message = str_replace("{%telephone%}", $this->customer->getTelephone(), $message);
             $message = str_replace("{%payment_address%}", $payment_address, $message);
             $message = str_replace("{%payment_method%}", $order['payment_method'], $message);
             $message = str_replace("{%shipping_address%}", $shipping_address, $message);
             $message = str_replace("{%shipping_method%}", $order['shipping_method'], $message);
             $message = str_replace("{%date_added%}", date('d-m-Y h:i A', strtotime($order['date_added'])), $message);
             $message = str_replace("{%ip%}", $order['ip'], $message);
             $message = str_replace("{%qr_code_store%}", '<img src="' . HTTP_IMAGE . $qrStore . '" alt="QR Code" />', $message);
             $message = str_replace("{%comment%}", $order['comment'], $message);
             $message = str_replace("{%qr_code_order%}", '<img src="' . HTTP_IMAGE . $qrOrder . '" alt="QR Code" />', $message);
             $message = str_replace("{%barcode_39_order_id%}", '<img src="' . HTTP_IMAGE . $eanStore . '" alt="QR Code" />', $message);
             $message .= "<p style=\"text-align:center\">Powered By <a href=\"http://www.necotienda.org\">Necotienda</a>&reg; " . date('Y') . "</p>";
             if ($this->config->get('marketing_email_order_pdf')) {
                 $pdfFile = DIR_CACHE . str_replace(" ", "_", $this->config->get('config_owner') . "_pedido_" . $order_id) . '.pdf';
                 $result = $this->modelNewsletter->getById($this->config->get('marketing_email_order_pdf'));
                 $pdfBody = html_entity_decode($result['htmlbody']);
                 $pdfBody = str_replace("{%store_url%}", HTTP_HOME, $pdfBody);
                 $pdfBody = str_replace("{%title%}", 'Pedido N&deg; ' . $order_id . " - " . $this->config->get('config_name'), $pdfBody);
                 $pdfBody = str_replace("{%store_owner%}", $this->config->get('config_owner'), $pdfBody);
                 $pdfBody = str_replace("{%store_name%}", $this->config->get('config_name'), $pdfBody);
                 $pdfBody = str_replace("{%store_rif%}", $this->config->get('config_rif'), $pdfBody);
                 $pdfBody = str_replace("{%store_email%}", $this->config->get('config_email'), $pdfBody);
                 $pdfBody = str_replace("{%store_telephone%}", $this->config->get('config_telephone'), $pdfBody);
                 $pdfBody = str_replace("{%store_address%}", $this->config->get('config_address'), $pdfBody);
                 $pdfBody = str_replace("{%products%}", $product_html, $pdfBody);
                 $pdfBody = str_replace("{%totals%}", $total_html, $pdfBody);
                 $pdfBody = str_replace("{%order_id%}", $this->config->get('config_invoice_prefix') . $order_id, $pdfBody);
                 $pdfBody = str_replace("{%invoice_id%}", $this->config->get('config_invoice_prefix') . $invoice_id, $pdfBody);
                 $pdfBody = str_replace("{%rif%}", $this->customer->getRif(), $pdfBody);
                 $pdfBody = str_replace("{%fullname%}", $this->customer->getFirstName() . " " . $this->customer->getFirstName(), $pdfBody);
                 $pdfBody = str_replace("{%company%}", $this->customer->getCompany(), $pdfBody);
                 $pdfBody = str_replace("{%email%}", $this->customer->getEmail(), $pdfBody);
                 $pdfBody = str_replace("{%telephone%}", $this->customer->getTelephone(), $pdfBody);
                 $pdfBody = str_replace("{%payment_address%}", $payment_address, $pdfBody);
                 $pdfBody = str_replace("{%payment_method%}", $order['payment_method'], $pdfBody);
                 $pdfBody = str_replace("{%shipping_address%}", $shipping_address, $pdfBody);
                 $pdfBody = str_replace("{%shipping_method%}", $order['shipping_method'], $pdfBody);
                 $pdfBody = str_replace("{%date_added%}", date('d-m-Y h:i A', strtotime($order['date_added'])), $pdfBody);
                 $pdfBody = str_replace("{%ip%}", $order['ip'], $pdfBody);
                 $pdfBody = str_replace("{%comment%}", $order['comment'], $pdfBody);
                 if (file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
                     $pdfBody = str_replace("{%store_logo%}", '<img src="' . HTTP_IMAGE . $this->config->get('config_logo') . '" alt="' . $this->config->get('config_name') . '" />', $pdfBody);
                 } else {
                     $pdfBody = str_replace("{%store_logo%}", '', $pdfBody);
                 }
                 if (file_exists(DIR_IMAGE . $qrStore)) {
                     $pdfBody = str_replace("{%qr_code_store%}", '<img src="' . HTTP_IMAGE . $qrStore . '" alt="QR Code" />', $pdfBody);
                 } else {
                     $pdfBody = str_replace("{%qr_code_store%}", '', $pdfBody);
                 }
                 if (file_exists(DIR_IMAGE . $qrOrder)) {
                     $pdfBody = str_replace("{%qr_code_order%}", '<img src="' . HTTP_IMAGE . $qrOrder . '" alt="QR Code" />', $pdfBody);
                 } else {
                     $pdfBody = str_replace("{%qr_code_order%}", '', $pdfBody);
                 }
                 $pdfBody = str_replace("{%barcode_39_order_id%}", '<img src="' . HTTP_IMAGE . $eanStore . '" alt="QR Code" />', $pdfBody);
                 $pdfBody .= "<p style=\"text-align:center\">Powered By Necotienda&reg; " . date('Y') . "</p>";
                 // create new PDF document
                 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
                 // set document information
                 $pdf->SetCreator("Powered By NecoTienda&reg;");
                 $pdf->SetTitle($this->config->get('config_name'));
                 $pdf->SetAuthor($this->config->get('config_name'));
                 $pdf->SetSubject($this->config->get('config_owner') . " " . $this->language->get('text_order') . " #" . $order_id);
                 $pdf->SetKeywords($this->config->get('config_name') . ', ' . $product_tags . ',pdf');
                 // set default header data
                 $pdf->SetHeaderData($this->config->get('config_logo'), PDF_HEADER_LOGO_WIDTH, $this->config->get('config_owner'), $this->config->get('config_name'));
                 // set header and footer fonts
                 $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
                 $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
                 // set default monospaced font
                 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
                 //set margins
                 $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
                 $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
                 $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
                 //set auto page breaks
                 $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
                 //set image scale factor
                 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
                 //set some language-dependent strings
                 $pdf->setLanguageArray($l);
                 // set font
                 $pdf->SetFont('dejavusans', '', 10);
                 // add a page
                 $pdf->AddPage();
                 // output the HTML content
                 $pdf->writeHTML($pdfBody, true, false, true, false, '');
                 //Close and output PDF document
                 $pdf->Output($pdfFile, 'F');
             }
             $subject = $this->config->get('config_owner') . " " . $this->language->get('text_new_order') . " #" . $order_id;
             if ($this->config->get('config_smtp_method') == 'smtp') {
                 $mailer->IsSMTP();
                 $mailer->Host = $this->config->get('config_smtp_host');
                 $mailer->Username = $this->config->get('config_smtp_username');
                 $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
                 $mailer->Port = $this->config->get('config_smtp_port');
                 $mailer->Timeout = $this->config->get('config_smtp_timeout');
                 $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
                 $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
             } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
                 $mailer->IsSendmail();
             } else {
                 $mailer->IsMail();
             }
             $mailer->IsHTML();
             $mailer->AddAddress($this->customer->getEmail(), $this->customer->getCompany());
             $mailer->AddBCC($this->config->get('config_email'), $this->config->get('config_name'));
             $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
             $mailer->Subject = $subject;
             $mailer->Body = html_entity_decode(htmlspecialchars_decode($message));
             if ($pdfFile && file_exists($pdfFile)) {
                 $mailer->AddAttachment($pdfFile);
             }
             $mailer->Send();
         }
         $order_id = $this->session->get('order_id');
         $this->cart->clear();
         $this->session->clear('shipping_method');
         $this->session->clear('shipping_methods');
         $this->session->clear('payment_method');
         $this->session->clear('payment_methods');
         $this->session->clear('guest');
         $this->session->clear('comment');
         $this->session->clear('order_id');
         $this->session->clear('coupon');
     }
     $this->document->title = $this->language->get('heading_title');
     $this->document->breadcrumbs = array();
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("common/home"), 'text' => $this->language->get('text_home'), 'separator' => false);
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("checkout/cart"), 'text' => $this->language->get('text_basket'), 'separator' => $this->language->get('text_separator'));
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("checkout/success"), 'text' => $this->language->get('text_checkout_success'), 'separator' => $this->language->get('text_separator'));
     $this->data['breadcrumbs'] = $this->document->breadcrumbs;
     $this->data['heading_title'] = $this->language->get('heading_title');
     if ($this->config->get('page_order_success')) {
         $this->load->model('content/page');
         $page = $this->modelPage->getById($this->config->get('page_order_success'));
         $this->data['text_message'] = html_entity_decode($page['description']);
     } else {
         $this->data['text_message'] = sprintf($this->language->get('text_message'), Url::createUrl("account/account"), Url::createUrl("account/order"), Url::createUrl("page/contact"));
     }
     // style files
     $csspath = defined("CDN") ? CDN . CSS : HTTP_CSS;
     $styles[] = array('media' => 'all', 'href' => $csspath . 'jquery-ui/jquery-ui.min.css');
     $styles[] = array('media' => 'all', 'href' => $csspath . 'neco.form.css');
     $this->data['styles'] = $this->styles = array_merge($this->styles, $styles);
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/checkout/success.tpl')) {
         $this->template = $this->config->get('config_template') . '/checkout/success.tpl';
     } else {
         $this->template = 'choroni/checkout/success.tpl';
     }
     $this->children[] = 'common/nav';
     $this->children[] = 'common/footer';
     $this->children[] = 'common/header';
     $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
 }
 public function index()
 {
     $Url = new Url($this->registry);
     if ($this->customer->isLogged()) {
         $this->redirect(Url::createUrl("account/account"));
     }
     $this->language->load('account/forgotten');
     $this->document->title = $this->language->get('heading_title');
     $this->load->model('account/customer');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->load->library('email/mailer');
         $this->load->library('BarcodeQR');
         $this->load->library('Barcode39');
         $mailer = new Mailer();
         $qr = new BarcodeQR();
         $barcode = new Barcode39(C_CODE);
         $password = substr(md5(rand()), 0, 11);
         $qrStore = "cache/" . str_replace(".", "_", $this->config->get('config_owner')) . '.png';
         $eanStore = "cache/" . str_replace(" ", "_", $this->config->get('config_owner') . "_barcode_39_order_id_" . $order_id) . '.gif';
         if (!file_exists(DIR_IMAGE . $qrStore)) {
             $qr->url(HTTP_HOME);
             $qr->draw(150, DIR_IMAGE . $qrStore);
         }
         if (!file_exists(DIR_IMAGE . $eanStore)) {
             $barcode->draw(DIR_IMAGE . $eanStore);
         }
         if ($this->config->get('marketing_email_new_password')) {
             $this->load->model("marketing/newsletter");
             $result = $this->modelNewsletter->getById($this->config->get('marketing_email_new_password'));
             $message = $result['htmlbody'];
             $message = str_replace("{%store_logo%}", '<img src="' . HTTP_IMAGE . $this->config->get('config_logo') . '" alt="' . $this->config->get('config_name') . '" />', $message);
             $message = str_replace("{%store_url%}", HTTP_HOME, $message);
             $message = str_replace("{%url_login%}", Url::createUrl("account/login"), $message);
             $message = str_replace("{%url_activate%}", Url::createUrl("account/activate", array('ac' => $this->request->post['activation_code'])), $message);
             $message = str_replace("{%store_owner%}", $this->config->get('config_owner'), $message);
             $message = str_replace("{%store_name%}", $this->config->get('config_name'), $message);
             $message = str_replace("{%store_rif%}", $this->config->get('config_rif'), $message);
             $message = str_replace("{%store_email%}", $this->config->get('config_email'), $message);
             $message = str_replace("{%store_telephone%}", $this->config->get('config_telephone'), $message);
             $message = str_replace("{%store_address%}", $this->config->get('config_address'), $message);
             $message = str_replace("{%email%}", $this->request->post['email'], $message);
             $message = str_replace("{%password%}", $password, $message);
             $message = str_replace("{%date_added%}", date('d-m-Y h:i A'), $message);
             $message = str_replace("{%ip%}", $_SERVER['REMOTE_ADDR'], $message);
             $message = str_replace("{%qr_code_store%}", '<img src="' . HTTP_IMAGE . $qrStore . '" alt="QR Code" />', $message);
             $message = str_replace("{%barcode_39_order_id%}", '<img src="' . HTTP_IMAGE . $eanStore . '" alt="NT Code" />', $message);
             $message .= "<p style=\"text-align:center\">Powered By Necotienda&reg; " . date('Y') . "</p>";
         } else {
             $message = "<h1>" . $this->config->get('config_name') . "</h1>";
             $message .= "<p>" . $this->language->get('text_password_renew') . "</p>";
             $message .= "<p><b>" . $password . "</b></p><br />";
             $message .= '<img src="' . HTTP_IMAGE . $qrStore . '" alt="QR Code" />';
             $message .= '<img src="' . HTTP_IMAGE . $eanStore . '" alt="NT Code" />';
             $message .= "<br /><p style=\"text-align:center\">Powered By Necotienda&reg; " . date('Y') . "</p>";
         }
         $subject = $this->config->get('config_name') . " " . $this->language->get('text_new_password');
         if ($this->config->get('config_smtp_method') == 'smtp') {
             $mailer->IsSMTP();
             $mailer->Host = $this->config->get('config_smtp_host');
             $mailer->Username = $this->config->get('config_smtp_username');
             $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
             $mailer->Port = $this->config->get('config_smtp_port');
             $mailer->Timeout = $this->config->get('config_smtp_timeout');
             $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
             $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
         } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
             $mailer->IsSendmail();
         } else {
             $mailer->IsMail();
         }
         $mailer->IsHTML();
         $mailer->AddAddress($this->request->post['email'], $this->config->get('config_name'));
         $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
         $mailer->Subject = $subject;
         $mailer->Body = html_entity_decode(htmlspecialchars_decode($message));
         $mailer->Send();
         $this->modelCustomer->editPassword($this->request->post['email'], $password);
         $this->session->set('success', $this->language->get('text_success'));
         $this->redirect(Url::createUrl("account/login"));
     }
     $this->document->breadcrumbs = array();
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("common/home"), 'text' => $this->language->get('text_home'), 'separator' => false);
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("account/account"), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'));
     $this->document->breadcrumbs[] = array('href' => Url::createUrl("account/forgotten"), 'text' => $this->language->get('text_forgotten'), 'separator' => $this->language->get('text_separator'));
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_your_email'] = $this->language->get('text_your_email');
     $this->data['text_email'] = $this->language->get('text_email');
     $this->data['entry_email'] = $this->language->get('entry_email');
     $this->data['button_continue'] = $this->language->get('button_continue');
     $this->data['button_back'] = $this->language->get('button_back');
     if (isset($this->error['message'])) {
         $this->data['error'] = $this->error['message'];
     } else {
         $this->data['error'] = '';
     }
     $this->data['action'] = Url::createUrl("account/forgotten");
     $this->data['back'] = Url::createUrl("account/account");
     $this->loadWidgets();
     if ($scripts) {
         $this->scripts = array_merge($this->scripts, $scripts);
     }
     $this->children[] = 'common/column_left';
     $this->children[] = 'common/column_right';
     $this->children[] = 'common/nav';
     $this->children[] = 'common/header';
     $this->children[] = 'common/footer';
     $template = $this->config->get('default_view_account_forgotten') ? $this->config->get('default_view_account_forgotten') : 'account/forgotten.tpl';
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/' . $template)) {
         $this->template = $this->config->get('config_template') . '/' . $template;
     } else {
         $this->template = 'choroni/' . $template;
     }
     $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
 }
 public function sendCampaign($task)
 {
     if ($this->isLocked('send_campaign', $task->task_id)) {
         $task->addMinute(15);
     } else {
         $task->start();
         $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "campaign c \r\n            LEFT JOIN " . DB_PREFIX . "newsletter n ON (n.newsletter_id=c.newsletter_id) \r\n            WHERE campaign_id = '" . (int) $task->params['campaign_id'] . "'");
         $campign_info = $query->row;
         $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "campaign_property \r\n            WHERE `group` = 'mail_server' \r\n            AND `key` = 'mail_server_id' \r\n            AND campaign_id = '" . (int) $task->params['campaign_id'] . "'");
         $mail_server_id = unserialize($query->row['value']);
         if ($mail_server_id) {
             $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "setting \r\n                WHERE `group` = 'mail_server' \r\n                AND `key` = '" . $mail_server_id . "'");
             $mail_server = unserialize($query->row['value']);
         } else {
             $mail_server = 'localhost';
         }
         $htmlbody = html_entity_decode($campign_info['htmlbody']);
         $count = 0;
         foreach ($task->getTaskQueue() as $key => $queue) {
             if ($count >= 50) {
                 break;
             }
             $params = unserialize($queue['params']);
             $cached = $this->cache->get("campaign.html.{$params['campaign_id']}.{$params['contact_id']}");
             if ($cached) {
                 $htmlbody = html_entity_decode($cached);
             } else {
                 $htmlbody = str_replace("%7B", "{", $htmlbody);
                 $htmlbody = str_replace("%7D", "}", $htmlbody);
                 $htmlbody = str_replace("{%contact_id%}", $params['contact_id'], $htmlbody);
                 $htmlbody = str_replace("{%campaign_id%}", $params['campaign_id'], $htmlbody);
                 $htmlbody = str_replace("{%fullname%}", $params['name'], $htmlbody);
                 $htmlbody = str_replace("{%rif%}", $params['rif'], $htmlbody);
                 $htmlbody = str_replace("{%company%}", $params['company'], $htmlbody);
                 $htmlbody = str_replace("{%email%}", $params['email'], $htmlbody);
                 $htmlbody = str_replace("{%telephone%}", $params['telephone'], $htmlbody);
                 $htmlbody = $this->prepareTemplate($htmlbody, $params);
                 $dom = new DOMDocument();
                 $dom->preserveWhiteSpace = false;
                 $dom->loadHTML($htmlbody);
                 /*
                 if ($params['embed_image']) {
                     $images = $dom->getElementsByTagName('img');
                     foreach ($images as $image) {
                         $src = $image->getAttribute('src');
                         $src = str_replace(HTTP_IMAGE,DIR_IMAGE,$src);
                         if (file_exists($src)) {
                             $img    = file_get_contents($src);
                             $ext    = substr($src,(strrpos($src,'.')+1));
                             $embed  = base64_encode($img); 
                             $image->setAttribute('src',"data:image/$ext;base64,$embed");
                             $total_embed_images++;
                         }
                         $total_images++;
                     }
                 }
                 */
                 $vars = array('contact_id' => $params['contact_id'], 'campaign_id' => $params['campaign_id'], 'referencedBy' => $params['email']);
                 /* trace the email */
                 $trace_url = Url::createUrl("marketing/campaign/trace", $vars, 'NONSSL', HTTP_HOME);
                 $trackEmail = $dom->createElement('img');
                 $trackEmail->setAttribute('src', $trace_url);
                 $dom->appendChild($trackEmail);
                 /* trace the clicks */
                 $links = $dom->getElementsByTagName('a');
                 foreach ($links as $link) {
                     $href = $link->getAttribute('href');
                     if (empty($href) || $href == "#" || strpos($href, "mailto:") || strpos($href, "callto:") || strpos($href, "skype:") || strpos($href, "tel:")) {
                         continue;
                     }
                     //TODO: validar enlaces
                     //TODO: sanitizar enlaces
                     $vars['link_index'] = $link_index = md5(time() . mt_rand(1000000, 9999999) . $href);
                     $_link = Url::createUrl("marketing/campaign/link", $vars, 'NONSSL', HTTP_HOME);
                     $this->db->query("INSERT INTO " . DB_PREFIX . "campaign_link SET \r\n                          `campaign_id` = '" . (int) $params['campaign_id'] . "',\r\n                          `url`         = '" . $this->db->escape($_link) . "',\r\n                          `redirect`    = '" . $this->db->escape($href) . "',\r\n                          `link`        = '" . $this->db->escape($link_index) . "',\r\n                          `date_added`  = NOW()");
                     $link->setAttribute('href', $_link);
                     //TODO: agregar valor a la etiqueta title si esta vacia
                 }
                 $htmlbody = html_entity_decode(htmlentities($dom->saveHTML()));
             }
             $mailer = new Mailer();
             if ($mail_server !== 'localhost') {
                 $mailer->IsSMTP();
                 $mailer->Host = $mail_server['server'];
                 $mailer->Username = $mail_server['username'];
                 $mailer->Password = $mail_server['password'];
                 if ($mail_server['port']) {
                     $mailer->Port = $mail_server['port'];
                 }
                 if ($mail_server['security']) {
                     $mailer->SMTPSecure = $mail_server['security'];
                 }
                 $mailer->SMTPAuth = true;
             } else {
                 $mailer->IsMail();
             }
             $mailer->AddAddress($params['email'], $params['name']);
             $mailer->IsHTML();
             $mailer->SetFrom($campign_info['from_email'], $campign_info['from_name']);
             $mailer->AddReplyTo($campign_info['replyto_email'], $campign_info['from_name']);
             $mailer->Subject = $campign_info['subject'];
             $mailer->Body = $htmlbody;
             $mailer->Send();
             $mailer->ClearAllRecipients();
             $task->setQueueDone($key);
             $count++;
         }
         if (count($task->getTaskDos($task->task_id))) {
             $task->addMinute(15);
         } else {
             $task->setTaskDone($task->task_id);
         }
     }
     $task->update();
     /**
      * - detectar la hora de la ejecución, si es mayor posponer tarea y actualizar el sort_order, si es menor y no se ha ejecutado, 
      * cambiar la hora de ejecución para más tarde, si la hora se pasa el siguiente día entonces actualizar la fecha completa
      * 
      * 
      * - comprobar que la cola de trabajo está libre o no está bloqueada
      * - si está bloqueada posponer time_exec 15 min a toda la tarea y la cola de trabajo
      * - si no lo está, bloquearla actualizando la tabla task_exec y continuar
      * - obtener datos de la campaña (SQL)
      * - dividir los contactos en grupos de 50
      * - agregar los destinatarios al objeto mailer
      * - enviar email
      * - actualizar queue con status 0 para indicar que están listas
      * - al enviar el grupo de cincuenta, 
      * - comprobar o contar cuantas actividades faltan
      * - si ya está lista, actualizar la tarea con status cero para indicar que ya fue enviada y actualizar el registro de la campaña y desbloquear la cola eliminando el registro de task_exec
      * - sino
      * - actualizar time_exec de la tarea sumando 15 min y time_last_exec con el tiempo ahora
      * - actualizar toda la cola de trabajo agregando 15 min a las actividades pendientes
      * */
 }
Exemple #12
0
function sendMail($mailto, $subject, $content)
{
    global $mailfrom;
    $mail = new Mailer();
    $mail->IsHTML(true);
    $mail->From = $mailfrom;
    $mail->FromName = $mailfrom;
    $mail->AddAddress(preg_replace('/(\\n+|\\r+|%0A|%0D)/i', '', $mailto));
    $mail->Subject = $subject;
    $mail->Body = bbcode_nletter($content);
    $mail->AltBody = bbcode_nletter_plain($content);
    return $mail->Send();
}
 public function register()
 {
     if (!$this->customer->islogged()) {
         $this->load->model("account/customer");
         $this->load->model("marketing/newsletter");
         $this->load->library('email/mailer');
         $this->load->library('BarcodeQR');
         $mailer = new Mailer();
         if (!file_exists(DIR_IMAGE . "cache/" . str_replace(".", "_", $this->config->get('config_owner')) . '.png')) {
             $qr = new BarcodeQR();
             $qr->url(HTTP_HOME);
             $qr->draw(100, DIR_IMAGE . "cache/" . str_replace(".", "_", $this->config->get('config_owner')) . '.png');
         }
         $this->request->post['rif'] = $this->request->post['riftype'] . $this->request->post['rif'];
         $this->request->post['password'] = substr(md5(rand(11111111, 99999999)), 0, 8);
         if ($this->request->hasPost('referencedBy')) {
             $promotor = $this->modelCustomer->getCustomerByEmail($this->request->getPost('referencedBy'));
             $this->request->post['referenced_by'] = $promotor['customer_id'] ? $promotor['customer_id'] : 0;
         }
         if ($this->modelCustomer->addCustomer($this->request->post)) {
             $this->customer->login($this->request->post['email'], $this->request->post['password'], true);
             if ($this->request->post['session_address_var']) {
                 $this->session->set($this->request->post['session_address_var'], $this->customer->getAddressId());
             }
             $this->session->clear('guest');
             if ($this->config->get('marketing_email_register_customer')) {
                 $newsletter = $this->modelNewsletter->getById($this->config->get('marketing_email_register_customer'));
                 $message = $newsletter['htmlbody'];
                 $message = str_replace("{%store_name%}", $this->config->get('config_owner'), $message);
                 $message = str_replace("{%store_rif%}", $this->config->get('config_rif'), $message);
                 $message = str_replace("{%store_address%}", $this->config->get('config_address'), $message);
                 $message = str_replace("{%company%}", $this->customer->getCompany(), $message);
                 $message = str_replace("{%email%}", $this->customer->getEmail(), $message);
                 $message = str_replace("{%password%}", $this->request->post['password'], $message);
                 $message = str_replace("{%date_added%}", date('d-m-Y h:i A', strtotime($order['date_added'])), $message);
                 $message = str_replace("{%ip%}", $order['ip'], $message);
                 $message = str_replace("{%qr_code_store%}", HTTP_IMAGE . "cache/" . str_replace(".", "_", $this->config->get('config_owner')) . '.png', $message);
                 $subject = $this->config->get('config_owner') . " " . $this->language->get('text_welcome');
                 if ($this->config->get('config_smtp_method') == 'smtp') {
                     $mailer->IsSMTP();
                     $mailer->Host = $this->config->get('config_smtp_host');
                     $mailer->Username = $this->config->get('config_smtp_username');
                     $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
                     $mailer->Port = $this->config->get('config_smtp_port');
                     $mailer->Timeout = $this->config->get('config_smtp_timeout');
                     $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
                     $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
                 } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
                     $mailer->IsSendmail();
                 } else {
                     $mailer->IsMail();
                 }
                 $mailer->IsHTML();
                 $mailer->AddAddress($this->customer->getEmail(), $this->customer->getCompany());
                 $mailer->AddBCC($this->config->get('config_email'), $this->config->get('config_name'));
                 $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
                 $mailer->Subject = $subject;
                 $mailer->Body = html_entity_decode(htmlspecialchars_decode($message));
                 $mailer->Send();
             }
         }
     }
 }
Exemple #14
0
        $user = $users->getFirst();
        $userid = $user->get('userid');
        $resetkey = randomID();
        $expire = date('Y-m-d H:i:s', time() + 86400);
        // create an entry in the password reset table
        $reset = Model_UserReset::Create();
        $reset->set('userid', $userid);
        $reset->set('resetkey', $resetkey);
        $reset->set('expire', $expire);
        $reset->save();
        // construct e-mail body
        $mm = new Pagemill($pm->root()->fork());
        $mm->setVariable('username', $user->get('username'));
        $mm->setVariable('reseturl', sprintf('http://%s%s/password?userid=%d&resetkey=%s', $_SERVER['HTTP_HOST'], TYPEF_WEB_DIR, $userid, $resetkey));
        $body = str_replace('&amp;', '&', $mm->writeString('<pm:include template="/users/reset.eml" />', true));
        // e-mail the user so they can reset their password
        $mailer = new Mailer();
        $mailer->Configure();
        $mailer->IsHTML(true);
        $mailer->AddAddress($_POST['email']);
        $mailer->Subject = 'Request to Reset Password for ' . TYPEF_TITLE;
        $mailer->Body = $body;
        $mailer->Send();
        $pm->setVariable('reset_email_sent', true);
        Typeframe::Log('Request to reset password for ' . $_POST['email']);
    } else {
        $pm->setVariable('reset_email_failed', true);
    }
}
// set template (controller is at root, but template lives in users directory
Typeframe::SetPageTemplate('/users/password-reset.html');
 protected function notifyReply($review_id, $product_id)
 {
     if (!$review_id) {
         return false;
     }
     $this->load->auto('email/mailer');
     $this->load->auto('store/product');
     $this->load->auto('account/customer');
     $this->load->auto('store/review');
     $this->load->auto('marketing/newsletter');
     $review_info = $this->modelReview->getById($review_id);
     $product_info = $this->modelProduct->getProduct($product_id);
     if ($this->config->get('marketing_email_new_reply') && $review_info) {
         $this->load->model("marketing/newsletter");
         $this->load->library('email/mailer');
         $this->load->library('BarcodeQR');
         $this->load->library('Barcode39');
         $mailer = new Mailer();
         $qr = new BarcodeQR();
         $barcode = new Barcode39(C_CODE);
         $qrStore = "cache/" . str_replace(".", "_", $this->config->get('config_owner')) . '.png';
         $eanStore = "cache/" . str_replace(" ", "_", $this->config->get('config_owner') . "_barcode_39_order_id_" . $order_id) . '.gif';
         if (!file_exists(DIR_IMAGE . $qrStore)) {
             $qr->url(HTTP_HOME);
             $qr->draw(150, DIR_IMAGE . $qrStore);
         }
         if (!file_exists(DIR_IMAGE . $eanStore)) {
             $barcode->draw(DIR_IMAGE . $eanStore);
         }
         $customer_info = $this->modelCustomer->getCustomer($review_info['customer_id']);
         $result = $this->modelNewsletter->getById($this->config->get('marketing_email_new_reply'));
         $message = $result['htmlbody'];
         $message = str_replace("{%store_logo%}", '<img src="' . HTTP_IMAGE . $this->config->get('config_logo') . '" alt="' . $this->config->get('config_name') . '" />', $message);
         $message = str_replace("{%store_url%}", HTTP_HOME, $message);
         $message = str_replace("{%store_owner%}", $this->config->get('config_owner'), $message);
         $message = str_replace("{%store_name%}", $this->config->get('config_name'), $message);
         $message = str_replace("{%store_rif%}", $this->config->get('config_rif'), $message);
         $message = str_replace("{%store_email%}", $this->config->get('config_email'), $message);
         $message = str_replace("{%store_telephone%}", $this->config->get('config_telephone'), $message);
         $message = str_replace("{%store_address%}", $this->config->get('config_address'), $message);
         $message = str_replace("{%product_url%}", Url::createUrl('store/product', array('product_id' => $product_id)), $message);
         $message = str_replace("{%url_account%}", Url::createUrl('account/review'), $message);
         $message = str_replace("{%product_name%}", $product_info['name'], $message);
         $message = str_replace("{%fullname%}", $customer_info['firstname'] . " " . $customer_info['lastname'], $message);
         $message = str_replace("{%company%}", $customer_info['company'], $message);
         $message = str_replace("{%email%}", $customer_info['email'], $message);
         $message = str_replace("{%qr_code_store%}", '<img src="' . HTTP_IMAGE . $qrStore . '" alt="QR Code" />', $message);
         $message = str_replace("{%barcode_39_order_id%}", '<img src="' . HTTP_IMAGE . $eanStore . '" alt="QR Code" />', $message);
         $message .= "<p style=\"text-align:center\">Powered By <a href=\"http://www.necotienda.org\">Necotienda</a>&reg; " . date('Y') . "</p>";
         $subject = $this->config->get('config_owner') . " " . $this->language->get('text_new_reply');
         if ($this->config->get('config_smtp_method') == 'smtp') {
             $mailer->IsSMTP();
             $mailer->Host = $this->config->get('config_smtp_host');
             $mailer->Username = $this->config->get('config_smtp_username');
             $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
             $mailer->Port = $this->config->get('config_smtp_port');
             $mailer->Timeout = $this->config->get('config_smtp_timeout');
             $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
             $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
         } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
             $mailer->IsSendmail();
         } else {
             $mailer->IsMail();
         }
         $mailer->IsHTML();
         $mailer->AddAddress($customer_info['email'], $customer_info['author']);
         $mailer->AddBCC($this->config->get('config_email'), $this->config->get('config_name'));
         $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
         $mailer->Subject = $subject;
         $mailer->Body = html_entity_decode($message);
         $mailer->Send();
     }
 }
 public function confirm()
 {
     $this->language->load('payment/cod');
     $this->load->model('account/order');
     $this->load->model('account/payment');
     $this->load->library('email/mailer');
     if ($this->session->has('order_id')) {
         $this->data['order_id'] = $this->session->get('order_id');
     } elseif ($this->request->hasQuery('order_id')) {
         $this->data['order_id'] = $this->request->getQuery('order_id');
     } elseif ($this->request->hasPost('cod_order_id')) {
         $this->data['order_id'] = $this->request->getPost('cod_order_id');
     } else {
         $this->data['order_id'] = 0;
     }
     $order_info = $this->modelOrder->getOrder($this->data['order_id']);
     if ($order_info && $this->customer->isLogged()) {
         $total_payment = $this->modelPayment->getSumPayments(array('order_id' => $order_info['order_id'], 'limit' => 1000));
         $total = $order_info['total'] - $total_payment;
         $amount = explode(",", $this->request->getPost('cod_amount'));
         $payment = round(str_replace(".", "", $amount[0]) . "." . $amount[1], 2);
         $data['order_id'] = $order_info['order_id'];
         $data['payment_method'] = $this->language->get('text_title');
         $data['amount'] = $payment;
         $data['comment'] = $this->language->get('text_date_of_payment') . ": " . $this->request->getPost('cod_date_of_payment') . "\n";
         $data['comment'] .= $this->language->get('text_payment_method_on_delivery') . ": " . $this->request->getPost('cod_payment_method_on_delivery') . "\n";
         $data['comment'] .= "\n" . $this->request->getPost('cod_comment');
         $data['order_status_id'] = $this->config->get('cod_order_status_id');
         $data['order_payment_status_id'] = $this->config->get('config_payment_status_id');
         $json['payment_id'] = $payment_id = $this->modelPayment->add($data);
         $this->modelOrder->addOrderHistory($order_info['order_id'], $data);
         $this->modelOrder->updateStatus($order_info['order_id'], $this->config->get('cod_order_status_id'));
         $this->modelOrder->updatePaymentMethod($order_info['order_id'], $this->language->get('text_title'));
         $diff = $payment - $total;
         if ($diff < 0) {
             //falta dinero
             $diff = $diff * -1;
             $json['warning'] = 1;
             $json['msg'] = str_replace('{%payment_receipt%}', Url::createUrl("account/payment"), $this->language->get('error_moneyless'));
             $json['msg'] = str_replace('{%invoice%}', Url::createUrl("account/invoice", array('order_id' => $order_info['order_id'])), $json['msg']);
             $json['msg'] = str_replace('{%diff%}', $this->currency->format($diff), $json['msg']);
         } elseif ($diff > 0) {
             //sobra dinero
             $json['warning'] = 1;
             $json['msg'] = str_replace('{%payment_receipt%}', Url::createUrl("account/payment"), $this->language->get('error_moneymore'));
             $json['msg'] = str_replace('{%invoice%}', Url::createUrl("account/invoice", array('order_id' => $order_info['order_id'])), $json['msg']);
             $json['msg'] = str_replace('{%diff%}', $this->currency->format($diff), $json['msg']);
         } else {
             $json['success'] = 1;
             $json['msg'] = $this->language->get('text_success');
         }
         $mailer = new Mailer();
         if ($this->config->get('cod_newsletter_id')) {
             $this->load->model("marketing/newsletter");
             $this->load->library('BarcodeQR');
             $this->load->library('Barcode39');
             $qr = new BarcodeQR();
             $barcode = new Barcode39(C_CODE);
             $totals = $this->modelOrder->getOrderTotals($order_id);
             $text = $this->config->get('config_owner') . "\n";
             $text .= "Pago ID: " . $payment_id . "\n";
             $text .= "Pedido ID: " . $order_id . "\n";
             $text .= "Fecha Emision del Pedido: " . date('d-m-Y h:i A', strtotime($order_info['date_added'])) . "\n";
             $text .= "Cliente: " . $this->customer->getCompany() . "\n";
             $text .= "RIF: " . $this->customer->getRif() . "\n";
             $text .= "Direccion IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
             $qrStore = "cache/" . str_replace(".", "_", $this->config->get('config_owner')) . '.jpg';
             $qrPayment = "cache/" . str_replace(" ", "_", $this->config->get('config_owner') . "_qr_code_payment_" . $payment_id) . '.jpg';
             $eanStore = "cache/" . str_replace(" ", "_", $this->config->get('config_owner') . "_barcode_39_order_id_" . $order_id) . '.gif';
             $qr->text($text);
             $qr->draw(150, DIR_IMAGE . $qrPayment);
             $qr->url(HTTP_HOME);
             $qr->draw(150, DIR_IMAGE . $qrStore);
             $barcode->draw(DIR_IMAGE . $eanStore);
             $payment_text = '<h1>' . $this->config->get('config_owner') . "</h1>";
             $payment_text .= "Pago ID: " . $payment_id . "<br />";
             $payment_text .= "Pedido ID: " . $order_id . "<br />";
             $payment_text .= "Fecha Emision del Pedido: " . date('d-m-Y h:i A', strtotime($order_info['date_added'])) . "<br />";
             $payment_text .= "Cliente: " . $this->customer->getCompany() . "<br />";
             $payment_text .= "RIF: " . $this->customer->getRif() . "<br />";
             $payment_text .= "Direccion IP: " . $_SERVER['REMOTE_ADDR'] . "<br />";
             $total_html = "<div class=\"clear:both;float:none;\"></div><br /><table>";
             foreach ($totals as $total) {
                 $total_html .= "<tr>";
                 $total_html .= "<td style=\"text-align:right;\">" . $total['title'] . "</td>";
                 $total_html .= "<td style=\"text-align:right;\">" . $total['text'] . "</td>";
                 $total_html .= "</tr>";
             }
             $total_html .= "</table>";
             $payment_text .= $total_html;
             $result = $this->modelNewsletter->getById($this->config->get('cod_newsletter_id'));
             $message = $result['htmlbody'];
             $message = str_replace("{%title%}", 'Pago N&deg; ' . $payment_id . " - " . $this->config->get('config_name'), $message);
             $message = str_replace("{%store_logo%}", '<img src="' . HTTP_IMAGE . $this->config->get('config_logo') . '" alt="' . $this->config->get('config_name') . '" />', $message);
             $message = str_replace("{%store_url%}", HTTP_HOME, $message);
             $message = str_replace("{%store_owner%}", $this->config->get('config_owner'), $message);
             $message = str_replace("{%store_name%}", $this->config->get('config_name'), $message);
             $message = str_replace("{%store_rif%}", $this->config->get('config_rif'), $message);
             $message = str_replace("{%store_email%}", $this->config->get('config_email'), $message);
             $message = str_replace("{%store_telephone%}", $this->config->get('config_telephone'), $message);
             $message = str_replace("{%store_address%}", $this->config->get('config_address'), $message);
             $message = str_replace("{%totals%}", $total_html, $message);
             $message = str_replace("{%order_id%}", $this->config->get('config_invoice_prefix') . $order_id, $message);
             $message = str_replace("{%invoice_id%}", $this->config->get('config_invoice_prefix') . $invoice_id, $message);
             $message = str_replace("{%rif%}", $this->customer->getRif(), $message);
             $message = str_replace("{%fullname%}", $this->customer->getFirstName() . " " . $this->customer->getFirstName(), $message);
             $message = str_replace("{%company%}", $this->customer->getCompany(), $message);
             $message = str_replace("{%email%}", $this->customer->getEmail(), $message);
             $message = str_replace("{%telephone%}", $this->customer->getTelephone(), $message);
             $message = str_replace("{%payment%}", $payment_text, $message);
             $message = str_replace("{%payment_method%}", $order_info['payment_method'], $message);
             $message = str_replace("{%date_added%}", date('d-m-Y h:i A', strtotime($order_info['date_added'])), $message);
             $message = str_replace("{%ip%}", $_SERVER['REMOTE_ADDR'], $message);
             $message = str_replace("{%qr_code_store%}", '<img src="' . HTTP_IMAGE . $qrStore . '" alt="QR Code" />', $message);
             $message = str_replace("{%comment%}", $order_info['comment'], $message);
             $message = str_replace("{%qr_code_payment%}", '<img src="' . HTTP_IMAGE . $qrPayment . '" alt="QR Code" />', $message);
             $message = str_replace("{%barcode_39_order_id%}", '<img src="' . HTTP_IMAGE . $eanStore . '" alt="QR Code" />', $message);
             $message .= "<p style=\"text-align:center\">Powered By Necotienda&reg; " . date('Y') . "</p>";
         } else {
             $message = $this->config->get('config_owner') . "\n";
             $message .= "Pago ID: " . $payment_id . "\n";
             $message .= "Pedido ID: " . $order_id . "\n";
             $message .= "Fecha Emision: " . date('d-m-Y h:i A', strtotime($order_info['date_added'])) . "\n";
             $message .= "Cliente: " . $this->customer->getCompany() . "\n";
             $message .= "RIF: " . $this->customer->getRif() . "\n";
             $message .= "Direccion IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
             $message .= "\n" . "Powered By Necotienda&reg; " . date('Y') . "\n";
         }
         if ($message) {
             if ($this->config->get('config_smtp_method') == 'smtp') {
                 $mailer->IsSMTP();
                 $mailer->Host = $this->config->get('config_smtp_host');
                 $mailer->Username = $this->config->get('config_smtp_username');
                 $mailer->Password = base64_decode($this->config->get('config_smtp_password'));
                 $mailer->Port = $this->config->get('config_smtp_port');
                 $mailer->Timeout = $this->config->get('config_smtp_timeout');
                 $mailer->SMTPSecure = $this->config->get('config_smtp_ssl');
                 $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false;
             } elseif ($this->config->get('config_smtp_method') == 'sendmail') {
                 $mailer->IsSendmail();
             } else {
                 $mailer->IsMail();
             }
             $mailer->IsHTML();
             $mailer->AddAddress($this->customer->getEmail(), $this->customer->getCompany());
             $mailer->AddBCC($this->config->get('config_email'), $this->config->get('config_name'));
             $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name'));
             $mailer->Subject = $this->config->get('config_owner') . " " . $this->language->get('text_new_payment') . " #" . $payment_id;
             $mailer->Body = html_entity_decode(htmlspecialchars_decode($message));
             $mailer->Send();
         }
     } elseif (!$this->customer->isLogged()) {
         $json['error'] = 1;
         $json['msg'] = $this->language->get('error_not_logged');
     } else {
         $json['error'] = 1;
         $json['msg'] = $this->language->get('error_payment');
     }
     $this->load->library('json');
     $this->response->setOutput(Json::encode($json), $this->config->get('config_compression'));
 }
Exemple #17
0
// after our sending limit is increased). Anyway, I get the same performance if using mass BCC in one email.
// Currently, these actual rates mean we can send about 4,500 emails in an hour. An email to an entire
// ward with, say, 160 members, would take just over 2 minutes. Previously, at 1 per second, it would take just under 3 minutes.
// TODO: If we are seeing a high volume of emails:
//  - Spawn up other threads to handle a single job, if the job is large enough, like stake-wide. Deal with concurrency. Yay...
//  - See if 2 or more other jobs are running; if so, wait time before trying. Run anyway after a certain length of time.
// Mark the job as started if not already. If already started or missing info, bail.
if ($job->Started > 0 || !$job->Subject || !$job->Message || !$job->SenderName() || !$job->SenderEmail()) {
    fail("Job properties incorrect (already started, or missing necessary information.\r\n");
}
// Ready... set... go!
$job->Started = now();
$job->Save();
// Prepare and send the emails
$mail = new Mailer();
$mail->IsHTML($job->IsHTML);
$mail->From($job->SenderName(), EMAIL_FROM);
$mail->ReplyTo($job->SenderName(), $job->SenderEmail());
$mail->Subject($job->Subject);
$mail->Body($job->Message);
$mail->RecipientArray($job->RecipientsAsArray());
// Send the messages!
$mail->Send();
// Store the list of those who didn't receive the email for whatever reason
$failedRecipients = $mail->FailedRecipients();
foreach ($failedRecipients as $recip) {
    $job->AddFailedRecipient($recip['name'], $recip['email']);
}
// This deed is done.
$job->Ended = now();
$job->Save();