본문으로 건너뛰기

게시판 이미지 업로드 지원 확대.

PHP 7 · GODO25
변경 파일 수: 5개
변경 파일 목록
5
변경 파일 코드
추가삭제
Component/Board/Board.php+4-4
변경 전Board.php
}
 
foreach ($saveFileNmArr as $index => $saveFileNm) {
$newSaveFileNm = substr(md5(microtime()), 0, 16) . rand(100, 999);
$binaryData = file_get_contents($saveFileNm);
$result = $imageUploadService->uploadBinaryImageToRealPath($binaryData, $movePath, $newSaveFileNm);
$dbTable = self::getBoardTableName($this->req['moveBdId']);
$parseGetUrl = parse_url($getUrl);
$parseDomain = $parseGetUrl["host"];
if (preg_match('/' . Request::getHost() . '/i', $parseDomain) != 1) {
throw new\Exception(__('무단링크를 금지합니다.'));
}
return true;
}
}
 
$uploadFileNm[$i] = $file_array[$i]['name'];
$saveFileNm[$i] = substr(md5(microtime()), 0, 16);
 
$listImageWidth = $this->cfg['bdListImgWidth'] ?? 500;
//이미지 아니면 섬네일 생성안됨;
}
 
$uploadFileNm = $fileData['name'];
$saveFileNm = 'tmp_' . substr(md5(microtime()), 0, 16);
 
if ($this->imageResize === true) {
$result = $this->storage->upload($fileData['tmp_name'], $this->cfg['bdUploadPath'] . $saveFileNm, ['width' => $reSizeImgWidth, 'height' => $reSizeImgHeight]);
 
변경 후Board.php
}
 
foreach ($saveFileNmArr as $index => $saveFileNm) {
$newSaveFileNm = ImageUploadService::generateSaveFileName($uploadFileNmArr[$index] ?? '', 16, true);
$binaryData = file_get_contents($saveFileNm);
$result = $imageUploadService->uploadBinaryImageToRealPath($binaryData, $movePath, $newSaveFileNm);
$dbTable = self::getBoardTableName($this->req['moveBdId']);
$parseGetUrl = parse_url($getUrl);
$parseDomain = $parseGetUrl["host"];
if (preg_match('/' . Request::getHost() . '/i', $parseDomain) != 1) {
throw new \Exception(__('무단링크를 금지합니다.'));
}
return true;
}
}
 
$uploadFileNm[$i] = $file_array[$i]['name'];
$saveFileNm[$i] = ImageUploadService::generateSaveFileName($uploadFileNm[$i]);
 
$listImageWidth = $this->cfg['bdListImgWidth'] ?? 500;
//이미지 아니면 섬네일 생성안됨;
}
 
$uploadFileNm = $fileData['name'];
$saveFileNm = 'tmp_' . ImageUploadService::generateSaveFileName($uploadFileNm);
 
if ($this->imageResize === true) {
$result = $this->storage->upload($fileData['tmp_name'], $this->cfg['bdUploadPath'] . $saveFileNm, ['width' => $reSizeImgWidth, 'height' => $reSizeImgHeight]);
 
Component/File/EditorUpload.php+1-1
변경 전EditorUpload.php
$result['result'] = false;
try {
if (file_exists($filePath)) {
$saveFileName = substr(md5(microtime()), 0, 16) . rand(100, 999);
$file = fopen($filePath, 'rb');
$size = filesize($filePath);
$binary_data = fread($file, $size);
 
변경 후EditorUpload.php
$result['result'] = false;
try {
if (file_exists($filePath)) {
$saveFileName = ImageUploadService::generateSaveFileName($filePath, 16, true);
$file = fopen($filePath, 'rb');
$size = filesize($filePath);
$binary_data = fread($file, $size);
 
Controller/Admin/Board/ArticlePsController.php+8-1
변경 전ArticlePsController.php
 
if (Board::isDefaultUploadStorage($req['bdId'])) {
$boardConfig = new BoardConfig($req['bdId']);
$result = (new ImageUploadService())->uploadImage($fileData, '/temp', true, $boardConfig->cfg['bdUploadMaxSize']);
 
 
 
 
 
 
 
} else {
$boardAct = new ArticleActAdmin($req);
$result = $boardAct->uploadAjax($fileData);
 
변경 후ArticlePsController.php
 
if (Board::isDefaultUploadStorage($req['bdId'])) {
$boardConfig = new BoardConfig($req['bdId']);
$imageUploadService = new ImageUploadService();
 
// 확장자 검증 (저장소 변경 경로의 uploadAjax 와 동일하게 차단)
if ($imageUploadService->isAllowUploadExtention($fileData['name']) === false) {
throw new AlertBackException('업로드 할 수 없는 파일입니다.');
}
 
$result = $imageUploadService->uploadImage($fileData, '/temp', true, $boardConfig->cfg['bdUploadMaxSize']);
} else {
$boardAct = new ArticleActAdmin($req);
$result = $boardAct->uploadAjax($fileData);
 
Controller/Front/Board/BoardPsController.php+8-1
변경 전BoardPsController.php
// 기본 저장소 인지 확인
if (Board::isDefaultUploadStorage($req['bdId'])) {
// 기본 저장소일 경우 OBS Upload 진행
$result = (new ImageUploadService())->uploadImage($fileData, '/temp', true, $boardConfig->cfg['bdUploadMaxSize']);
 
 
 
 
 
 
 
} else {
// 저장소 변경일 경우 해당 저장소에 Upload 진행
$boardAct = new BoardAct($req);
 
변경 후BoardPsController.php
// 기본 저장소 인지 확인
if (Board::isDefaultUploadStorage($req['bdId'])) {
// 기본 저장소일 경우 OBS Upload 진행
$imageUploadService = new ImageUploadService();
 
// 확장자 검증 (저장소 변경 경로의 uploadAjax 와 동일하게 차단)
if ($imageUploadService->isAllowUploadExtention($fileData['name']) === false) {
throw new AlertBackException('업로드 할 수 없는 파일입니다.');
}
 
$result = $imageUploadService->uploadImage($fileData, '/temp', true, $boardConfig->cfg['bdUploadMaxSize']);
} else {
// 저장소 변경일 경우 해당 저장소에 Upload 진행
$boardAct = new BoardAct($req);
 
Controller/Mobile/Board/BoardPsController.php+8-1
변경 전BoardPsController.php
// 기본 저장소 인지 확인
if (Board::isDefaultUploadStorage($req['bdId'])) {
// 기본 저장소일 경우 OBS Upload 진행
$result = (new ImageUploadService())->uploadImage($fileData, '/temp', true, $boardConfig->cfg['bdUploadMaxSize']);
 
 
 
 
 
 
 
} else {
// 저장소 변경일 경우 해당 저장소에 Upload 진행
$boardAct = new BoardAct($req);
 
변경 후BoardPsController.php
// 기본 저장소 인지 확인
if (Board::isDefaultUploadStorage($req['bdId'])) {
// 기본 저장소일 경우 OBS Upload 진행
$imageUploadService = new ImageUploadService();
 
// 확장자 검증 (저장소 변경 경로의 uploadAjax 와 동일하게 차단)
if ($imageUploadService->isAllowUploadExtention($fileData['name']) === false) {
throw new AlertBackException('업로드 할 수 없는 파일입니다.');
}
 
$result = $imageUploadService->uploadImage($fileData, '/temp', true, $boardConfig->cfg['bdUploadMaxSize']);
} else {
// 저장소 변경일 경우 해당 저장소에 Upload 진행
$boardAct = new BoardAct($req);