From 9cba30297eecef1a1efd2e07c75ab6bec430cd7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Wed, 11 Feb 2026 10:36:26 +0900 Subject: [PATCH] cfmgrv4 init...10 --- .../Admin/Cloudflare/RecordController.php | 69 ++++++++++--------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/app/Controllers/Admin/Cloudflare/RecordController.php b/app/Controllers/Admin/Cloudflare/RecordController.php index 1bea9c0..5b969bf 100644 --- a/app/Controllers/Admin/Cloudflare/RecordController.php +++ b/app/Controllers/Admin/Cloudflare/RecordController.php @@ -11,6 +11,7 @@ use App\Models\Cloudflare\ZoneModel; use App\Services\Cloudflare\RecordService; use CodeIgniter\HTTP\RedirectResponse; use App\Services\MyLogService; +use RuntimeException; class RecordController extends CloudflareController { @@ -81,41 +82,45 @@ class RecordController extends CloudflareController } protected function create_process(): void { - //DB작업도 Socket에서 다 처리하므로 parent::create_process()하면 않됨 - $this->formDatas = $this->create_validate($this->action, $this->fields); - //Type이 A형식일경우 IP형태인지 확인 - if ($this->formDatas['type'] === 'A') { - if (!$this->helper->isIPAddress($this->formDatas['content'], $this->formDatas['type'])) { - throw new \Exception("{$this->formDatas['type']}, {$this->formDatas['content']} 형식 오류[사설IP 않됨]"); + try { + //DB작업도 Socket에서 다 처리하므로 parent::create_process()하면 않됨 + $this->formDatas = $this->create_validate($this->action, $this->fields); + //Type이 A형식일경우 IP형태인지 확인 + if ($this->formDatas['type'] === 'A') { + if (!$this->helper->isIPAddress($this->formDatas['content'], $this->formDatas['type'])) { + throw new \Exception("{$this->formDatas['type']}, {$this->formDatas['content']} 형식 오류[사설IP 않됨]"); + } } - } - //호스트명 형식확인 - $hosts = explode("\n", $this->formDatas['hosts']); - if (!is_array($hosts) || !count($hosts)) { - throw new \Exception("호스트명이 정의되지 않았습니다."); - } - $cnt = 1; - foreach ($hosts as $host) { - if (!$this->helper->isHost($host)) { - throw new \Exception("입력하신 {$cnt}번째 : [{$host}]는 호스트명 입력형식에 맞지 않습니다."); + //호스트명 형식확인 + $hosts = explode("\n", $this->formDatas['hosts']); + if (!is_array($hosts) || !count($hosts)) { + throw new \Exception("호스트명이 정의되지 않았습니다."); } - $cnt++; + $cnt = 1; + foreach ($hosts as $host) { + if (!$this->helper->isHost($host)) { + throw new \Exception("입력하신 {$cnt}번째 : [{$host}]는 호스트명 입력형식에 맞지 않습니다."); + } + $cnt++; + } + //Socket처리 + //부모데이터정의 + $this->_zone_entity = $this->getParentEntity($this->formDatas[$this->getService()->getModel()::PARENT]); + $entitys = []; + foreach ($hosts as $host) { + $entity = $this->getService()->create( + $this->_zone_entity, + $host, + $this->formDatas['type'], + $this->formDatas['content'], + $this->formDatas['proxied'] + ); + $entitys[] = $entity; + } + $this->entitys = $entitys; + } catch (\Throwable $e) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류:" . $e->getMessage()); } - //Socket처리 - //부모데이터정의 - $this->_zone_entity = $this->getParentEntity($this->formDatas[$this->getService()->getModel()::PARENT]); - $entitys = []; - foreach ($hosts as $host) { - $entity = $this->getService()->create( - $this->_zone_entity, - $host, - $this->formDatas['type'], - $this->formDatas['content'], - $this->formDatas['proxied'] - ); - $entitys[] = $entity; - } - $this->entitys = $entitys; } //수정 (modify,toggle,batchjob사용) protected function modify_process(mixed $uid): void