1: | <?php
2: | namespace Opencart\Admin\Controller\Mail;
3: | /**
4: | * Class Authorize
5: | *
6: | * @package Opencart\Admin\Controller\Mail
7: | */
8: | class Authorize extends \Opencart\System\Engine\Controller {
9: | // admin/model/user/user/editCode/after
10: | /**
11: | * Index
12: | *
13: | * @param string $route
14: | * @param array<int, mixed> $args
15: | * @param array<mixed> $output
16: | *
17: | * @throws \Exception
18: | *
19: | * @return void
20: | */
21: | public function index(&$route, &$args, &$output): void {
22: | if (isset($this->request->get['route'])) {
23: | $route = (string)$this->request->get['route'];
24: | } else {
25: | $route = '';
26: | }
27: |
28: | $email = $this->user->getEmail();
29: |
30: | if (isset($this->session->data['code'])) {
31: | $code = $this->session->data['code'];
32: | } else {
33: | $code = '';
34: | }
35: |
36: | if ($email && $code && ($route == 'common/authorize.send') && filter_var($email, FILTER_VALIDATE_EMAIL)) {
37: | $this->load->language('mail/authorize');
38: |
39: | $data['username'] = $this->user->getUsername();
40: | $data['code'] = $code;
41: | $data['ip'] = $this->request->server['REMOTE_ADDR'];
42: | $data['store'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
43: |
44: | if ($this->config->get('config_mail_engine')) {
45: | $mail_option = [
46: | 'parameter' => $this->config->get('config_mail_parameter'),
47: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
48: | 'smtp_username' => $this->config->get('config_mail_smtp_username'),
49: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
50: | 'smtp_port' => $this->config->get('config_mail_smtp_port'),
51: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
52: | ];
53: |
54: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
55: | $mail->setTo($email);
56: | $mail->setFrom($this->config->get('config_email'));
57: | $mail->setSender($this->config->get('config_name'));
58: | $mail->setSubject($this->language->get('text_subject'));
59: | $mail->setText($this->load->view('mail/authorize', $data));
60: | $mail->send();
61: | }
62: | }
63: | }
64: |
65: | // admin/model/user/user/editCode/after
66: |
67: | /**
68: | * Reset
69: | *
70: | * @param string $route
71: | * @param array<int, mixed> $args
72: | * @param array<mixed> $output
73: | *
74: | * @throws \Exception
75: | *
76: | * @return void
77: | */
78: | public function reset(&$route, &$args, &$output): void {
79: | if (isset($this->request->get['route'])) {
80: | $route = $this->request->get['route'];
81: | } else {
82: | $route = '';
83: | }
84: |
85: | if (isset($args[0])) {
86: | $email = (string)$args[0];
87: | } else {
88: | $email = '';
89: | }
90: |
91: | if (isset($args[1])) {
92: | $code = (string)$args[1];
93: | } else {
94: | $code = '';
95: | }
96: |
97: | if ($email && $code && ($route == 'common/authorize.confirm') && filter_var($email, FILTER_VALIDATE_EMAIL)) {
98: | $this->load->language('mail/authorize_reset');
99: |
100: | $data['username'] = $this->user->getUsername();
101: | $data['reset'] = $this->url->link('common/authorize.reset', 'email=' . $email . '&code=' . $code, true);
102: | $data['ip'] = $this->request->server['REMOTE_ADDR'];
103: | $data['store'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
104: |
105: | if ($this->config->get('config_mail_engine')) {
106: | $mail_option = [
107: | 'parameter' => $this->config->get('config_mail_parameter'),
108: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
109: | 'smtp_username' => $this->config->get('config_mail_smtp_username'),
110: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
111: | 'smtp_port' => $this->config->get('config_mail_smtp_port'),
112: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
113: | ];
114: |
115: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
116: | $mail->setTo($email);
117: | $mail->setFrom($this->config->get('config_email'));
118: | $mail->setSender($this->config->get('config_name'));
119: | $mail->setSubject($this->language->get('text_subject'));
120: | $mail->setText($this->load->view('mail/authorize_reset', $data));
121: | $mail->send();
122: | }
123: | }
124: | }
125: | }
126: |

OpenCart API API documentation generated by ApiGen dev-master