_db = \Config\Database::connect(); } public function reload(mixed $uid = false): void { //Transaction Start // $this->_db->transStart(); try { $auth_model = model(AuthModel::class); if (is_numeric($uid) && $uid > 0) { $auth_model->where(AuthModel::PK, intval($uid)); } else { $auth_model->where('status', DEFAULTS["STATUS"]); } $auth_entitys = $auth_model->getEntitys(); foreach ($auth_entitys as $auth_entity) { $account = new AccountService(); $account_entitys = $account->reload($auth_entity); foreach (array_values($account_entitys) as $account_entity) { $zone = new ZoneService(); $record = new RecordService(); $firewall = new FirewallService(); $zone_entitys = $zone->reload($account_entity); $cnt = 1; $total = count($zone_entitys); foreach (array_values($zone_entitys) as $zone_entity) { log_message("notice", "\n-----------[{$cnt}/$total}] Zone {$zone_entity->getTitle()}의 Record/Firewall 처리 시작-----------"); $record->reload($zone_entity); $firewall->reload($zone_entity); log_message("notice", "\n-----------[{$cnt}/$total}] Zone {$zone_entity->getTitle()}의 Record/Firewall 처리 완료-----------"); $cnt++; } } } log_message("notice", "Reload 작업을 완료하였습니다."); // $this->_db->transCommit(); } catch (\Exception $e) { //Transaction Rollback // $this->_db->transRollback(); log_message( "error", "Reload 작업을 실패하였습니다.\n--------------\n" . $e->getMessage() . "\n--------------\n" ); } } public function auditlog(mixed $uid = false): void { //Transaction Start // $this->_db->transStart(); try { $auth_model = model(AuthModel::class); if (is_numeric($uid) && $uid > 0) { $auth_model->where(AuthModel::PK, intval($uid)); } else { $auth_model->where('status', DEFAULTS["STATUS"]); } $auth_entitys = $auth_model->getEntitys(); foreach ($auth_entitys as $auth_entity) { $account = new AccountService(); $account_entitys = $account->reload($auth_entity); $auditlog = new AuditLogService(); foreach ($account_entitys as $account_entity) { $auditlog->reload($account_entity); } } log_message("notice", "AuditLogs 작업을 완료하였습니다."); // $this->_db->transCommit(); } catch (\Exception $e) { //Transaction Rollback // $this->_db->transRollback(); log_message( "error", "Reload 작업을 실패하였습니다.\n--------------\n" . $e->getMessage() . "\n--------------\n" ); } } public function expire(string $domain = ""): void { //Transaction Start // $this->_db->transStart(); try { $zone_model = model(ZoneModel::class); if ($domain !== "") { $zone_model->where(['domain' => $domain]); } $account_entitys = []; $account_model = model(AccountModel::class); $zone = new ZoneService(); foreach ($zone_model->getEntitys() as $entity) { if (!array_key_exists($entity->getParent(), $account_entitys)) { $account_entitys[$entity->getParent()] = $account_model->getEntity($entity->getParent()); } $zone->expire($account_entitys[$entity->getParent()], $entity); } log_message("notice", "Expire 작업을 완료하였습니다."); // $this->_db->transCommit(); } catch (\Exception $e) { //Transaction Rollback // $this->_db->transRollback(); log_message( "error", "Expire 작업을 실패하였습니다.\n--------------\n" . $e->getMessage() . "\n--------------\n" ); } } }