diff --git a/app/Config/Routes.php b/app/Config/Routes.php index b4e086d..0409b07 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -141,7 +141,6 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou $routes->get('', 'ProductController::index'); $routes->get('excel', 'ProductController::excel/$1'); $routes->get('view/(:uuid)', 'ProductController::view/$1'); - $routes->get('download/(:any)/(:uuid)', 'ProductController::download/$1/$2'); }); $routes->group('order', static function ($routes) { $routes->get('', 'OrderController::index'); diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 6e62557..f359f1b 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -629,13 +629,18 @@ abstract class BaseController extends Controller } } //File Download관련 - final public function download(string $field, $uid) + public function download_process($entity) + { + return $entity; + } + public function download(string $field, $uid) { try { $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]); if (!$entity->$field) { throw new \Exception("첨부파일이 확인되지 않습니다."); } + $entity = $this->download_process($entity); list($origin_filename, $filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field); if (is_file(WRITEPATH . PATHS['UPLOAD'] . "/" . $origin_filename)) { throw new \Exception("파일이 확인되지 않습니다."); diff --git a/app/Controllers/Front/BoardController.php b/app/Controllers/Front/BoardController.php index 6023378..8cf3bbd 100644 --- a/app/Controllers/Front/BoardController.php +++ b/app/Controllers/Front/BoardController.php @@ -20,6 +20,12 @@ class BoardController extends FrontController public function getFields(string $action = ""): array { $fields = ['title', "board_file", "passwd", "content"]; + try { + //권한체크 + $this->isRole('upload'); + } catch (\Exception $e) { + $fields = ['title', "passwd", "content"]; + } switch ($action) { case "index": case "excel": @@ -132,4 +138,11 @@ class BoardController extends FrontController $this->_model->where("status", DEFAULTS['STATUS']); parent::index_setCondition(); } + //Download관련 + public function download_process($entity) + { + //권한체크 + $this->isRole('download'); + return $entity; + } } diff --git a/app/Controllers/Front/FrontController.php b/app/Controllers/Front/FrontController.php index cd557f8..c4acb33 100644 --- a/app/Controllers/Front/FrontController.php +++ b/app/Controllers/Front/FrontController.php @@ -39,6 +39,12 @@ abstract class FrontController extends BaseController case 'view': $category_field = CATEGORY_ROLE_FIELDS['READ']; break; + case 'upload': + $category_field = CATEGORY_ROLE_FIELDS['UPLOAD']; + break; + case 'download': + $category_field = CATEGORY_ROLE_FIELDS['DONWLOAD']; + break; default: $category_field = CATEGORY_ROLE_FIELDS['ACCESS']; break; diff --git a/app/Controllers/Front/ProductController.php b/app/Controllers/Front/ProductController.php index 725e954..47bb028 100644 --- a/app/Controllers/Front/ProductController.php +++ b/app/Controllers/Front/ProductController.php @@ -48,7 +48,6 @@ class ProductController extends FrontController $this->_model->addViewCount($entity); return parent::view_process($entity); } - //Index관련 protected function index_process() { @@ -63,4 +62,11 @@ class ProductController extends FrontController $this->_model->where("status", DEFAULTS['STATUS']); parent::index_setCondition(); } + //Download관련 + public function download_process($entity) + { + //권한체크 + $this->isRole('download'); + return $entity; + } }