diff --git a/app/Models/Cloudflare/AccountModel.php b/app/Models/Cloudflare/AccountModel.php index 7e3ac9c..6d49af0 100644 --- a/app/Models/Cloudflare/AccountModel.php +++ b/app/Models/Cloudflare/AccountModel.php @@ -95,4 +95,9 @@ class AccountModel extends CommonModel { return $this->modify_process($entity, $formDatas); } + //List 검색용 + public function setList_WordFilter(string $word): void + { + $this->orLike(self::TABLE . self::TITLE, $word, 'both'); + } } diff --git a/app/Models/Cloudflare/AuditLogModel.php b/app/Models/Cloudflare/AuditLogModel.php index db6aaba..def73bd 100644 --- a/app/Models/Cloudflare/AuditLogModel.php +++ b/app/Models/Cloudflare/AuditLogModel.php @@ -86,9 +86,9 @@ class AuditLogModel extends CommonModel return $this->modify_process($entity, $formDatas); } //List 검색용 - public function setList_WordFilter(string $word, $field = null): void + public function setList_WordFilter(string $word): void { - parent::setList_WordFilter($word, $field); + $this->orLike(self::TABLE . self::TITLE, $word, 'both'); $this->orLike(self::TABLE . '.zone_name', $word, 'both'); $this->orLike(self::TABLE . '.meta', $word, 'both'); $this->orLike(self::TABLE . '.resource', $word, 'both'); diff --git a/app/Models/Cloudflare/AuthModel.php b/app/Models/Cloudflare/AuthModel.php index e18e077..4080174 100644 --- a/app/Models/Cloudflare/AuthModel.php +++ b/app/Models/Cloudflare/AuthModel.php @@ -86,4 +86,10 @@ class AuthModel extends CommonModel { return $this->modify_process($entity, $formDatas); } + public function setList_WordFilter(string $word): void + { + $this->orLike(self::TABLE . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . '.authkey', $word, 'both'); + $this->orLike(self::TABLE . '.oldkey', $word, 'both'); + } } diff --git a/app/Models/Cloudflare/FirewallModel.php b/app/Models/Cloudflare/FirewallModel.php index 41636b3..0507305 100644 --- a/app/Models/Cloudflare/FirewallModel.php +++ b/app/Models/Cloudflare/FirewallModel.php @@ -105,9 +105,9 @@ class FirewallModel extends CommonModel return $this->modify_process($entity, $formDatas); } //List 검색용 - public function setList_WordFilter(string $word, $field = null): void + public function setList_WordFilter(string $word): void { - parent::setList_WordFilter($word, $field); - $this->orLike(self::TABLE . '.' . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . '.expression', $word, 'both'); } } diff --git a/app/Models/Cloudflare/RecordModel.php b/app/Models/Cloudflare/RecordModel.php index bb336f4..6259f97 100644 --- a/app/Models/Cloudflare/RecordModel.php +++ b/app/Models/Cloudflare/RecordModel.php @@ -128,9 +128,13 @@ class RecordModel extends CommonModel } } //List 검색용 - public function setList_WordFilter(string $word, $field = null): void + public function setList_WordFilter(string $word): void { - parent::setList_WordFilter($word, $field); - $this->orLike(self::TABLE . '.content', $word, 'both'); + if ($this->isIPAddress($word, 'ipv4')) { + $this->where(self::TABLE . '.content', $word); + } else { + $this->orLike(self::TABLE . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . '.content', $word, 'both'); + } } } diff --git a/app/Models/Cloudflare/ZoneModel.php b/app/Models/Cloudflare/ZoneModel.php index b9fb0a0..02d1419 100644 --- a/app/Models/Cloudflare/ZoneModel.php +++ b/app/Models/Cloudflare/ZoneModel.php @@ -130,30 +130,30 @@ class ZoneModel extends CommonModel return is_null($this->first()) ? true : false; } //List 검색용 - public function setList_WordFilter(string $word, $field = null): void + public function setList_WordFilter(string $word): void { - //Record의 content(IP검색)을 하기위함 - //Join 방식사용 - // $this->join(RecordModel::TABLE, sprintf( - // "%s.%s=%s.%s", - // self::TABLE, - // self::PK, - // RecordModel::TABLE, - // RecordModel::PARENT - // )); - // parent::setList_WordFilter($word, $field); - // $this->orLike(RecordModel::TABLE . '.content', $word, 'both'); - //Subquery 방식사용 - $recordModel = new RecordModel(); - $recordModel->like(RecordModel::TABLE . '.content', $word, 'both'); - $recordModel->orlike(RecordModel::TABLE . '.' . RecordModel::TITLE, $word, 'both'); - $recorde_entitys = $recordModel->select(RecordModel::PARENT)->findAll(); - $zone_uids = array_column($recorde_entitys, RecordModel::PARENT); - parent::setList_WordFilter($word, $field); - if (count($zone_uids)) { + if ($this->isIPAddress($word, 'ipv4')) { + //Record의 content(IP검색)을 하기위함 + //Join 방식사용 + // $this->join(RecordModel::TABLE, sprintf( + // "%s.%s=%s.%s", + // self::TABLE, + // self::PK, + // RecordModel::TABLE, + // RecordModel::PARENT + // )); + // parent::setList_WordFilter($word, $field); + // $this->orLike(RecordModel::TABLE . '.content', $word, 'both'); + //Subquery 방식사용 + $recordModel = new RecordModel(); + $recordModel->setList_WordFilter($word); + $recorde_entitys = $recordModel->select(RecordModel::PARENT)->findAll(); + $zone_uids = array_column($recorde_entitys, RecordModel::PARENT); $this->orWhereIn(self::TABLE . '.' . self::PK, array_values($zone_uids)); + } else { + $this->orLike(self::TABLE . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . '.name_servers', $word, 'both'); + $this->orLike(self::TABLE . '.original_name_servers', $word, 'both'); } - // var_dump($zone_uids); - // exit; } } diff --git a/app/Models/CommonModel.php b/app/Models/CommonModel.php index 252d495..85bede9 100644 --- a/app/Models/CommonModel.php +++ b/app/Models/CommonModel.php @@ -54,7 +54,7 @@ abstract class CommonModel extends Model abstract public function getFields(): array; abstract public function getFilterFields(): array; abstract public function getBatchJobFields(): array; - + abstract public function setList_WordFilter(string $word): void; final public function getTable(): string { return $this->table; @@ -219,16 +219,29 @@ abstract class CommonModel extends Model } // List용 + final public function isIPAddress(string $ip, $type = false): bool + { + switch ($type) { + case 'ipv4': + $result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); + break; + case 'ipv6': + $result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); + break; + case 'all': + $result = filter_var($ip, FILTER_VALIDATE_IP); + break; + default: + $result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE); + break; + } + return $result; + } + final public function setList_FieldFilter(string $field, int|string $value): void { $this->where($this->getTable() . '.' . $field, $value); } - - public function setList_WordFilter(string $word, string $field): void - { - $this->like($this->getTable() . '.' . $field, $word, 'both'); // before, after, both - } - final public function setList_DateFilter(string $start, string $end, $field = "created_at"): void { if ($start !== DEFAULTS['EMPTY']) { diff --git a/app/Models/MapurlModel.php b/app/Models/MapurlModel.php index febe8bd..01f18a4 100644 --- a/app/Models/MapurlModel.php +++ b/app/Models/MapurlModel.php @@ -73,4 +73,10 @@ class MapurlModel extends CommonModel { return $this->modify_process($entity, $formDatas); } + //List 검색용 + public function setList_WordFilter(string $word): void + { + $this->orLike(self::TABLE . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . '.new_url', $word, 'both'); + } } diff --git a/app/Models/MyLogModel.php b/app/Models/MyLogModel.php index 035258d..17afdd3 100644 --- a/app/Models/MyLogModel.php +++ b/app/Models/MyLogModel.php @@ -66,4 +66,10 @@ class MyLogModel extends CommonModel { return $this->create_process(new MyLogEntity(), $formDatas); } + //List 검색용 + public function setList_WordFilter(string $word): void + { + $this->orLike(self::TABLE . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . '.content', $word, 'both'); + } } diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 0ad7263..3b881e9 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -116,4 +116,11 @@ class UserModel extends CommonModel { return $this->modify_process($entity, $formDatas); } + //List 검색용 + public function setList_WordFilter(string $word): void + { + $this->orLike(self::TABLE . '.id', $word, 'both'); + $this->orLike(self::TABLE . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . '.email', $word, 'both'); + } } diff --git a/app/Models/UserSNSModel.php b/app/Models/UserSNSModel.php index 298b8a0..70d630d 100644 --- a/app/Models/UserSNSModel.php +++ b/app/Models/UserSNSModel.php @@ -95,10 +95,16 @@ class UserSNSModel extends CommonModel { return $this->create_process(new UserSNSEntity(), $formDatas); } - //modify용 public function modify(UserSNSEntity $entity, array $formDatas): UserSNSEntity { return $this->modify_process($entity, $formDatas); } + //List 검색용 + public function setList_WordFilter(string $word): void + { + $this->orLike(self::TABLE . '.id', $word, 'both'); + $this->orLike(self::TABLE . self::TITLE, $word, 'both'); + $this->orLike(self::TABLE . '.email', $word, 'both'); + } }