Compare commits
4 Commits
main
...
cloudflare
| Author | SHA1 | Date | |
|---|---|---|---|
| 756b1ba199 | |||
| a2129e49ae | |||
| 1893200123 | |||
| 2d41c92d98 |
@ -14,7 +14,7 @@ $routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}
|
|||||||
$routes->get('/', 'Home::index');
|
$routes->get('/', 'Home::index');
|
||||||
$routes->group('mangboard', ['namespace' => 'App\Controllers\Mangboard'], function ($routes) {
|
$routes->group('mangboard', ['namespace' => 'App\Controllers\Mangboard'], function ($routes) {
|
||||||
$routes->group('user', function ($routes) {
|
$routes->group('user', function ($routes) {
|
||||||
$routes->get('/', 'UserController::index', ['filter' => 'authFilter:manager']);
|
$routes->get('/', 'UserController::index');
|
||||||
$routes->cli('point/(:alpha)/(:num)', 'UserController::point/$1/$2');
|
$routes->cli('point/(:alpha)/(:num)', 'UserController::point/$1/$2');
|
||||||
$routes->cli('point/(:alpha)/(:num)/(:any)', 'UserController::point/$1/$2/$3');
|
$routes->cli('point/(:alpha)/(:num)/(:any)', 'UserController::point/$1/$2/$3');
|
||||||
$routes->cli('level/(:alpha)/(:num)', 'UserController::level/$1/$2');
|
$routes->cli('level/(:alpha)/(:num)', 'UserController::level/$1/$2');
|
||||||
|
|||||||
@ -1,156 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controllers;
|
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
|
||||||
use CodeIgniter\HTTP\RedirectResponse;
|
|
||||||
|
|
||||||
abstract class MVController extends CommonController
|
|
||||||
{
|
|
||||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
||||||
{
|
|
||||||
parent::initController($request, $response, $logger);
|
|
||||||
helper('common');
|
|
||||||
}
|
|
||||||
abstract protected function create_init(): void;
|
|
||||||
abstract protected function getModel(): mixed;
|
|
||||||
//Field별 Form Option용
|
|
||||||
protected function getFormFieldOption(string $field, array $options = []): array
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
default:
|
|
||||||
$temps = lang($this->class_name . '.' . strtoupper($field));
|
|
||||||
if (!is_array($temps)) {
|
|
||||||
throw new \Exception(__FUNCTION__ . "에서 {$field}의 데이터가 array가 아닙니다.\n" . var_export($temps, true));
|
|
||||||
}
|
|
||||||
$options = [
|
|
||||||
"" => lang($this->class_name . '.label.' . $field) . ' 선택',
|
|
||||||
...lang($this->class_name . '.' . strtoupper($field)),
|
|
||||||
];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $options;
|
|
||||||
}
|
|
||||||
protected function getFormFieldInput(string $field, string $value, array $inputs = []): array
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
case 'status':
|
|
||||||
$inputs[$field] = form_dropdown(
|
|
||||||
$field,
|
|
||||||
$this->getFormFieldOption($field),
|
|
||||||
$value
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'updated_at':
|
|
||||||
case 'created_at':
|
|
||||||
$inputs[$field] = form_input($field, $value, ["class" => " calender"]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$inputs[$field] = form_input($field, $value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $inputs;
|
|
||||||
}
|
|
||||||
final public function getFormFieldInputs(array $inputs = []): array
|
|
||||||
{
|
|
||||||
foreach ($this->fields as $field) {
|
|
||||||
if (is_array($field)) {
|
|
||||||
throw new \Exception(__FUNCTION__ . "에서 field array 입니다.\n" . var_export($field, true));
|
|
||||||
}
|
|
||||||
$inputs = $this->getFormFieldInput($field, old($field) ?? DEFAULTS['EMPTY'], $inputs);
|
|
||||||
}
|
|
||||||
return $inputs;
|
|
||||||
}
|
|
||||||
protected function getFormFieldRule(string $field, array $rules): array
|
|
||||||
{
|
|
||||||
if (is_array($field)) {
|
|
||||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
|
||||||
}
|
|
||||||
switch ($field) {
|
|
||||||
default:
|
|
||||||
$rules[$field] = $this->_model->getFieldRule($field, $rules);
|
|
||||||
;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $rules;
|
|
||||||
}
|
|
||||||
final public function getFormFieldRules(array $rules = []): array
|
|
||||||
{
|
|
||||||
foreach ($this->fields as $field) {
|
|
||||||
$rules = $this->getFormFieldRule($field, $rules);
|
|
||||||
}
|
|
||||||
return $rules;
|
|
||||||
}
|
|
||||||
//전송된 데이터 검증
|
|
||||||
protected function validateFormData(): void
|
|
||||||
{
|
|
||||||
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
|
|
||||||
$validation = service('validation');
|
|
||||||
$validation->setRules($this->getModel()->getFieldRules($this->fields));
|
|
||||||
if (!$validation->withRequest($this->request)->run()) {
|
|
||||||
throw new \Exception("데이터 검증 오류발생\n" . implode("\n", $validation->getErrors()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//전송된 데이터
|
|
||||||
protected function getFormData(string $field): void
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
default:
|
|
||||||
$this->formDatas[$field] = rtrim($this->request->getVar($field));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//전송된 데이터 재정의
|
|
||||||
protected function convertFormData(string $field): void
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final public function create_form_process(): RedirectResponse|string
|
|
||||||
{
|
|
||||||
helper(['form']);
|
|
||||||
try {
|
|
||||||
$this->create_init();
|
|
||||||
$this->forminputs = $this->getFormFieldInputs();
|
|
||||||
$this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
|
||||||
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
|
||||||
return view(
|
|
||||||
strtolower($this->class_name) . "/create",
|
|
||||||
['viewDatas' => $this->getAttributes()]
|
|
||||||
);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
log_message("error", $e->getMessage());
|
|
||||||
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with(SESSION_NAMES['RETURN_MSG'], $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
abstract protected function create_process_submit(): mixed;
|
|
||||||
final protected function create_process(): mixed
|
|
||||||
{
|
|
||||||
$this->getModel()->transStart();
|
|
||||||
try {
|
|
||||||
$this->create_init();
|
|
||||||
$this->validateFormData();
|
|
||||||
foreach ($this->fields as $field) {
|
|
||||||
$this->getFormData($field);
|
|
||||||
}
|
|
||||||
foreach ($this->fields as $field) {
|
|
||||||
$this->convertFormData($field);
|
|
||||||
}
|
|
||||||
$entity = $this->create_process_submit();
|
|
||||||
log_message("notice", __FUNCTION__ . "=>{$entity->getTitle()} 작업을 완료하였습니다.");
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,14 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controllers\Mangboard;
|
namespace App\Controllers\Mangboard\Admin;
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
|
||||||
use App\Models\Mangboard\UserModel;
|
|
||||||
|
|
||||||
use App\Libraries\MyMangboard\User;
|
|
||||||
use App\Controllers\CommonController;
|
use App\Controllers\CommonController;
|
||||||
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
use App\Models\Mangboard\UserModel;
|
||||||
|
|
||||||
class UserController extends CommonController
|
class UserController extends CommonController
|
||||||
{
|
{
|
||||||
@ -25,13 +24,6 @@ class UserController extends CommonController
|
|||||||
}
|
}
|
||||||
return $this->_model;
|
return $this->_model;
|
||||||
}
|
}
|
||||||
private function getUser(): User
|
|
||||||
{
|
|
||||||
if ($this->_user === null) {
|
|
||||||
$this->_user = new User();
|
|
||||||
}
|
|
||||||
return $this->_user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function point(string $id, string $point, string $sign = "+"): string
|
public function point(string $id, string $point, string $sign = "+"): string
|
||||||
{
|
{
|
||||||
@ -40,7 +32,7 @@ class UserController extends CommonController
|
|||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw new \Exception("해당 {$id}의 회원이 없습니다.");
|
throw new \Exception("해당 {$id}의 회원이 없습니다.");
|
||||||
}
|
}
|
||||||
$this->getUser()->setPoint($entity, intval($point), $sign);
|
$this->getModel()->setPoint($entity, intval($point), $sign);
|
||||||
return __FUNCTION__ . " 작업이 완료되었습니다.";
|
return __FUNCTION__ . " 작업이 완료되었습니다.";
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message("error", $e->getMessage());
|
log_message("error", $e->getMessage());
|
||||||
@ -54,7 +46,7 @@ class UserController extends CommonController
|
|||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw new \Exception("해당 {$id}의 회원이 없습니다.");
|
throw new \Exception("해당 {$id}의 회원이 없습니다.");
|
||||||
}
|
}
|
||||||
$this->getUser()->setLevel($entity, intval($level));
|
$this->getModel()->setLevel($entity, intval($level));
|
||||||
log_message("notice", "Mangboard->level 작업이 완료되었습니다.");
|
log_message("notice", "Mangboard->level 작업이 완료되었습니다.");
|
||||||
return __FUNCTION__ . " 작업이 완료되었습니다.";
|
return __FUNCTION__ . " 작업이 완료되었습니다.";
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -68,16 +60,16 @@ class UserController extends CommonController
|
|||||||
try {
|
try {
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
foreach ($this->getModel()->getEntitys() as $entity) {
|
foreach ($this->getModel()->getEntitys() as $entity) {
|
||||||
$level = $this->getUser()->getLevelByPoint($entity);
|
$level = $this->getModel->checkLevel($entity);
|
||||||
$this->getUser()->setLevel($entity, intval($level));
|
$this->getModel()->setLevel($entity, intval($level));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$entity = is_numeric($id) ? $this->getModel()->getEntityByPK(intval($id)) : $this->getModel()->getEntityByID($id);
|
$entity = is_numeric($id) ? $this->getModel()->getEntityByPK(intval($id)) : $this->getModel()->getEntityByID($id);
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw new \Exception("해당 {$id}의 회원이 없습니다.");
|
throw new \Exception("해당 {$id}의 회원이 없습니다.");
|
||||||
}
|
}
|
||||||
$level = $this->getUser()->getLevelByPoint($entity);
|
$level = $this->getModel->checkLevel($entity);
|
||||||
$this->getUser()->setLevel($entity, intval($level));
|
$this->getModel()->setLevel($entity, intval($level));
|
||||||
}
|
}
|
||||||
return __FUNCTION__ . " 작업이 완료되었습니다.";
|
return __FUNCTION__ . " 작업이 완료되었습니다.";
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|||||||
32
app/Entities/SNSUserEntity.php
Normal file
32
app/Entities/SNSUserEntity.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entities;
|
||||||
|
|
||||||
|
use App\Entities\CommonEntity;
|
||||||
|
use App\Models\SNSUserModel;
|
||||||
|
|
||||||
|
class SNSUserEntity extends CommonEntity
|
||||||
|
{
|
||||||
|
public function __toString(): string
|
||||||
|
{
|
||||||
|
return "{$this->getPK()}|{$this->getID()}|{$this->getTitle()}";
|
||||||
|
}
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return $this->attributes[SNSUserModel::TITLE];
|
||||||
|
}
|
||||||
|
public function setTitle(string $title): void
|
||||||
|
{
|
||||||
|
$this->attributes[SNSUserModel::TITLE] = $title;
|
||||||
|
}
|
||||||
|
//Common Function
|
||||||
|
|
||||||
|
public function getPK(): int
|
||||||
|
{
|
||||||
|
return $this->attributes[SNSUserModel::PK];
|
||||||
|
}
|
||||||
|
public function getID(): string
|
||||||
|
{
|
||||||
|
return $this->attributes['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Entities/UserEntity.php
Normal file
49
app/Entities/UserEntity.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entities;
|
||||||
|
|
||||||
|
use App\Entities\CommonEntity;
|
||||||
|
use App\Models\UserModel;
|
||||||
|
|
||||||
|
class UserEntity extends CommonEntity
|
||||||
|
{
|
||||||
|
public function __toString(): string
|
||||||
|
{
|
||||||
|
return "{$this->getPK()}:{$this->getID()}:{$this->getTitle()},{$this->getLevel()}/{$this->getPoint()}";
|
||||||
|
}
|
||||||
|
public function getPK(): int
|
||||||
|
{
|
||||||
|
return $this->attributes[UserModel::PK];
|
||||||
|
}
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return $this->attributes[UserModel::TITLE];
|
||||||
|
}
|
||||||
|
public function setTitle(string $title): void
|
||||||
|
{
|
||||||
|
$this->attributes[UserModel::TITLE] = $title;
|
||||||
|
}
|
||||||
|
//Common Function
|
||||||
|
|
||||||
|
public function getID(): string
|
||||||
|
{
|
||||||
|
return $this->attributes['id'];
|
||||||
|
}
|
||||||
|
public function getPoint(): int
|
||||||
|
{
|
||||||
|
return $this->attributes['point'];
|
||||||
|
}
|
||||||
|
public function setPoint(int $point): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->attributes['point'] = $point;
|
||||||
|
}
|
||||||
|
public function getLevel(): int
|
||||||
|
{
|
||||||
|
return $this->attributes['level'];
|
||||||
|
}
|
||||||
|
public function setLevel(int $value): void
|
||||||
|
{
|
||||||
|
$this->attributes['level'] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,110 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Libraries\MyAuth;
|
|
||||||
|
|
||||||
use App\Libraries\MySocket\Web\GoogleSocket;
|
|
||||||
use App\Entities\UserEntity;
|
|
||||||
use App\Entities\SNSUserEntity;
|
|
||||||
|
|
||||||
class GoogleAuth extends MyAuth
|
|
||||||
{
|
|
||||||
private $_mySocket = null;
|
|
||||||
private $_site = "GOOGLE";
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMySocket(): GoogleSocket
|
|
||||||
{
|
|
||||||
if ($this->_mySocket === null) {
|
|
||||||
$this->_mySocket = new GoogleSocket(getenv('yamap.host.url'));
|
|
||||||
}
|
|
||||||
return $this->_mySocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAuthButton()
|
|
||||||
{
|
|
||||||
$button = "";
|
|
||||||
if (!$this->getMySocket()->getAccessToken()) {
|
|
||||||
$button = anchor(
|
|
||||||
$this->getMySocket()->getClient()->createAuthUrl(),
|
|
||||||
ICONS['GOOGLE'],
|
|
||||||
["target" => "_self"]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $button;
|
|
||||||
}
|
|
||||||
public function execute(): UserEntity
|
|
||||||
{
|
|
||||||
return new UserEntity();
|
|
||||||
// try {
|
|
||||||
// //Google 접근 권한 설정.
|
|
||||||
// $this->getMySocket()->setAccessToken();
|
|
||||||
// //Google 서비스 설정
|
|
||||||
// //$service = new \Google\Service\Oauth2($this->getMySocket());
|
|
||||||
// $service = new \Google\Service\Oauth2($this->getMySocket());
|
|
||||||
// $result = $service->userinfo->get();
|
|
||||||
// log_message("debug", var_export($result, true));
|
|
||||||
// // throw new \Exception(__METHOD__ . "에서 데이터 처리 필요");
|
|
||||||
// // DEBUG - 2023-07-13 12:54:51 --> \Google\Service\Oauth2\Userinfo::__set_state(array(
|
|
||||||
// // 'internal_gapi_mappings' =>
|
|
||||||
// // array (
|
|
||||||
// // 'familyName' => 'family_name',
|
|
||||||
// // 'givenName' => 'given_name',
|
|
||||||
// // 'verifiedEmail' => 'verified_email',
|
|
||||||
// // ),
|
|
||||||
// // 'modelData' =>
|
|
||||||
// // array (
|
|
||||||
// // 'verified_email' => true,
|
|
||||||
// // 'given_name' => '이름',
|
|
||||||
// // 'family_name' => '성',
|
|
||||||
// // ),
|
|
||||||
// // 'processed' =>
|
|
||||||
// // array (
|
|
||||||
// // ),
|
|
||||||
// // 'email' => 'twsdfsew342s@gmail.com',
|
|
||||||
// // 'familyName' => '성',
|
|
||||||
// // 'gender' => NULL,
|
|
||||||
// // 'givenName' => '이름',
|
|
||||||
// // 'hd' => NULL,
|
|
||||||
// // 'id' => '103667492432234234236838324',
|
|
||||||
// // 'link' => NULL,
|
|
||||||
// // 'locale' => 'ko',
|
|
||||||
// // 'name' => '성이름',
|
|
||||||
// // 'picture' => 'https://lh3.googleusercontent.com/a/AAcHTteFSgefsdfsdRJBkJA2tBEmg4PQrvI1Ta_5IXu5=s96-c',
|
|
||||||
// // 'verifiedEmail' => true,
|
|
||||||
// // ))
|
|
||||||
// //조건에 해당하는 이미 등록된 사용자가 있는지 검사
|
|
||||||
// $snsEntity = null;
|
|
||||||
// try {
|
|
||||||
// $snsEntity = $this->getUserSNSModel()->asObject(SNSUSerEntity::class)->where(
|
|
||||||
// array("site" => $this->_site, "id" => $result['id'])
|
|
||||||
// )->first();
|
|
||||||
// } catch (\Exception $e) {
|
|
||||||
// $snsEntity = new SNSUSerEntity([
|
|
||||||
// 'site' => $this->_site,
|
|
||||||
// 'id' => $result['id'],
|
|
||||||
// 'name' => $result['name'],
|
|
||||||
// 'email' => $result['email'],
|
|
||||||
// 'detail' => json_encode($result),
|
|
||||||
// 'status' => 'standby',
|
|
||||||
// ]);
|
|
||||||
// $snsEntity = $this->getUserSNSModel()->create($snsEntity);
|
|
||||||
// }
|
|
||||||
// //상태가 use(승인완료)가 아니라면
|
|
||||||
// if ($snsEntity->status !== DEFAULTS['STATUS']) {
|
|
||||||
// throw new \Exception("{$this->_site}}의{$result['email']}:{$result['name']}님은 " . $snsEntity->status . "입니다");
|
|
||||||
// }
|
|
||||||
// //user_id가 연결되어있지 않았다면
|
|
||||||
// if (!$snsEntity->getID()) {
|
|
||||||
// throw new \Exception("{$this->_site}의{$result['email']}:{$result['name']}님은 아직 사용자 지정이 되지 않았습니다. ");
|
|
||||||
// }
|
|
||||||
// //인증된 사용자 정보를 가져온후 로그인처리
|
|
||||||
// $entity = $this->getUserModel()->getEntityByID($snsEntity->getID());
|
|
||||||
// return $this->setSession_process($entity);;
|
|
||||||
// } catch (\Exception $e) {
|
|
||||||
// throw new \Exception("관리자에게 문의하시기 바랍니다.<BR>{$e->getMessage()}");
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Libraries\MyAuth;
|
|
||||||
|
|
||||||
use App\Entities\UserEntity;
|
|
||||||
|
|
||||||
class LocalAuth extends MyAuth
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAuthButton()
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(): UserEntity
|
|
||||||
{
|
|
||||||
return new UserEntity();
|
|
||||||
// $formDatas = $this->getFormDatas();
|
|
||||||
// if (!isset($formDatas['id']) || !$formDatas['id'] || !isset($formDatas['passwd']) || !$formDatas['passwd']) {
|
|
||||||
// throw new \Exception("ID 나 암호의 값이 없습니다.");
|
|
||||||
// }
|
|
||||||
// $entity = $this->getUserModel()->getEntity(['id' => $formDatas['id'], 'status' => DEFAULTS['STATUS']]);
|
|
||||||
// if (!password_verify($formDatas['passwd'], $entity->passwd)) {
|
|
||||||
// throw new \Exception("암호가 맞지않습니다.");
|
|
||||||
// }
|
|
||||||
// //Session에 인증정보 설정
|
|
||||||
// return $this->setSession_process($entity);;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Libraries\MyAuth;
|
|
||||||
|
|
||||||
use App\Entities\UserEntity;
|
|
||||||
use App\Models\UserModel;
|
|
||||||
use App\Models\SNSUserModel;
|
|
||||||
|
|
||||||
// 참고:https://github.com/SyntaxPhoenix/iloclient
|
|
||||||
abstract class MyAuth
|
|
||||||
{
|
|
||||||
private $_userModel = null;
|
|
||||||
private $_snsUserModel = null;
|
|
||||||
protected $_session = null;
|
|
||||||
protected function __construct()
|
|
||||||
{
|
|
||||||
$this->_session = \Config\Services::session();
|
|
||||||
}
|
|
||||||
abstract public function getAuthButton();
|
|
||||||
abstract public function execute(): UserEntity;
|
|
||||||
|
|
||||||
final protected function getUserModel(): UserModel
|
|
||||||
{
|
|
||||||
if (is_null($this->_userModel)) {
|
|
||||||
$this->_userModel = new UserModel();
|
|
||||||
}
|
|
||||||
return $this->_userModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
final protected function getUserSNSModel(): SNSUSerModel
|
|
||||||
{
|
|
||||||
if (is_null($this->_snsUserModel)) {
|
|
||||||
$this->_snsUserModel = new SNSUserModel();
|
|
||||||
}
|
|
||||||
return $this->_snsUserModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setSession_process(UserEntity $entity): UserEntity
|
|
||||||
{
|
|
||||||
$this->_session->set(SESSION_NAMES['ISLOGIN'], true);
|
|
||||||
$auths = [];
|
|
||||||
foreach (array_values(AUTH_FIELDS) as $field) {
|
|
||||||
switch ($field) {
|
|
||||||
case 'id':
|
|
||||||
$auths[$field] = $entity->getPK();
|
|
||||||
break;
|
|
||||||
case 'title':
|
|
||||||
$auths[$field] = $entity->getTitle();
|
|
||||||
break;
|
|
||||||
case 'role':
|
|
||||||
$auths[$field] = $entity->$field;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->_session->set(SESSION_NAMES['AUTH'], $auths);
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Libraries\MyCrawler;
|
namespace App\Libraries\MyCrawler;
|
||||||
|
|
||||||
|
use App\Libraries\MySocket\WebSocket;
|
||||||
|
use App\Libraries\MyMangboard\Storage;
|
||||||
|
|
||||||
use Symfony\Component\DomCrawler\Crawler;
|
use Symfony\Component\DomCrawler\Crawler;
|
||||||
use App\Traits\FileTrait;
|
use App\Traits\FileTrait;
|
||||||
use App\Models\Mangboard\BoardsModel;
|
use App\Models\Mangboard\BoardsModel;
|
||||||
use App\Models\Mangboard\BoardModel;
|
use App\Models\Mangboard\BoardModel;
|
||||||
use App\Libraries\MyMangboard\Storage;
|
|
||||||
use App\Libraries\MySocket\WebSocket;
|
|
||||||
use App\Libraries\CommonLibrary;
|
use App\Libraries\CommonLibrary;
|
||||||
use App\Entities\Mangboard\UserEntity;
|
use App\Entities\Mangboard\UserEntity;
|
||||||
use App\Entities\Mangboard\BoardsEntity;
|
use App\Entities\Mangboard\BoardsEntity;
|
||||||
|
|||||||
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Libraries\MyMangboard;
|
namespace App\Libraries\MyMangboard;
|
||||||
|
|
||||||
use App\Traits\ImageTrait;
|
|
||||||
use App\Models\Mangboard\FileModel;
|
|
||||||
use App\Libraries\MyStorage\FileStorage;
|
|
||||||
use App\Entities\Mangboard\UserEntity;
|
|
||||||
use App\Entities\Mangboard\FileEntity;
|
|
||||||
use App\Entities\Mangboard\BoardsEntity;
|
|
||||||
use App\Entities\Mangboard\BoardEntity;
|
use App\Entities\Mangboard\BoardEntity;
|
||||||
|
use App\Entities\Mangboard\BoardsEntity;
|
||||||
|
use App\Entities\Mangboard\FileEntity;
|
||||||
|
use App\Entities\Mangboard\UserEntity;
|
||||||
|
use App\Libraries\MyStorage\FileStorage;
|
||||||
|
use App\Models\Mangboard\FileModel;
|
||||||
|
use App\Traits\ImageTrait;
|
||||||
|
|
||||||
class Storage extends FileStorage
|
class Storage extends FileStorage
|
||||||
{
|
{
|
||||||
@ -90,8 +90,9 @@ class Storage extends FileStorage
|
|||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function create_db(BoardsEntity $boards_entity, BoardEntity $board_entity, string $board_table): FileEntity
|
private function create_file(BoardsEntity $boards_entity, BoardEntity $board_entity, string $board_table): FileEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
$formDatas['board_pid'] = $board_entity->getPk();
|
$formDatas['board_pid'] = $board_entity->getPk();
|
||||||
$formDatas['user_pid'] = $this->_user_entity->getPK();
|
$formDatas['user_pid'] = $this->_user_entity->getPK();
|
||||||
$formDatas['user_name'] = $this->_user_entity->getTitle();
|
$formDatas['user_name'] = $this->_user_entity->getTitle();
|
||||||
@ -117,7 +118,7 @@ class Storage extends FileStorage
|
|||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create_small_image(BoardEntity $board_entity, $target_name = "small", int $width = 480, int $height = 319): void
|
private function create_small_image(BoardEntity $board_entity, $target_name = "small", int $width = 480, int $height = 319): void
|
||||||
{
|
{
|
||||||
$fileInfo = pathinfo($this->getFullPath() . DIRECTORY_SEPARATOR . $this->getOriginName(), PATHINFO_ALL);
|
$fileInfo = pathinfo($this->getFullPath() . DIRECTORY_SEPARATOR . $this->getOriginName(), PATHINFO_ALL);
|
||||||
$target_file_name = sprintf("%s_%s.%s", $fileInfo['filename'], $target_name, $fileInfo['extension']);
|
$target_file_name = sprintf("%s_%s.%s", $fileInfo['filename'], $target_name, $fileInfo['extension']);
|
||||||
@ -147,7 +148,7 @@ class Storage extends FileStorage
|
|||||||
final public function create(BoardsEntity $boards_entity, BoardEntity $board_entity, string $board_table): void
|
final public function create(BoardsEntity $boards_entity, BoardEntity $board_entity, string $board_table): void
|
||||||
{
|
{
|
||||||
//File DB에 넣기
|
//File DB에 넣기
|
||||||
$this->create_db($boards_entity, $board_entity, $board_table);
|
$this->create_file($boards_entity, $board_entity, $board_table);
|
||||||
//작은이미지 만들기
|
//작은이미지 만들기
|
||||||
$this->create_small_image($board_entity);
|
$this->create_small_image($board_entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,105 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Libraries\MyMangboard;
|
|
||||||
|
|
||||||
use App\Models\Mangboard\UserModel;
|
|
||||||
use App\Libraries\CommonLibrary;
|
|
||||||
use App\Entities\Mangboard\UserEntity;
|
|
||||||
|
|
||||||
class User extends CommonLibrary
|
|
||||||
{
|
|
||||||
private $_myStorage = null;
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
final protected function getMyStorage(): UserModel
|
|
||||||
{
|
|
||||||
if ($this->_myStorage === null) {
|
|
||||||
$this->_myStorage = new UserModel();
|
|
||||||
}
|
|
||||||
return $this->_myStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLevelByPoint(UserEntity $entity): int
|
|
||||||
{
|
|
||||||
//Admin용 Level로는 변경불가
|
|
||||||
if ($entity->getLevel() == getenv('mangboard.admin.level')) {
|
|
||||||
log_message("notice", "Admin용 Level을 변경하실수 없습니다.");
|
|
||||||
return $entity->getLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
//사용자 Point별 Level 계산
|
|
||||||
$levelup_point = getenv('mangboard.level.up.point.unit');
|
|
||||||
$level = intdiv($entity->getPoint(), $levelup_point);
|
|
||||||
|
|
||||||
//운영자면 7~9
|
|
||||||
if (getenv('mangboard.level.manager.min') <= $level && $level <= getenv('mangboard.level.manager.max')) {
|
|
||||||
$level = $level < getenv('mangboard.level.manager.min') ? getenv('mangboard.level.manager.min') : $level;
|
|
||||||
$level = getenv('mangboard.level.manager.max') < $level ? getenv('mangboard.level.manager.max') : $level;
|
|
||||||
}
|
|
||||||
// echo "point:" . $entity->getPoint() . ",level:" . $level . "\n";
|
|
||||||
|
|
||||||
//사용자 Level 1~5;
|
|
||||||
if (getenv('mangboard.level.user.min') <= $level && $level <= getenv('mangboard.level.user.max')) {
|
|
||||||
$level = $level < getenv('mangboard.level.user.min') ? getenv('mangboard.level.user.min') : $level;
|
|
||||||
$level = getenv('mangboard.level.user.max') < $level ? getenv('mangboard.level.user.max') : $level;
|
|
||||||
}
|
|
||||||
// echo "point:" . $entity->getPoint() . ",level:" . $level . "\n";
|
|
||||||
return $level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPoint(UserEntity $entity, int $point, $sign = '+'): UserEntity
|
|
||||||
{
|
|
||||||
switch ($sign) {
|
|
||||||
case '-':
|
|
||||||
if ($point < $point) {
|
|
||||||
throw new \Exception("기존포인트:{$point}가 감소 포인트:-{$point} 작습니다.\n");
|
|
||||||
}
|
|
||||||
$point = $point - $point;
|
|
||||||
break;
|
|
||||||
case '+':
|
|
||||||
$point = $point + $point;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new \Exception(__FUNCTION__ . "에서는 {$sign}은 사용할수 없습니다.\n");
|
|
||||||
// break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//기존정보와 Point값이 다르면 저장
|
|
||||||
if ($entity->getPoint() != $point) {
|
|
||||||
$formDatas = ["point" => $point];
|
|
||||||
$entity = $this->modify($entity, $formDatas);
|
|
||||||
log_message("notice", __FUNCTION__ . "=>{$entity->getTitle()}님의 Point가 {$entity->getPoint()}에서 {$point}로 변경되었습니다.");
|
|
||||||
}
|
|
||||||
return $this->setLevel($entity, $this->getLevelByPoint($entity));
|
|
||||||
}
|
|
||||||
public function setLevel(UserEntity $entity, int $level): UserEntity
|
|
||||||
{
|
|
||||||
//기존정보와 Level값이 다르면 저장
|
|
||||||
if ($entity->getLevel() != $level) {
|
|
||||||
$formDatas = ["level" => $level];
|
|
||||||
$entity = $this->modify($entity, $formDatas);
|
|
||||||
log_message("notice", __FUNCTION__ . "=>{$entity->getTitle()}님의 Level이 {$entity->getLevel()}에서 {$level}로 변경되었습니다.");
|
|
||||||
}
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function create(array $formDatas): UserEntity
|
|
||||||
{
|
|
||||||
$entity = $this->$this->getMyStorage()->create($formDatas);
|
|
||||||
log_message("notice", "Record:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
public function modify(UserEntity $entity, array $formDatas): UserEntity
|
|
||||||
{
|
|
||||||
$entity = $this->$this->getMyStorage()->modify($formDatas);
|
|
||||||
log_message("notice", "Record:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
|
||||||
return $entity;
|
|
||||||
}
|
|
||||||
public function delete(UserEntity $entity): void
|
|
||||||
{
|
|
||||||
$this->$this->getMyStorage()->delete($entity);
|
|
||||||
log_message("notice", "Record:" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
69
app/Libraries/MySocket/CloudflareSocket.php
Normal file
69
app/Libraries/MySocket/CloudflareSocket.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Libraries\MySocket;
|
||||||
|
|
||||||
|
|
||||||
|
use Cloudflare\API\Auth\APIKey;
|
||||||
|
use Cloudflare\API\Adapter\Guzzle;
|
||||||
|
use App\Models\Cloudflare\AccountModel;
|
||||||
|
use App\Libraries\CommonLibrary;
|
||||||
|
// use App\Entities\Cloudflare\AccountEntity;
|
||||||
|
// use Cloudflare\API\Endpoints\Zones;
|
||||||
|
// use Cloudflare\API\Endpoints\DNS;
|
||||||
|
// use Cloudflare\API\Endpoints\Accounts;
|
||||||
|
|
||||||
|
class CloudflareSocket extends CommonLibrary
|
||||||
|
{
|
||||||
|
private static int $_request = 0;
|
||||||
|
private static int $_request_max = 100;
|
||||||
|
private static int $_request_timewait = 60;
|
||||||
|
private $_accountModel = null;
|
||||||
|
private $_clients = [];
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->initAdapters();
|
||||||
|
self::$_request_max = getenv("cfmgr.request.max");
|
||||||
|
}
|
||||||
|
final protected function getAccountModel(): AccountModel
|
||||||
|
{
|
||||||
|
if ($this->_accountModel === null) {
|
||||||
|
$this->_accountModel = new AccountModel();
|
||||||
|
}
|
||||||
|
return $this->_accountModel;
|
||||||
|
}
|
||||||
|
final public function initAdapters(): void
|
||||||
|
{
|
||||||
|
foreach ($this->getAccountModel()->getEntitys() as $entity) {
|
||||||
|
$this->_clients[$entity->getAPIKey()] = new Guzzle(
|
||||||
|
new APIKey($entity->getTitle(), $entity->getAPIKey())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function request(string $apikey): Guzzle
|
||||||
|
{
|
||||||
|
if (!array_key_exists($apikey, $this->_clients)) {
|
||||||
|
throw new \Exception(+__FUNCTION__ . " => {$apikey}에 해당하는 Adapter를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
if (self::$_request >= self::$_request_max) {
|
||||||
|
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 시작--", self::$_request_timewait));
|
||||||
|
sleep(intval(getenv("cf.mgr.request.time.wait")));
|
||||||
|
self::$_request = 0;
|
||||||
|
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 종료--", self::$_request_timewait));
|
||||||
|
}
|
||||||
|
self::$_request++;
|
||||||
|
return $this->_clients[$apikey];
|
||||||
|
}
|
||||||
|
// public function getAccount(string $apikey): Accounts
|
||||||
|
// {
|
||||||
|
// return new Accounts($this->request($apikey));
|
||||||
|
// }
|
||||||
|
// public function getZone(string $apikey): Zones
|
||||||
|
// {
|
||||||
|
// return new Zones($this->request($apikey));
|
||||||
|
// }
|
||||||
|
// public function getRecord(string $apikey): DNS
|
||||||
|
// {
|
||||||
|
// return new DNS($this->request($apikey));
|
||||||
|
// }
|
||||||
|
}
|
||||||
@ -92,7 +92,8 @@ abstract class CommonModel extends Model
|
|||||||
$rules[$field] .= $this->getAction() == DB_ACTION["CREATE"] ? "|is_unique[{$this->table}.{$field}]" : "";
|
$rules[$field] .= $this->getAction() == DB_ACTION["CREATE"] ? "|is_unique[{$this->table}.{$field}]" : "";
|
||||||
} else {
|
} else {
|
||||||
$rules[$field] = "required|numeric";
|
$rules[$field] = "required|numeric";
|
||||||
};
|
}
|
||||||
|
;
|
||||||
break;
|
break;
|
||||||
case $this->getTitleField():
|
case $this->getTitleField():
|
||||||
$rules[$field] = "required|string";
|
$rules[$field] = "required|string";
|
||||||
@ -130,12 +131,12 @@ abstract class CommonModel extends Model
|
|||||||
}
|
}
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
public function getFormFieldOption(string $field, array $options = []): array
|
public function getFormFieldInputOption(string $field, array $options = []): array
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
default:
|
default:
|
||||||
foreach ($this->getEntitys() as $entity) {
|
foreach ($this->getEntitys() as $entity) {
|
||||||
$options[$field][$entity->getPK()] = $entity->getTitle();
|
$options[$entity->getPK()] = $entity->getTitle();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -231,4 +232,24 @@ abstract class CommonModel extends Model
|
|||||||
log_message("debug", $this->table . "=> " . __FUNCTION__ . " 작업 완료");
|
log_message("debug", $this->table . "=> " . __FUNCTION__ . " 작업 완료");
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//List용
|
||||||
|
final public function setList_FieldFilter(string $field, int|string $value): void
|
||||||
|
{
|
||||||
|
$this->where($field, $value);
|
||||||
|
}
|
||||||
|
public function setList_WordFilter(string $word, string $field = null): void
|
||||||
|
{
|
||||||
|
$this->like($field ?? $this->getTitleField(), $word, 'before'); //befor , after , both
|
||||||
|
}
|
||||||
|
public function setList_DateFilter(string $start, string $end, $field = "created_at"): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->where("{$field} >= {$start}");
|
||||||
|
$this->where("{$field} <= {$end}");
|
||||||
|
}
|
||||||
|
public function setList_OrderBy(string $order)
|
||||||
|
{
|
||||||
|
$this->orderBy($order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -169,4 +169,68 @@ class UserModel extends CommonModel
|
|||||||
$this->where('passwd', password_hash($password, PASSWORD_DEFAULT));
|
$this->where('passwd', password_hash($password, PASSWORD_DEFAULT));
|
||||||
return $this->getEntity();
|
return $this->getEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getLevelByPoint(UserEntity $entity): int
|
||||||
|
{
|
||||||
|
//Admin용 Level로는 변경불가
|
||||||
|
if ($entity->getLevel() == getenv('mangboard.admin.level')) {
|
||||||
|
log_message("notice", "Admin용 Level을 변경하실수 없습니다.");
|
||||||
|
return $entity->getLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
//사용자 Point별 Level 계산
|
||||||
|
$levelup_point = getenv('mangboard.level.up.point.unit');
|
||||||
|
$level = intval($entity->getPoint() / $levelup_point * $levelup_point / $levelup_point);
|
||||||
|
|
||||||
|
//운영자면 7~9
|
||||||
|
if (getenv('mangboard.level.manager.min') <= $level && $level <= getenv('mangboard.level.manager.max')) {
|
||||||
|
$level = $level < getenv('mangboard.level.manager.min') ? getenv('mangboard.level.manager.min') : $level;
|
||||||
|
$level = getenv('mangboard.level.manager.max') < $level ? getenv('mangboard.level.manager.max') : $level;
|
||||||
|
}
|
||||||
|
// echo "point:" . $entity->getPoint() . ",level:" . $level . "\n";
|
||||||
|
|
||||||
|
//사용자 Level 1~5;
|
||||||
|
if (getenv('mangboard.level.user.min') <= $level && $level <= getenv('mangboard.level.user.max')) {
|
||||||
|
$level = $level < getenv('mangboard.level.user.min') ? getenv('mangboard.level.user.min') : $level;
|
||||||
|
$level = getenv('mangboard.level.user.max') < $level ? getenv('mangboard.level.user.max') : $level;
|
||||||
|
}
|
||||||
|
// echo "point:" . $entity->getPoint() . ",level:" . $level . "\n";
|
||||||
|
return $level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPoint(UserEntity $entity, int $point, $sign = '+'): UserEntity
|
||||||
|
{
|
||||||
|
switch ($sign) {
|
||||||
|
case '-':
|
||||||
|
if ($point < $point) {
|
||||||
|
throw new \Exception("기존포인트:{$point}가 감소 포인트:-{$point} 작습니다.\n");
|
||||||
|
}
|
||||||
|
$point = $point - $point;
|
||||||
|
break;
|
||||||
|
case '+':
|
||||||
|
$point = $point + $point;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \Exception(__FUNCTION__ . "에서는 {$sign}은 사용할수 없습니다.\n");
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//기존정보와 Point값이 다르면 저장
|
||||||
|
if ($entity->getPoint() != $point) {
|
||||||
|
$formDatas = ["point" => $point];
|
||||||
|
$entity = $this->modify($entity, $formDatas);
|
||||||
|
log_message("notice", __FUNCTION__ . "=>{$entity->getTitle()}님의 Point가 {$entity->getPoint()}에서 {$point}로 변경되었습니다.");
|
||||||
|
}
|
||||||
|
return $this->setLevel($entity, $this->getLevelByPoint($entity));
|
||||||
|
}
|
||||||
|
public function setLevel(UserEntity $entity, int $level): UserEntity
|
||||||
|
{
|
||||||
|
//기존정보와 Level값이 다르면 저장
|
||||||
|
if ($entity->getLevel() != $level) {
|
||||||
|
$formDatas = ["level" => $level];
|
||||||
|
$entity = $this->modify($entity, $formDatas);
|
||||||
|
log_message("notice", __FUNCTION__ . "=>{$entity->getTitle()}님의 Level이 {$entity->getLevel()}에서 {$level}로 변경되었습니다.");
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use App\Entities\SNSUSerEntity;
|
|
||||||
use App\Models\CommonModel;
|
|
||||||
|
|
||||||
class SNSUserModel extends CommonModel
|
|
||||||
{
|
|
||||||
const TABLE = "sns_users";
|
|
||||||
const PK = "uid";
|
|
||||||
const TITLE = "name";
|
|
||||||
protected $table = self::TABLE;
|
|
||||||
protected $primaryKey = self::PK;
|
|
||||||
protected $returnType = SNSUSerEntity::class;
|
|
||||||
protected $allowedFields = [
|
|
||||||
"id",
|
|
||||||
"name",
|
|
||||||
"email",
|
|
||||||
"detail",
|
|
||||||
"status"
|
|
||||||
];
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
public function getTitleField(): string
|
|
||||||
{
|
|
||||||
return self::TITLE;
|
|
||||||
}
|
|
||||||
public function getFieldRule(string $field, array $rules): array
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
case "id":
|
|
||||||
$rules[$field] = "required|trim|min_length[4]|max_length[20]|is_unique[{$this->table}.{$field}]";
|
|
||||||
break;
|
|
||||||
case $this->getTitleField():
|
|
||||||
$rules[$field] = "required|trim|string";
|
|
||||||
break;
|
|
||||||
case "email":
|
|
||||||
$rules[$field] = "if_exist|trim|valid_email";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$rules = parent::getFieldRule($field, $rules);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $rules;
|
|
||||||
}
|
|
||||||
public function getEntityByPK(int $uid): null|SNSUSerEntity
|
|
||||||
{
|
|
||||||
$this->where($this->getPKField(), $uid);
|
|
||||||
return $this->getEntity();
|
|
||||||
}
|
|
||||||
public function getEntityByID(string $id): null|SNSUSerEntity
|
|
||||||
{
|
|
||||||
$this->where('id', $id);
|
|
||||||
return $this->getEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
//create용
|
|
||||||
public function create(array $formDatas = []): SNSUSerEntity
|
|
||||||
{
|
|
||||||
return $this->create_process(new SNSUSerEntity(), $formDatas);
|
|
||||||
}
|
|
||||||
|
|
||||||
//modify용
|
|
||||||
public function modify(SNSUSerEntity $entity, array $formDatas): SNSUSerEntity
|
|
||||||
{
|
|
||||||
return $this->modify_process($entity, $formDatas);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use App\Entities\UserEntity;
|
|
||||||
use App\Models\CommonModel;
|
|
||||||
|
|
||||||
class UserModel extends CommonModel
|
|
||||||
{
|
|
||||||
const TABLE = "users";
|
|
||||||
const PK = "uid";
|
|
||||||
const TITLE = "name";
|
|
||||||
protected $table = self::TABLE;
|
|
||||||
protected $primaryKey = self::PK;
|
|
||||||
protected $returnType = UserEntity::class;
|
|
||||||
protected $allowedFields = [
|
|
||||||
"id",
|
|
||||||
"passwd",
|
|
||||||
"name",
|
|
||||||
"email",
|
|
||||||
"pohne",
|
|
||||||
"mobild",
|
|
||||||
"role",
|
|
||||||
"status"
|
|
||||||
];
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
public function getTitleField(): string
|
|
||||||
{
|
|
||||||
return 'name';
|
|
||||||
}
|
|
||||||
public function getFieldRule(string $field, array $rules): array
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
case "id":
|
|
||||||
if ($this->getAction() == DB_ACTION["CREATE"]) {
|
|
||||||
$rules[$field] = "required|trim|min_length[4]|max_length[20]|is_unique[{$this->table}.{$field}]";
|
|
||||||
} else {
|
|
||||||
$rules[$field] = "required|trim|min_length[4]|max_length[20]";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case $this->getTitleField():
|
|
||||||
$rules[$field] = "required|trim|string";
|
|
||||||
break;
|
|
||||||
case "email":
|
|
||||||
$rules[$field] = "if_exist|trim|valid_email";
|
|
||||||
break;
|
|
||||||
case "role":
|
|
||||||
//아래 Rule은 입력시에는 되는데 수정시에는 않됨 이유를 ?
|
|
||||||
// $rules[$field] = "required|in_list[master,director,cloudflare,manager,gold,silver,brone,vip,user]";
|
|
||||||
//아래 Rule은 checkbox를 사용시에는 required만 우선 써야 수정시 validate문제없음
|
|
||||||
$rules[$field] = "if_exist|trim|string";
|
|
||||||
break;
|
|
||||||
case "passwd":
|
|
||||||
default:
|
|
||||||
$rules = parent::getFieldRule($field, $rules);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $rules;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEntityByPK(int $uid): null|UserEntity
|
|
||||||
{
|
|
||||||
$this->where($this->getPKField(), $uid);
|
|
||||||
return $this->getEntity();
|
|
||||||
}
|
|
||||||
public function getEntityByID(string $id): null|UserEntity
|
|
||||||
{
|
|
||||||
$this->where('id', $id);
|
|
||||||
return $this->getEntity();
|
|
||||||
}
|
|
||||||
|
|
||||||
//create용
|
|
||||||
public function create(array $formDatas = []): UserEntity
|
|
||||||
{
|
|
||||||
return $this->create_process(new UserEntity(), $formDatas);
|
|
||||||
}
|
|
||||||
|
|
||||||
//modify용
|
|
||||||
public function modify(UserEntity $entity, array $formDatas): UserEntity
|
|
||||||
{
|
|
||||||
return $this->modify_process($entity, $formDatas);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
# Disable directory browsing
|
|
||||||
Options -Indexes
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
|
||||||
# Rewrite engine
|
|
||||||
# ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Turning on the rewrite engine is necessary for the following rules and features.
|
|
||||||
# FollowSymLinks must be enabled for this to work.
|
|
||||||
<IfModule mod_rewrite.c>
|
|
||||||
Options +FollowSymlinks
|
|
||||||
RewriteEngine On
|
|
||||||
|
|
||||||
# If you installed CodeIgniter in a subfolder, you will need to
|
|
||||||
# change the following line to match the subfolder you need.
|
|
||||||
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
|
|
||||||
# RewriteBase /
|
|
||||||
|
|
||||||
# Redirect Trailing Slashes...
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-d
|
|
||||||
RewriteCond %{REQUEST_URI} (.+)/$
|
|
||||||
RewriteRule ^ %1 [L,R=301]
|
|
||||||
|
|
||||||
# Rewrite "www.example.com -> example.com"
|
|
||||||
RewriteCond %{HTTPS} !=on
|
|
||||||
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
|
|
||||||
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
|
|
||||||
|
|
||||||
# Checks to see if the user is attempting to access a valid file,
|
|
||||||
# such as an image or css document, if this isn't true it sends the
|
|
||||||
# request to the front controller, index.php
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-d
|
|
||||||
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]
|
|
||||||
|
|
||||||
# Ensure Authorization header is passed along
|
|
||||||
RewriteCond %{HTTP:Authorization} .
|
|
||||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
|
||||||
</IfModule>
|
|
||||||
|
|
||||||
<IfModule !mod_rewrite.c>
|
|
||||||
# If we don't have mod_rewrite installed, all 404's
|
|
||||||
# can be sent to index.php, and everything works as normal.
|
|
||||||
ErrorDocument 404 index.php
|
|
||||||
</IfModule>
|
|
||||||
|
|
||||||
# Disable server signature start
|
|
||||||
ServerSignature Off
|
|
||||||
# Disable server signature end
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.3 KiB |
Loading…
Reference in New Issue
Block a user