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 bool $richFolder = false;
public int $richSort = AbstractRenderer::SORT_FULL;
#public int $richSort = AbstractRenderer::SORT_FULL;
/**
* @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('auditlog', 'Cloudflare::auditlog');
$routes->cli('auditlog/(:num)', 'Cloudflare::auditlog/$1');
$routes->cli('expire', 'Cloudflare::expire');
$routes->cli('expire/(:any)', 'Cloudflare::expire/$1');
$routes->cli('hosts/(:any)', 'Cloudflare::hosts/$1');
});
});
$routes->get('/', 'Home::index');

View File

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

View File

@ -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;
@ -105,42 +102,24 @@ class Cloudflare extends BaseController
);
}
}
public function expire(string $domain): void
public function expire(string $domain = ""): void
{
//Transaction Start
// $this->_db->transStart();
try {
$zone_model = model(ZoneModel::class);
$zone_model->where(['domain' => $domain]);
$zone_entity = $zone_model->getEntity();
$zone = new ZoneService();
$zone->expire($zone_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"
);
}
}
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;
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);
}
echo implode("\n", $hosts);
log_message("notice", "Expire 작업을 완료하였습니다.");
// $this->_db->transCommit();
} catch (\Exception $e) {

View File

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

View File

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

View File

@ -25,7 +25,7 @@ class RecordService extends CloudflareService
}
return $this->_parent_entity;
}
private function setParentEntity(mixed $parent_entity): void
private function setParentEntity(ZoneEntity $parent_entity): void
{
$this->_parent_entity = $parent_entity;
$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\ZoneEntity;
use App\Models\Cloudflare\ZoneModel;
use Iodev\Whois\Factory;
class ZoneService extends CloudflareService
{
@ -31,10 +30,10 @@ class ZoneService extends CloudflareService
}
return $this->_parent_entity;
}
private function setParentEntity(mixed $parent_entity): void
private function setParentEntity(AccountEntity $parent_entity): void
{
$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) {
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
}
@ -159,15 +158,16 @@ class ZoneService extends CloudflareService
// log_message("debug", $this->getModel()->getLastQuery());
return $entity;
}
public function expire(ZoneEntity $entity)
public function expire(AccountEntity $parent_entity, ZoneEntity $entity): ZoneEntity
{
$whois = Factory::get()->createWhois();
$info = $whois->loadDomainInfo($entity->getTitle());
print_r([
'Domain created' => date("Y-m-d", $info->creationDate),
'Domain expires' => date("Y-m-d", $info->expirationDate),
'Domain owner' => $info->owner,
]);
$this->setParentEntity($parent_entity);
$response = $this->getMySocket()->get("accounts/{$entity->getParent()}/registrar/domains/{$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

View File

@ -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",