Compare commits

...

15 Commits

Author SHA1 Message Date
7c82052b64 Version UP CI4.6.0... 2025-01-27 13:10:45 +09:00
da90dd03ad cfmgrv4 init...4 2024-11-18 14:29:45 +09:00
23aed573d3 cfmgrv4 init...4 2024-11-18 14:27:30 +09:00
0178a6edc5 cfmgrv4 init...4 2024-11-18 14:21:59 +09:00
0702807666 cfmgrv4 init...4 2024-11-18 14:20:23 +09:00
3a5f26c801 cfmgrv4 init...4 2024-11-18 14:18:33 +09:00
56836d05fe cfmgrv4 init...4 2024-11-18 14:12:10 +09:00
d8b75a3db6 cfmgrv4 init...4 2024-11-18 14:08:07 +09:00
89090aafd5 cfmgrv4 init...4 2024-11-18 13:58:48 +09:00
e35a278b72 cfmgrv4 init...4 2024-11-18 11:49:14 +09:00
1702158376 cfmgrv4 init...4 2024-11-18 11:41:42 +09:00
574e1a602c cfmgrv4 init...4 2024-11-18 11:17:58 +09:00
c91e7270db cfmgrv4 init...4 2024-11-18 11:15:59 +09:00
3361dd891d cfmgrv4 init...4 2024-11-18 11:12:00 +09:00
35d0782065 cfmgrv4 init...4 2024-11-18 09:10:06 +09:00
9 changed files with 31 additions and 52 deletions

View File

@ -41,7 +41,7 @@ class Kint
*/ */
public string $richTheme = 'aante-light.css'; public string $richTheme = 'aante-light.css';
public bool $richFolder = false; public bool $richFolder = false;
public int $richSort = AbstractRenderer::SORT_FULL; #public int $richSort = AbstractRenderer::SORT_FULL;
/** /**
* @var array<string, class-string<ValuePluginInterface>>|null * @var array<string, class-string<ValuePluginInterface>>|null

View File

@ -17,8 +17,8 @@ $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes)
$routes->cli('reload/(:num)', 'Cloudflare::reload/$1'); $routes->cli('reload/(:num)', 'Cloudflare::reload/$1');
$routes->cli('auditlog', 'Cloudflare::auditlog'); $routes->cli('auditlog', 'Cloudflare::auditlog');
$routes->cli('auditlog/(:num)', 'Cloudflare::auditlog/$1'); $routes->cli('auditlog/(:num)', 'Cloudflare::auditlog/$1');
$routes->cli('expire', 'Cloudflare::expire');
$routes->cli('expire/(:any)', 'Cloudflare::expire/$1'); $routes->cli('expire/(:any)', 'Cloudflare::expire/$1');
$routes->cli('hosts/(:any)', 'Cloudflare::hosts/$1');
}); });
}); });
$routes->get('/', 'Home::index'); $routes->get('/', 'Home::index');

View File

@ -81,7 +81,7 @@ class AccountController extends CloudflareController
{ {
//부모데이터정의 //부모데이터정의
$this->auth_entity = $this->getAuthModel()->getEntityByPK($uid); $this->auth_entity = $this->getAuthModel()->getEntityByPK($uid);
if ($this->_zone_entity === null) { if ($this->auth_entity === null) {
throw new \Exception("Auth: [{$uid}] 정보를 찾을수 없습니다."); throw new \Exception("Auth: [{$uid}] 정보를 찾을수 없습니다.");
} }
$this->getService()->reload($this->auth_entity); $this->getService()->reload($this->auth_entity);

View File

@ -3,11 +3,8 @@
namespace App\Controllers\CLI; namespace App\Controllers\CLI;
use App\Controllers\BaseController; use App\Controllers\BaseController;
use App\Entities\Cloudflare\AccountEntity; use App\Models\Cloudflare\AccountModel;
use App\Entities\Cloudflare\AuthEntity;
use App\Entities\Cloudflare\ZoneEntity;
use App\Models\Cloudflare\AuthModel; use App\Models\Cloudflare\AuthModel;
use App\Models\Cloudflare\RecordModel;
use App\Models\Cloudflare\ZoneModel; use App\Models\Cloudflare\ZoneModel;
use App\Services\Cloudflare\AccountService; use App\Services\Cloudflare\AccountService;
use App\Services\Cloudflare\AuditLogService; use App\Services\Cloudflare\AuditLogService;
@ -105,42 +102,24 @@ 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(); }
$account_entitys = [];
$account_model = model(AccountModel::class);
$zone = new ZoneService(); $zone = new ZoneService();
$zone->expire($zone_entity); foreach ($zone_model->getEntitys() as $entity) {
log_message("notice", "Expire 작업을 완료하였습니다."); if (!array_key_exists($entity->getParent(), $account_entitys)) {
// $this->_db->transCommit(); $account_entitys[$entity->getParent()] = $account_model->getEntity($entity->getParent());
} catch (\Exception $e) {
//Transaction Rollback
// $this->_db->transRollback();
log_message(
"error",
"Expire 작업을 실패하였습니다.\n--------------\n" .
$e->getMessage() .
"\n--------------\n"
);
} }
$zone->expire($account_entitys[$entity->getParent()], $entity);
} }
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

@ -46,7 +46,7 @@ class CloudflareSocket extends MySocket
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 종료--", self::$_request_timewait)); log_message('warning', sprintf("--Cloudflare API Call %s초 대기 종료--", self::$_request_timewait));
} }
self::$_request++; self::$_request++;
// log_message("debug", "현재 [" . self::$_request . "]:{$uri}"); log_message("debug", "현재 [" . self::$_request . "]:{$uri}");
return parent::request($method, $uri, $options, $headers); return parent::request($method, $uri, $options, $headers);
} }
} }

View File

@ -25,7 +25,7 @@ class FirewallService extends CloudflareService
} }
return $this->_parent_entity; return $this->_parent_entity;
} }
private function setParentEntity(mixed $parent_entity): void private function setParentEntity(ZoneEntity $parent_entity): void
{ {
$this->_parent_entity = $parent_entity; $this->_parent_entity = $parent_entity;
$account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent()); $account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent());

View File

@ -25,7 +25,7 @@ class RecordService extends CloudflareService
} }
return $this->_parent_entity; return $this->_parent_entity;
} }
private function setParentEntity(mixed $parent_entity): void private function setParentEntity(ZoneEntity $parent_entity): void
{ {
$this->_parent_entity = $parent_entity; $this->_parent_entity = $parent_entity;
$account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent()); $account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent());

View File

@ -5,7 +5,6 @@ namespace App\Services\Cloudflare;
use App\Entities\Cloudflare\AccountEntity; use App\Entities\Cloudflare\AccountEntity;
use App\Entities\Cloudflare\ZoneEntity; use App\Entities\Cloudflare\ZoneEntity;
use App\Models\Cloudflare\ZoneModel; use App\Models\Cloudflare\ZoneModel;
use Iodev\Whois\Factory;
class ZoneService extends CloudflareService class ZoneService extends CloudflareService
{ {
@ -31,10 +30,10 @@ class ZoneService extends CloudflareService
} }
return $this->_parent_entity; return $this->_parent_entity;
} }
private function setParentEntity(mixed $parent_entity): void private function setParentEntity(AccountEntity $parent_entity): void
{ {
$this->_parent_entity = $parent_entity; $this->_parent_entity = $parent_entity;
$auth_entity = $this->getAuthModel()->getEntityByPK(uid: $this->getParentEntity()->getParent()); $auth_entity = $this->getAuthModel()->getEntityByPK($this->getParentEntity()->getParent());
if ($auth_entity === null) { if ($auth_entity === null) {
throw new \Exception("해당 계정정보를 찾을수 없습니다."); throw new \Exception("해당 계정정보를 찾을수 없습니다.");
} }
@ -159,15 +158,16 @@ 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(AccountEntity $parent_entity, ZoneEntity $entity): ZoneEntity
{ {
$whois = Factory::get()->createWhois(); $this->setParentEntity($parent_entity);
$info = $whois->loadDomainInfo($entity->getTitle()); $response = $this->getMySocket()->get("accounts/{$entity->getParent()}/registrar/domains/{$entity->getTitle()}");
print_r([ $body = json_decode($response->getBody());
'Domain created' => date("Y-m-d", $info->creationDate), $formDatas = ['expire_date', $body->result->expires_at];
'Domain expires' => date("Y-m-d", $info->expirationDate), // log_message("debug", var_export($formDatas, true));
'Domain owner' => $info->owner, $entity = $this->getModel()->modify($entity, $formDatas);
]); // log_message("debug", $this->getModel()->getLastQuery());
return $entity;
} }
//Reload //Reload

View File

@ -15,7 +15,7 @@
"codeigniter4/framework": "^4.5", "codeigniter4/framework": "^4.5",
"google/apiclient": "^2.15.0", "google/apiclient": "^2.15.0",
"guzzlehttp/guzzle": "^7.9", "guzzlehttp/guzzle": "^7.9",
"io-developer/php-whois": "4.0", "io-developer/php-whois": "^4.1",
"phpoffice/phpspreadsheet": "^1.27", "phpoffice/phpspreadsheet": "^1.27",
"symfony/css-selector": "^7.1", "symfony/css-selector": "^7.1",
"symfony/dom-crawler": "^7.1", "symfony/dom-crawler": "^7.1",