From 2d41c92d989ab5360cb6b3efed9cb3d5472ede0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Tue, 24 Sep 2024 17:09:29 +0900 Subject: [PATCH] Automation init...4 --- app/Config/Routes.php | 7 +- .../Cloudflare/AccountController.php | 59 +++-- .../Cloudflare/CloudflareController.php | 51 ++++ .../Cloudflare/RecordController.php | 113 +++++---- app/Controllers/Cloudflare/ZoneController.php | 149 ++++++++---- app/Controllers/MVController.php | 226 ++++++++++++++---- app/Language/en/Cloudflare/Record.php | 66 ++--- app/Libraries/MyCloudflare/Account.php | 3 +- app/Libraries/MyCloudflare/MyCloudflare.php | 16 +- app/Libraries/MyCloudflare/Record.php | 36 +-- app/Libraries/MyCloudflare/Zone.php | 20 +- app/Libraries/MyCrawler/MyCrawler.php | 55 ++--- .../Storage.php} | 75 ++++-- app/Models/Cloudflare/AccountModel.php | 25 +- app/Models/Cloudflare/RecordModel.php | 54 +++-- app/Models/Cloudflare/ZoneModel.php | 57 +++-- app/Models/CommonModel.php | 83 ++++--- app/Traits/ImageTrait.php | 51 +--- app/Views/cloudflare/account/index.php | 92 +++---- public/css/admin/left_menu.css | 8 +- 20 files changed, 808 insertions(+), 438 deletions(-) create mode 100644 app/Controllers/Cloudflare/CloudflareController.php rename app/Libraries/{MyStorage/MangboardStorage.php => MyMangboard/Storage.php} (54%) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 98c18da..59572a4 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -35,11 +35,14 @@ $routes->group('mangboard', ['namespace' => 'App\Controllers\Mangboard'], functi $routes->group('cloudflare', ['namespace' => 'App\Controllers\Cloudflare'], function ($routes) { $routes->group('account', function ($routes) { $routes->get('/', 'AccountController::index'); - $routes->get('create', 'AccountController::create_form'); $routes->post('create', 'AccountController::create'); }); $routes->group('zone', function ($routes) { $routes->get('/', 'ZoneController::index'); - $routes->get('create', 'ZoneController::create_form'); + $routes->post('create/(:uuid)', 'RecordController::create/$1'); + }); + $routes->group('record', function ($routes) { + $routes->get('/', 'RecordController::index'); + $routes->post('create/(:uuid)', 'RecordController::create/$1'); }); }); diff --git a/app/Controllers/Cloudflare/AccountController.php b/app/Controllers/Cloudflare/AccountController.php index cfc9148..3bece86 100644 --- a/app/Controllers/Cloudflare/AccountController.php +++ b/app/Controllers/Cloudflare/AccountController.php @@ -2,55 +2,70 @@ namespace App\Controllers\Cloudflare; -use App\Controllers\MVController; use Psr\Log\LoggerInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RedirectResponse; use App\Libraries\MyCloudflare\Account; -use App\Traits\AuthTrait; -use App\Models\Cloudflare\AccountModel; use App\Entities\Cloudflare\AccountEntity; -class AccountController extends MVController +class AccountController extends CloudflareController { - use AuthTrait; - private $_model = null; + private $_myLibrary = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); - $this->class_name = "Cloudflare/Account"; + $this->class_name .= "Account"; $this->layout = LAYOUTS['admin']; $this->title = lang("{$this->class_name}.title"); - $this->session = $this->session_AuthTrait(); helper($this->class_name); } - final protected function getModel(): AccountModel + final protected function getMyLibrary(): Account { - if ($this->_model === null) { - $this->_model = new AccountModel(); + if ($this->_myLibrary === null) { + $this->_myLibrary = new Account(); } - return $this->_model; + return $this->_myLibrary; } protected function create_init(): void { - $this->fields = [$this->getModel()::TITLE, 'apikey', 'status']; + $this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'apikey', 'status']; $this->filter_fields = ['status']; - $this->action = DB_ACTION["CREATE"]; - $this->getModel()->setAction($this->action); + $this->action = DB_ACTION['CREATE']; + $this->getMyLibrary()->getMyStorage()->setAction($this->action); } - public function create_form(): RedirectResponse|string + // public function create_form(): RedirectResponse|string + // { + // $this->create_init(); + // return $this->create_form_process(); + // } + protected function create_process_submit(): void { - return $this->create_form_process(); - } - protected function create_process_submit(): AccountEntity - { - $account = new Account(); - return $account->create($this->formDatas); + $entity = $this->getMyLibrary()->create($this->formDatas); } public function create(): RedirectResponse { + $this->create_init(); + $this->formDatas = []; + $this->getFormDatas(); + $this->convertFormDatas(); + $this->validateFormDatas(); return parent::create_process(); } + + protected function index_init(): void + { + $this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'apikey', 'status']; + $this->filter_fields = ['status']; + $this->action = DB_ACTION['CREATE']; + $this->getMyLibrary()->getMyStorage()->setAction($this->action); + helper(['form']); + $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; + } + public function index(): string + { + $this->create_init(); + return parent::list_process(); + } } diff --git a/app/Controllers/Cloudflare/CloudflareController.php b/app/Controllers/Cloudflare/CloudflareController.php new file mode 100644 index 0000000..f58fe9f --- /dev/null +++ b/app/Controllers/Cloudflare/CloudflareController.php @@ -0,0 +1,51 @@ +class_name = "Cloudflare/"; + $this->layout = LAYOUTS['admin']; + $this->session = $this->session_AuthTrait(); + } + final protected function getAccountModel(): AccountModel + { + if ($this->_accountModel === null) { + $this->_accountModel = new AccountModel(); + } + return $this->_accountModel; + } + final protected function getZoneModel(): ZoneModel + { + if ($this->_zoneModel === null) { + $this->_zoneModel = new ZoneModel(); + } + return $this->_zoneModel; + } + final protected function getRecordModel(): RecordModel + { + if ($this->_recordModel === null) { + $this->_recordModel = new RecordModel(); + } + return $this->_recordModel; + } + protected function modify_process_submit(): void + { + } +} diff --git a/app/Controllers/Cloudflare/RecordController.php b/app/Controllers/Cloudflare/RecordController.php index 2d77df8..67e0d06 100644 --- a/app/Controllers/Cloudflare/RecordController.php +++ b/app/Controllers/Cloudflare/RecordController.php @@ -2,75 +2,108 @@ namespace App\Controllers\Cloudflare; -use App\Controllers\MVController; use Psr\Log\LoggerInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RedirectResponse; -use App\Traits\AuthTrait; -use App\Libraries\MySocket\CloudflareSocket; use App\Libraries\MyCloudflare\Record; -use App\Models\Cloudflare\ZoneModel; -use App\Models\Cloudflare\AccountModel; -use App\Models\Cloudflare\API\RecordModel; use App\Entities\Cloudflare\RecordEntity; - -class RecordController extends MVController +class RecordController extends CloudflareController { - use AuthTrait; - private $_model = null; - private $_accountModel = null; - private $_zoneModel = null; + private $_myLibrary = null; + private $_account_entity = null; + private $_zone_entity = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); - $this->session = $this->session_AuthTrait(); - $this->class_name = 'Record'; + $this->class_name .= "Record"; + $this->layout = LAYOUTS['admin']; + $this->title = lang("{$this->class_name}.title"); helper($this->class_name); } - final protected function getModel(): RecordModel + final protected function getMyLibrary(): Record { - if ($this->_model === null) { - $this->_model = new RecordModel(); + if ($this->_myLibrary === null) { + $this->_myLibrary = new Record($this->_account_entity, $this->_zone_entity); } - return $this->_model; + return $this->_myLibrary; } - final protected function getAccountModel(): AccountModel + protected function getFormFieldInputOption(string $field, array $options = []): array { - if ($this->_accountModel === null) { - $this->_accountModel = new AccountModel(); + switch ($field) { + case $this->getMyLibrary()->getMyStorage()::PARENT: + $options = [ + DEFAULTS['EMPTY'] => lang($this->_className . '.label.' . $field) . ' 선택' + ]; + $this->getZoneModel()->where('status', DEFAULTS['STATUS']); + $options = $this->getZoneModel()->getFormFieldInputOption($field, $options); + break; + default: + $options = parent::getFormFieldInputOption($field, $options); + break; } - return $this->_accountModel; + return $options; } - final protected function getZoneModel(): ZoneModel + //전송된 데이터 + protected function getFormData(string $field): void { - if ($this->_zoneModel === null) { - $this->_zoneModel = new ZoneModel(); + switch ($field) { + case 'hosts': + $this->formDatas[$field] = explode("\n", $this->request->getVar($field)); + if (!is_array($this->formDatas[$field]) || !count($this->formDatas[$field])) { + throw new \Exception("호스트명이 정의되지 않았습니다."); + } + break; + default: + $this->formDatas[$field] = $this->request->getVar($field); + break; + } + } + //전송된 데이터 검증 + protected function validateFormData(string $field): void + { + switch ($field) { + case 'hosts': + break; + default: + parent::validateFormData($field); + break; } - return $this->_zoneModel; } protected function create_init(): void { - $this->fields = ['id', 'apikey']; - $this->filter_fields = ['status']; - $this->action = 'create'; - $this->getModel()->setAction($this->action); + $this->fields = [ + $this->getMyLibrary()->getMyStorage()::PARENT, + 'type', + 'content', + 'proxied', + 'hosts', + ]; + $this->filter_fields = [$this->getMyLibrary()->getMyStorage()::PARENT, 'type', 'proxied']; + $this->action = 'create'; + $this->getMyLibrary()->getMyStorage()->setAction($this->action); } - public function create_form(): RedirectResponse|string + // public function create_form(): RedirectResponse|string + // { + // return $this->create_form_process(); + // } + protected function create_process_submit(): void { - return $this->create_form_process(); + //Record생성 + foreach ($this->formDatas['hosts'] as $host) { + $this->getMyLibrary()->create($host, $this->formDatas); + } } - protected function create_process_submit(): RecordEntity - { - $zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]); - $account_entity = $this->getAccountModel()->getEntityByPK($zone_entity->getParent()); - $Record = new Record($account_entity, $zone_entity); - return $Record->create($this->formDatas); - } - public function create(): RedirectResponse + public function create(string $zone_uid): RedirectResponse { + $this->_zone_entity = $this->getZoneModel()->getEntityByPK($zone_uid); + $this->_account_entity = $this->getAccountModel()->getEntityByPK($this->_zone_entity->getParent()); + $this->formDatas = []; + $this->getFormDatas(); + $this->convertFormDatas(); + $this->validateFormDatas(); return parent::create_process(); } } diff --git a/app/Controllers/Cloudflare/ZoneController.php b/app/Controllers/Cloudflare/ZoneController.php index 7063c57..ca1d6d6 100644 --- a/app/Controllers/Cloudflare/ZoneController.php +++ b/app/Controllers/Cloudflare/ZoneController.php @@ -2,78 +2,143 @@ namespace App\Controllers\Cloudflare; -use App\Controllers\MVController; -use Psr\Log\LoggerInterface; -use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RedirectResponse; -use App\Traits\AuthTrait; +use CodeIgniter\HTTP\RequestInterface; +use CodeIgniter\HTTP\ResponseInterface; +use Psr\Log\LoggerInterface; use App\Libraries\MyCloudflare\Zone; -use App\Models\Cloudflare\ZoneModel; -use App\Models\Cloudflare\AccountModel; -use App\Entities\Cloudflare\ZoneEntity; +use App\Libraries\MyCloudflare\Record; -class ZoneController extends MVController +class ZoneController extends CloudflareController { - use AuthTrait; - private $_model = null; - private $_accountModel = null; + private $_myLibrary = null; + private $_account_entity = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); - $this->session = $this->session_AuthTrait(); - $this->class_name = "Zone"; + $this->class_name .= "Zone"; + $this->layout = LAYOUTS['admin']; + $this->title = lang("{$this->class_name}.title"); helper($this->class_name); } - final protected function getModel(): ZoneModel + final protected function getMyLibrary(): Zone { - if ($this->_model === null) { - $this->_model = new ZoneModel(); + if ($this->_myLibrary === null) { + $this->_myLibrary = new Zone($this->_account_entity); } - return $this->_model; + return $this->_myLibrary; } - final protected function getAccountModel(): AccountModel - { - if ($this->_accountModel === null) { - $this->_accountModel = new AccountModel(); - } - return $this->_accountModel; - } - protected function getFormFieldOption(string $field, array $options = []): array + protected function getFormFieldInputOption(string $field, array $options = []): array { switch ($field) { - case ZoneModel::PARENT: + case $this->getMyLibrary()->getMyStorage()::PARENT: $options = [ DEFAULTS['EMPTY'] => lang($this->_className . '.label.' . $field) . ' 선택' ]; - $options = $this->getAccountModel()->getFilterFieldOption($field, $options); + $this->getAccountModel()->where('status', DEFAULTS['STATUS']); + $options = $this->getAccountModel()->getFormFieldInputOption($field, $options); + break; + case 'type': + case 'proxied': + $options = [ + DEFAULTS['EMPTY'] => lang("Cloudflare/Record.label." . $field) . ' 선택', + ...lang("Cloudflare/Record.label." . strtoupper($field)), + ]; break; default: - $options = parent::getFormFieldOption($field, $options); + $options = parent::getFormFieldInputOption($field, $options); break; } return $options; } + protected function getFormFieldRule(string $field, array $rules): array + { + if (is_array($field)) { + throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true)); + } + switch ($field) { + default: + $rules[$field] = $this->getMyLibrary()->getMyStorage()->getFieldRule($field, $rules); + ; + break; + } + return $rules; + } + //전송된 데이터 + protected function getFormData(string $field): void + { + switch ($field) { + case 'domains': + $this->formDatas[$field] = explode("\n", $this->request->getVar($field)); + if (!is_array($this->formDatas[$field]) || !count($this->formDatas[$field])) { + throw new \Exception("도메인명이 정의되지 않았습니다."); + } + break; + case 'hosts': + $this->formDatas[$field] = $this->request->getVar($field); + if (!is_array($this->formDatas[$field]) || !count($this->formDatas[$field])) { + throw new \Exception("호스트명이 정의되지 않았습니다"); + } + break; + default: + $this->formDatas[$field] = $this->request->getVar($field); + break; + } + } + //전송된 데이터 검증 + protected function validateFormData(string $field): void + { + switch ($field) { + case 'domains': + case 'hosts': + break; + default: + parent::validateFormData($field); + break; + } + } protected function create_init(): void { - $this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'status', 'type']; - $this->filter_fields = [$this->getModel()::PARENT, 'status', 'type']; - $this->action = 'create'; - $this->getModel()->setAction($this->action); + $this->fields = [ + $this->getMyLibrary()->getMyStorage()::PARENT, + 'domains', + 'hosts', + 'type', + 'content', + 'proxied', + ]; + $this->filter_fields = [$this->getMyLibrary()->getMyStorage()::PARENT, 'type', 'proxied']; + $this->action = 'create'; + $this->getMyLibrary()->getMyStorage()->setAction($this->action); } - public function create_form(): RedirectResponse|string + // public function create_form(): RedirectResponse|string + // { + // return $this->create_form_process(); + // } + protected function create_process_submit(): void { - return $this->create_form_process(); + foreach ($this->formDatas['domains'] as $domain) { + //Zone생성 + $zone_entity = $this->getMyLibrary()->create($domain); + //Record생성 + $record = new Record($this->_account_entity, $zone_entity); + foreach ($this->formDatas['hosts'] as $host) { + $record->create($host, [ + 'type' => $this->formDatas['type'], + 'content' => $this->formDatas['content'], + 'proxied' => $this->formDatas['proxied'], + ]); + } + } } - protected function create_process_submit(): ZoneEntity - { - $account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]); - $zone = new Zone($account_entity); - return $zone->create($this->formDatas); - } - public function create(): RedirectResponse + public function create(string $account_uid): RedirectResponse { + $this->_account_entity = $this->getAccountModel()->getEntityByPK($account_uid); + $this->formDatas = []; + $this->getFormDatas(); + $this->convertFormDatas(); + $this->validateFormDatas(); return parent::create_process(); } } diff --git a/app/Controllers/MVController.php b/app/Controllers/MVController.php index 6c1002e..1e63fbd 100644 --- a/app/Controllers/MVController.php +++ b/app/Controllers/MVController.php @@ -14,17 +14,14 @@ abstract class MVController extends CommonController parent::initController($request, $response, $logger); helper('common'); } - abstract protected function create_init(): void; - abstract protected function getModel(): mixed; - //Field별 Form Option용 - protected function getFormFieldOption(string $field, array $options = []): array + abstract protected function getMyLibrary(): mixed; + abstract protected function create_process_submit(): void; + abstract protected function modify_process_submit(): void; + //Field별 Form Input Option용 + protected function getFormFieldInputOption(string $field, array $options = []): array { switch ($field) { default: - $temps = lang($this->class_name . '.' . strtoupper($field)); - if (!is_array($temps)) { - throw new \Exception(__FUNCTION__ . "에서 {$field}의 데이터가 array가 아닙니다.\n" . var_export($temps, true)); - } $options = [ "" => lang($this->class_name . '.label.' . $field) . ' 선택', ...lang($this->class_name . '.' . strtoupper($field)), @@ -33,13 +30,14 @@ abstract class MVController extends CommonController } return $options; } + //Field별 Form Input용 protected function getFormFieldInput(string $field, string $value, array $inputs = []): array { switch ($field) { case 'status': $inputs[$field] = form_dropdown( $field, - $this->getFormFieldOption($field), + $this->getFormFieldInputOption($field), $value ); break; @@ -53,7 +51,7 @@ abstract class MVController extends CommonController } return $inputs; } - final public function getFormFieldInputs(array $inputs = []): array + final protected function getFormFieldInputs(array $inputs = []): array { foreach ($this->fields as $field) { if (is_array($field)) { @@ -63,6 +61,7 @@ abstract class MVController extends CommonController } return $inputs; } + //전송된 데이터 Rule protected function getFormFieldRule(string $field, array $rules): array { if (is_array($field)) { @@ -70,38 +69,33 @@ abstract class MVController extends CommonController } switch ($field) { default: - $rules[$field] = $this->_model->getFieldRule($field, $rules); - ; + $rules[$field] = $this->getMyLibrary()->getMyStorage()->getFieldRule($field, $rules); break; } return $rules; } - final public function getFormFieldRules(array $rules = []): array + final protected function getFormFieldRules(array $rules = []): array { foreach ($this->fields as $field) { $rules = $this->getFormFieldRule($field, $rules); } return $rules; } - //전송된 데이터 검증 - protected function validateFormData(): void - { - //변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요 - $validation = service('validation'); - $validation->setRules($this->getModel()->getFieldRules($this->fields)); - if (!$validation->withRequest($this->request)->run()) { - throw new \Exception("데이터 검증 오류발생\n" . implode("\n", $validation->getErrors())); - } - } //전송된 데이터 protected function getFormData(string $field): void { switch ($field) { default: - $this->formDatas[$field] = rtrim($this->request->getVar($field)); + $this->formDatas[$field] = $this->request->getVar($field); break; } } + final protected function getFormDatas(): void + { + foreach ($this->fields as $field) { + $this->getFormData($field); + } + } //전송된 데이터 재정의 protected function convertFormData(string $field): void { @@ -110,12 +104,41 @@ abstract class MVController extends CommonController break; } } - - final public function create_form_process(): RedirectResponse|string + final protected function convertFormDatas(): void + { + foreach ($this->fields as $field) { + $this->convertFormData($field); + } + } + //전송된 데이터 검증 + protected function validateFormData(string $field): void + { + switch ($field) { + default: + if ( + !$this->validation->check( + $this->formDatas[$field], + $this->getMyLibrary()->getMyStorage()->getFieldRule($field) + ) + ) { + throw new \Exception("데이터 검증 오류발생\n" . implode("\n", $this->validation->getError())); + } + break; + } + } + final protected function validateFormDatas(): void + { + //변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요 + $this->validation = service('validation'); + foreach ($this->fields as $field) { + $this->validateFormData($field); + } + } + // 생성 + final protected function create_form_process(): RedirectResponse|string { helper(['form']); try { - $this->create_init(); $this->forminputs = $this->getFormFieldInputs(); $this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']); $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; @@ -128,29 +151,152 @@ abstract class MVController extends CommonController return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with(SESSION_NAMES['RETURN_MSG'], $e->getMessage()); } } - abstract protected function create_process_submit(): mixed; final protected function create_process(): mixed { - $this->getModel()->transStart(); + $this->getMyLibrary()->getMyStorage()->transStart(); try { - $this->create_init(); - $this->validateFormData(); - foreach ($this->fields as $field) { - $this->getFormData($field); - } - foreach ($this->fields as $field) { - $this->convertFormData($field); - } - $entity = $this->create_process_submit(); - log_message("notice", __FUNCTION__ . "=>{$entity->getTitle()} 작업을 완료하였습니다."); + $this->create_process_submit(); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); } catch (\Exception $e) { //Transaction Rollback - $this->getModel()->transRollback(); + $this->getMyLibrary()->getMyStorage()->transRollback(); log_message("error", $e->getMessage()); $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage()); $this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']); return redirect()->back()->withInput(); } } + + // 수정 + final protected function modify_form_process(): RedirectResponse|string + { + helper(['form']); + try { + $this->forminputs = $this->getFormFieldInputs(); + $this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']); + $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; + return view( + strtolower($this->class_name) . "/modify", + ['viewDatas' => $this->getAttributes()] + ); + } catch (\Exception $e) { + log_message("error", $e->getMessage()); + return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with(SESSION_NAMES['RETURN_MSG'], $e->getMessage()); + } + } + final protected function modify_process(): mixed + { + $this->getMyLibrary()->getMyStorage()->transStart(); + try { + $this->modify_process_submit(); + return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); + } catch (\Exception $e) { + //Transaction Rollback + $this->getMyLibrary()->getMyStorage()->transRollback(); + log_message("error", $e->getMessage()); + $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage()); + $this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']); + return redirect()->back()->withInput(); + } + } + + // 리스트 + protected function list_condition($isTotalCount = false): void + { + //조건절 처리 + foreach ($this->filter_fields as $field) { + $this->$field = $this->request->getVar($field) ?? DEFAULTS['EMPTY']; + if ($this->$field !== DEFAULTS['EMPTY']) { + $this->getMyLibrary()->getMyStorage()->setList_FieldFilter($field, $this->$field); + } + } + //검색어 처리 + $this->word = $this->request->getVar('word') ?? DEFAULTS['EMPTY']; + if ($this->word !== DEFAULTS['EMPTY']) { + $this->getMyLibrary()->getMyStorage()->setList_WordFilter($this->word); + } + //검색일 처리 + $this->start = $this->request->getVar('start') ?? DEFAULTS['EMPTY']; + $this->end = $this->request->getVar('end') ?? DEFAULTS['EMPTY']; + if ($this->start !== DEFAULTS['EMPTY'] && $this->end !== DEFAULTS['EMPTY']) { + $this->getMyLibrary()->getMyStorage()->setList_DateFilter($this->start, $this->end); + } + if (!$isTotalCount) { + //Sorting 처리 + $this->order_field = $this->request->getVar('order_field') ?? DEFAULTS['EMPTY']; + $this->order_value = $this->request->getVar('order_value') ?? DEFAULTS['EMPTY']; + if ($this->order_field !== DEFAULTS['EMPTY'] && $this->order_value !== DEFAULTS['EMPTY']) { + $this->getMyLibrary()->getMyStorage()->setList_OrderBy("{$this->order_field} {$this->order_value}"); + } + } + } + //Totalcount 처리 + protected function list_total(): int + { + $this->list_condition(true); + return $this->getMyLibrary()->getMyStorage()->countAllResults(); + } + //PageNation 처리 + protected function list_pagination($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full'): string + { + //Page, Per_page필요부분 + $this->page = (int)$this->request->getVar('page') ?: 1; + $this->per_page = (int)$this->request->getVar('per_page') ?: $this->_per_page; + //줄수 처리용 + $this->pageOptions = array("" => "줄수선택"); + for ($i = 10; $i <= $this->total_count + $this->per_page; $i += 10) { + $this->pageOptions[$i] = $i; + } + // 1.Views/Pagers/에 bootstrap_full.php,bootstrap_simple.php 생성 + // 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full', + // 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가 + $pager = \Config\Services::pager(); + // $this->getMyLibrary()->getMyStorage()->paginate($this->per_page, $pager_group, $this->page, $segment); + $pager->makeLinks( + $this->page, + $this->per_page, + $this->total_count, + $template, + $segment, + $pager_group + ); + $this->page = $pager->getCurrentPage($pager_group); + $this->total_page = $pager->getPageCount($pager_group); + return $pager->links($pager_group, $template); + } + protected function list_entitys(): array + { + $this->list_condition(); + if (array_key_exists('page', $this->_viewDatas)) { + $this->getMyLibrary()->getMyStorage()->limit( + $this->per_page, + $this->page * $this->per_page - $this->per_page + ); + } + return $this->getMyLibrary()->getMyStorage()->findAll(); + } + public function list_process(): string + { + try { + //URL처리 + $this->uri = $this->request->getUri(); + //total 처리 + $this->total_count = $this->list_total(); + //pagenation 처리 + $this->pagination = $this->list_pagination(); + //모델 처리 + $this->entitys = $this->list_entitys(); + // dd($this->getMyLibrary()->getMyStorage()->getLastQuery()); + //setting return_url to session flashdata + $this->session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery() ?: ""); + return view( + strtolower($this->class_name) . "/index", + ['viewDatas' => $this->getAttributes()] + ); + } catch (\Exception $e) { + log_message("error", $e->getMessage()); + return alert_CommonHelper($e->getMessage(), "back"); + // return redirect()->back()->with('return_message', $e->getMessage()); + } + } } diff --git a/app/Language/en/Cloudflare/Record.php b/app/Language/en/Cloudflare/Record.php index 4024389..c52a4a7 100644 --- a/app/Language/en/Cloudflare/Record.php +++ b/app/Language/en/Cloudflare/Record.php @@ -1,47 +1,47 @@ "Record정보", - 'label' => [ - 'uid' => "번호", - 'zone_uid' => "도메인", - 'type' => "Type", - 'host' => "호스트명", - 'content' => "IP정보", - 'ttl' => "TTL", - 'proxiable' => "proxiable", - 'fixed' => "CDN잠금", - 'proxied' => "CDN기능", - 'locked' => "서비스", + 'title' => "Record정보", + 'label' => [ + 'uid' => "번호", + 'zone_uid' => "도메인", + 'type' => "Type", + 'host' => "호스트명", + 'content' => "IP정보", + 'ttl' => "TTL", + 'proxiable' => "proxiable", + 'fixed' => "CDN잠금", + 'proxied' => "CDN기능", + 'locked' => "서비스", 'updated_at' => "수정일", - 'created_at' => "작성일" + 'created_at' => "작성일", ], - "ZONE_UID" => [], - "TYPE" => [ - 'A' => 'A', - 'AAAA' => 'AAAA(ipv6)', + "ZONE_UID" => [], + "TYPE" => [ + 'A' => 'A', + 'AAAA' => 'AAAA(ipv6)', 'CNAME' => 'CNAME', - 'MX' => 'MX', - 'SRV' => 'SRV', - 'PTR' => 'PTR', - 'SPF' => 'SPF', - 'TXT' => 'TXT', - 'NS' => 'NS', - 'INFO' => 'INFO', + 'NS' => 'NS', + 'MX' => 'MX', + 'PTR' => 'PTR', + 'SPF' => 'SPF', + 'TXT' => 'TXT', + 'SRV' => 'SRV', + 'INFO' => 'INFO', ], "PROXIABLE" => [ - "on" => "사용", + "on" => "사용", "off" => "사용 않함", ], - "FIXED" => [ - "on" => "사용", - "off" => "사용 않함", + "FIXED" => [ + "on" => "고정 사용", + "off" => "고정 사용 않함", ], - "PROXIED" => [ - "on" => "사용", - "off" => "사용 않함", + "PROXIED" => [ + "on" => "CDN 사용", + "off" => "CDN 사용 않함", ], - "LOCKED" => [ - "on" => "운영중", + "LOCKED" => [ + "on" => "운영중", "off" => "잠김", ], ]; diff --git a/app/Libraries/MyCloudflare/Account.php b/app/Libraries/MyCloudflare/Account.php index ea618de..151ca22 100644 --- a/app/Libraries/MyCloudflare/Account.php +++ b/app/Libraries/MyCloudflare/Account.php @@ -14,7 +14,7 @@ class Account extends MyCloudflare { parent::__construct(); } - final protected function getMyStorage(): AccountModel + final public function getMyStorage(): AccountModel { if ($this->_myStorage === null) { $this->_myStorage = new AccountModel(); @@ -47,7 +47,6 @@ class Account extends MyCloudflare } public function create(array $formDatas): AccountEntity { - throw new \Exception(var_dump($formDatas)); //Socket용 $cf = $this->getMySocket()->request($formDatas['apikey']) ->post('accounts', [ diff --git a/app/Libraries/MyCloudflare/MyCloudflare.php b/app/Libraries/MyCloudflare/MyCloudflare.php index c37c841..29f29e8 100644 --- a/app/Libraries/MyCloudflare/MyCloudflare.php +++ b/app/Libraries/MyCloudflare/MyCloudflare.php @@ -15,7 +15,7 @@ abstract class MyCloudflare extends CommonLibrary } abstract protected function getArrayByResult($result): array; abstract protected function reload_entity($cf): mixed; - abstract protected function getMyStorage(): mixed; + abstract public function getMyStorage(): mixed; final protected function getMySocket(): CloudflareSocket { if ($this->_mySocket === null) { @@ -30,7 +30,7 @@ abstract class MyCloudflare extends CommonLibrary if (count($cfs)) { $cnt = 1; foreach ($cfs as $cf) { - $entity = $this->reload_entity($cf); + $entity = $this->reload_entity($cf); $entity_uids[] = $entity->getPK(); log_message("debug", "{$cnt}번째: {$entity->getTitle()} 저장"); $cnt++; @@ -44,17 +44,17 @@ abstract class MyCloudflare extends CommonLibrary } final protected function reload_cfs(Guzzle $request, $uri): array { - $page = 1; //Page는 1부터 시작해야함 + $page = 1; //Page는 1부터 시작해야함 $perpage_max = getenv("cfmgr.request.perpage.max"); - $cfs = []; + $cfs = []; do { $query = [ - 'page' => $page, + 'page' => $page, 'per_page' => $perpage_max, - 'match' => 'all' + 'match' => 'all', ]; - $cf = $request->get($uri, $query); - $cf = json_decode($cf->getBody()); + $cf = $request->get($uri, $query); + $cf = json_decode($cf->getBody()); if (!$cf->success) { throw new \Exception(__FUNCTION__ . "에서 실패:\n" . var_export($cf, true)); } diff --git a/app/Libraries/MyCloudflare/Record.php b/app/Libraries/MyCloudflare/Record.php index 3d70076..6174ef1 100644 --- a/app/Libraries/MyCloudflare/Record.php +++ b/app/Libraries/MyCloudflare/Record.php @@ -18,13 +18,13 @@ class Record extends MyCloudflare { parent::__construct(); $this->_account_entity = $account_entity; - $this->_zone_entity = $zone_entity; + $this->_zone_entity = $zone_entity; } protected function getRequest(): Guzzle { return $this->getMySocket()->request($this->_account_entity->getAPIKey()); } - final protected function getMyStorage(): RecordModel + final public function getMyStorage(): RecordModel { if ($this->_myStorage === null) { $this->_myStorage = new RecordModel(); @@ -33,15 +33,15 @@ class Record extends MyCloudflare } protected function getArrayByResult($result): array { - $formDatas[$this->getMyStorage()->getPKField()] = $result->id; - $formDatas[$this->getMyStorage()::PARENT] = $result->zone_id; + $formDatas[$this->getMyStorage()->getPKField()] = $result->id; + $formDatas[$this->getMyStorage()::PARENT] = $result->zone_id; $formDatas[$this->getMyStorage()->getTitleField()] = $result->name; - $formDatas['type'] = $result->type; - $formDatas['content'] = $result->content; - $formDatas['ttl'] = (int) $result->ttl; - $formDatas['proxiable'] = $result->proxiable ? "on" : "off"; - $formDatas['proxied'] = $result->proxied ? "on" : "off"; - $formDatas['locked'] = "on"; + $formDatas['type'] = $result->type; + $formDatas['content'] = $result->content; + $formDatas['ttl'] = (int)$result->ttl; + $formDatas['proxiable'] = $result->proxiable ? "on" : "off"; + $formDatas['proxied'] = $result->proxied ? "on" : "off"; + $formDatas['locked'] = "on"; if (isset($result->locked) && $result->locked) { $formDatas['locked'] = "off"; } @@ -49,13 +49,13 @@ class Record extends MyCloudflare $formDatas['created_at'] = $result->created_on; return $formDatas; } - public function create(array $formDatas): RecordEntity + public function create(string $host, array $formDatas): RecordEntity { //Socket용 //도메인생성을 위해 Cloudflare에 전송 $cf = $this->getRequest()->post('zones/' . $this->_zone_entity->getPK() . '/dns_records', [ - 'name' => $formDatas['host'], - 'type' => $formDatas['type'], + 'name' => $host, + 'type' => $formDatas['type'], 'content' => $formDatas['content'], 'proxied' => isset($formDatas['proxied']) && $formDatas['proxied'] === 'on' ? true : false ]); @@ -65,19 +65,19 @@ class Record extends MyCloudflare } //Storage용 $formDatas = $this->getArrayByResult($cf->result); - $entity = $this->$this->getMyStorage()->create($formDatas); + $entity = $this->$this->getMyStorage()->create($formDatas); log_message("notice", "Record:" . __FUNCTION__ . "=> 작업을 완료하였습니다."); return $entity; } - public function update(RecordEntity $entity, array $formDatas): RecordEntity + public function modify(RecordEntity $entity, array $formDatas): RecordEntity { //TTL값은 CDN(proxied)가 사용함일때는 무조건 1, 않함일때는 120이 적용 $datas = [ - 'type' => isset($formDatas['type']) ? $formDatas['type'] : $entity->type, - 'name' => isset($formDatas['host']) ? $formDatas['host'] : $entity->host, + 'type' => isset($formDatas['type']) ? $formDatas['type'] : $entity->type, + 'name' => isset($formDatas['host']) ? $formDatas['host'] : $entity->host, 'content' => isset($formDatas['content']) ? $formDatas['content'] : $entity->content, 'proxied' => $entity->proxied == 'on' ? true : false, - 'ttl' => intval($entity->ttl) + 'ttl' => intval($entity->ttl), ]; //변경작업: 2024-08-09 if (isset($formDatas['proxied']) && $formDatas['proxied'] === 'on') { diff --git a/app/Libraries/MyCloudflare/Zone.php b/app/Libraries/MyCloudflare/Zone.php index 2648e3e..8a6431c 100644 --- a/app/Libraries/MyCloudflare/Zone.php +++ b/app/Libraries/MyCloudflare/Zone.php @@ -22,7 +22,7 @@ class Zone extends MyCloudflare { return $this->getMySocket()->request($this->_account_entity->getAPIKey()); } - final protected function getMyStorage(): ZoneModel + final public function getMyStorage(): ZoneModel { if ($this->_myStorage === null) { $this->_myStorage = new ZoneModel(); @@ -31,10 +31,10 @@ class Zone extends MyCloudflare } protected function getArrayByResult($result): array { - $formDatas[$this->getMyStorage()->getPKField()] = $result->id; - $formDatas[$this->getMyStorage()::PARENT] = $result->account->id; + $formDatas[$this->getMyStorage()->getPKField()] = $result->id; + $formDatas[$this->getMyStorage()::PARENT] = $result->account->id; $formDatas[$this->getMyStorage()->getTitleField()] = $result->name; - $formDatas['status'] = $result->status; + $formDatas['status'] = $result->status; //$formDatas['type'] = $result->type; // full 이게있는데 뭔지 잘모름 $formDatas['name_servers'] = 'none'; if (isset($result->name_servers)) { @@ -54,7 +54,7 @@ class Zone extends MyCloudflare } $formDatas['updated_at'] = $result->modified_on; $formDatas['created_at'] = $result->created_on; - $formDatas['plan'] = $result->plan->name; + $formDatas['plan'] = $result->plan->name; return $formDatas; } //Cfzone에서 가져온 값을 zone에 setting @@ -91,13 +91,13 @@ class Zone extends MyCloudflare $entity->$field = $cf->result->value; return $entity; } - public function create(array $formDatas, $jump_start = false): ZoneEntity + public function create(string $domain, $jump_start = false): ZoneEntity { //Socket용 //도메인생성을 위해 Cloudflare에 전송 $cf = $this->getRequest()->post('zones/', [ - 'accountId' => $this->_account_entity->getPK(), - 'name' => $formDatas['domain'], + 'accountId' => $this->_account_entity->getPK(), + 'name' => $domain, 'jump_start' => $jump_start, ]); $cf = json_decode($cf->getBody()); @@ -106,7 +106,7 @@ class Zone extends MyCloudflare } //Storage용 $formDatas = $this->getArrayByResult($cf->result); - $entity = $this->$this->getMyStorage()->create($formDatas); + $entity = $this->$this->getMyStorage()->create($formDatas); //아래는 추가 셋팅 ipv6 TurnOFF , //Development mode TurnOFF $entity = $this->setCFSetting($entity, 'ipv6', 'off'); $entity = $this->setCFSetting($entity, 'development_mode', 'off'); @@ -114,7 +114,7 @@ class Zone extends MyCloudflare log_message("notice", "Zone:" . __FUNCTION__ . "=> 작업을 완료하였습니다."); return $entity; } - public function update(ZoneEntity $entity, array $formDatas): ZoneEntity + public function modify(ZoneEntity $entity, array $formDatas): ZoneEntity { //ipv6 , //development_mode , //security_level foreach ($formDatas as $field => $value) { diff --git a/app/Libraries/MyCrawler/MyCrawler.php b/app/Libraries/MyCrawler/MyCrawler.php index 7de618d..bef79b4 100644 --- a/app/Libraries/MyCrawler/MyCrawler.php +++ b/app/Libraries/MyCrawler/MyCrawler.php @@ -2,12 +2,13 @@ namespace App\Libraries\MyCrawler; +use App\Libraries\MySocket\WebSocket; +use App\Libraries\MyMangboard\Storage; + use Symfony\Component\DomCrawler\Crawler; use App\Traits\FileTrait; use App\Models\Mangboard\BoardsModel; use App\Models\Mangboard\BoardModel; -use App\Libraries\MyStorage\MangboardStorage; -use App\Libraries\MySocket\WebSocket; use App\Libraries\CommonLibrary; use App\Entities\Mangboard\UserEntity; use App\Entities\Mangboard\BoardsEntity; @@ -27,8 +28,8 @@ abstract class MyCrawler extends CommonLibrary protected function __construct(string $host, string $board_name, UserEntity $user_entity) { parent::__construct(); - $this->_host = $host; - $this->_board_name = $board_name; + $this->_host = $host; + $this->_board_name = $board_name; $this->_user_entity = $user_entity; } abstract protected function getDetailSelector(array $listInfo): array; @@ -40,17 +41,17 @@ abstract class MyCrawler extends CommonLibrary } return $this->_mySocket; } - final protected function getMyStorage(): MangboardStorage + final protected function getMyStorage(): Storage { if ($this->_myStorage === null) { - $this->_myStorage = new MangboardStorage($this->_board_name, $this->_user_entity); + $this->_myStorage = new Storage($this->_board_name, $this->_user_entity); } return $this->_myStorage; } final protected function getBoardsEntity(): BoardsEntity { if ($this->_boards_entity === null) { - $boardsModel = new BoardsModel(); + $boardsModel = new BoardsModel(); $this->_boards_entity = $boardsModel->getEntityByID($this->getMyStorage()->getBoardName()); if ($this->_boards_entity === null) { throw new \Exception(__FUNCTION__ . "=> {$this->getMyStorage()->getBoardName()}에 해당 Board 정보가 존재하지 않습니다."); @@ -85,7 +86,7 @@ abstract class MyCrawler extends CommonLibrary { return preg_match('/^[^?]+/', $url, $matches) ? $matches[0] : null; } - protected function getUrlByMediaType(Crawler $node, string $media_tag, string $attr): null|string + protected function getUrlByMediaType(Crawler $node, string $media_tag, string $attr): null|string { switch ($media_tag) { case 'video': @@ -143,8 +144,8 @@ abstract class MyCrawler extends CommonLibrary throw new \Exception("URL이 파일명 형식이 아닙니다 : " . $this->getMySocket()->getHost() . $url); } $file_name = array_pop($file_names); - $temps = explode(".", $file_name); - $file_ext = array_pop($temps); + $temps = explode(".", $file_name); + $file_ext = array_pop($temps); if (!$this->isFileType_FileTrait($file_ext, $media_tag)) { throw new \Exception("파일명 형식이 {$media_tag}가 아닙니다"); } @@ -155,14 +156,14 @@ abstract class MyCrawler extends CommonLibrary private function media_process(array $media_urls): array { $file_sequence = 1; - $storages = []; //CreateBoard에서 사용을 위해 DetailPage마다 초기화 + $storages = []; //CreateBoard에서 사용을 위해 DetailPage마다 초기화 foreach ($media_urls as $media_tag => $urls) { $total = count($urls); foreach ($urls as $url) { log_message("notice", __FUNCTION__ . " {$file_sequence}번째/총:{$total} MediaType->{$media_tag} 작업 시작"); try { list($file_name, $content) = $this->media_download($media_tag, $url); - $storage = $this->media_save($file_sequence, $media_tag, $file_name, $content); + $storage = $this->media_save($file_sequence, $media_tag, $file_name, $content); log_message("debug", __FUNCTION__ . " {$file_sequence}번째/총:{$total} 결과=>" . $storage->getOriginName()); $storages[] = $storage; } catch (\Exception $e) { @@ -186,14 +187,14 @@ abstract class MyCrawler extends CommonLibrary //Board DB 등록작업등 //미디어관련정보 entity에 넣기 $formDatas[BoardModel::TITLE] = $listInfo["title"]; - $formDatas['user_pid'] = $this->getMyStorage()->getUserEntity()->getPK(); - $formDatas['user_id'] = $this->getMyStorage()->getUserEntity()->getID(); - $formDatas['user_name'] = $listInfo["nickname"] != "" ? $listInfo["nickname"] : $this->getMyStorage()->getUserEntity()->getTitle(); - $formDatas['level'] = $this->getBoardsEntity()->getListLevel(); - $formDatas['hit'] = intval($listInfo['hit']); - $formDatas['reg_date'] = date("Y-m-d H:i:s", strtotime($listInfo['date'])); - $formDatas['data_type'] = "html"; - $formDatas['editor_type'] = "S"; + $formDatas['user_pid'] = $this->getMyStorage()->getUserEntity()->getPK(); + $formDatas['user_id'] = $this->getMyStorage()->getUserEntity()->getID(); + $formDatas['user_name'] = $listInfo["nickname"] != "" ? $listInfo["nickname"] : $this->getMyStorage()->getUserEntity()->getTitle(); + $formDatas['level'] = $this->getBoardsEntity()->getListLevel(); + $formDatas['hit'] = intval($listInfo['hit']); + $formDatas['reg_date'] = date("Y-m-d H:i:s", strtotime($listInfo['date'])); + $formDatas['data_type'] = "html"; + $formDatas['editor_type'] = "S"; foreach ($storages as $storage) { if ($formDatas['image_path'] == "") { $formDatas['image_path'] = $storage->getBasePath() . DIRECTORY_SEPARATOR . $storage->getPath() . DIRECTORY_SEPARATOR . $storage->getOriginName(); @@ -243,9 +244,9 @@ abstract class MyCrawler extends CommonLibrary private function detail_copy_process(int $cnt, array $listInfo): array { list($selector, $listInfo) = $this->getDetailSelector($listInfo); - $formDatas = []; - $formDatas['image_path'] = ""; - $formDatas['content'] = $selector->html(); + $formDatas = []; + $formDatas['image_path'] = ""; + $formDatas['content'] = $selector->html(); //Board 등록작업등 $this->create_board($cnt, $listInfo, [], $formDatas); log_message("notice", __FUNCTION__ . " 작업이 완료되었습니다."); @@ -254,8 +255,8 @@ abstract class MyCrawler extends CommonLibrary private function detail_download_process(int $cnt, array $listInfo): array { list($selector, $listInfo) = $this->getDetailSelector($listInfo); - $media_urls = $this->getUrlsByMediaType($selector, "img", "src"); - $media_urls = $this->getUrlsByMediaType($selector, "video", "src", $media_urls); + $media_urls = $this->getUrlsByMediaType($selector, "img", "src"); + $media_urls = $this->getUrlsByMediaType($selector, "video", "src", $media_urls); if ($this->isDebug) { throw new \Exception(sprintf( "\n--------------%s Debug--------------\n%s%s\n---------------------------------------\n", @@ -281,8 +282,8 @@ abstract class MyCrawler extends CommonLibrary { //Limit가 0이면 $listInfos 갯수만큼 다하고, LIMIT 갯수 혹은 item의 갯수중 작은수만큼 한다. $max_limit = !$max_limit || count($listInfos) <= $max_limit ? count($listInfos) : $max_limit; - $total = count($listInfos); - $i = 1; + $total = count($listInfos); + $i = 1; foreach ($listInfos as $listInfo) { if ($i <= $max_limit) { log_message("notice", __FUNCTION__ . " 게시물 {$i}번째/총:{$total} {$listInfo["nickname"]} 작업시작"); diff --git a/app/Libraries/MyStorage/MangboardStorage.php b/app/Libraries/MyMangboard/Storage.php similarity index 54% rename from app/Libraries/MyStorage/MangboardStorage.php rename to app/Libraries/MyMangboard/Storage.php index af78bd4..69c08c5 100644 --- a/app/Libraries/MyStorage/MangboardStorage.php +++ b/app/Libraries/MyMangboard/Storage.php @@ -1,14 +1,16 @@ _board_name = $board_name; + $this->_board_name = $board_name; $this->_user_entity = $user_entity; } final public function getBoardName(): string @@ -88,24 +90,24 @@ class MangboardStorage extends FileStorage return $content; } - final public function create(BoardsEntity $boards_entity, BoardEntity $board_entity, string $board_table): void + private function create_file(BoardsEntity $boards_entity, BoardEntity $board_entity, string $board_table): FileEntity { - //File DB에 넣기 - $formDatas['board_pid'] = $board_entity->getPk(); - $formDatas['user_pid'] = $this->_user_entity->getPK(); - $formDatas['user_name'] = $this->_user_entity->getTitle(); - $formDatas['board_name'] = $boards_entity->getTitle(); - $formDatas['table_name'] = $board_table; - $formDatas['file_path'] = $this->getBasePath() . DIRECTORY_SEPARATOR . $this->getPath() . DIRECTORY_SEPARATOR . $this->getOriginName(); - $formDatas[FileModel::TITLE] = $this->getOriginName(); - $formDatas['file_type'] = $this->getMimeType(); - $formDatas['file_caption'] = $this->getOriginName(); - $formDatas['file_alt'] = $this->getOriginName(); + + $formDatas['board_pid'] = $board_entity->getPk(); + $formDatas['user_pid'] = $this->_user_entity->getPK(); + $formDatas['user_name'] = $this->_user_entity->getTitle(); + $formDatas['board_name'] = $boards_entity->getTitle(); + $formDatas['table_name'] = $board_table; + $formDatas['file_path'] = $this->getBasePath() . DIRECTORY_SEPARATOR . $this->getPath() . DIRECTORY_SEPARATOR . $this->getOriginName(); + $formDatas[FileModel::TITLE] = $this->getOriginName(); + $formDatas['file_type'] = $this->getMimeType(); + $formDatas['file_caption'] = $this->getOriginName(); + $formDatas['file_alt'] = $this->getOriginName(); $formDatas['file_description'] = "Filedata"; - $formDatas['file_size'] = $this->getFileSize(); - $formDatas['file_sequence'] = $this->getOriginSequence(); - $formDatas['reg_date'] = date("Y-m-d H:i:s"); - $entity = $this->getFileModel()->create($formDatas); + $formDatas['file_size'] = $this->getFileSize(); + $formDatas['file_sequence'] = $this->getOriginSequence(); + $formDatas['reg_date'] = date("Y-m-d H:i:s"); + $entity = $this->getFileModel()->create($formDatas); log_message("notice", sprintf( "%s -> %s 게시물의 %s번째:%s 파일 등록 완료", __FUNCTION__, @@ -113,8 +115,41 @@ class MangboardStorage extends FileStorage $this->getOriginSequence(), $entity->getTitle() )); + return $entity; + } + private function create_small_image(BoardEntity $board_entity, $target_name = "small", int $width = 480, int $height = 319): void + { + $fileInfo = pathinfo($this->getFullPath() . DIRECTORY_SEPARATOR . $this->getOriginName(), PATHINFO_ALL); + $target_file_name = sprintf("%s_%s.%s", $fileInfo['filename'], $target_name, $fileInfo['extension']); + if (!$this->isFileType_FileTrait($fileInfo['extension'])) { + throw new \Exception("{$this->getOriginName()} Image 형식파일이 아닙니다."); + } + // 이미지 파일 로드 + $this->load_ImageTrait($this->getFullPath() . DIRECTORY_SEPARATOR . $this->getOriginName()); + // 200x200으로 이미지 크기 조정 + $this->resize_ImageTrait($width, $height); + // 파일 저장 + $this->save_ImageTrait($this->getFullPath() . DIRECTORY_SEPARATOR . $target_file_name); + // 메모리 해제 + $this->destroy_ImageTrait(); + log_message("notice", sprintf( + "%s -> %s 게시물의 %s번째:%s->%s 작은이미지(W:%s,H:%s) 생성 완료", + __FUNCTION__, + $board_entity->getTitle(), + $this->getOriginSequence(), + $this->getOriginName(), + $target_file_name, + $width, + $height + )); + } + + final public function create(BoardsEntity $boards_entity, BoardEntity $board_entity, string $board_table): void + { + //File DB에 넣기 + $this->create_file($boards_entity, $board_entity, $board_table); //작은이미지 만들기 - $this->create_small_ImageTrait($board_entity, $this); + $this->create_small_image($board_entity, $this); } } diff --git a/app/Models/Cloudflare/AccountModel.php b/app/Models/Cloudflare/AccountModel.php index e38d3a0..b42526f 100644 --- a/app/Models/Cloudflare/AccountModel.php +++ b/app/Models/Cloudflare/AccountModel.php @@ -8,13 +8,13 @@ use App\Models\CommonModel; class AccountModel extends CommonModel { const TABLE = "cloudflarerecord"; - const PK = "uid"; + const PK = "uid"; const TITLE = "id"; - protected $table = self::TABLE; - protected $primaryKey = self::PK; + protected $table = self::TABLE; + protected $primaryKey = self::PK; protected $useAutoIncrement = false; - protected $returnType = AccountEntity::class; //object,array,entity명::class - protected $allowedFields = [self::PK, self::TITLE, 'apikey', 'oldkey', 'type', 'status', 'updated_at', 'created_at']; + protected $returnType = AccountEntity::class; //object,array,entity명::class + protected $allowedFields = [self::PK, self::TITLE, 'apikey', 'oldkey', 'type', 'status', 'updated_at', 'created_at']; protected $useTimestamps = true; public function __construct() { @@ -30,10 +30,12 @@ class AccountModel extends CommonModel case self::TITLE: $rules[$field] = "required|valid_emailvalid_email|is_unique[cloudflareauth.id]"; case "apikey": - $rules[$field] = $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";; + $rules[$field] = $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; + ; break; case "oldkey": - $rules[$field] = $rules[$field] = "if_exist|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";; + $rules[$field] = $rules[$field] = "if_exist|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; + ; break; case "type": $rules[$field] = "if_exist|in_list[standard,enterprise]"; @@ -44,23 +46,22 @@ class AccountModel extends CommonModel } return $rules; } - public function getFormFieldOption(string $field, array $options = []): array + public function getFormFieldInputOption(string $field, array $options = []): array { switch ($field) { default: - $this->where('status', DEFAULTS['STATUS']); $this->orderBy(self::TITLE, 'asc'); - $options = parent::getFormFieldOption($field, $options); + $options = parent::getFormFieldInputOption($field, $options); break; } return $options; } - public function getEntityByPK(int $uid): null | AccountEntity + public function getEntityByPK(int $uid): null|AccountEntity { $this->where($this->getPKField(), $uid); return $this->getEntity(); } - public function getEntityByID(string $id): null | AccountEntity + public function getEntityByID(string $id): null|AccountEntity { $this->where($this->getTitleField(), $id); return $this->getEntity(); diff --git a/app/Models/Cloudflare/RecordModel.php b/app/Models/Cloudflare/RecordModel.php index 0e4d895..4db90b8 100644 --- a/app/Models/Cloudflare/RecordModel.php +++ b/app/Models/Cloudflare/RecordModel.php @@ -8,15 +8,15 @@ use App\Entities\Cloudflare\RecordEntity; class RecordModel extends Model { - const TABLE = "cloudflarerecord"; - const PK = "uid"; - const TITLE = "host"; + const TABLE = "cloudflarerecord"; + const PK = "uid"; + const TITLE = "host"; const PARENT = "zone_uid"; - protected $table = self::TABLE; - protected $primaryKey = self::PK; + protected $table = self::TABLE; + protected $primaryKey = self::PK; protected $useAutoIncrement = false; - protected $returnType = RecordEntity::class; //object,array,entity명::class - protected $allowedFields = [self::PK, self::PARENT, self::TITLE, 'type', 'content', 'ttl', 'proxiable', 'proxied', 'fixed', 'locked', 'updated_at', 'crated_at']; + protected $returnType = RecordEntity::class; //object,array,entity명::class + protected $allowedFields = [self::PK, self::PARENT, self::TITLE, 'type', 'content', 'ttl', 'proxiable', 'proxied', 'fixed', 'locked', 'updated_at', 'crated_at']; protected $useTimestamps = true; public function __construct() @@ -31,7 +31,8 @@ class RecordModel extends Model { switch ($field) { case self::PARENT: - $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";; + $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; + ; break; case self::TITLE: case "content": @@ -43,8 +44,8 @@ class RecordModel extends Model case "ttl": $rules[$field] = "if_exist|numeric"; break; - case "proxied": case "proxiable": + case "proxied": case "fixed": case "locked": $rules[$field] = "if_exist|in_list[on,off]"; @@ -55,12 +56,22 @@ class RecordModel extends Model } return $rules; } - public function getEntityByPK(int $uid): null | RecordEntity + public function getFormFieldInputOption(string $field, array $options = []): array + { + switch ($field) { + default: + $this->orderBy(self::TITLE, 'asc'); + $options = parent::getFormFieldInputOption($field, $options); + break; + } + return $options; + } + public function getEntityByPK(int $uid): null|RecordEntity { $this->where(self::PK, $uid); return $this->getEntity(); } - public function getEntityByID(string $id): null | RecordEntity + public function getEntityByID(string $id): null|RecordEntity { $this->where(self::TITLE, $id); return $this->getEntity(); @@ -97,19 +108,18 @@ class RecordModel extends Model log_message("notice", "-----set fixed Records " . implode(",", $hosts) . "처리 완료-----"); } } - //Index 검색어용 - public function setIndexWordFilter(string $word) + + //List 검색용 + public function setList_WordFilter(string $word, $field = null): void { - $this->like('host', $word, 'before'); //befor , after , both - $this->orWhere('content', $word); + parent::setList_WordFilter($word, $field); + $this->orLike('content', $word, 'both'); } - public function setIndexDateFilter($start, $end) + public function setList_OrderBy(string $order) { - $this->where('created_at >=', $start); - $this->where('created_at <=', $end); - } - public function setIndexOrderBy($field, $order = 'ASC') - { - $this->orderBy(self::PARENT . " ASC, host ASC, {$field} {$order}"); + //Join을 해서 도메인부터 Sorting하기위함 + $this->join('cloudflarezone', "cloudflarezone.uid=cloudflarerecord.zone_uid"); + $this->orderBy("cloudflare.domain ASC"); + parent::setList_OrderBy($order); } } diff --git a/app/Models/Cloudflare/ZoneModel.php b/app/Models/Cloudflare/ZoneModel.php index 5066156..348b02a 100644 --- a/app/Models/Cloudflare/ZoneModel.php +++ b/app/Models/Cloudflare/ZoneModel.php @@ -9,15 +9,15 @@ use App\Entities\Cloudflare\AccountEntity; class ZoneModel extends CommonModel { - const TABLE = "cloudflarezone"; - const PK = "uid"; - const TITLE = "domain"; + const TABLE = "cloudflarezone"; + const PK = "uid"; + const TITLE = "domain"; const PARENT = "account_uid"; - protected $table = self::TABLE; - protected $primaryKey = self::PK; + protected $table = self::TABLE; + protected $primaryKey = self::PK; protected $useAutoIncrement = false; - protected $returnType = ZoneEntity::class; //object,array,entity명::class - protected $allowedFields = [self::PK, self::PARENT, self::TITLE, 'name_servers', 'original_name_servers', 'plan', 'development_mode', 'ipv6', 'security_level', 'status', 'updated_at', 'crated_at ']; + protected $returnType = ZoneEntity::class; //object,array,entity명::class + protected $allowedFields = [self::PK, self::PARENT, self::TITLE, 'name_servers', 'original_name_servers', 'plan', 'development_mode', 'ipv6', 'security_level', 'status', 'updated_at', 'crated_at ']; protected $useTimestamps = true; public function __construct() { @@ -31,7 +31,8 @@ class ZoneModel extends CommonModel { switch ($field) { case self::PARENT: - $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";; + $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; + ; break; case self::TITLE: case "plan": @@ -51,12 +52,25 @@ class ZoneModel extends CommonModel } return $rules; } - public function getEntityByPK(int $uid): null | ZoneEntity + public function getFormFieldInputOption(string $field, array $options = []): array + { + switch ($field) { + case "status": + $options[$field] = lang($this->class_name . '.' . strtoupper($field)); + break; + default: + $this->orderBy(self::TITLE, 'asc'); + $options = parent::getFormFieldInputOption($field, $options); + break; + } + return $options; + } + public function getEntityByPK(int $uid): null|ZoneEntity { $this->where(self::PK, $uid); return $this->getEntity(); } - public function getEntityByID(string $id): null | ZoneEntity + public function getEntityByID(string $id): null|ZoneEntity { $this->where(self::TITLE, $id); return $this->getEntity(); @@ -84,20 +98,19 @@ class ZoneModel extends CommonModel $this->where(self::TITLE, $domain); return is_null($this->first()) ? true : false; } - //Index 검색용 - public function setIndexWordFilter(string $word): void + //List 검색용 + public function setList_WordFilter(string $word, $field = null): void { - $subquery = $this->db->table(RecordModel::TABLE)->select(RecordModel::PARENT)->like('content', $word, 'both'); - $this->like(self::TITLE, $word, 'both'); //befor , after , both - $this->orWhereIn(self::PK, $subquery); + //Join을 해서 Record의 content(IP검색)을 하기위함 + parent::setList_WordFilter($word, $field); + $this->join('cloudflarerecord', "cloudflarezone.uid=cloudflarerecord.zone_uid"); + $this->orLike('cloudflarerecord.content', $word, 'both'); + // $subquery = $this->db->table(RecordModel::TABLE)->select(RecordModel::PARENT)->like('content', $word, 'both'); + // $this->orWhereIn(self::PK, $subquery); } - public function setIndexDateFilter($start, $end): void + public function setList_OrderBy(string $order): void { - $this->where('created_at >=', $start); - $this->where('created_at <=', $end); - } - public function setIndexOrderBy($field, $order = 'ASC') - { - $this->orderBy(self::TITLE . " ASC, {$field} {$order}"); + $this->orderBy(self::TITLE . " ASC"); + parent::setList_OrderBy($order); } } diff --git a/app/Models/CommonModel.php b/app/Models/CommonModel.php index ba828b5..6e30f47 100644 --- a/app/Models/CommonModel.php +++ b/app/Models/CommonModel.php @@ -6,14 +6,14 @@ use CodeIgniter\Model; abstract class CommonModel extends Model { - protected $table = ''; - protected $primaryKey = ''; + protected $table = ''; + protected $primaryKey = ''; protected $useAutoIncrement = true; - protected $returnType = 'array'; + protected $returnType = 'array'; - protected $useSoftDeletes = false; - protected $protectFields = true; - protected $allowedFields = []; + protected $useSoftDeletes = false; + protected $protectFields = true; + protected $allowedFields = []; protected bool $allowEmptyInserts = false; protected bool $updateOnlyChanged = true; @@ -23,27 +23,27 @@ abstract class CommonModel extends Model // Dates protected $useTimestamps = false; - protected $dateFormat = 'datetime'; - protected $createdField = 'created_at'; - protected $updatedField = 'updated_at'; - protected $deletedField = 'deleted_at'; + protected $dateFormat = 'datetime'; + protected $createdField = 'created_at'; + protected $updatedField = 'updated_at'; + protected $deletedField = 'deleted_at'; // Validation - protected $validationRules = []; - protected $validationMessages = []; - protected $skipValidation = false; + protected $validationRules = []; + protected $validationMessages = []; + protected $skipValidation = false; protected $cleanValidationRules = true; // Callbacks protected $allowCallbacks = true; - protected $beforeInsert = []; - protected $afterInsert = []; - protected $beforeUpdate = []; - protected $afterUpdate = []; - protected $beforeFind = []; - protected $afterFind = []; - protected $beforeDelete = []; - protected $afterDelete = []; + protected $beforeInsert = []; + protected $afterInsert = []; + protected $beforeUpdate = []; + protected $afterUpdate = []; + protected $beforeFind = []; + protected $afterFind = []; + protected $beforeDelete = []; + protected $afterDelete = []; private $_action = DB_ACTION["CREATE"]; protected function __construct() @@ -92,10 +92,11 @@ abstract class CommonModel extends Model $rules[$field] .= $this->getAction() == DB_ACTION["CREATE"] ? "|is_unique[{$this->table}.{$field}]" : ""; } else { $rules[$field] = "required|numeric"; - }; + } + ; break; case $this->getTitleField(): - $rules[$field] = "required|string"; + $rules[$field] = "required|string"; break; case "passwd": $rules[$field] = $this->getAction() == DB_ACTION["CREATE"] ? "required" : "if_exist" . "|trim|string"; @@ -104,13 +105,13 @@ abstract class CommonModel extends Model $rules["confirmpassword"] = $this->getAction() == DB_ACTION["CREATE"] ? "required" : "if_exist" . "|trim|string|matches[passwd]"; break; case "email": - $rules[$field] = "if_exist|trim|valid_email"; + $rules[$field] = "if_exist|trim|valid_email"; break; case 'image': - $rules[$field] = "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]"; + $rules[$field] = "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]"; break; case "status": - $rules[$field] = "if_exist|in_list[use,unuse]"; + $rules[$field] = "if_exist|in_list[use,unuse]"; break; case "updated_at": case "created_at": @@ -130,12 +131,12 @@ abstract class CommonModel extends Model } return $rules; } - public function getFormFieldOption(string $field, array $options = []): array + public function getFormFieldInputOption(string $field, array $options = []): array { switch ($field) { default: foreach ($this->getEntitys() as $entity) { - $options[$field][$entity->getPK()] = $entity->getTitle(); + $options[$entity->getPK()] = $entity->getTitle(); } break; } @@ -157,7 +158,7 @@ abstract class CommonModel extends Model //$formDatas에 전달된 값이 없는경우 if (!array_key_exists($field, $formDatas)) { $randomBytes = bin2hex(random_bytes(32)); - $value = sprintf( + $value = sprintf( '%08s-%04s-%04x-%04x-%12s', substr($randomBytes, 0, 8), substr($randomBytes, 8, 4), @@ -212,8 +213,8 @@ abstract class CommonModel extends Model $entity = $this->save_process($entity); //primaryKey가 자동입력이면 if ($this->useAutoIncrement) { - $pkField = $this->getPKField(); - $entity->$pkField = $this->getInsertID(); + $pkField = $this->getPKField(); + $entity->$pkField = $this->getInsertID(); } log_message("debug", $this->table . "=> " . __FUNCTION__ . " 작업 완료"); return $entity; @@ -231,4 +232,24 @@ abstract class CommonModel extends Model log_message("debug", $this->table . "=> " . __FUNCTION__ . " 작업 완료"); return $entity; } + + //List용 + final public function setList_FieldFilter(string $field, int|string $value): void + { + $this->where($field, $value); + } + public function setList_WordFilter(string $word, string $field = null): void + { + $this->like($field ?? $this->getTitleField(), $word, 'before'); //befor , after , both + } + public function setList_DateFilter(string $start, string $end, $field = "created_at"): void + { + + $this->where("{$field} >= {$start}"); + $this->where("{$field} <= {$end}"); + } + public function setList_OrderBy(string $order) + { + $this->orderBy($order); + } } diff --git a/app/Traits/ImageTrait.php b/app/Traits/ImageTrait.php index 9741778..957bc78 100644 --- a/app/Traits/ImageTrait.php +++ b/app/Traits/ImageTrait.php @@ -10,19 +10,19 @@ trait ImageTrait private $_image; private $_imageType; - final protected function getWidth_ImageTrait() + final public function getWidth_ImageTrait() { return imagesx($this->_image); } // 이미지의 현재 높이를 반환하는 메소드 - final protected function getHeight_ImageTrait() + final public function getHeight_ImageTrait() { return imagesy($this->_image); } // 이미지 파일을 로드하는 메소드 - final protected function load_ImageTrait($file) + final public function load_ImageTrait($file) { - $imageInfo = getimagesize($file); + $imageInfo = getimagesize($file); $this->_imageType = $imageInfo[2]; switch ($this->_imageType) { case IMAGETYPE_JPEG: @@ -40,7 +40,7 @@ trait ImageTrait } } // 이미지 크기를 지정된 너비, 높이로 변경하는 메소드 - final protected function resize_ImageTrait($width, $height) + final public function resize_ImageTrait($width, $height) { $newImage = imagecreatetruecolor($width, $height); imagecopyresampled( @@ -58,26 +58,26 @@ trait ImageTrait $this->_image = $newImage; } // 이미지 비율을 유지하면서 크기를 조정하는 메소드 - final protected function resizeToWidth_ImageTrait($width) + final public function resizeToWidth_ImageTrait($width) { - $ratio = $width / $this->getWidth_ImageTrait(); + $ratio = $width / $this->getWidth_ImageTrait(); $height = $this->getHeight_ImageTrait() * $ratio; $this->resize_ImageTrait($width, $height); } - final protected function resizeToHeight_ImageTrait($height) + final public function resizeToHeight_ImageTrait($height) { $ratio = $height / $this->getHeight_ImageTrait(); $width = $this->getWidth_ImageTrait() * $ratio; $this->resize_ImageTrait($width, $height); } - final protected function scale($scale) + final public function scale($scale) { - $width = $this->getWidth_ImageTrait() * ($scale / 100); + $width = $this->getWidth_ImageTrait() * ($scale / 100); $height = $this->getHeight_ImageTrait() * ($scale / 100); $this->resize_ImageTrait($width, $height); } // 이미지를 저장하는 메소드 - final protected function save_ImageTrait($file, $imageType = IMAGETYPE_WEBP, $compression = 75) + final public function save_ImageTrait($file, $imageType = IMAGETYPE_WEBP, $compression = 75) { switch ($imageType) { case IMAGETYPE_JPEG: @@ -96,35 +96,8 @@ trait ImageTrait } } // 메모리 해제를 위한 메소드 - final protected function destroy_ImageTrait() + final public function destroy_ImageTrait() { imagedestroy($this->_image); } - - public function create_small_ImageTrait(BoardEntity $board_entity, MangboardStorage $storage, $target_name = "small", int $width = 480, int $height = 319): void - { - $fileInfo = pathinfo($storage->getFullPath() . DIRECTORY_SEPARATOR . $storage->getOriginName(), PATHINFO_ALL); - $target_file_name = sprintf("%s_%s.%s", $fileInfo['filename'], $target_name, $fileInfo['extension']); - if (!$this->isFileType_FileTrait($fileInfo['extension'])) { - throw new \Exception("{$storage->getOriginName()} Image 형식파일이 아닙니다."); - } - // 이미지 파일 로드 - $this->load_ImageTrait($storage->getFullPath() . DIRECTORY_SEPARATOR . $storage->getOriginName()); - // 200x200으로 이미지 크기 조정 - $this->resize_ImageTrait($width, $height); - // 파일 저장 - $this->save_ImageTrait($storage->getFullPath() . DIRECTORY_SEPARATOR . $target_file_name); - // 메모리 해제 - $this->destroy_ImageTrait(); - log_message("notice", sprintf( - "%s -> %s 게시물의 %s번째:%s->%s 작은이미지(W:%s,H:%s) 생성 완료", - __FUNCTION__, - $board_entity->getTitle(), - $storage->getOriginSequence(), - $storage->getOriginName(), - $target_file_name, - $width, - $height - )); - } } diff --git a/app/Views/cloudflare/account/index.php b/app/Views/cloudflare/account/index.php index 4ba60b3..a0690b9 100644 --- a/app/Views/cloudflare/account/index.php +++ b/app/Views/cloudflare/account/index.php @@ -1,50 +1,54 @@ extend('layouts/admin') ?> section('content') ?> -
-
- "get")) ?> - - include('templates/admin/index_head') ?> - -
- - - - - - - - - - - - - status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> - - - - - - - - - -
#@
- "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> - getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
-
- - -
+
+ "get")) ?> + + include('templates/admin/index_head') ?>
+ + + + + + + + + + + + + + status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> + + + + + + + + + +
#@
+ "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> + getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?> + + getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> +
+
+ + +
+ endSection() ?> \ No newline at end of file diff --git a/public/css/admin/left_menu.css b/public/css/admin/left_menu.css index 288a6d3..bd83d75 100644 --- a/public/css/admin/left_menu.css +++ b/public/css/admin/left_menu.css @@ -23,12 +23,12 @@ div#left_menu > div.accordion { width: 20px; display: none; } -div#left_menu > div.accordion > div.accordion-item:hover { +div#left_menu > div.accordion div.accordion-item:hover { background-color: #e7e7e7; } -div#left_menu > div.accordion > div.accordion-item > a { - padding-left: 10px; +div#left_menu > div.accordion div.accordion-item a { + padding-left: 20px; } -div#left_menu > div.accordion > div.accordion-collapse > a { +div#left_menu > div.accordion div.accordion-collapse a { padding-left: 30px; }