1: | <?php
2: | namespace Opencart\Admin\Controller\Extension\Opencart\Fraud;
3: | /**
4: | * Class DDOS
5: | *
6: | * @package Opencart\Admin\Controller\Extension\Opencart\Fraud
7: | */
8: | class Ddos extends \Opencart\System\Engine\Controller {
9: | /**
10: | * Index
11: | *
12: | * @return void
13: | */
14: | public function index(): void {
15: | $this->load->language('extension/opencart/fraud/ddos');
16: |
17: | $this->document->setTitle($this->language->get('heading_title'));
18: |
19: | $data['breadcrumbs'] = [];
20: |
21: | $data['breadcrumbs'][] = [
22: | 'text' => $this->language->get('text_home'),
23: | 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
24: | ];
25: |
26: | $data['breadcrumbs'][] = [
27: | 'text' => $this->language->get('text_extension'),
28: | 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=fraud')
29: | ];
30: |
31: | $data['breadcrumbs'][] = [
32: | 'text' => $this->language->get('text_fraud'),
33: | 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=fraud')
34: | ];
35: |
36: | $data['breadcrumbs'][] = [
37: | 'text' => $this->language->get('heading_title'),
38: | 'href' => $this->url->link('extension/opencart/fraud/ddos', 'user_token=' . $this->session->data['user_token'])
39: | ];
40: |
41: | $data['save'] = $this->url->link('extension/opencart/fraud/ddos.save', 'user_token=' . $this->session->data['user_token']);
42: | $data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=fraud');
43: |
44: | $this->load->model('localisation/order_status');
45: |
46: | $data['fraud_ddos_status'] = $this->config->get('fraud_ddos_status');
47: |
48: | $data['user_token'] = $this->session->data['user_token'];
49: |
50: | $data['header'] = $this->load->controller('common/header');
51: | $data['column_left'] = $this->load->controller('common/column_left');
52: | $data['footer'] = $this->load->controller('common/footer');
53: |
54: | $this->response->setOutput($this->load->view('extension/opencart/fraud/ip', $data));
55: | }
56: |
57: | /**
58: | * Save
59: | *
60: | * @return void
61: | */
62: | public function save(): void {
63: | $this->load->language('extension/opencart/fraud/ddos');
64: |
65: | $json = [];
66: |
67: | if (!$this->user->hasPermission('modify', 'extension/opencart/fraud/ddos')) {
68: | $json['error'] = $this->language->get('error_permission');
69: | }
70: |
71: | if (!$json) {
72: | $this->load->model('setting/setting');
73: |
74: | $this->model_setting_setting->editSetting('fraud_ddos', $this->request->post);
75: |
76: | $json['success'] = $this->language->get('text_success');
77: | }
78: |
79: | $this->response->addHeader('Content-Type: application/json');
80: | $this->response->setOutput(json_encode($json));
81: | }
82: |
83: | /**
84: | * Install
85: | *
86: | * @return void
87: | */
88: | public function install(): void {
89: | if ($this->user->hasPermission('modify', 'extension/fraud')) {
90: | $this->load->model('extension/opencart/fraud/ddos');
91: |
92: | $this->model_extension_opencart_fraud_ddos->install();
93: | }
94: | }
95: |
96: | /**
97: | * Uninstall
98: | *
99: | * @return void
100: | */
101: | public function uninstall(): void {
102: | if ($this->user->hasPermission('modify', 'extension/fraud')) {
103: | $this->load->model('extension/opencart/fraud/ddos');
104: |
105: | $this->model_extension_opencart_fraud_ddos->uninstall();
106: | }
107: | }
108: |
109: | /**
110: | * Ip
111: | *
112: | * @return void
113: | */
114: | public function report(): void {
115: | $this->load->language('extension/opencart/fraud/ddos');
116: |
117: | if (isset($this->request->get['page'])) {
118: | $page = (int)$this->request->get['page'];
119: | } else {
120: | $page = 1;
121: | }
122: |
123: | $limit = 10;
124: |
125: | $data['ips'] = [];
126: |
127: | $this->load->model('extension/opencart/fraud/ddos');
128: | $this->load->model('customer/customer');
129: |
130: | $results = $this->model_extension_opencart_fraud_ddos->getDdos(($page - 1) * $limit, $limit);
131: |
132: | foreach ($results as $result) {
133: | $data['ips'][] = [
134: | 'ip' => $result['ip'],
135: | 'total' => $this->model_customer_customer->getTotalCustomersByIp($result['ip']),
136: | 'date_added' => date('d/m/y', strtotime($result['date_added'])),
137: | 'filter_ip' => $this->url->link('customer/customer', 'user_token=' . $this->session->data['user_token'] . '&filter_ip=' . $result['ip'])
138: | ];
139: | }
140: |
141: | $ip_total = $this->model_extension_opencart_fraud_ddos->getTotalDdos();
142: |
143: | $data['pagination'] = $this->load->controller('common/pagination', [
144: | 'total' => $ip_total,
145: | 'page' => $page,
146: | 'limit' => $limit,
147: | 'url' => $this->url->link('extension/opencart/fraud/ip.ip', 'user_token=' . $this->session->data['user_token'] . '&page={page}')
148: | ]);
149: |
150: | $data['results'] = sprintf($this->language->get('text_pagination'), ($ip_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($ip_total - $limit)) ? $ip_total : ((($page - 1) * $limit) + $limit), $ip_total, ceil($ip_total / $limit));
151: |
152: | $this->response->setOutput($this->load->view('extension/opencart/fraud/ddos_ip', $data));
153: | }
154: | }
155: |

OpenCart API API documentation generated by ApiGen dev-master