cfmgrv4 init...2

This commit is contained in:
최준흠 2024-10-15 17:53:21 +09:00
parent c70ab29ef7
commit ff80c95c44
23 changed files with 306 additions and 307 deletions

View File

@ -33,6 +33,7 @@ $routes->group('admin/mapurl', ['namespace' => 'App\Controllers\Admin', 'filter'
$routes->post('create', 'MapurlController::create');
$routes->get('modify/(:num)', 'MapurlController::modify_form/$1');
$routes->post('modify/(:num)', 'MapurlController::modify/$1');
$routes->get('view/(:num)', 'MapurlController::view/$1');
$routes->get('delete/(:num)', 'MapurlController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'MapurlController::toggle/$1/$2');
$routes->post('batchjob', 'MapurlController::batcjob');
@ -44,6 +45,7 @@ $routes->group('admin/user', ['namespace' => 'App\Controllers\Admin', 'filter' =
$routes->post('create', 'UserController::create');
$routes->get('modify/(:num)', 'UserController::modify_form/$1');
$routes->post('modify/(:num)', 'UserController::modify/$1');
$routes->get('view/(:num)', 'UserController::view/$1');
$routes->get('delete/(:num)', 'UserController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'UserController::toggle/$1/$2');
$routes->post('batchjob', 'UserController::batcjob');
@ -63,6 +65,7 @@ $routes->group('admin/cloudflare', ['namespace' => 'App\Controllers\Admin\Cloudf
$routes->get('create', 'AuthController::create_form');
$routes->post('create', 'AuthController::create');
$routes->get('modify/(:num)', 'AuthController::modify_form/$1');
$routes->get('view/(:num)', 'AuthController::view/$1');
$routes->get('delete/(:num)', 'AuthController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'AuthController::toggle/$1/$2');
$routes->post('batchjob', 'AuthController::batcjob');
@ -77,6 +80,7 @@ $routes->group('admin/cloudflare', ['namespace' => 'App\Controllers\Admin\Cloudf
$routes->get('/', 'ZoneController::index');
$routes->get('create', 'ZoneController::create_form');
$routes->post('create', 'ZoneController::create');
$routes->get('view/(:alphanum)', 'ZoneController::view/$1');
$routes->get('delete/(:alphanum)', 'ZoneController::delete/$1');
$routes->get('sync/(:alphanum)', 'ZoneController::sync/$1');
$routes->get('toggle/(:alphanum)/(:any)', 'ZoneController::toggle/$1/$2');
@ -88,6 +92,7 @@ $routes->group('admin/cloudflare', ['namespace' => 'App\Controllers\Admin\Cloudf
$routes->get('/', 'RecordController::index');
$routes->get('create', 'RecordController::create_form');
$routes->post('create', 'RecordController::create');
$routes->get('view/(:alphanum)', 'RecordController::view/$1');
$routes->get('delete/(:alphanum)', 'RecordController::delete/$1');
$routes->get('sync/(:alphanum)', 'RecordController::sync/$1');
$routes->get('toggle/(:alphanum)/(:any)', 'RecordController::toggle/$1/$2');

View File

@ -65,7 +65,7 @@ class AccountController extends CloudflareController
return $this->list_procedure();
}
// Download
public function download(string $output_type, $uid = false): DownloadResponse|string
public function download(string $output_type, mixed $uid = false): DownloadResponse|string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'status', 'updated_at', 'created_at'];
@ -78,7 +78,7 @@ class AccountController extends CloudflareController
//reload Account By Auth
protected function reload_process(mixed $uid): void
{
$this->_auth_entity = $this->getAuthModel()->getEntityByPK(intval($uid));
$this->_auth_entity = $this->getAuthModel()->getEntityByPK($uid);
if ($this->_auth_entity === null) {
throw new \Exception("Auth: {$uid} 정보를 찾을수 없습니다.");
}

View File

@ -48,12 +48,12 @@ class AuthController extends CloudflareController
return $this->create_procedure();
}
//수정
public function modify_form(string $uid): RedirectResponse|string
public function modify_form(int $uid): RedirectResponse|string
{
$this->init('modify');
return $this->modify_form_procedure($uid);
}
public function modify(string $uid): RedirectResponse|string
public function modify(int $uid): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->modify_procedure($uid);
@ -66,6 +66,12 @@ class AuthController extends CloudflareController
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
return $this->batcjob_procedure();
}
//View
public function view(int $uid): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->view_procedure($uid);
}
// 리스트
public function index(): string
{
@ -78,7 +84,7 @@ class AuthController extends CloudflareController
return $this->list_procedure();
}
// Download
public function download(string $output_type, $uid = false): DownloadResponse|string
public function download(string $output_type, mixed $uid = false): DownloadResponse|string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::TITLE, 'oldkey', 'status', 'updated_at', 'created_at'];

View File

@ -72,7 +72,7 @@ class RecordController extends CloudflareController
private function init(string $action): void
{
$this->action = $action;
$this->fields = [$this->getModel()::PARENT, 'type', 'content', 'proxied', 'hosts'];
$this->fields = [$this->getModel()::PARENT, 'hosts', 'type', 'content', 'proxied'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
@ -90,6 +90,10 @@ class RecordController extends CloudflareController
//hosts를 제외한 fields Valid처리
parent::create_validate($action, array_diff($fields, ['hosts']));
}
private function setEntitys(array $entitys): void
{
$this->entitys = $entitys;
}
protected function create_process(): void
{
//DB작업도 Socket에서 다 처리하므로 parent::create_process()하면 않됨
@ -102,7 +106,7 @@ class RecordController extends CloudflareController
foreach ($this->formDatas['hosts'] as $host) {
//호스트명 형식확인
if (!$this->helper->isHost($host)) {
throw new \Exception("{$this->_zone_entity->getTitle()}{$cnt}번째 {$host} 호스트명 형식 오류");
throw new \Exception("{$host} 호스트명 형식 오류");
}
$cnt++;
}
@ -118,16 +122,15 @@ class RecordController extends CloudflareController
log_message("debug", message: "Record:{$entity->getTitle()} 생성 작업을 완료하였습니다.");
$entitys[] = $entity;
}
$this->entitys = $entitys;
$this->setEntitys($entitys); // 새로운 메서드를 사용하여 entitys 설정
}
protected function create_result(): string
protected function create_process_result(): RedirectResponse|string
{
$this->fields = [$this->getModel()::PARENT, 'type', 'content', 'proxied', 'host'];
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'name_servers', 'original_name_servers', 'plan', 'development_mode', 'ipv6', 'security_level', 'status', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
return view(
$this->view_path . strtolower($this->class_path) . "/view",
data: ['viewDatas' => $this->getViewDatas()]
);
$this->filter_fields = [$this->getModel()::PARENT, 'development_mode', 'ipv6', 'security_level'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
return $this->view_process_result();
}
public function create(): RedirectResponse|string
{
@ -135,7 +138,7 @@ class RecordController extends CloudflareController
return $this->create_procedure();
}
//수정 (modify,toggle,batchjob사용)
protected function modify_process(string $uid): void
protected function modify_process(mixed $uid): void
{
//DB작업도 Socket에서 다 처리하므로 parent::modify_process($uid)하면 않됨
$this->modify_validate($this->action, $this->fields);
@ -158,13 +161,6 @@ class RecordController extends CloudflareController
$this->entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas);
}
}
protected function modify_result(): string
{
return view(
$this->view_path . strtolower($this->class_path) . "/view",
data: ['viewDatas' => $this->getViewDatas()]
);
}
//일괄처리작업
public function batcjob(): RedirectResponse
{
@ -173,25 +169,33 @@ class RecordController extends CloudflareController
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
return $this->batcjob_procedure();
}
//Sync작업
protected function sync_process(string $uid): void
//View
protected function view_process(mixed $uid): void
{
//자신정보정의
$this->entity = $this->getModel()->getEntityByPK($uid);
if ($this->entity === null) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
}
//부모데이터정의
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->entity->getParent());
//Socket처리
$this->entity = $this->getMyLibrary()->sync($this->entity);
//해당 Zone의 모든 Record를 가져오기
$this->getModel()->where($this->getModel()::PARENT, $uid);
$this->entitys = $this->getModel()->getEntitys();
}
public function sync(string $uid): RedirectResponse
protected function view_process_result(): string
{
return $this->sync_procedure($uid);
helper(['form']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return view(
strtolower($this->view_path . $this->class_path . "/view"),
data: ['viewDatas' => $this->getViewDatas()]
);
}
public function view(string $uid): RedirectResponse|string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'content', 'ttl', 'proxied', 'locked', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied', 'fixed'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
return $this->view_procedure($uid);
}
//삭제
protected function delete_process(string $uid): void
protected function delete_process(mixed $uid): void
{
//DB작업도 Socket에서 다 처리하므로 parent::delete_process($uid)하면 않됨
//자신정보정의
@ -245,7 +249,7 @@ class RecordController extends CloudflareController
return $this->list_procedure();
}
// Download
public function download(string $output_type, $uid = false): DownloadResponse|string
public function download(string $output_type, mixed $uid = false): DownloadResponse|string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'content', 'ttl', 'proxied', 'locked', 'updated_at', 'created_at'];
@ -255,6 +259,23 @@ class RecordController extends CloudflareController
$this->batchjob_fields = ['proxied'];
return $this->download_procedure($output_type, $uid);
}
//Sync작업
protected function sync_process(string $uid): void
{
//자신정보정의
$this->entity = $this->getModel()->getEntityByPK($uid);
if ($this->entity === null) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
}
//부모데이터정의
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->entity->getParent());
//Socket처리
$this->entity = $this->getMyLibrary()->sync($this->entity);
}
public function sync(string $uid): RedirectResponse
{
return $this->sync_procedure($uid);
}
//reload Record By Zone
protected function reload_process(mixed $uid): void
{

View File

@ -69,7 +69,7 @@ class ZoneController extends CloudflareController
}
break;
case 'hosts':
$formDatas[$field] = $this->request->getVar($field);
$formDatas[$field] = explode("\n", $this->request->getVar($field));
if (!is_array($formDatas[$field]) || !count($formDatas[$field])) {
throw new \Exception("호스트명이 정의되지 않았습니다");
}
@ -101,6 +101,10 @@ class ZoneController extends CloudflareController
//domains,hosts를 제외한 fields Valid처리
parent::create_validate($action, array_diff($fields, ['domains', 'hosts']));
}
private function setEntitys(array $entitys): void
{
$this->entitys = $entitys;
}
protected function create_process(): void
{
//DB작업도 Socket에서 다 처리하므로 parent::create_process()하면 않됨
@ -112,18 +116,18 @@ class ZoneController extends CloudflareController
//Type이 A형식일경우 IP형태인지 확인
if ($this->formDatas['type'] === 'A') {
if (!$this->helper->isIPAddress($this->formDatas['content'], $this->formDatas['type'])) {
throw new \Exception("{$this->_account_entity->getTitle()}{$this->formDatas['type']}, {$this->formDatas['content']} 형식 오류[사설IP 않됨]");
throw new \Exception("{$this->formDatas['type']}, {$this->formDatas['content']} 형식 오류[사설IP 않됨]");
}
}
$cnt = 1;
foreach ($this->formDatas['domains'] as $domain) {
//도메인명 형식확인
if (!$this->helper->isDomain($domain)) {
throw new \Exception("{$this->_account_entity->getTitle()}{$cnt}번째 {$domain} 형식 오류");
throw new \Exception("{$domain} 형식 오류");
}
//도메인명이 해당계정의 유일한 도메인인지 확인
if (!$this->getModel()->isUniqueDomain($this->_account_entity, $domain)) {
throw new \Exception("{$this->_account_entity->getTitle()}{$cnt}번째 {$domain}은 이미 등록된 도메인입니다.");
throw new \Exception("{$domain}은 이미 등록된 도메인입니다.");
}
$cnt++;
}
@ -131,7 +135,7 @@ class ZoneController extends CloudflareController
foreach ($this->formDatas['hosts'] as $host) {
//호스트명 형식확인
if (!$this->helper->isHost($host)) {
throw new \Exception("{$this->_account_entity->getTitle()}{$cnt}번째 {$host} 호스트명 형식 오류");
throw new \Exception("{$host} 호스트명 형식 오류");
}
$cnt++;
}
@ -146,7 +150,7 @@ class ZoneController extends CloudflareController
$cnt++;
}
//Record생성
$this->entitys = [];
$entitys = [];
foreach ($zone_entitys as $zone_entity) {
$record = new Record($zone_entity);
$record_entitys = [];
@ -161,15 +165,17 @@ class ZoneController extends CloudflareController
$record_entitys[] = $entity;
}
$zone_entity->records = $record_entitys;
$this->entitys[] = $zone_entity;
$entitys[] = $zone_entity;
}
$this->setEntitys($entitys);
}
protected function create_result(): string
protected function create_process_result(): RedirectResponse|string
{
return view(
$this->view_path . strtolower($this->class_path) . DIRECTORY_SEPARATOR . "view",
data: ['viewDatas' => $this->getViewDatas()]
);
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'name_servers', 'original_name_servers', 'plan', 'development_mode', 'ipv6', 'security_level', 'status', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'development_mode', 'ipv6', 'security_level'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
return $this->view_process_result();
}
public function create(): RedirectResponse|string
{
@ -177,7 +183,7 @@ class ZoneController extends CloudflareController
return $this->create_procedure();
}
//수정 (modify,toggle,batchjob사용)
protected function modify_process(string $uid): void
protected function modify_process(mixed $uid): void
{
//DB작업도 Socket에서 다 처리하므로 parent::modify_process($uid)하면 않됨
$this->modify_validate($this->action, $this->fields);
@ -192,13 +198,6 @@ class ZoneController extends CloudflareController
//Socket처리
$this->entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas);
}
protected function modify_result(): string
{
return view(
$this->view_path . strtolower($this->class_path) . DIRECTORY_SEPARATOR . "view",
data: ['viewDatas' => $this->getViewDatas()]
);
}
//일괄처리작업
public function batcjob(): RedirectResponse
{
@ -207,25 +206,38 @@ class ZoneController extends CloudflareController
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
return $this->batcjob_procedure();
}
//Sync작업
protected function sync_process(mixed $uid): void
//View
protected function view_process(mixed $uid): void
{
//자신정보정의
$this->entity = $this->getModel()->getEntityByPK($uid);
if ($this->entity === null) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
//해당 Account의 모든 Zone를 가져오기
$this->getModel()->where($this->getModel()::PARENT, $uid);
$entitys = $this->getModel()->getEntitys();
foreach ($entitys as $entity) {
$this->getRecordModel()->where($this->getRecordModel()::PARENT, $entity->getPK());
$entity->records = $this->getRecordModel()->getEntitys();
}
//부모데이터정의
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent());
//Socket처리
$this->entity = $this->getMyLibrary()->sync($this->entity);
$this->entitys = $entitys;
}
public function sync(string $uid): RedirectResponse
protected function view_process_result(): string
{
return $this->sync_procedure($uid);
helper(['form']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return view(
strtolower($this->view_path . $this->class_path . "/view"),
data: ['viewDatas' => $this->getViewDatas()]
);
}
public function view(string $uid): RedirectResponse|string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'name_servers', 'original_name_servers', 'plan', 'development_mode', 'ipv6', 'security_level', 'status', 'updated_at', 'created_at'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'development_mode', 'ipv6', 'security_level'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
return $this->view_procedure($uid);
}
//삭제
protected function delete_process(string $uid): void
protected function delete_process(mixed $uid): void
{
//DB작업도 Socket에서 다 처리하므로 parent::delete_process($uid)하면 않됨
//자신정보정의
@ -233,9 +245,15 @@ class ZoneController extends CloudflareController
if ($this->entity === null) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
}
//Record부터 삭제필요
$this->getRecordModel()->where($this->getRecordModel()::PARENT, $this->entity->getPK());
foreach ($this->getRecordModel()->getEntitys() as $record_entity) {
$record = new Record($this->entity);
$record->delete($record_entity);
}
//Zone 삭제
//부모데이터정의
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent());
//Cloudflare 삭제
$this->entity = $this->getMyLibrary()->delete($this->entity);
}
// 리스트
@ -279,7 +297,7 @@ class ZoneController extends CloudflareController
return $this->list_procedure();
}
// Download
public function download(string $output_type, $uid = false): DownloadResponse|string
public function download(string $output_type, mixed $uid = false): DownloadResponse|string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'name_servers', 'original_name_servers', 'plan', 'development_mode', 'ipv6', 'security_level', 'status', 'updated_at', 'created_at'];
@ -289,6 +307,23 @@ class ZoneController extends CloudflareController
$this->batchjob_fields = ['development_mode', 'ipv6', 'security_level'];
return $this->download_procedure($output_type, $uid);
}
//Sync작업
protected function sync_process(mixed $uid): void
{
//자신정보정의
$this->entity = $this->getModel()->getEntityByPK($uid);
if ($this->entity === null) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
}
//부모데이터정의
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent());
//Socket처리
$this->entity = $this->getMyLibrary()->sync($this->entity);
}
public function sync(string $uid): RedirectResponse
{
return $this->sync_procedure($uid);
}
//reload Zone By Account
protected function reload_process(mixed $uid): void
{

View File

@ -89,18 +89,18 @@ class MapurlController extends AdminController
return $this->create_procedure();
}
//수정
public function modify_form(string $uid): RedirectResponse|string
public function modify_form(int $uid): RedirectResponse|string
{
$this->init('modify');
return $this->modify_form_procedure($uid);
}
//(modify,toggle,batchjob사용)
protected function modify_process(string $uid): void
protected function modify_process(mixed $uid): void
{
parent::modify_process($uid);
$this->remaping_process();
}
public function modify(string $uid): RedirectResponse|string
public function modify(int $uid): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->modify_procedure($uid);
@ -113,8 +113,14 @@ class MapurlController extends AdminController
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
return $this->batcjob_procedure();
}
//View
public function view(int $uid): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->view_procedure($uid);
}
//삭제
protected function delete_process(string $uid): void
protected function delete_process(mixed $uid): void
{
parent::delete_process($uid);
$this->remaping_process();
@ -132,7 +138,7 @@ class MapurlController extends AdminController
}
// Download
public function download(string $output_type, $uid = false): DownloadResponse|string
public function download(string $output_type, mixed $uid = false): DownloadResponse|string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::TITLE, 'newurl', 'status'];

View File

@ -100,12 +100,12 @@ class UserController extends AdminController
return $this->create_procedure();
}
//수정
public function modify_form(string $uid): RedirectResponse|string
public function modify_form(int $uid): RedirectResponse|string
{
$this->init('modify');
return $this->modify_form_procedure($uid);
}
public function modify(string $uid): RedirectResponse|string
public function modify(int $uid): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->modify_procedure($uid);
@ -118,6 +118,12 @@ class UserController extends AdminController
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
return $this->batcjob_procedure();
}
//View
public function view(int $uid): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->view_procedure($uid);
}
// 리스트
public function index(): string
{
@ -130,7 +136,7 @@ class UserController extends AdminController
return $this->list_procedure();
}
// Download
public function download(string $output_type, $uid = false): DownloadResponse|string
public function download(string $output_type, mixed $uid = false): DownloadResponse|string
{
$this->action = __FUNCTION__;
$this->fields = ['id', $this->getModel()::TITLE, 'email', 'mobile', 'role', 'status'];

View File

@ -74,12 +74,12 @@ class UserSNSController extends AdminController
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
}
//수정
public function modify_form(string $uid): RedirectResponse|string
public function modify_form(int $uid): RedirectResponse|string
{
$this->init('modify');
return $this->modify_form_procedure($uid);
}
public function modify(string $uid): RedirectResponse|string
public function modify(int $uid): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->modify_procedure($uid);
@ -104,7 +104,7 @@ class UserSNSController extends AdminController
return $this->list_procedure();
}
// Download
public function download(string $output_type, $uid = false): DownloadResponse|string
public function download(string $output_type, mixed $uid = false): DownloadResponse|string
{
$this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, 'site', 'id', $this->getModel()::TITLE, 'email', 'status'];

View File

@ -77,9 +77,7 @@ abstract class MVController extends CommonController
return $formDatas;
}
// 생성
protected function create_form_process(): void
{
}
protected function create_form_process(): void {}
final protected function create_form_procedure(): RedirectResponse|string
{
try {
@ -112,12 +110,10 @@ abstract class MVController extends CommonController
$this->formDatas = $this->getFormDatas();
$this->entity = $this->getModel()->create(formDatas: $this->formDatas);
}
protected function create_result(): string
protected function create_process_result(): RedirectResponse|string
{
return view(
$this->view_path . "view",
data: ['viewDatas' => $this->getViewDatas()]
);
$url = strtolower(base_url() . $this->uri_path . "/" . $this->class_path . "/view/" . $this->entity->getPK());
return redirect()->to($url)->with('error', $this->message);
}
final protected function create_procedure(): RedirectResponse|string
{
@ -128,7 +124,8 @@ abstract class MVController extends CommonController
$this->create_process();
$this->getModel()->transCommit();
$this->message = "{$this->class_name} : 생성작업이 완료되었습니다.";
return $this->create_result();
log_message("notice", $this->message);
return $this->create_process_result();
} catch (\Exception $e) {
//Transaction Rollback
$this->getModel()->transRollback();
@ -137,14 +134,14 @@ abstract class MVController extends CommonController
}
}
// 수정
protected function modify_form_process(string $uid): void
protected function modify_form_process(mixed $uid): void
{
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
$this->entity = $this->getModel()->getEntityByPK($uid);
if ($this->entity === null) {
throw new \Exception("해당 정보를 찾을수 없습니다.");
}
}
final protected function modify_form_procedure(string $uid): RedirectResponse|string
final protected function modify_form_procedure(mixed $uid): RedirectResponse|string
{
try {
helper(['form']);
@ -170,7 +167,7 @@ abstract class MVController extends CommonController
));
}
}
protected function modify_process(string $uid): void
protected function modify_process(mixed $uid): void
{
$this->modify_validate($this->action, $this->fields);
$this->formDatas = $this->getFormDatas();
@ -181,14 +178,12 @@ abstract class MVController extends CommonController
}
$this->entity = $this->getModel()->modify($this->entity, $this->formDatas);
}
protected function modify_result(): string
protected function modify_process_result(): RedirectResponse|string
{
return view(
$this->view_path . "view",
data: ['viewDatas' => $this->getViewDatas()]
);
$url = strtolower(base_url() . $this->uri_path . "/" . $this->class_path . "/view/" . $this->entity->getPK());
return redirect()->to($url)->with('error', $this->message);
}
final protected function modify_procedure(string $uid): RedirectResponse|string
final protected function modify_procedure(mixed $uid): RedirectResponse|string
{
//Transaction Start
$this->getModel()->transStart();
@ -197,7 +192,8 @@ abstract class MVController extends CommonController
$this->modify_process($uid);
$this->getModel()->transCommit();
$this->message = "{$this->class_name} : 수정작업이 완료되었습니다.";
return $this->modify_result();
log_message("notice", $this->message);
return $this->modify_process_result();
} catch (\Exception $e) {
//Transaction Rollback
$this->getModel()->transRollback();
@ -206,7 +202,7 @@ abstract class MVController extends CommonController
}
}
//일괄처리작업
final protected function batcjob_procedure(): RedirectResponse
final protected function batcjob_procedure(): RedirectResponse|string
{
//Transaction Start
$this->getModel()->transStart();
@ -219,8 +215,9 @@ abstract class MVController extends CommonController
foreach (explode(",", $uids) as $uid) {
$this->modify_process($uid);
}
$this->getModel()->transCommit();
$this->message = "{$this->class_name} : 일괄처리작업이 완료되었습니다.";
log_message("notice", __FUNCTION__ . $this->message);
log_message("notice", $this->message);
// 이전 URL로 리다이렉트
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message);
} catch (\Exception $e) {
@ -231,7 +228,7 @@ abstract class MVController extends CommonController
}
}
//단일필드작업
final public function toggle(string $uid, string $field): RedirectResponse
final public function toggle(mixed $uid, string $field): RedirectResponse
{
//Transaction Start
$this->getModel()->transStart();
@ -239,9 +236,9 @@ abstract class MVController extends CommonController
$this->action = __FUNCTION__;
$this->fields = [$field];
$this->modify_process($uid);
$this->message = "{$this->class_name} : Toggle 수정작업이 완료되었습니다.";
$this->getModel()->transCommit();
log_message("notice", __FUNCTION__ . $this->message);
$this->message = "{$this->class_name} : 단일필드작업이 완료되었습니다.";
log_message("notice", $this->message);
// 이전 URL로 리다이렉트
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message);
} catch (\Exception $e) {
@ -251,25 +248,53 @@ abstract class MVController extends CommonController
return redirect()->back()->with('error', __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
}
}
//삭제
protected function delete_process(string $uid): void
//View
protected function view_process(mixed $uid): void
{
//자신정보정의
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
$this->entity = $this->getModel()->getEntityByPK($uid);
if ($this->entity === null) {
throw new \Exception("해당 정보를 찾을수 없습니다.");
}
}
protected function view_process_result(): string
{
helper(['form']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return view(
$this->view_path . "view",
data: ['viewDatas' => $this->getViewDatas()]
);
}
final protected function view_procedure(mixed $uid): RedirectResponse|string
{
try {
$this->view_process($uid);
return $this->view_process_result();
} catch (\Exception $e) {
log_message("error", $e->getMessage());
return redirect()->back()->with('error', $e->getMessage());
}
}
//삭제
protected function delete_process(mixed $uid): void
{
//자신정보정의
$this->entity = $this->getModel()->getEntityByPK($uid);
if ($this->entity === null) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
}
$this->entity = $this->getModel()->delete($this->entity->getPK());
}
final public function delete(string $uid): RedirectResponse
final public function delete(mixed $uid): RedirectResponse
{
//Transaction Start
$this->getModel()->transStart();
try {
$this->delete_process($uid);
$this->message = "{$this->class_name} : 삭제작업이 완료되었습니다.";
$this->getModel()->transCommit();
log_message("notice", __FUNCTION__ . $this->message);
$this->message = "{$this->class_name} : 삭제작업이 완료되었습니다.";
log_message("notice", $this->message);
// 이전 URL로 리다이렉트
return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message);
} catch (\Exception $e) {
@ -406,7 +431,7 @@ abstract class MVController extends CommonController
return array($full_path, $file_name);
}
//File Download관련
final protected function download_procedure(string $output_type, $uid = false): DownloadResponse|RedirectResponse
final protected function download_procedure(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse
{
try {
helper(['form']);
@ -431,7 +456,7 @@ abstract class MVController extends CommonController
if (!$uid) {
throw new \Exception("{$output_type}은 반드시 uid의 값이 필요합니다.");
}
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
$this->entity = $this->getModel()->getEntityByPK($uid);
if ($this->entity === null) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
}

View File

@ -12,6 +12,19 @@ class RecordHelper extends CommonHelper
{
parent::__construct();
}
public function getFieldLabel(string $field, array $viewDatas, array $extras = []): string
{
switch ($field) {
case 'hosts':
$extras = ["class" => 'text-danger', ...$extras];
$label = form_label(lang("{$viewDatas['class_path']}.label.{$field}"), $field, $extras);
break;
default:
$label = parent::getFieldLabel($field, $viewDatas, $extras);
break;
}
return $label;
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
$value = $value ?: DEFAULTS['EMPTY'];

View File

@ -32,7 +32,7 @@ class ZoneHelper extends CommonHelper
$form = form_textarea($field, $value, ['rows' => '5', ...$extras]);
break;
case 'hosts':
$form = form_textarea($field, $value == DEFAULTS['EMPTY'] ? "@\n*\nm\nwww" : $value, [
$form = form_textarea($field, $value == DEFAULTS['EMPTY'] ? "*\nm\nwww" : $value, [
'rows' => '5',
...$extras
]);

View File

@ -134,7 +134,7 @@ abstract class CommonHelper
switch ($field) {
default:
if (strpos($viewDatas['field_rules'][$field], 'required') !== false) {
$extras = ["class" => 'text-danger', ...$extras];
$extras = ["class" => "text-danger ", ...$extras];
}
$label = form_label(lang("{$viewDatas['class_path']}.label.{$field}"), $field, $extras);
break;

View File

@ -19,7 +19,6 @@ return [
"ZONE_UID" => [],
"TYPE" => [
'A' => 'A',
'AAAA' => 'AAAA(ipv6)',
'CNAME' => 'CNAME',
'NS' => 'NS',
'MX' => 'MX',

View File

@ -42,7 +42,7 @@ class RecordModel extends CommonModel
$rule = "required|trim|string";
break;
case "type":
$rule = "required|in_list[A,AAAA,CNAME,NS,MX,PTR,SPF,TXT,SRV,INFO]";
$rule = "required|in_list[A,CNAME,NS,MX,PTR,SPF,TXT,SRV,INFO]";
break;
case "ttl":
$rule = "if_exist|numeric";
@ -55,6 +55,9 @@ class RecordModel extends CommonModel
case "locked":
$rule = "if_exist|in_list[on,off]";
break;
case "hosts": //create form에서 사용
$rule = "required|string";
break;
default:
$rule = parent::getFieldRule($action, $field);
break;

View File

@ -51,6 +51,21 @@ class ZoneModel extends CommonModel
case "status":
$rule = "if_exist|in_list[active,pending,moved]";
break;
case "domains": //create form에서 사용
$rule = "required|string";
break;
case "hosts": //create form에서 사용
$rule = "required|string";
break;
case "type": //create form에서 사용
$rule = "required|in_list[A,CNAME,NS,MX,PTR,SPF,TXT,SRV,INFO]";
break;
case "content": //create form에서 사용
$rule = "required|trim|string";
break;
case "proxied": //create form에서 사용
$rule = "required|in_list[on,off]";
break;
default:
$rule = parent::getFieldRule($action, $field);
break;
@ -105,7 +120,6 @@ class ZoneModel extends CommonModel
{
//Record의 content(IP검색)을 하기위함
//Join 방식사용
$this->select(self::TABLE . '.*')->distinct();
$this->join(RecordModel::TABLE, sprintf(
"%s.%s=%s.%s",
self::TABLE,

View File

@ -5,28 +5,20 @@
<div class="action_form">
<table class="table table-bordered">
<tr>
<th>번호</th>
<?php foreach ($viewDatas['fields'] as $field): ?>
<th nowrap class="text-center"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<?php endforeach ?>
</tr>
<?php $cnt = 1 ?>
<?php foreach ($viewDatas['entitys'] as $entity): ?>
<?php $viewDatas['entity'] = $entity ?>
<tr>
<td><?= $cnt ?></td>
<?php foreach ($viewDatas['fields'] as $field): ?>
<td nowrap class="text-center"><?= $viewDatas['helper']->getFieldView($field, $viewDatas) ?></td>
<?php endforeach ?>
</tr>
<?php $cnt++ ?>
<?php endforeach ?>
<tr>
<td colspan="<?= count($viewDatas['fields']) + 1 ?>" class="text-center">
<div><?= $viewDatas['message'] ?></div>
</td>
</tr>
</table>
<?= isset($viewDatas['message']) ? "<div>{$viewDatas['message']}</div>" : '' ?>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,33 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<div class="action_form">
<table class="table table-bordered">
<tr>
<?php foreach ($viewDatas['fields'] as $field): ?>
<th nowrap class="text-center"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<?php endforeach ?>
</tr>
<?php foreach ($viewDatas['entitys'] as $entity): ?>
<?php $viewDatas['entity'] = $entity ?>
<tr>
<?php foreach ($viewDatas['fields'] as $field): ?>
<td nowrap class="text-center"><?= $viewDatas['helper']->getFieldView($field, $viewDatas) ?></td>
<?php endforeach ?>
</tr>
<?php if ($viewDatas['entity']->records): ?>
<tr>
<td colspan="<?= count($viewDatas['fields']) ?>">
<?php foreach ($viewDatas['entity']->records as $record): ?>
<div><?= $record->getTitle() ?></div>
<?php endforeach ?>
</td>
</tr>
<?php endif ?>
<?php endforeach ?>
</table>
<?= isset($viewDatas['message']) ? "<div>{$viewDatas['message']}</div>" : '' ?>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -4,36 +4,30 @@
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<div class="action_form">
<table class="table table-bordered">
<tr>
<?php foreach ($viewDatas['fields'] as $field): ?>
<th nowrap class="text-center"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<?php endforeach ?>
</tr>
<?php foreach ($viewDatas['entitys'] as $entity): ?>
<?php $viewDatas['entity'] = $entity ?>
<?php $cnt = 1 ?>
<tr>
<?php foreach ($viewDatas['fields'] as $field): ?>
<th>번호</th>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<td nowrap class="text-center"><?= $viewDatas['helper']->getFieldView($field, $viewDatas) ?></td>
<?php endforeach ?>
</tr>
<tr>
<?php foreach ($viewDatas['fields'] as $field): ?>
<th><?= $cnt ?></th>
<td nowrap class="text-start"><?= $viewDatas['helper']->getFieldView($field, $viewDatas, $viewDatas) ?></td>
<?php endforeach ?>
</tr>
<tr>
<td colspan="<?= count($viewDatas['fields']) + 1 ?>">
<?php foreach ($entity->records as $record): ?>
<?= $record->getTitle() ?>
<?php endforeach ?>
</td>
</tr>
<?php $cnt++ ?>
<?php if ($viewDatas['entity']->records): ?>
<tr>
<td colspan="<?= count($viewDatas['fields']) ?>">
<?php foreach ($viewDatas['entity']->records as $record): ?>
<div><?= $record->getTitle() ?></div>
<?php endforeach ?>
</td>
</tr>
<?php endif ?>
<?php endforeach ?>
<tr>
<td colspan="<?= $cnt * 2 ?>" class="text-center">
<div><?= $viewDatas['message'] ?></div>
</td>
</tr>
</table>
<?= isset($viewDatas['message']) ? "<div>{$viewDatas['message']}</div>" : '' ?>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -9,14 +9,14 @@
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldView($field, $viewDatas, $viewDatas) ?>
<?= $viewDatas['helper']->getFieldView($field, $viewDatas) ?>
</td>
<?php $cnt++ ?>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="<?= $cnt * 2 ?>" class="text-center">
<div><?= $viewDatas['message'] ?></div>
<div><?= isset($viewDatas['message']) ? $viewDatas['message'] : '' ?></div>
</td>
</tr>
</table>

View File

@ -1,35 +0,0 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<div class="action_form">
<table class="table table-bordered">
<?php $cnt = 1 ?>
<?php foreach ($viewDatas['fields'] as $field): ?>
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<td nowrap class="text-start">
<?php
$extras = ["class" => "form-control"];
if (strpos($viewDatas['field_rules'][$field], 'required') !== false) {
$extras = ["required" => "", ...$extras];
}
?>
<?= $viewDatas['helper']->getFieldForm($field, old($field), $viewDatas, $extras) ?>
<div><?= validation_show_error($field); ?></div>
</td>
<?php $cnt++ ?>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="<?= $cnt * 2 ?>" class="text-center">
<?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?>
</td>
</tr>
</table>
<?= form_close(); ?>
</div>
</div>
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/form.js"></script>
<?= $this->endSection() ?>

View File

@ -1,57 +0,0 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div class="layout_top"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/top'); ?></div>
<div class="layout_middle">
<div class="layout_left"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu'); ?></div>
<div class="layout_right">
<?= $this->include("templates/{$viewDatas['layout']}/index_header"); ?>
<div id="container" class="layout_content">
<link href="/css/<?= $viewDatas['layout'] ?>/index.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/css/common/resizeTable.css" media="screen" rel="stylesheet" type="text/css" />
<div class="index_body">
<?= $this->include("templates/{$viewDatas['layout']}/index_content_top"); ?>
<table class="index_table data table table-bordered table-hover table-striped"
data-rtc-resizable-table="reisze_table">
<thead>
<tr>
<th class="index_head_short_column">번호</th>
<?php foreach ($viewDatas['fields'] as $field): ?>
<th data-rtc-resizable="<?= $field ?>"><?= $viewDatas['helper']->getListLabel($field, $viewDatas) ?></th>
<?php endforeach ?>
<th class="index_head_short_column">작업</th>
</tr>
</thead>
<tbody>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity): ?>
<tr <?= $viewDatas['helper']->getListRowColor($entity) ?>>
<?php $viewDatas['cnt'] = $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt); ?>
<?php $viewDatas['entity'] = $entity; ?>
<td>
<?= $viewDatas['helper']->getListButton('modify', $viewDatas) ?>
</td>
<?php foreach ($viewDatas['fields'] as $field): ?>
<td><?= $viewDatas['helper']->getFieldView($field, $viewDatas) ?></td>
<?php endforeach ?>
<td>
<?= $viewDatas['helper']->getListButton('delete', $viewDatas) ?>
</td>
</tr>
<?php $cnt++ ?>
<?php endforeach ?>
</tbody>
</table>
<?= $this->include("templates/{$viewDatas['layout']}/index_content_batchjob"); ?>
</div>
<div class=" index_pagination"><?= $viewDatas['pagination'] ?></div>
<div class="index_bottom"><?= $this->include("templates/common/modal_fetch"); ?></div>
<script type="text/javascript" src="/js/common/resizeTable.js"></script>
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/index.js"></script>
</div>
<div class="layout_footer"><?= $this->include("templates/{$viewDatas['layout']}/index_footer"); ?></div>
</div>
</div>
<div class="layout_bottom">
<?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?>
</div>
<?= $this->endSection() ?>

View File

@ -1,27 +0,0 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div class="layout_middle">
<div class="layout_right">
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/login.css" media="screen" rel="stylesheet" type="text/css" />
<div class="login-container border rounded p-4 shadow">
<?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<h2 class="text-center mb-5">CF-MGR 로그인</h2>
<div class="mb-3">
<label for="userId" class="form-label">아이디</label>
<input type="text" class="form-control" id="userId" name="id" value="<?= set_value('id') ?>" required>
</div>
<div class="mb-3">
<label for="userPassword" class="form-label">비밀번호</label>
<input type="password" class="form-control" id="userPassword" name="passwd" required>
</div>
<div class="d-flex justify-content-between align-items-center">
<button type="submit" class="btn btn-primary">Login</button>
<?= anchor($viewDatas['google_url'], ICONS['GOOGLE'] . 'Google 로그인', ["class" => "btn btn-danger"]) ?>
<button type="button" class="btn btn-outline-primary">회원가입</button>
</div>
<?= form_close(); ?>
</div>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -1,34 +0,0 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<?= form_open(current_url(), ['id' => 'action_form', ...$viewDatas['forms']['attributes']], $viewDatas['forms']['hiddens']) ?>
<div class="action_form">
<table class="table table-bordered">
<?php $cnt = 1 ?>
<?php foreach ($viewDatas['fields'] as $field): ?>
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<td nowrap class="text-start">
<?php
$extras = ["class" => 'form-control'];
if (strpos($viewDatas['field_rules'][$field], 'required') !== false) {
$extras = ["required" => "", ...$extras];
}
?>
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? $viewDatas['entity']->$field, $viewDatas, $extras) ?>
<div><?= validation_show_error($field); ?></div>
</td>
<?php $cnt++ ?>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="<?= $cnt * 2 ?>" class="text-center">
<?= form_submit("", '수정', ["class" => "btn btn-outline btn-primary"]) ?>
</td>
</tr>
</table>
<?= form_close(); ?>
</div>
</div>
<?= $this->endSection() ?>