cfmgrv4 init...4

This commit is contained in:
최준흠 2024-11-18 11:12:00 +09:00
parent 35d0782065
commit 3361dd891d
2 changed files with 10 additions and 36 deletions

View File

@ -105,42 +105,19 @@ class Cloudflare extends BaseController
); );
} }
} }
public function expire(string $domain): void public function expire(string $domain = ""): void
{ {
//Transaction Start //Transaction Start
// $this->_db->transStart(); // $this->_db->transStart();
try { try {
$zone_model = model(ZoneModel::class); $zone_model = model(ZoneModel::class);
if ($domain !== "") {
$zone_model->where(['domain' => $domain]); $zone_model->where(['domain' => $domain]);
$zone_entity = $zone_model->getEntity(); }
$zone = new ZoneService(); $zone = new ZoneService();
$zone->expire($zone_entity); foreach ($zone_model->getEntitys() as $entity) {
log_message("notice", "Expire 작업을 완료하였습니다."); $zone->expire($entity);
// $this->_db->transCommit();
} catch (\Exception $e) {
//Transaction Rollback
// $this->_db->transRollback();
log_message(
"error",
"Expire 작업을 실패하였습니다.\n--------------\n" .
$e->getMessage() .
"\n--------------\n"
);
} }
}
public function hosts(string $ip): void
{
//Transaction Start
// $this->_db->transStart();
try {
$record_model = model(RecordModel::class);
$record_model->where(['content' => $ip]);
$hosts = [];
foreach ($record_model->getEntitys() as $entity) {
$hosts[] = $entity->host;
}
echo implode("\n", $hosts);
log_message("notice", "Expire 작업을 완료하였습니다."); log_message("notice", "Expire 작업을 완료하였습니다.");
// $this->_db->transCommit(); // $this->_db->transCommit();
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@ -159,15 +159,12 @@ class ZoneService extends CloudflareService
// log_message("debug", $this->getModel()->getLastQuery()); // log_message("debug", $this->getModel()->getLastQuery());
return $entity; return $entity;
} }
public function expire(ZoneEntity $entity) public function expire(ZoneEntity $entity): void
{ {
$whois = Factory::get()->createWhois(); $whois = Factory::get()->createWhois();
$info = $whois->loadDomainInfo($entity->getTitle()); $info = $whois->loadDomainInfo($entity->getTitle());
print_r([ $formDatas = ['expire_date' => date("Y-m-d", $info->expirationDate)];
'Domain created' => date("Y-m-d", $info->creationDate), $this->getModel()->modify($entity, $formDatas);
'Domain expires' => date("Y-m-d", $info->expirationDate),
'Domain owner' => $info->owner,
]);
} }
//Reload //Reload