cfmgrv4 init..1
This commit is contained in:
parent
cb08006d57
commit
66d34a9101
@ -21,6 +21,12 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($rou
|
||||
$routes->post('create', 'UserController::create');
|
||||
$routes->get('modify/(:num)', 'UserController::modify_form/$1');
|
||||
$routes->post('modify/(:num)', 'UserController::modify/$1');
|
||||
$routes->get('delete/(:num)', 'UserController::delete/$1');
|
||||
$routes->get('toggle/(:num)/(:alpha)', 'UserController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'UserController::batcjob');
|
||||
$routes->get('roles/(:num)', 'UserController::roles/$1');
|
||||
$routes->get('download/(:alpha)', 'UserController::download/$1');
|
||||
$routes->get('download/(:alpha)/(:any)', 'UserController::download/$1/$2');
|
||||
});
|
||||
$routes->group('mapurl', function ($routes) {
|
||||
$routes->get('/', 'MapurlController::index');
|
||||
@ -28,6 +34,11 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($rou
|
||||
$routes->post('create', 'MapurlController::create');
|
||||
$routes->get('modify/(:num)', 'MapurlController::modify_form/$1');
|
||||
$routes->post('modify/(:num)', 'MapurlController::modify/$1');
|
||||
$routes->get('delete/(:num)', 'MapurlController::delete/$1');
|
||||
$routes->get('toggle/(:num)/(:alpha)', 'MapurlController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'MapurlController::batcjob');
|
||||
$routes->get('download/(:alpha)', 'MapurlController::download/$1');
|
||||
$routes->get('download/(:alpha)/(:any)', 'MapurlController::download/$1/$2');
|
||||
});
|
||||
$routes->group('cloudflare', ['namespace' => 'App\Controllers\Admin\Cloudflare'], function ($routes) {
|
||||
$routes->cli('/reload', 'CloudflareController::reload');
|
||||
@ -36,22 +47,38 @@ $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->post('modify/(:num)', 'AuthController::modify/$1');
|
||||
$routes->post('create', 'AuthController::create');
|
||||
$routes->get('toggle/(:num)/(:alpha)', 'AuthController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'AuthController::batcjob');
|
||||
$routes->get('download/(:alpha)', 'AuthController::download/$1');
|
||||
$routes->get('download/(:alpha)/(:any)', 'AuthController::download/$1/$2');
|
||||
});
|
||||
$routes->group('account', function ($routes) {
|
||||
$routes->get('/', 'AccountController::index');
|
||||
$routes->post('create/(:uuid)', 'AccountController::create');
|
||||
$routes->get('download/(:alpha)', 'AccountController::download/$1');
|
||||
$routes->get('download/(:alpha)/(:any)', 'AccountController::download/$1/$2');
|
||||
});
|
||||
$routes->group('zone', function ($routes) {
|
||||
$routes->get('/', 'ZoneController::index');
|
||||
$routes->get('create', 'ZoneController::create_form');
|
||||
$routes->post('create/(:uuid)', 'ZoneController::create/$1');
|
||||
$routes->get('delete/(:uuid)', 'ZoneController::delete/$1');
|
||||
$routes->get('toggle/(:uuid)/(:alpha)', 'ZoneController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'ZoneController::batcjob');
|
||||
$routes->get('download/(:alpha)', 'ZoneController::download/$1');
|
||||
$routes->get('download/(:alpha)/(:any)', 'ZoneController::download/$1/$2');
|
||||
});
|
||||
$routes->group('record', function ($routes) {
|
||||
$routes->get('/', 'RecordController::index');
|
||||
$routes->get('create', 'RecordController::create_form');
|
||||
$routes->post('create/(:uuid)', 'RecordController::create/$1');
|
||||
$routes->get('delete/(:uuid)', 'RecordController::delete/$1');
|
||||
$routes->get('toggle/(:uuid)/(:alpha)', 'RecordController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'RecordController::batcjob');
|
||||
$routes->get('download/(:alpha)', 'RecordController::download/$1');
|
||||
$routes->get('download/(:alpha)/(:any)', 'RecordController::download/$1/$2');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -41,48 +41,36 @@ class AuthController extends CloudflareController
|
||||
$this->init('create');
|
||||
return $this->create_form_procedure();
|
||||
}
|
||||
protected function create_process(): void
|
||||
{
|
||||
$this->create_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
parent::create_process();
|
||||
$this->entity = $this->getModel()->create(formDatas: $this->formDatas);
|
||||
}
|
||||
public function create(): RedirectResponse
|
||||
{
|
||||
$this->init(__FUNCTION__);
|
||||
$this->create_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->create_procedure();
|
||||
}
|
||||
//수정
|
||||
protected function modify_form_process(string $uid): void
|
||||
{
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("해당 정보를 찾을수 없습니다.");
|
||||
}
|
||||
parent::modify_form_process($uid);
|
||||
}
|
||||
public function modify_form(string $uid): RedirectResponse|string
|
||||
{
|
||||
$this->init('modify');
|
||||
return $this->modify_form_procedure($uid);
|
||||
}
|
||||
protected function modify_process(string $uid): void
|
||||
{
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
parent::modify_process($uid);
|
||||
$this->entity = $this->getModel()->modify($this->entity, $this->formDatas);
|
||||
}
|
||||
public function modify(string $uid): RedirectResponse
|
||||
{
|
||||
$this->init(__FUNCTION__);
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->modify_procedure($uid);
|
||||
}
|
||||
//일괄처리작업
|
||||
public function batcjob(): RedirectResponse
|
||||
{
|
||||
$this->action = __FUNCTION__;
|
||||
$this->fields = ['status'];
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->batcjob_procedure();
|
||||
}
|
||||
// 리스트
|
||||
public function index(): string
|
||||
{
|
||||
|
||||
@ -86,13 +86,13 @@ class RecordController extends CloudflareController
|
||||
}
|
||||
protected function create_process(): void
|
||||
{
|
||||
//DB작업도 Socket에서 다 처리하므로 parent::create_process()하면 않됨
|
||||
//부모데이터정의
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
|
||||
//Record생성
|
||||
foreach ($this->formDatas['hosts'] as $host) {
|
||||
$result = $this->getMySocket()->create($host, $this->formDatas['type'], $this->formDatas['content'], $this->formDatas['proxied']);
|
||||
$formDatas = $this->getMySocket()->getArrayByResult($result);
|
||||
$entity = $this->getRecordModel()->create($formDatas);
|
||||
log_message("debug", "Record:{$entity->getTitle()} 작업을 완료하였습니다.");
|
||||
//Cloudflare 생성
|
||||
$entity = $this->getMySocket()->create($host, $this->formDatas['type'], $this->formDatas['content'], $this->formDatas['proxied']);
|
||||
log_message("debug", "Record:{$entity->getTitle()} 생성 작업을 완료하였습니다.");
|
||||
}
|
||||
}
|
||||
public function create(): RedirectResponse
|
||||
@ -100,8 +100,6 @@ class RecordController extends CloudflareController
|
||||
$this->init(__FUNCTION__);
|
||||
$this->create_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
//부모데이터 정의
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
|
||||
$cnt = 1;
|
||||
foreach ($this->formDatas['hosts'] as $host) {
|
||||
//호스트명 형식확인
|
||||
@ -112,7 +110,43 @@ class RecordController extends CloudflareController
|
||||
}
|
||||
return $this->create_procedure();
|
||||
}
|
||||
//수정
|
||||
//수정 (modify,toggle,batchjob사용)
|
||||
protected function modify_process(string $uid): void
|
||||
{
|
||||
//DB작업도 Socket에서 다 처리하므로 parent::modify_process($uid)하면 않됨
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
//부모데이터정의
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
|
||||
//Cloudflare 수정
|
||||
$entity = $this->getMySocket()->modify($this->entity, $this->formDatas);
|
||||
log_message("debug", "Record:{$entity->getTitle()} 수정 작업을 완료하였습니다.");
|
||||
}
|
||||
//일괄처리작업
|
||||
public function batcjob(): RedirectResponse
|
||||
{
|
||||
$this->action = __FUNCTION__;
|
||||
$this->fields = ['proxied'];
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->batcjob_procedure();
|
||||
}
|
||||
//삭제
|
||||
protected function delete_process(string $uid): void
|
||||
{
|
||||
//DB작업도 Socket에서 다 처리하므로 parent::delete_process($uid)하면 않됨
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
//부모데이터정의
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
|
||||
//Cloudflare 삭제
|
||||
$this->getMySocket()->delete($this->entity);
|
||||
}
|
||||
// 리스트
|
||||
public function index(): string
|
||||
{
|
||||
|
||||
@ -99,7 +99,7 @@ class ZoneController extends CloudflareController
|
||||
}
|
||||
protected function create_process(): void
|
||||
{
|
||||
parent::create_process();
|
||||
//DB작업도 Socket에서 다 처리하므로 parent::create_process()하면 않됨
|
||||
//Zone생성
|
||||
$cnt = 1;
|
||||
$zone_entitys = [];
|
||||
@ -153,6 +153,43 @@ class ZoneController extends CloudflareController
|
||||
}
|
||||
return $this->create_procedure();
|
||||
}
|
||||
//수정 (modify,toggle,batchjob사용)
|
||||
protected function modify_process(string $uid): void
|
||||
{
|
||||
//DB작업도 Socket에서 다 처리하므로 parent::modify_process($uid)하면 않됨
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
//부모데이터정의
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
|
||||
//Cloudflare 수정
|
||||
$entity = $this->getMySocket()->modify($this->entity, $this->formDatas);
|
||||
log_message("debug", "Record:{$entity->getTitle()} 수정 작업을 완료하였습니다.");
|
||||
}
|
||||
//일괄처리작업
|
||||
public function batcjob(): RedirectResponse
|
||||
{
|
||||
$this->action = __FUNCTION__;
|
||||
$this->fields = ['development_mode', 'ipv6', 'security_level'];
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->batcjob_procedure();
|
||||
}
|
||||
//삭제
|
||||
protected function delete_process(string $uid): void
|
||||
{
|
||||
//DB작업도 Socket에서 다 처리하므로 parent::delete_process($uid)하면 않됨
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
//부모데이터정의
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
|
||||
//Cloudflare 삭제
|
||||
$this->getMySocket()->delete($this->entity);
|
||||
}
|
||||
// 리스트
|
||||
public function index(): string
|
||||
{
|
||||
|
||||
@ -89,48 +89,51 @@ class MapurlController extends AdminController
|
||||
}
|
||||
protected function create_process(): void
|
||||
{
|
||||
$this->create_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
parent::create_process();
|
||||
$this->entity = $this->getModel()->create(formDatas: $this->formDatas);
|
||||
$this->remaping_process();
|
||||
}
|
||||
public function create(): RedirectResponse
|
||||
{
|
||||
$this->init(__FUNCTION__);
|
||||
$this->create_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->create_procedure();
|
||||
}
|
||||
//수정
|
||||
protected function modify_form_process(string $uid): void
|
||||
{
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("해당 정보를 찾을수 없습니다.");
|
||||
}
|
||||
parent::modify_form_process($uid);
|
||||
}
|
||||
public function modify_form(string $uid): RedirectResponse|string
|
||||
{
|
||||
$this->init('modify');
|
||||
return $this->modify_form_procedure($uid);
|
||||
}
|
||||
//(modify,toggle,batchjob사용)
|
||||
protected function modify_process(string $uid): void
|
||||
{
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
parent::modify_process($uid);
|
||||
$this->entity = $this->getModel()->modify($this->entity, $this->formDatas);
|
||||
$this->remaping_process();
|
||||
}
|
||||
public function modify(string $uid): RedirectResponse
|
||||
{
|
||||
$this->init(__FUNCTION__);
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->modify_procedure($uid);
|
||||
}
|
||||
//일괄처리작업
|
||||
public function batcjob(): RedirectResponse
|
||||
{
|
||||
$this->action = __FUNCTION__;
|
||||
$this->fields = ['status'];
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->batcjob_procedure();
|
||||
}
|
||||
//삭제
|
||||
protected function delete_process(string $uid): void
|
||||
{
|
||||
parent::delete_process($uid);
|
||||
$this->remaping_process();
|
||||
}
|
||||
// 리스트
|
||||
public function index(): string
|
||||
{
|
||||
|
||||
@ -3,8 +3,9 @@
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\UserModel;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -39,6 +40,20 @@ class UserController extends AdminController
|
||||
protected function getFormData(string $field, array $formDatas): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'role':
|
||||
$roles = $this->request->getVar($field . "[]");
|
||||
if (!count($roles)) {
|
||||
throw new \Exception("권한이 지정되지 않았습니다.");
|
||||
}
|
||||
$formDatas[$field] = implode(DEFAULTS["DELIMITER_ROLE"],);
|
||||
break;
|
||||
case 'roles[]':
|
||||
$roles = $this->request->getVar($field);
|
||||
if (!count($roles)) {
|
||||
throw new \Exception("권한이 지정되지 않았습니다.");
|
||||
}
|
||||
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"],);
|
||||
break;
|
||||
default:
|
||||
$formDatas = parent::getFormData($field, $formDatas);
|
||||
break;
|
||||
@ -59,46 +74,43 @@ class UserController extends AdminController
|
||||
$this->init('create');
|
||||
return $this->create_form_procedure();
|
||||
}
|
||||
protected function create_process(): void
|
||||
{
|
||||
$this->create_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
parent::create_process();
|
||||
$this->entity = $this->getModel()->create(formDatas: $this->formDatas);
|
||||
}
|
||||
public function create(): RedirectResponse
|
||||
{
|
||||
$this->init(__FUNCTION__);
|
||||
$this->create_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->create_procedure();
|
||||
}
|
||||
//수정
|
||||
protected function modify_form_process(string $uid): void
|
||||
{
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("해당 정보를 찾을수 없습니다.");
|
||||
}
|
||||
parent::modify_form_process($uid);
|
||||
}
|
||||
public function modify_form(string $uid): RedirectResponse|string
|
||||
{
|
||||
$this->init('modify');
|
||||
return $this->modify_form_procedure($uid);
|
||||
}
|
||||
protected function modify_process(string $uid): void
|
||||
{
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
parent::modify_process($uid);
|
||||
$this->entity = $this->getModel()->modify($this->entity, $this->formDatas);
|
||||
}
|
||||
public function modify(string $uid): RedirectResponse
|
||||
{
|
||||
$this->init(__FUNCTION__);
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->modify_procedure($uid);
|
||||
}
|
||||
//일괄작업
|
||||
public function batcjob(): RedirectResponse
|
||||
{
|
||||
$this->action = __FUNCTION__;
|
||||
$this->fields = ['status'];
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->batcjob_procedure();
|
||||
}
|
||||
//Role변경작업
|
||||
public function roles(string $uid): RedirectResponse
|
||||
{
|
||||
$this->action = __FUNCTION__;
|
||||
$this->fields = ["roles[]"];
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->modify_procedure($uid);
|
||||
}
|
||||
// 리스트
|
||||
@ -109,7 +121,18 @@ class UserController extends AdminController
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
|
||||
$this->filter_fields = ['role', 'status'];
|
||||
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
|
||||
$this->batchjob_fields = ['role', 'status'];
|
||||
$this->batchjob_fields = ['status'];
|
||||
return $this->list_procedure();
|
||||
}
|
||||
// Download
|
||||
public function download(string $output_type, $uid = false): DownloadResponse|string
|
||||
{
|
||||
$this->action = __FUNCTION__;
|
||||
$this->fields = ['id', $this->getModel()::TITLE, 'email', 'mobile', 'role', 'status'];
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
|
||||
$this->filter_fields = ['role', 'status'];
|
||||
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
|
||||
$this->batchjob_fields = ['status'];
|
||||
return $this->download_procedure($output_type, $uid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,9 @@ use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Html;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class MVController extends CommonController
|
||||
@ -85,7 +88,10 @@ abstract class MVController extends CommonController
|
||||
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with(SESSION_NAMES['RETURN_MSG'], $e->getMessage());
|
||||
}
|
||||
}
|
||||
protected function create_process(): void {}
|
||||
protected function create_process(): void
|
||||
{
|
||||
$this->entity = $this->getModel()->create(formDatas: $this->formDatas);
|
||||
}
|
||||
final protected function create_procedure(): RedirectResponse
|
||||
{
|
||||
//Transaction Start
|
||||
@ -118,7 +124,13 @@ abstract class MVController extends CommonController
|
||||
));
|
||||
}
|
||||
}
|
||||
protected function modify_form_process(string $uid): void {}
|
||||
protected function modify_form_process(string $uid): void
|
||||
{
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("해당 정보를 찾을수 없습니다.");
|
||||
}
|
||||
}
|
||||
final protected function modify_form_procedure(string $uid): RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
@ -135,7 +147,14 @@ abstract class MVController extends CommonController
|
||||
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with(SESSION_NAMES['RETURN_MSG'], $e->getMessage());
|
||||
}
|
||||
}
|
||||
protected function modify_process(string $uid): void {}
|
||||
protected function modify_process(string $uid): void
|
||||
{
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->entity = $this->getModel()->modify($this->entity, $this->formDatas);
|
||||
}
|
||||
final protected function modify_procedure(string $uid): RedirectResponse
|
||||
{
|
||||
//Transaction Start
|
||||
@ -155,6 +174,76 @@ abstract class MVController extends CommonController
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
}
|
||||
//단일필드작업
|
||||
final public function toggle(string $field, string $uid): RedirectResponse
|
||||
{
|
||||
$this->action = __FUNCTION__;
|
||||
$this->field = [$field];
|
||||
$this->modify_validate($this->action, $this->fields);
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
return $this->modify_procedure($uid);
|
||||
}
|
||||
//일괄처리작업
|
||||
protected function batcjob_process(): void
|
||||
{
|
||||
//변경할 UIDS
|
||||
$uids = $this->request->getVar('batchjob_uids[]');
|
||||
if (!count($uids)) {
|
||||
throw new \Exception("지정된 정보가 없습니다.");
|
||||
}
|
||||
$this->entitys = [];
|
||||
foreach ($uids as $uid) {
|
||||
$this->modify_process($uid);
|
||||
$this->entitys = $this->entity;
|
||||
}
|
||||
}
|
||||
final protected function batcjob_procedure(): RedirectResponse
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getModel()->transStart();
|
||||
try {
|
||||
$this->batcjob_process();
|
||||
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n");
|
||||
$this->getModel()->transCommit();
|
||||
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();
|
||||
}
|
||||
}
|
||||
//삭제
|
||||
protected function delete_process(string $uid): void
|
||||
{
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
$this->entity = $this->getModel()->delete($this->entity->getPK());
|
||||
}
|
||||
final public function delete(string $uid): RedirectResponse
|
||||
{
|
||||
//Transaction Start
|
||||
$this->getModel()->transStart();
|
||||
try {
|
||||
$this->delete_process($uid);
|
||||
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n");
|
||||
$this->getModel()->transCommit();
|
||||
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();
|
||||
}
|
||||
}
|
||||
// 리스트
|
||||
private function list_condition_process(): void
|
||||
{
|
||||
@ -262,12 +351,12 @@ abstract class MVController extends CommonController
|
||||
switch ($document_type) {
|
||||
case 'excel':
|
||||
$file_name = sprintf("%s_%s.xlsx", $this->class_name, date('Y-m-d_Hm'));
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($loaded_data, 'Xlsx');
|
||||
$writer = IOFactory::createWriter($loaded_data, 'Xlsx');
|
||||
$writer->save($full_path . DIRECTORY_SEPARATOR . $file_name);
|
||||
break;
|
||||
case 'pdf':
|
||||
$file_name = sprintf("%s_%s.pdf", $this->class_name, date('Y-m-d_Hm'));
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($loaded_data);
|
||||
$writer = new Mpdf($loaded_data);
|
||||
$writer->save($full_path . DIRECTORY_SEPARATOR . $file_name);
|
||||
break;
|
||||
default:
|
||||
@ -287,30 +376,43 @@ abstract class MVController extends CommonController
|
||||
return array($full_path, $file_name);
|
||||
}
|
||||
//File Download관련
|
||||
final public function download_procedure(string $output_type, mixed $entity = null): DownloadResponse|RedirectResponse
|
||||
final protected function download_procedure(string $output_type, $uid = false): DownloadResponse|string
|
||||
{
|
||||
try {
|
||||
helper(['form']);
|
||||
//URL처리
|
||||
$this->uri = $this->request->getUri();
|
||||
switch ($output_type) {
|
||||
case 'excel':
|
||||
case 'pdf':
|
||||
//data loading
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Html();
|
||||
// string buffer에서 읽어오는 경우
|
||||
$this->entitys = $this->list_entitys_process();
|
||||
$loaded_data = $reader->loadFromString(view(
|
||||
strtolower($this->class_path) . DIRECTORY_SEPARATOR . $output_type,
|
||||
$html = view(
|
||||
strtolower($this->class_path) . DIRECTORY_SEPARATOR . $this->action,
|
||||
['viewDatas' => $this->getViewDatas()]
|
||||
));
|
||||
);
|
||||
//data loading
|
||||
$reader = new Html();
|
||||
$loaded_data = $reader->loadFromString($html);
|
||||
list($full_path, $file_name) = $this->output_save_process($output_type, $loaded_data);
|
||||
$full_path .= DIRECTORY_SEPARATOR . $file_name;
|
||||
break;
|
||||
default:
|
||||
list($file_name, $uploaded_filename) = $entity->getDownlaodFile();
|
||||
if (!$uid) {
|
||||
throw new \Exception("{$output_type}은 반드시 uid의 값이 필요합니다.");
|
||||
}
|
||||
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
|
||||
if ($this->entity === null) {
|
||||
throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
|
||||
}
|
||||
list($file_name, $uploaded_filename) = $this->entity->getDownlaodFile();
|
||||
$full_path = WRITEPATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . $uploaded_filename;
|
||||
break;
|
||||
}
|
||||
return $this->response->download($full_path, null)->setFileName($file_name);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
|
||||
log_message("error", $e->getMessage());
|
||||
return alert_CommonHelper($e->getMessage(), "back");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ function getFieldForm_AccountHelper(string $field, mixed $value, array $viewData
|
||||
// return implode(" ", $checkboxs);
|
||||
break;
|
||||
case AccountModel::TITLE:
|
||||
$form = form_input($field, $value, ["placeholder" => "예)test@exmaple.com", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
$form = form_input($field, $value, ["placeholder" => "예)test@exmaple.com", "style" => "width:100%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'type':
|
||||
case 'status':
|
||||
@ -48,7 +48,7 @@ function getFieldForm_AccountHelper(string $field, mixed $value, array $viewData
|
||||
$form = form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
$form = form_input($field, $value, ["style" => "width:60%;"]);
|
||||
$form = form_input($field, $value, ["style" => "width:100%;"]);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
@ -69,7 +69,7 @@ function getFieldView_AccountHelper(string $field, AccountEntity $entity, array
|
||||
"class" => "btn btn-sm btn-primary btn-circle",
|
||||
"target" => "_self"
|
||||
]
|
||||
) . " <span class=\"label_accounts\">" .
|
||||
) . " <span class=\"label_auth\">" .
|
||||
preg_replace("/(\w+)@(.+)/", "$1", $viewDatas['field_options'][$field][$value])
|
||||
. "</span>";
|
||||
}
|
||||
@ -106,16 +106,16 @@ function getFieldView_AccountHelper(string $field, AccountEntity $entity, array
|
||||
$value = $value ? date("Y-m-d", strtotime($value)) : "";
|
||||
break;
|
||||
default:
|
||||
// if (in_array($field, $viewDatas['filter_fields']) && $value) {
|
||||
// $extras["onChange"] = sprintf(
|
||||
// 'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
|
||||
// current_url(),
|
||||
// $entity->getPK(),
|
||||
// $field,
|
||||
// $field
|
||||
// );
|
||||
// $value = getFieldForm_AccountHelper($field, $entity->$field, $viewDatas, $extras);
|
||||
// }
|
||||
if (in_array($field, $viewDatas['filter_fields']) && $value) {
|
||||
$extras["onChange"] = sprintf(
|
||||
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
|
||||
current_url(),
|
||||
$entity->getPK(),
|
||||
$field,
|
||||
$field
|
||||
);
|
||||
$value = getFieldForm_AccountHelper($field, $entity->$field, $viewDatas, $extras);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
|
||||
@ -20,7 +20,7 @@ function getFieldForm_AuthHelper(string $field, mixed $value, array $viewDatas,
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case AuthModel::TITLE:
|
||||
$form = form_input($field, $value, ["placeholder" => "예)test@example.com", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
$form = form_input($field, $value, ["placeholder" => "예)test@example.com", "style" => "width:100%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'status':
|
||||
$form = form_dropdown($field, [
|
||||
@ -33,7 +33,7 @@ function getFieldForm_AuthHelper(string $field, mixed $value, array $viewDatas,
|
||||
$form = form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
$form = form_input($field, $value, ["style" => "width:60%;"]);
|
||||
$form = form_input($field, $value, ["style" => "width:100%;"]);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
|
||||
@ -57,7 +57,7 @@ function getFieldForm_RecordHelper(string $field, mixed $value, array $viewDatas
|
||||
$form = form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
$form = form_input($field, $value, ["style" => "width:60%;"]);
|
||||
$form = form_input($field, $value, ["style" => "width:100%;"]);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
@ -106,10 +106,11 @@ function getFieldView_RecordHelper(string $field, RecordEntity $entity, array $v
|
||||
default:
|
||||
if (in_array($field, $viewDatas['filter_fields']) && $value) {
|
||||
$extras["onChange"] = sprintf(
|
||||
'location.href="%s/toggle/%s?%s="+this.options[this.selectedIndex].value',
|
||||
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
|
||||
current_url(),
|
||||
$entity->getPK(),
|
||||
$field,
|
||||
$field
|
||||
);
|
||||
$value = getFieldForm_RecordHelper($field, $entity->$field, $viewDatas, $extras);
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ function getFieldForm_ZoneHelper(string $field, mixed $value, array $viewDatas,
|
||||
// return implode(" ", $checkboxs);
|
||||
break;
|
||||
case ZoneModel::TITLE:
|
||||
$form = form_input($field, $value, ["placeholder" => "예)exmaple.com", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
$form = form_input($field, $value, ["placeholder" => "예)exmaple.com", "style" => "width:100%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'domains':
|
||||
$form = form_textarea($field, $value, ['class' => 'editor', 'rows' => '5']);
|
||||
@ -66,7 +66,7 @@ function getFieldForm_ZoneHelper(string $field, mixed $value, array $viewDatas,
|
||||
$form = form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
$form = form_input($field, $value, ["style" => "width:60%;"]);
|
||||
$form = form_input($field, $value, ["style" => "width:100%;"]);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
|
||||
@ -36,7 +36,7 @@ function getFieldForm_MapurlHelper(string $field, mixed $value, array $viewDatas
|
||||
$form = form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
$form = form_input($field, $value, ["style" => "width:60%;"]);
|
||||
$form = form_input($field, $value, ["style" => "width:100%;"]);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
|
||||
@ -20,21 +20,44 @@ function getFieldForm_UserHelper(string $field, mixed $value, array $viewDatas,
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case UserModel::TITLE:
|
||||
$form = form_input($field, $value, ["placeholder" => "예)test@example.com", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
$form = form_input($field, $value, ["placeholder" => "예)", "style" => "width:100%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'role':
|
||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
||||
$forms = [];
|
||||
foreach ($viewDatas['field_options'][$field] as $key => $label) {
|
||||
$roles = explode(DEFAULTS["DELIMITER_ROLE"], $value);
|
||||
$forms[] = form_checkbox("{$field}[]", $value, in_array($key, $roles)) . $label;
|
||||
}
|
||||
$form = implode(" ", $forms);
|
||||
} else {
|
||||
$form = form_dropdown($field, [
|
||||
"" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택',
|
||||
...$viewDatas['field_options'][$field]
|
||||
], $value, $extras);
|
||||
}
|
||||
break;
|
||||
case 'status':
|
||||
$form = form_dropdown($field, [
|
||||
"" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택',
|
||||
...$viewDatas['field_options'][$field]
|
||||
], $value, $extras);
|
||||
break;
|
||||
case 'passwd':
|
||||
$form = form_password($field, "", ["style" => "width:100%;"]);
|
||||
break;
|
||||
case 'email':
|
||||
$form = form_input($field, $value, ["placeholder" => "예)test@example.com", "style" => "width:100%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'mobile':
|
||||
$form = form_input($field, $value, ["placeholder" => "예)010-0010-0010", "style" => "width:100%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
$form = form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
$form = form_input($field, $value, ["style" => "width:60%;"]);
|
||||
$form = form_input($field, $value, ["style" => "width:100%;"]);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
@ -54,9 +77,13 @@ function getFieldView_UserHelper(string $field, UserEntity $entity, array $viewD
|
||||
break;
|
||||
case 'role':
|
||||
foreach ($viewDatas['field_options'][$field] as $key => $label) {
|
||||
$checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label;
|
||||
$roles = explode(DEFAULTS["DELIMITER_ROLE"], $value);
|
||||
$checkboxs[] = form_checkbox("roles[]", $key, in_array($key, $roles)) . $label;
|
||||
}
|
||||
$value = implode(" ", $checkboxs);
|
||||
$checkbox_form = implode(" ", $checkboxs);
|
||||
$checkbox_form .= form_submit("", '권한처리', ["formaction" => current_url() . "/roles/{$entity->getPK()}", "class" => "btn btn-outline-primary"]);
|
||||
$checkbox_form .= form_close();
|
||||
$value = $checkbox_form;
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
|
||||
@ -16,8 +16,8 @@ return [
|
||||
],
|
||||
"ROLE" => [
|
||||
"guest" => "비회원",
|
||||
"user" => "회원",
|
||||
"vip" => "회원",
|
||||
"user" => "일반회원",
|
||||
"vip" => "VIP회원",
|
||||
"manager" => "관리자",
|
||||
"cloudflare" => "Cloudflare관리자",
|
||||
"director" => "감독자",
|
||||
|
||||
@ -64,6 +64,7 @@ class RecordSocket extends CloudflareSocket
|
||||
if (!$cf->success) {
|
||||
throw new \Exception("Record:" . __FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
||||
}
|
||||
//DB생성
|
||||
$formDatas = $this->getArrayByResult($cf->result);
|
||||
return $this->getModel()->create($formDatas);
|
||||
}
|
||||
@ -77,7 +78,6 @@ class RecordSocket extends CloudflareSocket
|
||||
'proxied' => $entity->proxied == 'on' ? true : false,
|
||||
'ttl' => intval($entity->ttl),
|
||||
];
|
||||
//변경작업: 2024-08-09
|
||||
if (isset($formDatas['proxied']) && $formDatas['proxied'] === 'on') {
|
||||
$datas['proxied'] = true;
|
||||
$datas['ttl'] = 1;
|
||||
@ -90,8 +90,9 @@ class RecordSocket extends CloudflareSocket
|
||||
if (!$cf->success) {
|
||||
throw new \Exception("Record:" . __FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
||||
}
|
||||
log_message("notice", "Record:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
return $entity;
|
||||
//DB수정
|
||||
$formDatas = $this->getArrayByResult($cf->result);
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
public function delete(RecordEntity $entity): void
|
||||
{
|
||||
@ -100,11 +101,13 @@ class RecordSocket extends CloudflareSocket
|
||||
if (!$cf->success) {
|
||||
throw new \Exception("Record:" . __FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
||||
}
|
||||
log_message("notice", "Record:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
//DB삭제
|
||||
$this->getModel()->where(RecordModel::PK, $entity->getPK());
|
||||
$this->getModel()->delete();
|
||||
}
|
||||
public function sync(RecordEntity $entity): void
|
||||
{
|
||||
//Sync형태
|
||||
//기존 Sync형태
|
||||
// $cf = $this->getClient()->get("zones/{$this->_zone_entity->getPK()}/dns_records/" . $entity->getPK());
|
||||
// $cf = json_decode($cf->getBody());
|
||||
// if (!$cf->success) {
|
||||
@ -116,6 +119,7 @@ class RecordSocket extends CloudflareSocket
|
||||
$promise->then(
|
||||
onFulfilled: function ($response) use ($entity): RecordEntity {
|
||||
$record = json_decode($response->getBody(), true)['result'];
|
||||
//DB수정
|
||||
return $this->getModel()->modify($entity, $this->getArrayByResult($record));
|
||||
},
|
||||
onRejected: function ($error) {
|
||||
@ -131,12 +135,13 @@ class RecordSocket extends CloudflareSocket
|
||||
log_message("notice", "-----{$this->_zone_entity->getTitle()} 처리 시작-----");
|
||||
$entity_uids = [];
|
||||
$results = $this->reload_procedure("zones/{$this->_zone_entity->getPK()}/dns_records");
|
||||
//DB수정
|
||||
foreach ($results as $result) {
|
||||
$formDatas = $this->getArrayByResult($result);
|
||||
$entity = $this->getModel()->modify($this->getModel()->getEntity(), $formDatas);
|
||||
$entity_uids[] = $entity->getPK();
|
||||
}
|
||||
//부모키를 기준으로 CF에 존재하지 않는 데이터 삭제용
|
||||
//부모키를 기준으로 CF에 존재하지 않는 데이터 DB삭제
|
||||
$this->getModel()->where(RecordModel::PARENT, $this->_zone_entity);
|
||||
$this->getModel()->whereNotIn(RecordModel::PK, $entity_uids);
|
||||
$this->getModel()->delete();
|
||||
|
||||
@ -88,8 +88,7 @@ class ZoneSocket extends CloudflareSocket
|
||||
throw new \Exception("Zone:" . __FUNCTION__ . "에서 {$field}->{$value} 변경실패:\n" . var_export($cf, true));
|
||||
}
|
||||
//최종 결과값은 body->result->id='필드명',body->result->value='on/off'이런식으로 받음
|
||||
$entity->$field = $cf->result->value;
|
||||
return $entity;
|
||||
return $cf->result->value;
|
||||
}
|
||||
public function create(string $domain, bool $jump_start = false): ZoneEntity
|
||||
{
|
||||
@ -104,23 +103,27 @@ class ZoneSocket extends CloudflareSocket
|
||||
if (!$cf->success) {
|
||||
throw new \Exception("Zone:" . __FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
||||
}
|
||||
//Storage용
|
||||
//DB생성
|
||||
$formDatas = $this->getArrayByResult($cf->result);
|
||||
$entity = $this->getModel()->create($formDatas);
|
||||
//아래는 추가 셋팅 ipv6 TurnOFF , //Development mode TurnOFF
|
||||
$entity = $this->setCFSetting($entity, 'ipv6', 'off');
|
||||
$entity = $this->setCFSetting($entity, 'development_mode', 'off');
|
||||
$entity = $this->setCFSetting($entity, 'security_level', 'medium');
|
||||
return $entity;
|
||||
|
||||
//초기화값 추가셋팅 ipv6 , development_mode , security_level
|
||||
$formDatas = [];
|
||||
$formDatas['ipv6'] = $this->setCFSetting($entity, 'ipv6', 'off');
|
||||
$formDatas['development_mode'] = $this->setCFSetting($entity, 'development_mode', 'off');
|
||||
$formDatas['security_level'] = $this->setCFSetting($entity, 'security_level', 'medium');
|
||||
//DB수정
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
public function modify(ZoneEntity $entity, array $formDatas): ZoneEntity
|
||||
{
|
||||
//ipv6 , //development_mode , //security_level
|
||||
//modify,toggle,batchjob 사용 셋팅 ipv6 , //development_mode , //security_level
|
||||
$formDatas = [];
|
||||
foreach ($formDatas as $field => $value) {
|
||||
$entity = $this->setCFSetting($entity, $field, $value);
|
||||
$formDatas[$field] = $this->setCFSetting($entity, $field, $value);
|
||||
}
|
||||
log_message("notice", "Zone:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
return $entity;
|
||||
//DB수정
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
public function delete(ZoneEntity $entity): void
|
||||
{
|
||||
@ -129,17 +132,34 @@ class ZoneSocket extends CloudflareSocket
|
||||
if (!$cf->success) {
|
||||
throw new \Exception("Zone:" . __FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
||||
}
|
||||
log_message("notice", "Zone:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
//DB삭제
|
||||
$this->getModel()->where(ZoneModel::PK, $entity->getPK());
|
||||
$this->getModel()->delete();
|
||||
}
|
||||
public function sync(ZoneEntity $entity): ZoneEntity
|
||||
public function sync(ZoneEntity $entity): void
|
||||
{
|
||||
$cf = $this->getClient()->get('zones/' . $entity->getPK());
|
||||
$cf = json_decode($cf->getBody());
|
||||
if (!$cf->success) {
|
||||
throw new \Exception("Zone:" . __FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
||||
}
|
||||
log_message("notice", "Zone:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
return new ZoneEntity($this->getArrayByResult($cf->result));
|
||||
//기존 Sync형태
|
||||
// $cf = $this->getClient()->get('zones/' . $entity->getPK());
|
||||
// $cf = json_decode($cf->getBody());
|
||||
// if (!$cf->success) {
|
||||
// throw new \Exception("Zone:" . __FUNCTION__ . "에서 실패:\n" . var_export($cf, true));
|
||||
// }
|
||||
// log_message("notice", "Zone:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
// return new ZoneEntity($this->getArrayByResult($cf->result));
|
||||
//Async형태
|
||||
$promise = $this->getClient()->getAsync("zones/{$entity->getPK()}");
|
||||
$promise->then(
|
||||
onFulfilled: function ($response) use ($entity): ZoneEntity {
|
||||
$record = json_decode($response->getBody(), true)['result'];
|
||||
//DB수정
|
||||
return $this->getModel()->modify($entity, $this->getArrayByResult($record));
|
||||
},
|
||||
onRejected: function ($error) {
|
||||
log_message('error', 'Failed to fetch DNS records: ' . $error->getMessage());
|
||||
// throw new \Exception('Failed to fetch DNS records: ' . $error->getMessage());
|
||||
}
|
||||
);
|
||||
$promise->wait();
|
||||
}
|
||||
//Reload
|
||||
public function reload(): void
|
||||
|
||||
@ -49,6 +49,10 @@ class UserModel extends CommonModel
|
||||
//아래 Rule은 checkbox를 사용시에는 required만 우선 써야 수정시 validate문제없음
|
||||
$rules[$field] = "required|trim|string";
|
||||
break;
|
||||
case "role[]":
|
||||
case "roles[]":
|
||||
$rules[$field] = "if_exist|trim|string";
|
||||
break;
|
||||
case "passwd":
|
||||
default:
|
||||
$rules = parent::getFieldRule($action, $field, $rules);
|
||||
@ -73,7 +77,6 @@ class UserModel extends CommonModel
|
||||
{
|
||||
return $this->create_process(new UserEntity(), $formDatas);
|
||||
}
|
||||
|
||||
//modify용
|
||||
public function modify(UserEntity $entity, array $formDatas): UserEntity
|
||||
{
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/content.js"></script>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/index_top'); ?>
|
||||
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="index_table table table-bordered table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -30,5 +29,4 @@
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?= form_close() ?>
|
||||
<?= $this->endSection() ?>
|
||||
@ -3,7 +3,7 @@
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/content.js"></script>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/index_top'); ?>
|
||||
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<?= form_open("", $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="index_table table table-bordered table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -35,17 +35,17 @@
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?= form_close() ?>
|
||||
<div class="index_bottom">
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
|
||||
<?php foreach ($viewDatas['batchjob_fields'] as $field): ?>
|
||||
<?= getFieldForm_AuthHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")) ?></li>
|
||||
<li class="nav-item"><?= form_submit("", '일괄처리', ['formaction' => current_url() . '/batchjob', "class" => "btn btn-outline btn-warning"]) ?></li>
|
||||
<li class="nav-item"><button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="<?= current_url() . '/create' ?>">입력</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?= form_close() ?>
|
||||
<div class="index_pagination"><?= $viewDatas['pagination'] ?></div>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/modalform'); ?>
|
||||
<?= $this->endSection() ?>
|
||||
@ -3,7 +3,7 @@
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/content.js"></script>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/index_top'); ?>
|
||||
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<?= form_open("", $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="index_table table table-bordered table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -37,17 +37,17 @@
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?= form_close() ?>
|
||||
<div class="index_bottom">
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
|
||||
<?php foreach ($viewDatas['batchjob_fields'] as $field): ?>
|
||||
<?= getFieldForm_RecordHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")) ?></li>
|
||||
<li class="nav-item"><?= form_submit("", '일괄처리', ['formaction' => current_url() . '/batchjob', "class" => "btn btn-outline btn-warning"]) ?></li>
|
||||
<li class="nav-item"><button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="<?= current_url() . '/create' ?>">입력</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?= form_close() ?>
|
||||
<div class="index_pagination"><?= $viewDatas['pagination'] ?></div>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/modalform'); ?>
|
||||
<?= $this->endSection() ?>
|
||||
@ -3,7 +3,7 @@
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/content.js"></script>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/index_top'); ?>
|
||||
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<?= form_open("", $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="index_table table table-bordered table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -35,17 +35,17 @@
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?= form_close() ?>
|
||||
<div class="index_bottom">
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
|
||||
<?php foreach ($viewDatas['batchjob_fields'] as $field): ?>
|
||||
<?= getFieldForm_ZoneHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")) ?></li>
|
||||
<li class="nav-item"><?= form_submit("", '일괄처리', ['formaction' => current_url() . '/batchjob', "class" => "btn btn-outline btn-warning"]) ?></li>
|
||||
<li class="nav-item"><button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="<?= current_url() . '/create' ?>">입력</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?= form_close() ?>
|
||||
<div class="index_pagination"><?= $viewDatas['pagination'] ?></div>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/modalform'); ?>
|
||||
<?= $this->endSection() ?>
|
||||
@ -2,7 +2,7 @@
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/content.js"></script>
|
||||
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<?= form_open("", $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/index_top'); ?>
|
||||
<table class="index_table table table-bordered table-hover table-striped">
|
||||
<thead>
|
||||
@ -35,17 +35,17 @@
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?= form_close() ?>
|
||||
<div class="index_bottom">
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
|
||||
<?php foreach ($viewDatas['batchjob_fields'] as $field): ?>
|
||||
<?= getFieldForm_MapurlHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")) ?></li>
|
||||
<li class="nav-item"><?= form_submit("", '일괄처리', ['formaction' => current_url() . '/batchjob', "class" => "btn btn-outline btn-warning"]) ?></li>
|
||||
<li class="nav-item"><button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="<?= current_url() . '/create' ?>">입력</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?= form_close() ?>
|
||||
<div class="index_pagination"><?= $viewDatas['pagination'] ?></div>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/modalform'); ?>
|
||||
<?= $this->endSection() ?>
|
||||
20
app/Views/admin/user/download.php
Normal file
20
app/Views/admin/user/download.php
Normal file
@ -0,0 +1,20 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ($viewDatas['fields'] as $field): ?>
|
||||
<th><?= lang("{$viewDatas['class_path']}.label.{$field}") ?></th>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $cnt = 0 ?>
|
||||
<?php foreach ($viewDatas['entitys'] as $entity): ?>
|
||||
<tr>
|
||||
<?php foreach ($viewDatas['fields'] as $field): ?>
|
||||
<td><?= $entity->$field ?></td>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
<?php $cnt++ ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -3,7 +3,7 @@
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/content.js"></script>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/index_top'); ?>
|
||||
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<?= form_open("", $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="index_table table table-bordered table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -35,17 +35,17 @@
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?= form_close() ?>
|
||||
<div class="index_bottom">
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
|
||||
<?php foreach ($viewDatas['batchjob_fields'] as $field): ?>
|
||||
<?= getFieldForm_UserHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")) ?></li>
|
||||
<li class="nav-item"><?= form_submit("", '일괄처리', ['formaction' => current_url() . '/batchjob', "class" => "btn btn-outline btn-warning"]) ?></li>
|
||||
<li class="nav-item"><button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="<?= current_url() . '/create' ?>">입력</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?= form_close() ?>
|
||||
<div class=" index_pagination"><?= $viewDatas['pagination'] ?></div>
|
||||
<?= $this->include('templates/' . $viewDatas['layout'] . '/modalform'); ?>
|
||||
<?= $this->endSection() ?>
|
||||
@ -12,8 +12,7 @@
|
||||
검색어:<?= form_input('word', $viewDatas['word']) ?>
|
||||
검색일:<?= form_input('start', $viewDatas['start'], ["class" => "calender"]) ?><?= form_input('end', $viewDatas['end'], ["class" => "calender"]) ?>
|
||||
<?= form_submit('', '검색하기') ?>
|
||||
<?= anchor(current_url() . '/download?output_type=excel' . $viewDatas['uri']->getQuery(), ICONS['EXCEL'], ["target" => "_self", "class" => "excel"]) ?>
|
||||
<?= anchor(current_url() . '/download?output_type=pdf' . $viewDatas['uri']->getQuery(), ICONS['PDF'], ["target" => "_self", "class" => "pdf"]) ?>
|
||||
<?= anchor(current_url() . '/download/excel', ICONS['EXCEL'], ["target" => "_self", "class" => "excel"]) ?>
|
||||
</nav>
|
||||
<nav class="pageinfo nav justify-content-end">
|
||||
페이지 : <?= $viewDatas['page'] ?>/<?= $viewDatas['total_page'] ?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user