diff --git a/app/Controllers/Admin/Cloudflare/API/APIController.php b/app/Controllers/Admin/Cloudflare/API/APIController.php index 4fe11f7..ca9f885 100644 --- a/app/Controllers/Admin/Cloudflare/API/APIController.php +++ b/app/Controllers/Admin/Cloudflare/API/APIController.php @@ -87,14 +87,34 @@ class APIController extends \App\Controllers\Admin\Cloudflare\CloudflareControll { return $entity; } - final public function sync($uid) + protected function sync_procedure($uid) { + $entity = $this->_model->getEntity($uid); try { - $entity = $this->_model->getEntity($uid); $entity = $this->sync_process($entity); return alert_CommonHelper("{$this->_viewDatas['title']} " . __FUNCTION__ . " 완료하였습니다.", session()->get(RETURN_URL)); } catch (\Exception $e) { return alert_CommonHelper($e->getMessage(), 'back'); } } + //Reload관련 + protected function reload_process($entity) + { + return $entity; + } + protected function reload_procedure($uid) + { + $entity = $this->_model->getEntity($uid); + try { + $entity = $this->reload_process($entity); + $message = __FUNCTION__ . " 완료하였습니다."; + Log::save("{$this->_viewDatas['title']} {$message}"); + return alert_CommonHelper("{$this->_viewDatas['title']} " . __FUNCTION__ . " 완료하였습니다.", session()->get(RETURN_URL)); + } catch (\Exception $e) { + $message = "{$entity->getTitle()} " . __FUNCTION__ . " 실패하였습니다."; + Log::add("warning", $e->getMessage()); + Log::save("{$this->_viewDatas['title']} {$message}", false); + return alert_CommonHelper($e->getMessage(), 'back'); + } + } } diff --git a/app/Controllers/Admin/Cloudflare/API/AccountController.php b/app/Controllers/Admin/Cloudflare/API/AccountController.php index 507f47a..2e45207 100644 --- a/app/Controllers/Admin/Cloudflare/API/AccountController.php +++ b/app/Controllers/Admin/Cloudflare/API/AccountController.php @@ -53,21 +53,59 @@ class AccountController extends APIController } } + ////Action 모음 + //Insert관련 + // final public function insert() + // { + // return $this->insert_procedure(); + // } + //Update관련 + // final public function update($uid) + // { + // return $this->update_procedure($uid); + // } + //Toggle관련 + // final public function toggle($uid, string $field) + // { + // return $this->toggle_procedure($uid, $field); + // } + //Batchjob 관련 + // final public function batchjob() + // { + // return $this->batchjob_procedure(); + // } + //Delete 관련 + // final public function delete($uid) + // { + // return $this->delete_procedure($uid); + // } + //View 관련 + // final public function view($uid) + // { + // return $this->view_procedure($uid); + // } + //Index 관련 + final public function index() + { + return $this->index_procedure(); + } + //Excel 관련 + final public function excel() + { + return $this->excel_procedure(); + } + ////API Action //Reload관련 + protected function reload_process($entity) + { + //Zone Reload + $zoneApi = new \App\Libraries\Cloudflare\API\Zone($entity, false); + $zoneApi->reload(); + + return $entity; + } final public function reload($uid) { - try { - $entity = $this->_model->getEntity($uid); - $zoneApi = new \App\Libraries\Cloudflare\API\Zone($entity, false); - $zoneApi->reload(); - $message = __FUNCTION__ . " 완료하였습니다."; - Log::save("{$this->_viewDatas['title']} {$message}"); - return alert_CommonHelper("{$this->_viewDatas['title']} " . __FUNCTION__ . " 완료하였습니다.", session()->get(RETURN_URL)); - } catch (\Exception $e) { - $message = "{$entity->getTitle()} " . __FUNCTION__ . " 실패하였습니다."; - Log::add("warning", $e->getMessage()); - Log::save("{$this->_viewDatas['title']} {$message}", false); - return alert_CommonHelper($e->getMessage(), 'back'); - } + return $this->reload_procedure($uid); } } diff --git a/app/Controllers/Admin/Cloudflare/API/AuthController.php b/app/Controllers/Admin/Cloudflare/API/AuthController.php index 0130839..360fc77 100644 --- a/app/Controllers/Admin/Cloudflare/API/AuthController.php +++ b/app/Controllers/Admin/Cloudflare/API/AuthController.php @@ -85,21 +85,60 @@ class AuthController extends APIController $this->getAccountModel()->setStatusByAuth($entity->getPrimaryKey(), $this->_viewDatas['fieldDatas']['status']); return parent::batchjob_process($entity); } + + ////Action 모음 + //Insert관련 + final public function insert() + { + return $this->insert_procedure(); + } + //Update관련 + final public function update($uid) + { + return $this->update_procedure($uid); + } + //Toggle관련 + final public function toggle($uid, string $field) + { + return $this->toggle_procedure($uid, $field); + } + //Batchjob 관련 + // final public function batchjob() + // { + // return $this->batchjob_procedure(); + // } + //Delete 관련 + // final public function delete($uid) + // { + // return $this->delete_procedure($uid); + // } + //View 관련 + final public function view($uid) + { + return $this->view_procedure($uid); + } + //Index 관련 + final public function index() + { + return $this->index_procedure(); + } + //Excel 관련 + final public function excel() + { + return $this->excel_procedure(); + } + ////API Action //Reload관련 + protected function reload_process($entity) + { + //Account Reload + $accountApi = new \App\Libraries\Cloudflare\API\Account($entity); + $accountApi->reload(); + return $entity; + } final public function reload($uid) { - try { - $entity = $this->_model->getEntity($uid); - $accountApi = new \App\Libraries\Cloudflare\API\Account($entity); - $accountApi->reload(); - $message = __FUNCTION__ . " 완료하였습니다."; - Log::save("{$this->_viewDatas['title']} {$message}"); - return alert_CommonHelper("{$this->_viewDatas['title']} " . __FUNCTION__ . " 완료하였습니다.", session()->get(RETURN_URL)); - } catch (\Exception $e) { - $message = "{$entity->getTitle()} " . __FUNCTION__ . " 실패하였습니다."; - Log::add("warning", $e->getMessage()); - Log::save("{$this->_viewDatas['title']} {$message}", false); - return alert_CommonHelper($e->getMessage(), 'back'); - } + return $this->reload_procedure($uid); } + ////추가 Action } diff --git a/app/Controllers/Admin/Cloudflare/API/FirewallController.php b/app/Controllers/Admin/Cloudflare/API/FirewallController.php index 2c20afc..4c3fb97 100644 --- a/app/Controllers/Admin/Cloudflare/API/FirewallController.php +++ b/app/Controllers/Admin/Cloudflare/API/FirewallController.php @@ -131,4 +131,59 @@ class FirewallController extends APIController { return $this->index_getRows_builder($page, $per_page); } + + ////Action 모음 + //Insert관련 + // final public function insert() + // { + // return $this->insert_procedure(); + // } + //Update관련 + // final public function update($uid) + // { + // return $this->update_procedure($uid); + // } + //Toggle관련 + final public function toggle($uid, string $field) + { + return $this->toggle_procedure($uid, $field); + } + //Batchjob 관련 + final public function batchjob() + { + return $this->batchjob_procedure(); + } + //Delete 관련 + // final public function delete($uid) + // { + // return $this->delete_procedure($uid); + // } + //View 관련 + // final public function view($uid) + // { + // return $this->view_procedure($uid); + // } + //Index 관련 + final public function index() + { + return $this->index_procedure(); + } + //Excel 관련 + final public function excel() + { + return $this->excel_procedure(); + } + ////API Action + //Sync관련 + protected function sync_process($entity) + { + $api = new Firewall($this->getZoneModel()->getEntity($entity->getParentFieldData())); + $entity = $api->sync($entity); + return parent::sync_process($entity); + } + final public function sync($uid) + { + return $this->sync_procedure($uid); + } + ////추가 Action } diff --git a/app/Controllers/Admin/Cloudflare/API/RecordController.php b/app/Controllers/Admin/Cloudflare/API/RecordController.php index 23461c3..9b5563c 100644 --- a/app/Controllers/Admin/Cloudflare/API/RecordController.php +++ b/app/Controllers/Admin/Cloudflare/API/RecordController.php @@ -101,7 +101,6 @@ class RecordController extends APIController ); } } - //Update관련 protected function update_process($entity) { @@ -130,13 +129,6 @@ class RecordController extends APIController $api->delete($entity); return parent::delete_process($entity); } - //Sync관련 - protected function sync_process($entity) - { - $api = new Record($this->getZoneModel()->getEntity($entity->getParentFieldData())); - $entity = $api->sync($entity); - return parent::sync_process($entity); - } //Index관련 private function index_setCondition_builder($builder) { @@ -185,6 +177,61 @@ class RecordController extends APIController { return $this->index_getRows_builder($page, $per_page); } + + ////Action 모음 + //Insert관련 + final public function insert() + { + return $this->insert_procedure(); + } + //Update관련 + final public function update($uid) + { + return $this->update_procedure($uid); + } + //Toggle관련 + final public function toggle($uid, string $field) + { + return $this->toggle_procedure($uid, $field); + } + //Batchjob 관련 + final public function batchjob() + { + return $this->batchjob_procedure(); + } + //Delete 관련 + final public function delete($uid) + { + return $this->delete_procedure($uid); + } + //View 관련 + // final public function view($uid) + // { + // return $this->view_procedure($uid); + // } + //Index 관련 + final public function index() + { + return $this->index_procedure(); + } + //Excel 관련 + final public function excel() + { + return $this->excel_procedure(); + } + ////API Action + //Sync관련 + protected function sync_process($entity) + { + $api = new Record($this->getZoneModel()->getEntity($entity->getParentFieldData())); + $entity = $api->sync($entity); + return parent::sync_process($entity); + } + final public function sync($uid) + { + return $this->sync_procedure($uid); + } + ////추가 Action //CDN고정관련 final public function cdnToggle(string $uid) { diff --git a/app/Controllers/Admin/Cloudflare/API/ZoneController.php b/app/Controllers/Admin/Cloudflare/API/ZoneController.php index db9edda..d559401 100644 --- a/app/Controllers/Admin/Cloudflare/API/ZoneController.php +++ b/app/Controllers/Admin/Cloudflare/API/ZoneController.php @@ -149,35 +149,6 @@ class ZoneController extends APIController $api->delete($entity); return parent::delete_process($entity); } - //일괄삭제관련 - final public function batchjob_delete() - { - $message = ""; - try { - $uids = $this->request->getVar('batchjob_uids'); - if (!is_array($uids) || count($uids) === 0) { - throw new \Exception($this->_viewDatas['title'] . '가 uid가 선택되지 않았습니다.'); - } - foreach ($uids as $uid) { - $this->delete_process($this->_model->getEntity($uid)); - } - $message = "총:" . count($uids) . "개의 삭제 완료하였습니다."; - Log::save("{$this->_viewDatas['title']} {$message}"); - return alert_CommonHelper($message, session()->get(RETURN_URL)); - } catch (\Exception $e) { - $message = "삭제 실패하였습니다."; - Log::add("warning", $message . "\n" . $e->getMessage()); - Log::save("{$this->_viewDatas['title']} {$message}", false); - return alert_CommonHelper($message . "\n" . $e->getMessage(), 'back'); - } - } - //Sync관련 - protected function sync_process($entity) - { - $api = new Zone($this->getAccountModel()->getEntity($entity->getParentFieldData())); - $entity = $api->sync($entity); - return parent::sync_process($entity); - } //Index관련 private function index_setCondition_builder($builder) { @@ -227,24 +198,96 @@ class ZoneController extends APIController { return parent::index_getRows($page, $per_page); } + + ////Action 모음 + //Insert관련 + final public function insert() + { + return $this->insert_procedure(); + } + //Update관련 + final public function update($uid) + { + return $this->update_procedure($uid); + } + //Toggle관련 + final public function toggle($uid, string $field) + { + return $this->toggle_procedure($uid, $field); + } + //Batchjob 관련 + final public function batchjob() + { + return $this->batchjob_procedure(); + } + //Delete 관련 + final public function delete($uid) + { + return $this->delete_procedure($uid); + } + //View 관련 + // final public function view($uid) + // { + // return $this->view_procedure($uid); + // } + //Index 관련 + final public function index() + { + return $this->index_procedure(); + } + //Excel 관련 + final public function excel() + { + return $this->excel_procedure(); + } + ////API Action + //Sync관련 + protected function sync_process($entity) + { + $api = new Zone($this->getAccountModel()->getEntity($entity->getParentFieldData())); + $entity = $api->sync($entity); + return parent::sync_process($entity); + } + final public function sync($uid) + { + return $this->sync_procedure($uid); + } //Reload관련 + protected function reload_process($entity) + { + //Record Reload + $recordApi = new \App\Libraries\Cloudflare\API\Record($entity); + $recordApi->reload(); + //Firewall Reload + // $firewallApi = new \App\Libraries\Cloudflare\API\Firewall($entity); + // $firewallApi->reload(); + return $entity; + } final public function reload($uid) { + return $this->reload_procedure($uid); + } + ////추가 Action + //일괄삭제관련 + final public function batchjob_delete() + { + $message = ""; try { - $entity = $this->_model->getEntity($uid); - $recordApi = new \App\Libraries\Cloudflare\API\Record($entity); - $recordApi->reload(); - //Firewall Reload - $firewallApi = new \App\Libraries\Cloudflare\API\Firewall($entity); - $firewallApi->reload(); - $message = __FUNCTION__ . " 완료하였습니다."; + $uids = $this->request->getVar('batchjob_uids'); + if (!is_array($uids) || count($uids) === 0) { + throw new \Exception($this->_viewDatas['title'] . '가 uid가 선택되지 않았습니다.'); + } + foreach ($uids as $uid) { + $this->delete_process($this->_model->getEntity($uid)); + } + $message = "총:" . count($uids) . "개의 삭제 완료하였습니다."; Log::save("{$this->_viewDatas['title']} {$message}"); - return alert_CommonHelper("{$this->_viewDatas['title']} " . __FUNCTION__ . " 완료하였습니다.", session()->get(RETURN_URL)); + return alert_CommonHelper($message, session()->get(RETURN_URL)); } catch (\Exception $e) { - $message = "{$entity->getTitle()} " . __FUNCTION__ . " 실패하였습니다."; - Log::add("warning", $e->getMessage()); + $message = "삭제 실패하였습니다."; + Log::add("warning", $message . "\n" . $e->getMessage()); Log::save("{$this->_viewDatas['title']} {$message}", false); - return alert_CommonHelper($e->getMessage(), 'back'); + return alert_CommonHelper($message . "\n" . $e->getMessage(), 'back'); } } } diff --git a/app/Controllers/Admin/LoggerController.php b/app/Controllers/Admin/LoggerController.php index 978b4bf..1782688 100644 --- a/app/Controllers/Admin/LoggerController.php +++ b/app/Controllers/Admin/LoggerController.php @@ -63,4 +63,46 @@ class LoggerController extends \App\Controllers\Admin\AdminController break; } } + + ////Action 모음 + //Insert관련 + final public function insert() + { + return $this->insert_procedure(); + } + //Update관련 + final public function update($uid) + { + return $this->update_procedure($uid); + } + //Toggle관련 + final public function toggle($uid, string $field) + { + return $this->toggle_procedure($uid, $field); + } + //Batchjob 관련 + // final public function batchjob() + // { + // return $this->batchjob_procedure(); + // } + //Delete 관련 + // final public function delete($uid) + // { + // return $this->delete_procedure($uid); + // } + //View 관련 + final public function view($uid) + { + return $this->view_procedure($uid); + } + //Index 관련 + final public function index() + { + return $this->index_procedure(); + } + //Excel 관련 + final public function excel() + { + return $this->excel_procedure(); + } } diff --git a/app/Controllers/Admin/MapurlController.php b/app/Controllers/Admin/MapurlController.php index 22eaef8..1f716a7 100644 --- a/app/Controllers/Admin/MapurlController.php +++ b/app/Controllers/Admin/MapurlController.php @@ -117,4 +117,46 @@ class MapurlController extends \App\Controllers\Admin\AdminController $entity = parent::delete_process($entity); $this->remapurl(); //MapURL용 index.html 생성 } + + ////Action 모음 + //Insert관련 + final public function insert() + { + return $this->insert_procedure(); + } + //Update관련 + final public function update($uid) + { + return $this->update_procedure($uid); + } + //Toggle관련 + final public function toggle($uid, string $field) + { + return $this->toggle_procedure($uid, $field); + } + //Batchjob 관련 + final public function batchjob() + { + return $this->batchjob_procedure(); + } + //Delete 관련 + final public function delete($uid) + { + return $this->delete_procedure($uid); + } + //View 관련 + final public function view($uid) + { + return $this->view_procedure($uid); + } + //Index 관련 + final public function index() + { + return $this->index_procedure(); + } + //Excel 관련 + final public function excel() + { + return $this->excel_procedure(); + } } diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index dcb8537..db1ee15 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -73,4 +73,46 @@ class UserController extends \App\Controllers\Admin\AdminController $entity->passwd = password_hash($entity->passwd, PASSWORD_DEFAULT); return parent::update_process($entity); } + + ////Action 모음 + //Insert관련 + final public function insert() + { + return $this->insert_procedure(); + } + //Update관련 + final public function update($uid) + { + return $this->update_procedure($uid); + } + //Toggle관련 + final public function toggle($uid, string $field) + { + return $this->toggle_procedure($uid, $field); + } + //Batchjob 관련 + final public function batchjob() + { + return $this->batchjob_procedure(); + } + //Delete 관련 + final public function delete($uid) + { + return $this->delete_procedure($uid); + } + //View 관련 + final public function view($uid) + { + return $this->view_procedure($uid); + } + //Index 관련 + final public function index() + { + return $this->index_procedure(); + } + //Excel 관련 + final public function excel() + { + return $this->excel_procedure(); + } } diff --git a/app/Controllers/Common/CommonController.php b/app/Controllers/Common/CommonController.php index 2e6812d..2515177 100644 --- a/app/Controllers/Common/CommonController.php +++ b/app/Controllers/Common/CommonController.php @@ -122,7 +122,7 @@ class CommonController extends BaseController throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors(), true)); } } - final public function insert() + protected function insert_procedure() { $message = ""; try { @@ -199,7 +199,7 @@ class CommonController extends BaseController } return $entity; } - final public function update($uid) + protected function update_procedure($uid) { $entity = $this->_model->getEntity($uid); $message = ""; @@ -254,7 +254,7 @@ class CommonController extends BaseController } return $entity; } - public function toggle($uid, string $field) + protected function toggle_procedure($uid, string $field) { $entity = $this->_model->getEntity($uid); $message = ""; @@ -319,7 +319,7 @@ class CommonController extends BaseController } return $entity; } - final public function batchjob() + protected function batchjob_procedure() { $message = ""; $uids = array(); @@ -352,7 +352,7 @@ class CommonController extends BaseController $this->_model->delete($entity->getPrimaryKey()); return $entity; } - final public function delete($uid) + protected function delete_procedure($uid) { $entity = $this->_model->getEntity($uid); $message = ""; @@ -383,7 +383,7 @@ class CommonController extends BaseController { return $entity; } - final public function view($uid) + protected function view_procedure($uid) { try { $entity = $this->_model->getEntity($uid); @@ -484,7 +484,7 @@ class CommonController extends BaseController //pagenation 처리 $this->_viewDatas['pagination'] = $this->index_getPagination(); } - final public function index() + protected function index_procedure() { try { $this->index_init(); @@ -538,7 +538,7 @@ class CommonController extends BaseController header(sprintf("Content-Disposition: attachment; filename=%s", urlencode($fileName))); return $writer->save('php://output'); } - final public function excel() + protected function excel_procedure() { try { $this->excel_init(); diff --git a/app/Views/admin/cloudflare/api/firewall/index.php b/app/Views/admin/cloudflare/api/firewall/index.php index fb7c553..bf79848 100644 --- a/app/Views/admin/cloudflare/api/firewall/index.php +++ b/app/Views/admin/cloudflare/api/firewall/index.php @@ -16,7 +16,6 @@