cfmgrv4 init...1

This commit is contained in:
최준흠 2024-10-03 10:03:14 +09:00
parent 5002eebb1c
commit 8ce1c0ffb0
10 changed files with 2758 additions and 30 deletions

View File

@ -41,7 +41,7 @@ class AuthController extends CloudflareController
$this->init('create');
return $this->create_form_procedure();
}
public function create(): RedirectResponse
public function create(): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->create_procedure();
@ -52,7 +52,7 @@ class AuthController extends CloudflareController
$this->init('modify');
return $this->modify_form_procedure($uid);
}
public function modify(string $uid): RedirectResponse
public function modify(string $uid): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->modify_procedure($uid);

View File

@ -95,7 +95,7 @@ class RecordController extends CloudflareController
log_message("debug", "Record:{$entity->getTitle()} 생성 작업을 완료하였습니다.");
}
}
public function create(): RedirectResponse
public function create(): RedirectResponse|string
{
$this->init(__FUNCTION__);
$this->create_validate($this->action, $this->fields);

View File

@ -118,7 +118,7 @@ class ZoneController extends CloudflareController
}
}
}
public function create(): RedirectResponse
public function create(): RedirectResponse|string
{
$this->init(__FUNCTION__);
$this->create_validate($this->action, $this->fields);

View File

@ -58,19 +58,8 @@ class MapurlController extends AdminController
//모든 필요한 FormOption등 조기화작업 필요
$this->getModel()->where('status', DEFAULTS['STATUS']);
$this->getModel()->orderBy('oldurl', 'ASC');
//html의 case문 설정
$urls = array("");
foreach ($this->getModel()->getEntitys() as $entity) {
$temp_oldurl = sprintf("case '%s':", trim($entity->oldurl));
//한글을 포함하고 있는지 체크
if (preg_match("/[\xE0-\xFF][\x80-\xFF][\x80-\xFF]/", $entity->oldurl)) {
//도메인 URL 분리
preg_match("/^(https?:\/\/)(.*)/", $entity->oldurl, $matches);
$temp_oldurl = sprintf("case '%s%s':\ncase '%s':", $matches[1], idn_to_ascii($matches[2]), trim($entity->oldurl));
}
array_push($urls, sprintf("\t\t\t%s\n \t\t\twindow.location.href='%s';\n \t\tbreak;", $temp_oldurl, trim($entity->newurl)));
}
$remap_page = view($this->class_path . DIRECTORY_SEPARATOR . __FUNCTION__, ["urls" => $urls]);
$this->entitys = $this->getModel()->getEntitys();
$remap_page = view($this->class_path . DIRECTORY_SEPARATOR . 'remap_template', ["viewDatas" => $this->getViewDatas()]);
$remap_path = FCPATH . DIRECTORY_SEPARATOR . "mapurl";
//디렉토리 생성 여부 확인
if (!is_dir($remap_path)) {
@ -92,7 +81,7 @@ class MapurlController extends AdminController
parent::create_process();
$this->remaping_process();
}
public function create(): RedirectResponse
public function create(): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->create_procedure();
@ -109,7 +98,7 @@ class MapurlController extends AdminController
parent::modify_process($uid);
$this->remaping_process();
}
public function modify(string $uid): RedirectResponse
public function modify(string $uid): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->modify_procedure($uid);

View File

@ -90,7 +90,7 @@ class UserController extends AdminController
$this->init('create');
return $this->create_form_procedure();
}
public function create(): RedirectResponse
public function create(): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->create_procedure();
@ -123,7 +123,7 @@ class UserController extends AdminController
$this->init('modify');
return $this->modify_form_procedure($uid);
}
public function modify(string $uid): RedirectResponse
public function modify(string $uid): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->modify_procedure($uid);

View File

@ -64,7 +64,7 @@ abstract class MVController extends CommonController
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
$this->validation = service('validation');
foreach ($fields as $field) {
$this->validation->setRule($field, $this->getModel()->getFieldRule($action, $field));
$this->validation->setRule($field, $field, $this->getModel()->getFieldRule($action, $field));
}
if (!$this->validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
@ -96,7 +96,7 @@ abstract class MVController extends CommonController
$this->formDatas = $this->getFormDatas();
$this->entity = $this->getModel()->create(formDatas: $this->formDatas);
}
final protected function create_procedure(): RedirectResponse
final protected function create_procedure(): RedirectResponse|string
{
//Transaction Start
$this->getModel()->transStart();
@ -104,8 +104,9 @@ abstract class MVController extends CommonController
$this->create_process();
$this->getModel()->transCommit();
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n");
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
// $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n");
// return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
return alert_CommonHelper(__FUNCTION__ . " => 작업을 완료하였습니다.\n");
} catch (\Exception $e) {
//Transaction Rollback
$this->getModel()->transRollback();
@ -120,7 +121,9 @@ abstract class MVController extends CommonController
{
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
$this->validation = service('validation');
$this->validation->setRules($this->getModel()->getFieldRules($action, $fields));
foreach ($fields as $field) {
$this->validation->setRule($field, $field, $this->getModel()->getFieldRule($action, $field));
}
if (!$this->validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
"\n",
@ -162,7 +165,7 @@ abstract class MVController extends CommonController
}
$this->entity = $this->getModel()->modify($this->entity, $this->formDatas);
}
final protected function modify_procedure(string $uid): RedirectResponse
final protected function modify_procedure(string $uid): RedirectResponse|string
{
//Transaction Start
$this->getModel()->transStart();
@ -170,8 +173,9 @@ abstract class MVController extends CommonController
$this->modify_process($uid);
$this->getModel()->transCommit();
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n");
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
// $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n");
// return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
return alert_CommonHelper(__FUNCTION__ . " => 작업을 완료하였습니다.\n");
} catch (\Exception $e) {
//Transaction Rollback
$this->getModel()->transRollback();

View File

@ -98,3 +98,31 @@ function getListColumns_MapurlHelper(string $field, array $viewDatas, array $ext
}
return sprintf("<th %s>%s</th>", implode(" ", $extras), $label);
}
function getRemapPage_MapurlHelper(array $viewDatas): string
{
$urls = [];
foreach ($viewDatas['entitys'] as $entity) {
//한글을 포함하고 있는지 체크 HTTP 나 HTTPS 와 도메인 분리해서 한글도메인을 Punycode로 변환
if (preg_match("/[\xE0-\xFF][\x80-\xFF][\x80-\xFF]/", $entity->oldurl)) {
preg_match("/^(https?:\/\/)(.*)/", $entity->oldurl, $matches);
$oldurl = $matches[1] . idn_to_ascii($matches[2]);
} else {
$oldurl = trim($entity->oldurl);
}
$urls[] = sprintf(
"case '%s': window.location.href='%s'; break;",
$oldurl,
trim($entity->newurl)
);
}
return sprintf("
switch (window.location.origin) {
%s
default:
alert(window.location.origin + ' 지정되지 않은 URL입니다');
history.go(-1);
break;
}
", implode("\n", $urls));
}

View File

@ -84,7 +84,7 @@ abstract class CommonModel extends Model
$rule = $action == "create" ? "required" : "if_exist" . "|trim|string";
break;
case "confirmpassword":
$rules["confirmpassword"] = $action == "create" ? "required" : "if_exist" . "|trim|string|matches[passwd]";
$rule = $action == "create" ? "required" : "if_exist" . "|trim|string|matches[passwd]";
break;
case "email":
$rule = "if_exist|trim|valid_email";

View File

@ -0,0 +1,15 @@
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script type="text/javascript" charset="UTF-8">
window.location.origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? (':' + window.location.port) : '');
<?= getRemapPage_MapurlHelper($viewDatas) ?>
</script>
</body>
</html>

2692
public/mapurl/index.html Normal file

File diff suppressed because it is too large Load Diff