cfmgrv4 init...1
This commit is contained in:
parent
5002eebb1c
commit
8ce1c0ffb0
@ -41,7 +41,7 @@ class AuthController extends CloudflareController
|
|||||||
$this->init('create');
|
$this->init('create');
|
||||||
return $this->create_form_procedure();
|
return $this->create_form_procedure();
|
||||||
}
|
}
|
||||||
public function create(): RedirectResponse
|
public function create(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->init(__FUNCTION__);
|
$this->init(__FUNCTION__);
|
||||||
return $this->create_procedure();
|
return $this->create_procedure();
|
||||||
@ -52,7 +52,7 @@ class AuthController extends CloudflareController
|
|||||||
$this->init('modify');
|
$this->init('modify');
|
||||||
return $this->modify_form_procedure($uid);
|
return $this->modify_form_procedure($uid);
|
||||||
}
|
}
|
||||||
public function modify(string $uid): RedirectResponse
|
public function modify(string $uid): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->init(__FUNCTION__);
|
$this->init(__FUNCTION__);
|
||||||
return $this->modify_procedure($uid);
|
return $this->modify_procedure($uid);
|
||||||
|
|||||||
@ -95,7 +95,7 @@ class RecordController extends CloudflareController
|
|||||||
log_message("debug", "Record:{$entity->getTitle()} 생성 작업을 완료하였습니다.");
|
log_message("debug", "Record:{$entity->getTitle()} 생성 작업을 완료하였습니다.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function create(): RedirectResponse
|
public function create(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->init(__FUNCTION__);
|
$this->init(__FUNCTION__);
|
||||||
$this->create_validate($this->action, $this->fields);
|
$this->create_validate($this->action, $this->fields);
|
||||||
|
|||||||
@ -118,7 +118,7 @@ class ZoneController extends CloudflareController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function create(): RedirectResponse
|
public function create(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->init(__FUNCTION__);
|
$this->init(__FUNCTION__);
|
||||||
$this->create_validate($this->action, $this->fields);
|
$this->create_validate($this->action, $this->fields);
|
||||||
|
|||||||
@ -58,19 +58,8 @@ class MapurlController extends AdminController
|
|||||||
//모든 필요한 FormOption등 조기화작업 필요
|
//모든 필요한 FormOption등 조기화작업 필요
|
||||||
$this->getModel()->where('status', DEFAULTS['STATUS']);
|
$this->getModel()->where('status', DEFAULTS['STATUS']);
|
||||||
$this->getModel()->orderBy('oldurl', 'ASC');
|
$this->getModel()->orderBy('oldurl', 'ASC');
|
||||||
//html의 case문 설정
|
$this->entitys = $this->getModel()->getEntitys();
|
||||||
$urls = array("");
|
$remap_page = view($this->class_path . DIRECTORY_SEPARATOR . 'remap_template', ["viewDatas" => $this->getViewDatas()]);
|
||||||
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]);
|
|
||||||
$remap_path = FCPATH . DIRECTORY_SEPARATOR . "mapurl";
|
$remap_path = FCPATH . DIRECTORY_SEPARATOR . "mapurl";
|
||||||
//디렉토리 생성 여부 확인
|
//디렉토리 생성 여부 확인
|
||||||
if (!is_dir($remap_path)) {
|
if (!is_dir($remap_path)) {
|
||||||
@ -92,7 +81,7 @@ class MapurlController extends AdminController
|
|||||||
parent::create_process();
|
parent::create_process();
|
||||||
$this->remaping_process();
|
$this->remaping_process();
|
||||||
}
|
}
|
||||||
public function create(): RedirectResponse
|
public function create(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->init(__FUNCTION__);
|
$this->init(__FUNCTION__);
|
||||||
return $this->create_procedure();
|
return $this->create_procedure();
|
||||||
@ -109,7 +98,7 @@ class MapurlController extends AdminController
|
|||||||
parent::modify_process($uid);
|
parent::modify_process($uid);
|
||||||
$this->remaping_process();
|
$this->remaping_process();
|
||||||
}
|
}
|
||||||
public function modify(string $uid): RedirectResponse
|
public function modify(string $uid): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->init(__FUNCTION__);
|
$this->init(__FUNCTION__);
|
||||||
return $this->modify_procedure($uid);
|
return $this->modify_procedure($uid);
|
||||||
|
|||||||
@ -90,7 +90,7 @@ class UserController extends AdminController
|
|||||||
$this->init('create');
|
$this->init('create');
|
||||||
return $this->create_form_procedure();
|
return $this->create_form_procedure();
|
||||||
}
|
}
|
||||||
public function create(): RedirectResponse
|
public function create(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->init(__FUNCTION__);
|
$this->init(__FUNCTION__);
|
||||||
return $this->create_procedure();
|
return $this->create_procedure();
|
||||||
@ -123,7 +123,7 @@ class UserController extends AdminController
|
|||||||
$this->init('modify');
|
$this->init('modify');
|
||||||
return $this->modify_form_procedure($uid);
|
return $this->modify_form_procedure($uid);
|
||||||
}
|
}
|
||||||
public function modify(string $uid): RedirectResponse
|
public function modify(string $uid): RedirectResponse|string
|
||||||
{
|
{
|
||||||
$this->init(__FUNCTION__);
|
$this->init(__FUNCTION__);
|
||||||
return $this->modify_procedure($uid);
|
return $this->modify_procedure($uid);
|
||||||
|
|||||||
@ -64,7 +64,7 @@ abstract class MVController extends CommonController
|
|||||||
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
|
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
|
||||||
$this->validation = service('validation');
|
$this->validation = service('validation');
|
||||||
foreach ($fields as $field) {
|
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()) {
|
if (!$this->validation->withRequest($this->request)->run()) {
|
||||||
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
|
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
|
||||||
@ -96,7 +96,7 @@ abstract class MVController extends CommonController
|
|||||||
$this->formDatas = $this->getFormDatas();
|
$this->formDatas = $this->getFormDatas();
|
||||||
$this->entity = $this->getModel()->create(formDatas: $this->formDatas);
|
$this->entity = $this->getModel()->create(formDatas: $this->formDatas);
|
||||||
}
|
}
|
||||||
final protected function create_procedure(): RedirectResponse
|
final protected function create_procedure(): RedirectResponse|string
|
||||||
{
|
{
|
||||||
//Transaction Start
|
//Transaction Start
|
||||||
$this->getModel()->transStart();
|
$this->getModel()->transStart();
|
||||||
@ -104,8 +104,9 @@ abstract class MVController extends CommonController
|
|||||||
$this->create_process();
|
$this->create_process();
|
||||||
$this->getModel()->transCommit();
|
$this->getModel()->transCommit();
|
||||||
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||||
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n");
|
// $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n");
|
||||||
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
// return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||||
|
return alert_CommonHelper(__FUNCTION__ . " => 작업을 완료하였습니다.\n");
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
//Transaction Rollback
|
//Transaction Rollback
|
||||||
$this->getModel()->transRollback();
|
$this->getModel()->transRollback();
|
||||||
@ -120,7 +121,9 @@ abstract class MVController extends CommonController
|
|||||||
{
|
{
|
||||||
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
|
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
|
||||||
$this->validation = service('validation');
|
$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()) {
|
if (!$this->validation->withRequest($this->request)->run()) {
|
||||||
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
|
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
|
||||||
"\n",
|
"\n",
|
||||||
@ -162,7 +165,7 @@ abstract class MVController extends CommonController
|
|||||||
}
|
}
|
||||||
$this->entity = $this->getModel()->modify($this->entity, $this->formDatas);
|
$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
|
//Transaction Start
|
||||||
$this->getModel()->transStart();
|
$this->getModel()->transStart();
|
||||||
@ -170,8 +173,9 @@ abstract class MVController extends CommonController
|
|||||||
$this->modify_process($uid);
|
$this->modify_process($uid);
|
||||||
$this->getModel()->transCommit();
|
$this->getModel()->transCommit();
|
||||||
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||||
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n");
|
// $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " => 작업을 완료하였습니다.\n");
|
||||||
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
// return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||||
|
return alert_CommonHelper(__FUNCTION__ . " => 작업을 완료하였습니다.\n");
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
//Transaction Rollback
|
//Transaction Rollback
|
||||||
$this->getModel()->transRollback();
|
$this->getModel()->transRollback();
|
||||||
|
|||||||
@ -98,3 +98,31 @@ function getListColumns_MapurlHelper(string $field, array $viewDatas, array $ext
|
|||||||
}
|
}
|
||||||
return sprintf("<th %s>%s</th>", implode(" ", $extras), $label);
|
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));
|
||||||
|
}
|
||||||
|
|||||||
@ -84,7 +84,7 @@ abstract class CommonModel extends Model
|
|||||||
$rule = $action == "create" ? "required" : "if_exist" . "|trim|string";
|
$rule = $action == "create" ? "required" : "if_exist" . "|trim|string";
|
||||||
break;
|
break;
|
||||||
case "confirmpassword":
|
case "confirmpassword":
|
||||||
$rules["confirmpassword"] = $action == "create" ? "required" : "if_exist" . "|trim|string|matches[passwd]";
|
$rule = $action == "create" ? "required" : "if_exist" . "|trim|string|matches[passwd]";
|
||||||
break;
|
break;
|
||||||
case "email":
|
case "email":
|
||||||
$rule = "if_exist|trim|valid_email";
|
$rule = "if_exist|trim|valid_email";
|
||||||
|
|||||||
15
app/Views/admin/mapurl/remap_template.php
Normal file
15
app/Views/admin/mapurl/remap_template.php
Normal 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
2692
public/mapurl/index.html
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user