안녕하세요.
카페24에서 호스팅을 이용중인데 웹하드용량이 4g에 cdn용량이 1g입니다
매일 업로드하는 이미지의 양과 횟수가 많아 용량의 압박을 받고 고민하며
글을 검색하던중 오래전에 올려주신 글에서 cheditor에서 cdn을 이용할 수
있다는걸 알게 되어 적용을 해보려했는데 소스외 따로 설치를 해야하는 부분이 있는건지
아니면 버전이 달라서 그런건지..;; 제가 잘몰라서요
아무리 해도 안되어서 도움을 요청드리려합니다ㅠㅠ
그누보드5 에디터와 카페24 연동하기 글도 올라와 있던데 봐도 g4용으로
바꿔 쓸 수없는 실력이라서요;;
http://sir.co.kr/bbs/board.php?bo_table=g5_tip&wr_id=1342
아래는 오래전 그누보드 에디터 연동 원본글입니다
http://threes.org/gnu3/?doc=bbs/gnuboard.php&bo_table=bwork&wr_id=323
아래는 insert_image.php를 수정해본 소스입니다
<?php
include_once("_common.php");
//////////////////////////////////////////////////////////////////////////
// 이미지 파일이 저장될 디렉토리 경로를 지정합니다. 퍼미션 777
//
//define('SAVE_AS_DIRECTORY', "/home/account/www/cheditor/attach/");
@mkdir("$g4[path]/data/$g4[cheditor4]/", 0707);
@chmod("$g4[path]/data/$g4[cheditor4]/", 0707);
$ym = date("ym", $g4[server_time]);
define('SAVE_AS_DIRECTORY', "$g4[path]/data/$g4[cheditor4]/$ym/");
@mkdir(SAVE_AS_DIRECTORY, 0707);
@chmod(SAVE_AS_DIRECTORY, 0707);
//////////////////////////////////////////////////////////////////////////
// SAVE_AS_DIRECTOR에 대한 URL 경로를 입력합니다.
//
//define('SAVE_AS_URL', "http://udomain.com/cheditor/attach/");
define('SAVE_AS_URL', "$g4[url]/data/$g4[cheditor4]/$ym/");
//////////////////////////////////////////////////////////////////////////
// 이미지 파일 형식을 설정합니다.
//
define('ALLOW_FORMAT', "jpeg|jpg|gif|png");
//////////////////////////////////////////////////////////////////////////
// 파일 저장 옵션을 설정합니다.
// 파일 이름에 한글 또는 사용되어 서는 안될 특수문자가 있을 경우, 잘라버립니다.
//
// 저장 옵션:
// 1 = 같은 이름의 파일이 존재 하면 덮어 씁니다.
// 2 = 같은 이름의 파일이 존재할 경우, 파일 이름 뒤에 _copy,jpg, _copy1.jpg ... 식으로 이름을 붙입니다.
// 3 = 같은 이름의 파일이 존재할 경우, 업로드하지 않습니다.
//
define('SAVE_OPTION', 2);
if ($_REQUEST['do'] == "submit") {
require_once "imageupload-class.php";
$attach = new uploader;
//////////////////////////////////////////////////////////////////////////
// 옵션:
//
// $attach->max_filesize(102400); // 이미지 업로드 최대 크기
// $attach->max_image_size(1024, 1024); // 이미지 가로, 세로 최대 픽셀 크기
$attach->max_image_size(8096, 8096);
$success = $attach->upload("AttachFile", ALLOW_FORMAT, "");
//if ($success) {
//$success = $attach->save_file(SAVE_AS_DIRECTORY, SAVE_OPTION);
//$filename = SAVE_AS_URL . $attach->file['name'];
if ($success) {
$ncftp_info = "/usr/bin/ncftpput -u **** -p **** -m -DD iup.cdn3.cafe24.com ";
$remote_dir = "/www/$g4[editor]/$ym/ ";
$local_file = $save_as_url . $attach->file['name'];
$ncftp_cmd = $ncftp_info . $remote_dir . $local_file;
system($ncftp_cmd, $status);
ncftp에서 -DD 옵션을 사용했으므로 파일의 유무에 따라서 성공여부 결정
if(!file_exists($local_tmp)) {
$save_as_url = "http://****.cdn3.cafe24.com/$g4[editor]/$ym/";
}
$filename = $save_as_url . $attach->file['name'];
echo '<script type="text/javascript">';
echo 'var obj = parent.window.insert_form;';
echo 'obj.attachSuccess(\''.$filename.'\');';
echo '</script>';
}
else {
if ($attach->errors) {
$msg = '';
while (list($k, $v) = each($attach->errors)) {
$msg .= $v;
}
echo '<script type="text/javascript">';
echo 'alert(\''.$msg.'\');';
echo '</script>';
}
}
}
else if ($_REQUEST['do'] == "delete") {
foreach (explode(' ', $_REQUEST['img']) as $del) {
$del = trim($del);
$file = SAVE_AS_DIRECTORY . $del;
if (is_file($file)) {
unlink($file);
}
}
echo true;
}
?>
답변을 작성하려면 로그인이 필요합니다.