cfmgrv4 init...10
This commit is contained in:
parent
ae498d3f37
commit
b945ff6f74
@ -2,16 +2,17 @@
|
||||
|
||||
namespace App\Controllers\Admin\Cloudflare;
|
||||
|
||||
use App\Entities\Cloudflare\AccountEntity;
|
||||
use App\Helpers\Cloudflare\ZoneHelper;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use App\Services\Cloudflare\RecordService;
|
||||
use App\Services\Cloudflare\ZoneService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use RuntimeException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Services\MyLogService;
|
||||
use App\Helpers\Cloudflare\ZoneHelper;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use App\Models\Cloudflare\AccountModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use App\Services\Cloudflare\ZoneService;
|
||||
use App\Entities\Cloudflare\AccountEntity;
|
||||
use App\Services\Cloudflare\RecordService;
|
||||
|
||||
class ZoneController extends CloudflareController
|
||||
{
|
||||
@ -88,69 +89,74 @@ class ZoneController extends CloudflareController
|
||||
}
|
||||
protected function create_process(): void
|
||||
{
|
||||
//DB작업도 Socket에서 다 처리하므로 parent::create_process()하면 않됨
|
||||
$this->formDatas = $this->create_validate($this->action, $this->fields);
|
||||
//부모데이터 정의
|
||||
$this->_account_entity = $this->getParentEntity($this->formDatas[$this->getService()->getModel()::PARENT]);
|
||||
//데이터검증
|
||||
//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);
|
||||
//부모데이터 정의
|
||||
$this->_account_entity = $this->getParentEntity($this->formDatas[$this->getService()->getModel()::PARENT]);
|
||||
//데이터검증
|
||||
//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 않됨]");
|
||||
}
|
||||
}
|
||||
}
|
||||
//도메인명 형식확인
|
||||
$domains = explode("\n", $this->formDatas['domains']);
|
||||
if (!is_array($domains) || !count($domains)) {
|
||||
throw new \Exception("도메인명이 정의되지 않았습니다.");
|
||||
}
|
||||
$cnt = 1;
|
||||
foreach ($domains as $domain) {
|
||||
//도메인명 형식확인
|
||||
if (!$this->helper->isDomain($domain)) {
|
||||
throw new \Exception("{$cnt}번째 : [{$domain}]는 도메인명 형식에 맞지 않습니다.");
|
||||
$domains = explode("\n", $this->formDatas['domains']);
|
||||
if (!is_array($domains) || !count($domains)) {
|
||||
throw new \Exception("도메인명이 정의되지 않았습니다.");
|
||||
}
|
||||
//도메인명이 해당계정의 유일한 도메인인지 확인
|
||||
if (!$this->getService()->getModel()->isUniqueDomain($this->_account_entity, $domain)) {
|
||||
throw new \Exception("{$cnt}번째 : [{$domain}]는 이미 등록된 도메인입니다.");
|
||||
$cnt = 1;
|
||||
foreach ($domains as $domain) {
|
||||
//도메인명 형식확인
|
||||
if (!$this->helper->isDomain($domain)) {
|
||||
throw new \Exception("{$cnt}번째 : [{$domain}]는 도메인명 형식에 맞지 않습니다.");
|
||||
}
|
||||
//도메인명이 해당계정의 유일한 도메인인지 확인
|
||||
if (!$this->getService()->getModel()->isUniqueDomain($this->_account_entity, $domain)) {
|
||||
throw new \Exception("{$cnt}번째 : [{$domain}]는 이미 등록된 도메인입니다.");
|
||||
}
|
||||
$cnt++;
|
||||
}
|
||||
$cnt++;
|
||||
}
|
||||
//호스트명 형식확인
|
||||
$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++;
|
||||
}
|
||||
//Socket처리
|
||||
//Zone생성
|
||||
$entitys = [];
|
||||
foreach ($domains as $domain) {
|
||||
$entity = $this->getService()->create($this->_account_entity, $domain);
|
||||
$entitys[] = $entity;
|
||||
}
|
||||
//Record생성
|
||||
$record = new RecordService();
|
||||
foreach ($entitys as $entity) {
|
||||
$record_entitys = [];
|
||||
$cnt = 1;
|
||||
foreach ($hosts as $host) {
|
||||
$record_entitys[] = $record->create(
|
||||
$entity,
|
||||
$host,
|
||||
$this->formDatas['type'],
|
||||
$this->formDatas['content'],
|
||||
$this->formDatas['proxied']
|
||||
);
|
||||
if (!$this->helper->isHost($host)) {
|
||||
throw new \Exception("{$cnt}번째 : [{$host}]는 호스트명 형식에 맞지 않습니다.");
|
||||
}
|
||||
$cnt++;
|
||||
}
|
||||
$entity->records = $record_entitys;
|
||||
//Socket처리
|
||||
//Zone생성
|
||||
$entitys = [];
|
||||
foreach ($domains as $domain) {
|
||||
$entity = $this->getService()->create($this->_account_entity, $domain);
|
||||
$entitys[] = $entity;
|
||||
}
|
||||
//Record생성
|
||||
$record = new RecordService();
|
||||
foreach ($entitys as $entity) {
|
||||
$record_entitys = [];
|
||||
foreach ($hosts as $host) {
|
||||
$record_entitys[] = $record->create(
|
||||
$entity,
|
||||
$host,
|
||||
$this->formDatas['type'],
|
||||
$this->formDatas['content'],
|
||||
$this->formDatas['proxied']
|
||||
);
|
||||
}
|
||||
$entity->records = $record_entitys;
|
||||
}
|
||||
$this->entitys = $entitys;
|
||||
} catch (\Throwable $e) {
|
||||
log_message('debug', static::class . '->' . __FUNCTION__ . "에서 오류:" . $e->getMessage());
|
||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류:" . $e->getMessage());
|
||||
}
|
||||
$this->entitys = $entitys;
|
||||
}
|
||||
|
||||
//수정관련 (modify,toggle,batchjob사용)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user