1: | <?php
|
2: | namespace Opencart\Catalog\Model\Account;
|
3: | |
4: | |
5: | |
6: | |
7: |
|
8: | class Api extends \Opencart\System\Engine\Model {
|
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: |
|
17: | public function login(string $username, string $key): array {
|
18: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api` WHERE `username` = '" . $this->db->escape($username) . "' AND `key` = '" . $this->db->escape($key) . "' AND `status` = '1'");
|
19: |
|
20: | return $query->row;
|
21: | }
|
22: |
|
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: |
|
32: | public function addSession(int $api_id, string $session_id, string $ip): int {
|
33: | $this->db->query("INSERT INTO `" . DB_PREFIX . "api_session` SET `api_id` = '" . (int)$api_id . "', `session_id` = '" . $this->db->escape($session_id) . "', `ip` = '" . $this->db->escape($ip) . "', `date_added` = NOW(), `date_modified` = NOW()");
|
34: |
|
35: | return $this->db->getLastId();
|
36: | }
|
37: |
|
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: |
|
45: | public function getIps(int $api_id): array {
|
46: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api_ip` WHERE `api_id` = '" . (int)$api_id . "'");
|
47: |
|
48: | return $query->rows;
|
49: | }
|
50: | }
|
51: | |