1: | <?php
2: | namespace Opencart\Catalog\Model\Extension\Opencart\Fraud;
3: | /**
4: | * Class Ip
5: | *
6: | * @package Opencart\Catalog\Model\Extension\Opencart\Fraud
7: | */
8: | class Ip extends \Opencart\System\Engine\Model {
9: | /**
10: | * Check IP
11: | *
12: | * @param array<string, mixed> $order_info
13: | *
14: | * @return int
15: | */
16: | public function check(array $order_info): int {
17: | $status = false;
18: |
19: | if ($order_info['customer_id']) {
20: | $this->load->model('account/customer');
21: |
22: | $results = $this->model_account_customer->getIps($order_info['customer_id']);
23: |
24: | foreach ($results as $result) {
25: | $ips = $this->getIps($result['ip']);
26: |
27: | if ($ips) {
28: | $status = true;
29: |
30: | break;
31: | }
32: | }
33: | } else {
34: | $ips = $this->getIps($order_info['ip']);
35: |
36: | if ($ips) {
37: | $status = true;
38: | }
39: | }
40: |
41: | if ($status) {
42: | return (int)$this->config->get('fraud_ip_order_status_id');
43: | } else {
44: | return 0;
45: | }
46: | }
47: |
48: | /**
49: | * Get IPs
50: | *
51: | * @param string $ip
52: | *
53: | * @return array<int, array<string, mixed>>
54: | */
55: | public function getIps(string $ip): array {
56: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "fraud_ip` WHERE `ip` = '" . $this->db->escape($ip) . "'");
57: |
58: | return $query->rows;
59: | }
60: | }
61: |

OpenCart API API documentation generated by ApiGen dev-master