From 2bbea6a4b040d80bfaf5b8c77413f3e4674768ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Sun, 6 Oct 2024 13:18:14 +0900 Subject: [PATCH] cfmgrv4 init...1 --- app/.htaccess | 4 ++ app/Config/Routes.php | 10 ++-- app/Controllers/Admin/AdminController.php | 2 +- .../Admin/Cloudflare/AccountController.php | 4 +- .../Admin/Cloudflare/AuthController.php | 4 +- .../Admin/Cloudflare/CloudflareController.php | 10 ++-- .../Admin/Cloudflare/RecordController.php | 15 ++--- .../Admin/Cloudflare/ZoneController.php | 7 ++- app/Controllers/Admin/MapurlController.php | 4 +- app/Controllers/Admin/UserController.php | 4 +- app/Controllers/MVController.php | 58 ++++++++++++------- app/Filters/AuthFilter.php | 1 - app/Helpers/Cloudflare/Account_helper.php | 33 +---------- app/Helpers/Cloudflare/Auth_helper.php | 35 +---------- app/Helpers/Cloudflare/Record_helper.php | 57 +----------------- app/Helpers/Cloudflare/Zone_helper.php | 57 +----------------- app/Helpers/Common_helper.php | 28 +++++++++ app/Helpers/Mapurl_helper.php | 35 +---------- app/Helpers/User_helper.php | 36 +----------- app/Libraries/MySocket/CloudflareSocket.php | 7 +-- app/Views/layouts/admin/top.php | 15 ++--- app/Views/layouts/front/top.php | 25 ++++---- 22 files changed, 128 insertions(+), 323 deletions(-) diff --git a/app/.htaccess b/app/.htaccess index 3462048..499b73a 100644 --- a/app/.htaccess +++ b/app/.htaccess @@ -4,3 +4,7 @@ Deny from all + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)$ index.php/$1 [L] \ No newline at end of file diff --git a/app/Config/Routes.php b/app/Config/Routes.php index d6ab991..ca2e4b7 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -22,15 +22,15 @@ $routes->group('cli', ['namespace' => 'App\CLI'], function ($routes) { $routes->cli('reload', 'Cloudflare::reload'); }); }); -$routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($routes) { +$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], function ($routes) { $routes->get('/', 'Home::index'); $routes->group('user', function ($routes) { $routes->get('/', 'UserController::index'); - $routes->get('create', 'UserController::create_form'); - $routes->post('create', 'UserController::create'); + $routes->get('create', 'UserController::create_form', ['filter' => 'authFilter:master']); + $routes->post('create', 'UserController::create', ['filter' => 'authFilter:master']); $routes->get('modify/(:num)', 'UserController::modify_form/$1'); $routes->post('modify/(:num)', 'UserController::modify/$1'); - $routes->get('delete/(:num)', 'UserController::delete/$1'); + $routes->get('delete/(:num)', 'UserController::delete/$1', ['filter' => 'authFilter:master']); $routes->get('toggle/(:num)/(:any)', 'UserController::toggle/$1/$2'); $routes->post('batchjob', 'UserController::batcjob'); $routes->get('download/(:alpha)', 'UserController::download/$1'); @@ -52,7 +52,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($rou $routes->get('create', 'AuthController::create_form'); $routes->post('create', 'AuthController::create'); $routes->get('modify/(:num)', 'AuthController::modify_form/$1'); - $routes->get('delete/(:num)', 'AuthController::delete/$1'); + $routes->get('delete/(:num)', 'AuthController::delete/$1', ['filter' => 'authFilter:master']); $routes->get('toggle/(:num)/(:any)', 'AuthController::toggle/$1/$2'); $routes->post('batchjob', 'AuthController::batcjob'); $routes->get('download/(:alpha)', 'AccountController::download/$1'); diff --git a/app/Controllers/Admin/AdminController.php b/app/Controllers/Admin/AdminController.php index 54a5d1e..326f7c4 100644 --- a/app/Controllers/Admin/AdminController.php +++ b/app/Controllers/Admin/AdminController.php @@ -14,6 +14,6 @@ abstract class AdminController extends MVController parent::initController($request, $response, $logger); $this->layout = "admin"; $this->view_root .= "admin/"; - $this->action_form = FORMS['MODAL']; + $this->action_form = FORMS['IFRAME']; } } diff --git a/app/Controllers/Admin/Cloudflare/AccountController.php b/app/Controllers/Admin/Cloudflare/AccountController.php index 10fefe6..f304c6c 100644 --- a/app/Controllers/Admin/Cloudflare/AccountController.php +++ b/app/Controllers/Admin/Cloudflare/AccountController.php @@ -61,7 +61,7 @@ class AccountController extends CloudflareController $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields); $this->filter_fields = [$this->getModel()::PARENT, 'type', 'status']; $this->field_options = $this->getFormFieldOptions($this->filter_fields); - $this->batchjob_fields = ['typep', 'status']; + $this->batchjob_fields = ['type', 'status']; return $this->list_procedure(); } // Download @@ -72,7 +72,7 @@ class AccountController extends CloudflareController $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields); $this->filter_fields = [$this->getModel()::PARENT, 'type', 'status']; $this->field_options = $this->getFormFieldOptions($this->filter_fields); - $this->batchjob_fields = ['typep', 'status']; + $this->batchjob_fields = ['type', 'status']; return $this->download_procedure($output_type, $uid); } //reload Account By Auth diff --git a/app/Controllers/Admin/Cloudflare/AuthController.php b/app/Controllers/Admin/Cloudflare/AuthController.php index 9534728..3cd327e 100644 --- a/app/Controllers/Admin/Cloudflare/AuthController.php +++ b/app/Controllers/Admin/Cloudflare/AuthController.php @@ -45,7 +45,7 @@ class AuthController extends CloudflareController public function create(): RedirectResponse|string { $this->init(__FUNCTION__); - return $this->create_procedure($this->action_form); + return $this->create_procedure(); } //수정 public function modify_form(string $uid): RedirectResponse|string @@ -56,7 +56,7 @@ class AuthController extends CloudflareController public function modify(string $uid): RedirectResponse|string { $this->init(__FUNCTION__); - return $this->modify_procedure($uid, $this->action_form); + return $this->modify_procedure($uid); } //일괄처리작업 public function batcjob(): RedirectResponse diff --git a/app/Controllers/Admin/Cloudflare/CloudflareController.php b/app/Controllers/Admin/Cloudflare/CloudflareController.php index b46bfe2..61f0f4a 100644 --- a/app/Controllers/Admin/Cloudflare/CloudflareController.php +++ b/app/Controllers/Admin/Cloudflare/CloudflareController.php @@ -59,10 +59,9 @@ abstract class CloudflareController extends AdminController $this->getModel()->transStart(); try { $this->sync_process($uid); - $message = "Sync 작업을 완료하였습니다."; - log_message("notice", $message); - $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $message); $this->getModel()->transCommit(); + log_message("notice", $this->message); + $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); } catch (\Exception $e) { //Transaction Rollback @@ -80,10 +79,9 @@ abstract class CloudflareController extends AdminController $this->getModel()->transStart(); try { $this->reload_process($uid); - $message = "Reload 작업을 완료하였습니다."; - log_message("notice", $message); - $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $message); $this->getModel()->transCommit(); + log_message("notice", $this->message); + $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); } catch (\Exception $e) { //Transaction Rollback diff --git a/app/Controllers/Admin/Cloudflare/RecordController.php b/app/Controllers/Admin/Cloudflare/RecordController.php index 2bd3598..2ebcee6 100644 --- a/app/Controllers/Admin/Cloudflare/RecordController.php +++ b/app/Controllers/Admin/Cloudflare/RecordController.php @@ -110,11 +110,12 @@ class RecordController extends CloudflareController $entity = $this->getMyLibrary()->create($host, $this->formDatas['type'], $this->formDatas['content'], $this->formDatas['proxied']); log_message("debug", "Record:{$entity->getTitle()} 생성 작업을 완료하였습니다."); } + $this->message = "Record {$this->action} 작업을 완료하였습니다."; } public function create(mixed $zone_uid = false): RedirectResponse|string { $this->init(__FUNCTION__); - return $this->create_procedure($this->action_form); + return $this->create_procedure(); } //수정 (modify,toggle,batchjob사용) protected function modify_process(string $uid): void @@ -136,15 +137,7 @@ class RecordController extends CloudflareController //Socket처리 $entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas); } - log_message("debug", "Record:{$entity->getTitle()} 수정 작업을 완료하였습니다."); - } - //단일필드작업 - public function toggle(string $uid, string $field): RedirectResponse - { - $this->action = __FUNCTION__; - $this->fields = [$field]; - $this->modify_process($uid); - return $this->modify_procedure($uid); + $this->message = "Record:{$entity->getTitle()} {$this->action} 작업을 완료하였습니다."; } //일괄처리작업 public function batcjob(): RedirectResponse @@ -166,6 +159,7 @@ class RecordController extends CloudflareController $this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->entity->getParent()); //Socket처리 $this->getMyLibrary()->sync($this->entity); + $this->message = "Record:{$this->entity->getTitle()} {$this->action} 작업을 완료하였습니다."; } public function sync(string $uid): RedirectResponse { @@ -184,6 +178,7 @@ class RecordController extends CloudflareController $this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]); //Cloudflare 삭제 $this->getMyLibrary()->delete($this->entity); + $this->message = "Record:{$this->entity->getTitle()} {$this->action} 작업을 완료하였습니다."; } // 리스트 public function index(): string diff --git a/app/Controllers/Admin/Cloudflare/ZoneController.php b/app/Controllers/Admin/Cloudflare/ZoneController.php index 098024b..06014ca 100644 --- a/app/Controllers/Admin/Cloudflare/ZoneController.php +++ b/app/Controllers/Admin/Cloudflare/ZoneController.php @@ -153,11 +153,12 @@ class ZoneController extends CloudflareController log_message("debug", "Record:{$entity->getTitle()} 작업을 완료하였습니다."); } } + $this->message = "Zone {$this->action} 작업을 완료하였습니다."; } public function create(): RedirectResponse|string { $this->init(__FUNCTION__); - return $this->create_procedure($this->action_form); + return $this->create_procedure(); } //수정 (modify,toggle,batchjob사용) protected function modify_process(string $uid): void @@ -174,7 +175,7 @@ class ZoneController extends CloudflareController $this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent()); //Socket처리 $entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas); - log_message("debug", "Zone:{$entity->getTitle()} 수정 작업을 완료하였습니다."); + $this->message = "Zone:{$entity->getTitle()} {$this->action} 작업을 완료하였습니다."; } //일괄처리작업 public function batcjob(): RedirectResponse @@ -196,6 +197,7 @@ class ZoneController extends CloudflareController $this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent()); //Socket처리 $this->getMyLibrary()->sync($this->entity); + $this->message = "Zone:{$this->entity->getTitle()} {$this->action} 작업을 완료하였습니다."; } public function sync(string $uid): RedirectResponse { @@ -214,6 +216,7 @@ class ZoneController extends CloudflareController $this->_account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]); //Cloudflare 삭제 $this->getMyLibrary()->delete($this->entity); + $this->message = "Zone:{$this->entity->getTitle()} {$this->action} 작업을 완료하였습니다."; } // 리스트 public function index(): string diff --git a/app/Controllers/Admin/MapurlController.php b/app/Controllers/Admin/MapurlController.php index 8953b0a..204ac88 100644 --- a/app/Controllers/Admin/MapurlController.php +++ b/app/Controllers/Admin/MapurlController.php @@ -86,7 +86,7 @@ class MapurlController extends AdminController public function create(): RedirectResponse|string { $this->init(__FUNCTION__); - return $this->create_procedure($this->action_form); + return $this->create_procedure(); } //수정 public function modify_form(string $uid): RedirectResponse|string @@ -103,7 +103,7 @@ class MapurlController extends AdminController public function modify(string $uid): RedirectResponse|string { $this->init(__FUNCTION__); - return $this->modify_procedure($uid, $this->action_form); + return $this->modify_procedure($uid); } //일괄처리작업 public function batcjob(): RedirectResponse diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index 19f37f2..4a7df82 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -85,7 +85,7 @@ class UserController extends AdminController public function create(): RedirectResponse|string { $this->init(__FUNCTION__); - return $this->create_procedure($this->action_form); + return $this->create_procedure(); } //수정 public function modify_form(string $uid): RedirectResponse|string @@ -96,7 +96,7 @@ class UserController extends AdminController public function modify(string $uid): RedirectResponse|string { $this->init(__FUNCTION__); - return $this->modify_procedure($uid, $this->action_form); + return $this->modify_procedure($uid); } //일괄작업 public function batcjob(): RedirectResponse diff --git a/app/Controllers/MVController.php b/app/Controllers/MVController.php index 6cf7d3a..9d4d8ca 100644 --- a/app/Controllers/MVController.php +++ b/app/Controllers/MVController.php @@ -111,9 +111,9 @@ abstract class MVController extends CommonController $this->create_validate($this->action, $this->fields); $this->formDatas = $this->getFormDatas(); $this->entity = $this->getModel()->create(formDatas: $this->formDatas); - $this->message = "입력작업이 완료되었습니다."; + $this->message = "{$this->action} 작업이 완료되었습니다."; } - final protected function create_procedure(string $action_form = "default"): RedirectResponse|string + final protected function create_procedure(): RedirectResponse|string { //Transaction Start $this->getModel()->transStart(); @@ -121,12 +121,12 @@ abstract class MVController extends CommonController $this->create_process(); $this->getModel()->transCommit(); log_message("notice", __FUNCTION__ . $this->message); - switch ($action_form) { + switch ($this->action_form) { case FORMS['MODAL']: - $result = view("templates/{$this->layout}/{$action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); + $result = view("templates/{$this->layout}/{$this->action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); break; case FORMS['IFRAME']: - $result = view("templates/{$this->layout}/{$action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); + $result = view("templates/{$this->layout}/{$this->action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); break; default: $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message); @@ -188,9 +188,9 @@ abstract class MVController extends CommonController throw new \Exception(__FUNCTION__, " => {$uid} 정보를 찾을수 없습니다."); } $this->entity = $this->getModel()->modify($this->entity, $this->formDatas); - $this->message = "수정작업이 완료되었습니다."; + $this->message = "{$this->action} 작업이 완료되었습니다."; } - final protected function modify_procedure(string $uid, string $action_form = "default"): RedirectResponse|string + final protected function modify_procedure(string $uid): RedirectResponse|string { //Transaction Start $this->getModel()->transStart(); @@ -198,12 +198,12 @@ abstract class MVController extends CommonController $this->modify_process($uid); $this->getModel()->transCommit(); log_message("notice", __FUNCTION__ . $this->message); - switch ($action_form) { + switch ($this->action_form) { case FORMS['MODAL']: - $result = view("templates/{$this->layout}/{$action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); + $result = view("templates/{$this->layout}/{$this->action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); break; - case FORMS['IFRAMEE']: - $result = view("templates/{$this->layout}/{$action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); + case FORMS['IFRAME']: + $result = view("templates/{$this->layout}/{$this->action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); break; default: $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message); @@ -220,13 +220,6 @@ abstract class MVController extends CommonController return redirect()->back()->withInput(); } } - //단일필드작업 - public function toggle(string $uid, string $field): RedirectResponse - { - $this->action = __FUNCTION__; - $this->fields = [$field]; - return $this->modify_procedure($uid); - } //일괄처리작업 final protected function batcjob_procedure(): RedirectResponse { @@ -242,9 +235,30 @@ abstract class MVController extends CommonController $this->modify_process($uid); } $this->getModel()->transCommit(); - $message = "일괄처리 작업을 완료하였습니다."; - log_message("notice", $message); - $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $message); + log_message("notice", $this->message); + $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message); + return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); + } catch (\Exception $e) { + //Transaction Rollback + $this->getModel()->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 public function toggle(string $uid, string $field): RedirectResponse + { + $this->action = __FUNCTION__; + $this->fields = [$field]; + //Transaction Start + $this->getModel()->transStart(); + try { + $this->modify_process($uid); + $this->getModel()->transCommit(); + log_message("notice", $this->message); + $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); } catch (\Exception $e) { //Transaction Rollback @@ -376,7 +390,7 @@ abstract class MVController extends CommonController //모델 처리 $this->entitys = $this->list_entitys_process(); //setting return_url to session flashdata - $this->session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->uri->getQuery() ?: ""); + $this->session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . $this->uri->getQuery() ? "?" . $this->uri->getQuery() : ""); return view( $this->view_path . "/index", ['viewDatas' => $this->getViewDatas()] diff --git a/app/Filters/AuthFilter.php b/app/Filters/AuthFilter.php index ce683a1..8826c34 100644 --- a/app/Filters/AuthFilter.php +++ b/app/Filters/AuthFilter.php @@ -41,7 +41,6 @@ class AuthFilter implements FilterInterface ); } } else { - dd(session()->get(SESSION_NAMES['AUTH'])); session()->setFlashdata(SESSION_NAMES['RETURN_URL'], $request->getUri()->getPath() . '?' . $request->getUri()->getQuery()); return redirect()->to(URLS['LOGIN'])->with('return_message', '로그인을하셔야합니다.'); } diff --git a/app/Helpers/Cloudflare/Account_helper.php b/app/Helpers/Cloudflare/Account_helper.php index 6d34caa..c56e2b8 100644 --- a/app/Helpers/Cloudflare/Account_helper.php +++ b/app/Helpers/Cloudflare/Account_helper.php @@ -144,44 +144,13 @@ function getListLabel_AccountHelper(string $field, array $viewDatas, array $extr } return sprintf("%s", implode(" ", $extras), $label); } -function getListButtonLabel_AccountHelper(string $action, string $label, array $viewDatas, array $extras = []): string -{ - switch ($viewDatas['action_form']) { - case FORMS['MODAL']: - $label = form_label( - $label, - "", - [ - "data-src" => $viewDatas['list_action_url'], - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - ...$extras - ] - ); - break; - case FORMS['IFRAME']: - if ($action == 'create') { - $label = form_label($label, "", [ - "onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')", - ...$extras, - ]); - } else { - $label = ""; - } - break; - default: - $label = anchor($viewDatas['list_action_url'], $label, $extras); - break; - } - return $label; -} function getListButton_AccountHelper(string $action, array $viewDatas, array $extras = []): string { switch ($action) { case 'create': $viewDatas['list_action_url'] = current_url() . '/' . $action . '?' . $viewDatas['uri']->getQuery(['only' => AccountModel::PARENT]); $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; - $action = getListButtonLabel_AccountHelper($action, '입력', $viewDatas, $extras); + $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras); break; case 'sync': $action = $viewDatas['cnt']; diff --git a/app/Helpers/Cloudflare/Auth_helper.php b/app/Helpers/Cloudflare/Auth_helper.php index 1b913d3..448c420 100644 --- a/app/Helpers/Cloudflare/Auth_helper.php +++ b/app/Helpers/Cloudflare/Auth_helper.php @@ -111,44 +111,13 @@ function getListLabel_AuthHelper(string $field, array $viewDatas, array $extras } return sprintf("%s", implode(" ", $extras), $label); } -function getListButtonLabel_AuthHelper(string $action, string $label, array $viewDatas, array $extras = []): string -{ - switch ($viewDatas['action_form']) { - case FORMS['MODAL']: - $label = form_label( - $label, - "", - [ - "data-src" => $viewDatas['list_action_url'], - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - ...$extras - ] - ); - break; - case FORMS['IFRAME']: - if ($action == 'create') { - $label = form_label($label, "", [ - "onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')", - ...$extras, - ]); - } else { - $label = ""; - } - break; - default: - $label = anchor($viewDatas['list_action_url'], $label, $extras); - break; - } - return $label; -} function getListButton_AuthHelper(string $action, array $viewDatas, array $extras = []): string { switch ($action) { case 'create': $viewDatas['list_action_url'] = current_url() . '/' . $action; $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; - $action = getListButtonLabel_AuthHelper($action, '입력', $viewDatas, $extras); + $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras); break; case 'modify': $pk = $viewDatas['entity']->getPK(); @@ -160,7 +129,7 @@ function getListButton_AuthHelper(string $action, array $viewDatas, array $extra "checked" => in_array($pk, old("batchjob_uids", [])) ]); $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); - $action = $checkbox . getListButtonLabel_AuthHelper($action, $viewDatas['cnt'], $viewDatas, $extras); + $action = $checkbox . getListButtonLabel_CommonHelper($action, $viewDatas['cnt'], $viewDatas, $extras); break; case 'delete': $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); diff --git a/app/Helpers/Cloudflare/Record_helper.php b/app/Helpers/Cloudflare/Record_helper.php index e7067bf..1f1f5e5 100644 --- a/app/Helpers/Cloudflare/Record_helper.php +++ b/app/Helpers/Cloudflare/Record_helper.php @@ -160,68 +160,13 @@ function getListLabel_RecordHelper(string $field, array $viewDatas, array $extra } return sprintf("%s", implode(" ", $extras), $label); } -function getListButtonLabel_RecordHelper(string $action, string $label, array $viewDatas, array $extras = []): string -{ - switch ($action) { - case 'create': - switch ($viewDatas['action_form']) { - case FORMS['MODAL']: - $value = form_label( - $label, - "", - [ - "data-src" => $viewDatas['list_action_url'], - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - ...$extras - ] - ); - break; - case FORMS['IFRAME']: - $value = ""; - break; - default: - $value = anchor($viewDatas['list_action_url'], $label, $extras); - break; - } - break; - case 'modify': - switch ($viewDatas['action_form']) { - case FORMS['MODAL']: - $value = form_label( - $label, - "", - [ - "data-src" => $viewDatas['list_action_url'], - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - ...$extras - ] - ); - break; - case FORMS['IFRAME']: - $value = form_label($label, "", [ - "onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')", - ...$extras - ]); - break; - default: - $value = anchor($viewDatas['list_action_url'], $label, $extras); - break; - } - break; - default: - break; - } - return $value; -} function getListButton_RecordHelper(string $action, array $viewDatas, array $extras = []): string { switch ($action) { case 'create': $viewDatas['list_action_url'] = current_url() . '/' . $action . '?' . $viewDatas['uri']->getQuery(['only' => RecordModel::PARENT]); $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; - $action = getListButtonLabel_RecordHelper($action, '입력', $viewDatas, $extras); + $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras); break; case 'sync': $checkbox = ""; diff --git a/app/Helpers/Cloudflare/Zone_helper.php b/app/Helpers/Cloudflare/Zone_helper.php index 16fc2b2..0ad7d80 100644 --- a/app/Helpers/Cloudflare/Zone_helper.php +++ b/app/Helpers/Cloudflare/Zone_helper.php @@ -192,68 +192,13 @@ function getListLabel_ZoneHelper(string $field, array $viewDatas, array $extras } return sprintf("%s", implode(" ", $extras), $label); } -function getListButtonLabel_ZoneHelper(string $action, string $label, array $viewDatas, array $extras = []): string -{ - switch ($action) { - case 'create': - switch ($viewDatas['action_form']) { - case FORMS['MODAL']: - $value = form_label( - $label, - "", - [ - "data-src" => $viewDatas['list_action_url'], - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - ...$extras - ] - ); - break; - case FORMS['IFRAME']: - $value = ""; - break; - default: - $value = anchor($viewDatas['list_action_url'], $label, $extras); - break; - } - break; - case 'modify': - switch ($viewDatas['action_form']) { - case FORMS['MODAL']: - $value = form_label( - $label, - "", - [ - "data-src" => $viewDatas['list_action_url'], - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - ...$extras - ] - ); - break; - case FORMS['IFRAME']: - $value = form_label($label, "", [ - "onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')", - ...$extras - ]); - break; - default: - $value = anchor($viewDatas['list_action_url'], $label, $extras); - break; - } - break; - default: - break; - } - return $value; -} function getListButton_ZoneHelper(string $action, array $viewDatas, array $extras = []): string { switch ($action) { case 'create': $viewDatas['list_action_url'] = current_url() . '/' . $action . '?' . $viewDatas['uri']->getQuery(['only' => ZoneModel::PARENT]); $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; - $action = getListButtonLabel_ZoneHelper($action, '입력', $viewDatas, $extras); + $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras); break; case 'sync': $pk = $viewDatas['entity']->getPK(); diff --git a/app/Helpers/Common_helper.php b/app/Helpers/Common_helper.php index 94fc840..18644b0 100644 --- a/app/Helpers/Common_helper.php +++ b/app/Helpers/Common_helper.php @@ -222,3 +222,31 @@ function form_dropdown_test($data = '', $options = [], $selected = [], $extra = return $form . "\n"; } + +function getListButtonLabel_CommonHelper(string $action, string $label, array $viewDatas, array $extras = []): string +{ + switch ($viewDatas['action_form']) { + case FORMS['MODAL']: + $label = form_label( + $label, + "", + [ + "data-src" => $viewDatas['list_action_url'], + "data-bs-toggle" => "modal", + "data-bs-target" => "#index_action_form", + ...$extras + ] + ); + break; + case FORMS['IFRAME']: + $label = form_label($label, "", [ + "onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')", + ...$extras, + ]); + break; + default: + $label = anchor($viewDatas['list_action_url'], $label, $extras); + break; + } + return $label; +} diff --git a/app/Helpers/Mapurl_helper.php b/app/Helpers/Mapurl_helper.php index 3456d8b..988469c 100644 --- a/app/Helpers/Mapurl_helper.php +++ b/app/Helpers/Mapurl_helper.php @@ -116,44 +116,13 @@ function getListLabel_MapurlHelper(string $field, array $viewDatas, array $extra } return sprintf("%s", implode(" ", $extras), $label); } -function getListButtonLabel_MapurlHelper(string $action, string $label, array $viewDatas, array $extras = []): string -{ - switch ($viewDatas['action_form']) { - case FORMS['MODAL']: - $label = form_label( - $label, - "", - [ - "data-src" => $viewDatas['list_action_url'], - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - ...$extras - ] - ); - break; - case FORMS['IFRAME']: - if ($action == 'create') { - $label = form_label($label, "", [ - "onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')", - ...$extras, - ]); - } else { - $label = ""; - } - break; - default: - $label = anchor($viewDatas['list_action_url'], $label, $extras); - break; - } - return $label; -} function getListButton_MapurlHelper(string $action, array $viewDatas, array $extras = []): string { switch ($action) { case 'create': $viewDatas['list_action_url'] = current_url() . '/' . $action; $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; - $action = getListButtonLabel_MapurlHelper($action, '입력', $viewDatas, $extras); + $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras); break; case 'modify': $pk = $viewDatas['entity']->getPK(); @@ -165,7 +134,7 @@ function getListButton_MapurlHelper(string $action, array $viewDatas, array $ext "checked" => in_array($pk, old("batchjob_uids", [])) ]); $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); - $action = $checkbox . getListButtonLabel_MapurlHelper($action, $viewDatas['cnt'], $viewDatas, $extras); + $action = $checkbox . getListButtonLabel_CommonHelper($action, $viewDatas['cnt'], $viewDatas, $extras); break; case 'delete': $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); diff --git a/app/Helpers/User_helper.php b/app/Helpers/User_helper.php index 657af84..816abba 100644 --- a/app/Helpers/User_helper.php +++ b/app/Helpers/User_helper.php @@ -142,44 +142,13 @@ function getListLabel_UserHelper(string $field, array $viewDatas, array $extras } return sprintf("%s", implode(" ", $extras), $label); } -function getListButtonLabel_UserHelper(string $action, string $label, array $viewDatas, array $extras = []): string -{ - switch ($viewDatas['action_form']) { - case FORMS['MODAL']: - $label = form_label( - $label, - "", - [ - "data-src" => $viewDatas['list_action_url'], - "data-bs-toggle" => "modal", - "data-bs-target" => "#index_action_form", - ...$extras - ] - ); - break; - case FORMS['IFRAME']: - if ($action == 'create') { - $label = form_label($label, "", [ - "onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')", - ...$extras, - ]); - } else { - $label = ""; - } - break; - default: - $label = anchor($viewDatas['list_action_url'], $label, $extras); - break; - } - return $label; -} function getListButton_UserHelper(string $action, array $viewDatas, array $extras = []): string { switch ($action) { case 'create': $viewDatas['list_action_url'] = current_url() . '/' . $action; $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; - $action = getListButtonLabel_UserHelper($action, '입력', $viewDatas, $extras); + $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras); break; case 'modify': $pk = $viewDatas['entity']->getPK(); @@ -190,9 +159,8 @@ function getListButton_UserHelper(string $action, array $viewDatas, array $extra "class" => "batchjobuids_checkboxs", "checked" => in_array($pk, old("batchjob_uids", [])) ]); - $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); - $action = $checkbox . getListButtonLabel_UserHelper($action, $viewDatas['cnt'], $viewDatas, $extras); + $action = $checkbox . getListButtonLabel_CommonHelper($action, $viewDatas['cnt'], $viewDatas, $extras); break; case 'delete': $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); diff --git a/app/Libraries/MySocket/CloudflareSocket.php b/app/Libraries/MySocket/CloudflareSocket.php index 124333e..9c25534 100644 --- a/app/Libraries/MySocket/CloudflareSocket.php +++ b/app/Libraries/MySocket/CloudflareSocket.php @@ -16,14 +16,11 @@ class CloudflareSocket extends MySocket parent::__construct([ 'base_uri' => 'https://api.cloudflare.com/client/v4/', 'headers' => [ - 'X-Auth-Email' => $auth_entity->getID(), // 인증 토큰 사용 - 'X-Auth-Key' => $auth_entity->getAuthKey(), // 인증 토큰 사용 + 'X-Auth-Email' => $auth_entity->getID(), + 'X-Auth-Key' => $auth_entity->getAuthKey(), 'Content-Type' => 'application/json', ] ]); - self::$_request_max = getenv("cfmgr.request.max") ?: 1000; - self::$_request_perpage_max = getenv("cfmgr.request.perpage.max") ?: 700; - self::$_request_timewait = getenv("cfmgr.request.timewait") ?: 60; } final public function request(string $method, $uri = '', array $options = []): ResponseInterface diff --git a/app/Views/layouts/admin/top.php b/app/Views/layouts/admin/top.php index e641fab..15af1b8 100644 --- a/app/Views/layouts/admin/top.php +++ b/app/Views/layouts/admin/top.php @@ -22,19 +22,20 @@ diff --git a/app/Views/layouts/front/top.php b/app/Views/layouts/front/top.php index a5e2fde..d1af82c 100644 --- a/app/Views/layouts/front/top.php +++ b/app/Views/layouts/front/top.php @@ -22,18 +22,19 @@