1: | <?php
2: | namespace Opencart\Admin\Controller\Mail;
3: | /**
4: | * Class Forgotten
5: | *
6: | * @package Opencart\Admin\Controller\Mail
7: | */
8: | class Forgotten extends \Opencart\System\Engine\Controller {
9: | /**
10: | * Index
11: | *
12: | * admin/model/user/user/editCode/after
13: | *
14: | * @param string $route
15: | * @param array<int, mixed> $args
16: | * @param mixed $output
17: | *
18: | * @throws \Exception
19: | *
20: | * @return void
21: | */
22: | public function index(string &$route, array &$args, &$output): void {
23: | if (isset($this->request->get['route'])) {
24: | $route = (string)$this->request->get['route'];
25: | } else {
26: | $route = '';
27: | }
28: |
29: | if (isset($args[0])) {
30: | $email = urldecode((string)$args[0]);
31: | } else {
32: | $email = '';
33: | }
34: |
35: | if (isset($args[1])) {
36: | $code = (string)$args[1];
37: | } else {
38: | $code = '';
39: | }
40: |
41: | if ($email && $code && ($route == 'common/forgotten.confirm') && filter_var($email, FILTER_VALIDATE_EMAIL)) {
42: | $this->load->language('mail/forgotten');
43: |
44: | $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
45: |
46: | $subject = sprintf($this->language->get('text_subject'), $store_name);
47: |
48: | $data['text_greeting'] = sprintf($this->language->get('text_greeting'), $store_name);
49: |
50: | $data['reset'] = $this->url->link('common/forgotten.reset', 'email=' . $email . '&code=' . $code, true);
51: | $data['ip'] = $this->request->server['REMOTE_ADDR'];
52: |
53: | $data['store'] = $store_name;
54: | $data['store_url'] = $this->config->get('config_store_url');
55: |
56: | if ($this->config->get('config_mail_engine')) {
57: | $mail_option = [
58: | 'parameter' => $this->config->get('config_mail_parameter'),
59: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
60: | 'smtp_username' => $this->config->get('config_mail_smtp_username'),
61: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
62: | 'smtp_port' => $this->config->get('config_mail_smtp_port'),
63: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
64: | ];
65: |
66: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
67: | $mail->setTo($email);
68: | $mail->setFrom($this->config->get('config_email'));
69: | $mail->setSender($store_name);
70: | $mail->setSubject($subject);
71: | $mail->setHtml($this->load->view('mail/forgotten', $data));
72: | $mail->send();
73: | }
74: | }
75: | }
76: | }
77: |

OpenCart API API documentation generated by ApiGen dev-master