Compare commits
15 Commits
40700434ca
...
7c82052b64
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c82052b64 | |||
| da90dd03ad | |||
| 23aed573d3 | |||
| 0178a6edc5 | |||
| 0702807666 | |||
| 3a5f26c801 | |||
| 56836d05fe | |||
| d8b75a3db6 | |||
| 89090aafd5 | |||
| e35a278b72 | |||
| 1702158376 | |||
| 574e1a602c | |||
| c91e7270db | |||
| 3361dd891d | |||
| 35d0782065 |
@ -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
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user