mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 14:52:24 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@100 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
dc1bf81d06
commit
cf88cc4cb2
42 changed files with 209 additions and 1387 deletions
|
|
@ -137,7 +137,8 @@
|
|||
$oTagController->deleteTag($document_srl);
|
||||
|
||||
// 첨부 파일 삭제
|
||||
if($document->uploaded_count) $this->deleteFiles($document->module_srl, $document_srl);
|
||||
$oFileController = getController('file');
|
||||
if($document->uploaded_count) $oFileController->deleteFiles($document->module_srl, $document_srl);
|
||||
|
||||
// 카테고리가 있으면 카테고리 정보 변경
|
||||
if($document->category_srl) $this->updateCategoryCount($document->category_srl);
|
||||
|
|
@ -368,123 +369,5 @@
|
|||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 첨부파일 추가
|
||||
**/
|
||||
function insertFile($module_srl, $document_srl) {
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$file_info = Context::get('file');
|
||||
|
||||
// 정상적으로 업로드된 파일이 아니면 오류 출력
|
||||
if(!is_uploaded_file($file_info['tmp_name'])) return false;
|
||||
|
||||
// 이미지인지 기타 파일인지 체크하여 upload path 지정
|
||||
if(eregi("\.(jpg|jpeg|gif|png|wmv|mpg|mpeg|avi|swf|flv|mp3|asaf|wav|asx|midi)$", $file_info['name'])) {
|
||||
$path = sprintf("./files/attach/images/%s/%s/", $module_srl,$document_srl);
|
||||
$filename = $path.$file_info['name'];
|
||||
$direct_download = 'Y';
|
||||
} else {
|
||||
$path = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl);
|
||||
$filename = $path.md5(crypt(rand(1000000,900000), rand(0,100)));
|
||||
$direct_download = 'N';
|
||||
}
|
||||
|
||||
// 디렉토리 생성
|
||||
if(!FileHandler::makeDir($path)) return false;
|
||||
|
||||
// 파일 이동
|
||||
if(!move_uploaded_file($file_info['tmp_name'], $filename)) return false;
|
||||
|
||||
// 사용자 정보를 구함
|
||||
$oMemberModel = getModel('member');
|
||||
$member_srl = $oMemberModel->getMemberSrl();
|
||||
|
||||
// 파일 정보를 정리
|
||||
$args->file_srl = $oDB->getNextSequence();
|
||||
$args->document_srl = $document_srl;
|
||||
$args->module_srl = $module_srl;
|
||||
$args->direct_download = $direct_download;
|
||||
$args->source_filename = $file_info['name'];
|
||||
$args->uploaded_filename = $filename;
|
||||
$args->file_size = filesize($filename);
|
||||
$args->comment = NULL;
|
||||
$args->member_srl = $member_srl;
|
||||
$args->sid = md5($args->source_filename);
|
||||
|
||||
$output = $oDB->executeQuery('document.insertFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
$output->add('file_srl', $args->file_srl);
|
||||
$output->add('file_size', $args->file_size);
|
||||
$output->add('source_filename', $args->source_filename);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 첨부파일 삭제
|
||||
**/
|
||||
function deleteFile($file_srl) {
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
// 파일 정보를 가져옴
|
||||
$args->file_srl = $file_srl;
|
||||
$output = $oDB->executeQuery('document.getFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
$file_info = $output->data;
|
||||
if(!$file_info) return new Object(-1, 'file_not_founded');
|
||||
|
||||
$source_filename = $output->data->source_filename;
|
||||
$uploaded_filename = $output->data->uploaded_filename;
|
||||
|
||||
// DB에서 삭제
|
||||
$output = $oDB->executeQuery('document.deleteFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
// 삭제 성공하면 파일 삭제
|
||||
unlink($uploaded_filename);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 문서의 첨부파일을 모두 삭제
|
||||
**/
|
||||
function deleteFiles($module_srl, $document_srl) {
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->document_srl = $document_srl;
|
||||
$output = $oDB->executeQuery('document.deleteFiles', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
// 실제 파일 삭제
|
||||
$path[0] = sprintf("./files/attach/images/%s/%s/", $module_srl, $document_srl);
|
||||
$path[1] = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl);
|
||||
|
||||
FileHandler::removeDir($path[0]);
|
||||
FileHandler::removeDir($path[1]);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 모두의 첨부파일 모두 삭제
|
||||
**/
|
||||
function deleteModuleFiles($module_srl) {
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->module_srl = $module_srl;
|
||||
$output = $oDB->executeQuery('document.deleteModuleFiles', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
// 실제 파일 삭제
|
||||
$path[0] = sprintf("./files/attach/images/%s/", $module_srl);
|
||||
$path[1] = sprintf("./files/attach/binaries/%s/", $module_srl);
|
||||
FileHandler::removeDir($path[0]);
|
||||
FileHandler::removeDir($path[1]);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -189,54 +189,6 @@
|
|||
return (int)$output->data->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 문서에 속한 첨부파일의 개수를 return
|
||||
**/
|
||||
function getFilesCount($document_srl) {
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->document_srl = $document_srl;
|
||||
$output = $oDB->executeQuery('document.getFilesCount', $args);
|
||||
return (int)$output->data->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 파일 정보를 구함
|
||||
**/
|
||||
function getFile($file_srl) {
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->file_srl = $file_srl;
|
||||
$output = $oDB->executeQuery('document.getFile', $args);
|
||||
return $output->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 문서에 속한 파일을 모두 return
|
||||
**/
|
||||
function getFiles($document_srl) {
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->document_srl = $document_srl;
|
||||
$args->sort_index = 'file_srl';
|
||||
$output = $oDB->executeQuery('document.getFiles', $args);
|
||||
|
||||
$file_list = $output->data;
|
||||
|
||||
if($file_list && !is_array($file_list)) $file_list = array($file_list);
|
||||
|
||||
for($i=0;$i<count($file_list);$i++) {
|
||||
$direct_download = $file_list[$i]->direct_download;
|
||||
|
||||
if($direct_download!='Y') continue;
|
||||
|
||||
$uploaded_filename = Context::getRequestUri().substr($file_list[$i]->uploaded_filename,2);
|
||||
|
||||
$file_list[$i]->uploaded_filename = $uploaded_filename;
|
||||
}
|
||||
return $file_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 내용의 플러그인이나 기타 기능에 대한 code를 실제 code로 변경
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
<query id="deleteFile" action="delete">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="file_srl" var="file_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<query id="deleteFiles" action="delete">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<query id="deleteModuleFiles" action="delete">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<query id="getFile" action="select">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="file_srl" var="file_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<query id="getFiles" action="select">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="sort_index" order="asc" />
|
||||
</navigation>
|
||||
</query>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<query id="getFilesCount" action="select">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<query id="insertFile" action="insert">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="file_srl" var="file_srl" notnull="notnull" />
|
||||
<column name="document_srl" var="document_srl" filter="number" default="0" notnull="notnull" />
|
||||
<column name="sid" var="sid" />
|
||||
<column name="module_srl" var="module_srl" filter="number" default="0" notnull="notnull" />
|
||||
<column name="source_filename" var="source_filename" notnull="notnull" minlength="1" maxlength="250" />
|
||||
<column name="uploaded_filename" var="uploaded_filename" notnull="notnull" minlength="1" maxlength="250" />
|
||||
<column name="file_size" var="file_size" notnull="notnull" default="0" />
|
||||
<column name="direct_download" var="direct_download" notnull="notnull" default="N" />
|
||||
<column name="comment" var="comment" />
|
||||
<column name="downloaded_count" var="downloaded_count" default="0" />
|
||||
<column name="member_srl" var="member_srl" default="0" />
|
||||
<column name="regdate" var="regdate" default="curdate()" />
|
||||
<column name="ipaddress" var="ipaddress" default="ipaddress()" />
|
||||
</columns>
|
||||
</query>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<query id="updateDownloadCount" action="update">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="download_count" var="download_count" default="plus(1)" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="file_srl" var="file_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<table name="files">
|
||||
<column name="file_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="sid" type="varchar" size="60" />
|
||||
<column name="document_srl" type="number" size="11" default="0" notnull="notnull" index="idx_document_srl" />
|
||||
<column name="module_srl" type="number" size="11" default="0" notnull="notnull" index="idx_module_srl" />
|
||||
<column name="member_srl" type="number" size="11" notnull="notnull" index="idx_member_srl" />
|
||||
<column name="download_count" type="number" size="11" notnull="notnull" default="0" />
|
||||
<column name="direct_download" type="char" size="1" default="N" notnull="notnull" />
|
||||
<column name="source_filename" type="varchar" size="250" />
|
||||
<column name="uploaded_filename" type="varchar" size="250" />
|
||||
<column name="file_size" type="number" size="11" default="0" notnull="notnull" />
|
||||
<column name="comment" type="varchar" size="250" />
|
||||
<column name="downloaded_count" type="number" size="11" default="0" notnull="notnull" />
|
||||
<column name="regdate" type="date" index="idx_regdate" />
|
||||
<column name="ipaddress" type="varchar" size="128" notnull="notnull" index="idx_ipaddress"/>
|
||||
</table>
|
||||
Loading…
Add table
Add a link
Reference in a new issue