diff --git a/app/Controllers/CLI/Cloudflare.php b/app/Controllers/CLI/Cloudflare.php index b91fa92..e9c6d8c 100644 --- a/app/Controllers/CLI/Cloudflare.php +++ b/app/Controllers/CLI/Cloudflare.php @@ -3,11 +3,8 @@ namespace App\Controllers\CLI; use App\Controllers\BaseController; -use App\Entities\Cloudflare\AccountEntity; -use App\Entities\Cloudflare\AuthEntity; -use App\Entities\Cloudflare\ZoneEntity; +use App\Models\Cloudflare\AccountModel; use App\Models\Cloudflare\AuthModel; -use App\Models\Cloudflare\RecordModel; use App\Models\Cloudflare\ZoneModel; use App\Services\Cloudflare\AccountService; use App\Services\Cloudflare\AuditLogService; @@ -114,9 +111,11 @@ class Cloudflare extends BaseController if ($domain !== "") { $zone_model->where(['domain' => $domain]); } + $account_model = model(AccountModel::class); $zone = new ZoneService(); foreach ($zone_model->getEntitys() as $entity) { - $zone->expire($entity); + $account_entity = $account_model->getEntity($entity->getParent()); + $zone->expire($account_entity, $entity); } log_message("notice", "Expire 작업을 완료하였습니다."); // $this->_db->transCommit(); diff --git a/app/Services/Cloudflare/ZoneService.php b/app/Services/Cloudflare/ZoneService.php index 286a42a..020e003 100644 --- a/app/Services/Cloudflare/ZoneService.php +++ b/app/Services/Cloudflare/ZoneService.php @@ -5,7 +5,6 @@ namespace App\Services\Cloudflare; use App\Entities\Cloudflare\AccountEntity; use App\Entities\Cloudflare\ZoneEntity; use App\Models\Cloudflare\ZoneModel; -use Iodev\Whois\Factory; class ZoneService extends CloudflareService { @@ -159,17 +158,16 @@ class ZoneService extends CloudflareService // log_message("debug", $this->getModel()->getLastQuery()); return $entity; } - public function expire(ZoneEntity $entity): void + public function expire(AccountEntity $parent_entity, ZoneEntity $entity): ZoneEntity { - $whois = Factory::get()->createWhois(); - if ($whois->isDomainAvailable($entity->getTitle())) { - $info = $whois->loadDomainInfo($entity->getTitle()); - $expire_date = date("Y-m-d", $info->expirationDate); - $this->getModel()->modify($entity, ['expire_date' => $expire_date]); - log_message('debug', __FUNCTION__ . " : {$entity->getTitle()} => {$expire_date}"); - } else { - log_message('debug', "{$entity->getTitle()} 이 도메인은 등록되지 않았습니다."); - } + $this->setParentEntity($parent_entity); + $response = $this->getMySocket()->get("accounts/{$entity->getPK()}/registrar/{$entity->getTitle()}"); + $body = json_decode($response->getBody()); + $formDatas = ['expire_date', $body->result->expires_at]; + // log_message("debug", var_export($formDatas, true)); + $entity = $this->getModel()->modify($entity, $formDatas); + // log_message("debug", $this->getModel()->getLastQuery()); + return $entity; } //Reload diff --git a/composer.json b/composer.json index 59c9b58..51506da 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "codeigniter4/framework": "^4.5", "google/apiclient": "^2.15.0", "guzzlehttp/guzzle": "^7.9", - "io-developer/php-whois": "4.0", + "io-developer/php-whois": "^4.1", "phpoffice/phpspreadsheet": "^1.27", "symfony/css-selector": "^7.1", "symfony/dom-crawler": "^7.1",