Compare commits

..

No commits in common. "7c82052b64849b510f0c1e527ec964e05532c7db" and "40700434caeacf9c1a214a01d81da3a80bee65e8" have entirely different histories.

9 changed files with 51 additions and 30 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->auth_entity === null) {
if ($this->_zone_entity === null) {
throw new \Exception("Auth: [{$uid}] 정보를 찾을수 없습니다.");
}
$this->getService()->reload($this->auth_entity);

View File

@ -3,8 +3,11 @@
namespace App\Controllers\CLI;
use App\Controllers\BaseController;
use App\Models\Cloudflare\AccountModel;
use App\Entities\Cloudflare\AccountEntity;
use App\Entities\Cloudflare\AuthEntity;
use App\Entities\Cloudflare\ZoneEntity;
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;
@ -102,24 +105,42 @@ 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);
if ($domain !== "") {
$zone_model->where(['domain' => $domain]);
}
$account_entitys = [];
$account_model = model(AccountModel::class);
$zone_model->where(['domain' => $domain]);
$zone_entity = $zone_model->getEntity();
$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);
$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;
}
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(ZoneEntity $parent_entity): void
private function setParentEntity(mixed $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(ZoneEntity $parent_entity): void
private function setParentEntity(mixed $parent_entity): void
{
$this->_parent_entity = $parent_entity;
$account_entity = $this->getAccountModel()->getEntityByPK($this->getParentEntity()->getParent());

View File

@ -5,6 +5,7 @@ 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
{
@ -30,10 +31,10 @@ class ZoneService extends CloudflareService
}
return $this->_parent_entity;
}
private function setParentEntity(AccountEntity $parent_entity): void
private function setParentEntity(mixed $parent_entity): void
{
$this->_parent_entity = $parent_entity;
$auth_entity = $this->getAuthModel()->getEntityByPK($this->getParentEntity()->getParent());
$auth_entity = $this->getAuthModel()->getEntityByPK(uid: $this->getParentEntity()->getParent());
if ($auth_entity === null) {
throw new \Exception("해당 계정정보를 찾을수 없습니다.");
}
@ -158,16 +159,15 @@ class ZoneService extends CloudflareService
// log_message("debug", $this->getModel()->getLastQuery());
return $entity;
}
public function expire(AccountEntity $parent_entity, ZoneEntity $entity): ZoneEntity
public function expire(ZoneEntity $entity)
{
$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;
$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,
]);
}
//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.1",
"io-developer/php-whois": "4.0",
"phpoffice/phpspreadsheet": "^1.27",
"symfony/css-selector": "^7.1",
"symfony/dom-crawler": "^7.1",