mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-31 00:59:58 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@1826 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
0b40c9e772
commit
e74c0e7035
7 changed files with 324 additions and 273 deletions
15
.htaccess
15
.htaccess
|
|
@ -6,22 +6,25 @@ RewriteRule ^([a-zA-Z0-9_]+)/([[:digit:]]+)page$ ./index.php?mid=$1&page=$2 [L]
|
||||||
# administrator page
|
# administrator page
|
||||||
RewriteRule ^admin$ ./index.php?module=admin [L]
|
RewriteRule ^admin$ ./index.php?module=admin [L]
|
||||||
|
|
||||||
|
# mid + act
|
||||||
|
RewriteRule ^([a-zA-Z0-9_]+)/api$ ./index.php?mid=$1&act=api [L]
|
||||||
|
|
||||||
# document permanent link
|
# document permanent link
|
||||||
RewriteRule ^([[:digit:]]+)$ ./index.php?document_srl=$1 [L]
|
RewriteRule ^([[:digit:]]+)$ ./index.php?document_srl=$1 [L]
|
||||||
|
|
||||||
# document + act permanent link
|
# document + act link
|
||||||
RewriteRule ^([[:digit:]]+)/([a-zA-Z0-9_]+)$ ./index.php?document_srl=$1&act=$2 [L]
|
RewriteRule ^([[:digit:]]+)/([a-zA-Z0-9_]+)$ ./index.php?document_srl=$1&act=$2 [L]
|
||||||
|
|
||||||
# mid + document permanent link
|
# mid + document link
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)/([[:digit:]]+)$ ./index.php?mid=$1&document_srl=$2 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)/([[:digit:]]+)$ ./index.php?mid=$1&document_srl=$2 [L]
|
||||||
|
|
||||||
# mid + act permanent link
|
# mid + act link
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)$ ./index.php?mid=$1&act=$2 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)$ ./index.php?mid=$1&act=$2 [L]
|
||||||
|
|
||||||
# mid + page permanent link
|
# mid + page link
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)/page/([[:digit:]]+)$ ./index.php?mid=$1&page=$2 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)/page/([[:digit:]]+)$ ./index.php?mid=$1&page=$2 [L]
|
||||||
|
|
||||||
# mid + category permanent link
|
# mid + category link
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)/category/([[:digit:]]+)$ ./index.php?mid=$1&category=$2 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)/category/([[:digit:]]+)$ ./index.php?mid=$1&category=$2 [L]
|
||||||
|
|
||||||
# mid + category + page
|
# mid + category + page
|
||||||
|
|
@ -39,5 +42,5 @@ RewriteRule ^([a-zA-Z0-9_]+)/tag/(.*)$ ./index.php?mid=$1&search_target=tag&sear
|
||||||
# mid + search target writer
|
# mid + search target writer
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)/writer/(.*)$ ./index.php?mid=$1&search_target=nick_name&search_keyword=$2 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)/writer/(.*)$ ./index.php?mid=$1&search_target=nick_name&search_keyword=$2 [L]
|
||||||
|
|
||||||
# module permanent link
|
# module link
|
||||||
RewriteRule ^([a-zA-Z0-9_]+)(/){0,1}$ ./index.php?mid=$1 [L]
|
RewriteRule ^([a-zA-Z0-9_]+)(/){0,1}$ ./index.php?mid=$1 [L]
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
* 모듈 실행 이전(before_module_proc)에 호출이 되어야 하며 정상동작후에는 강제 종료를 한다.
|
* 모듈 실행 이전(before_module_proc)에 호출이 되어야 하며 정상동작후에는 강제 종료를 한다.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// called_position가 after_module_proc일때 rsd태그 삽입
|
// called_position가 after_module_proc일때 rsd 태그 삽입
|
||||||
if($called_position == 'after_module_proc') {
|
if($called_position == 'after_module_proc') {
|
||||||
// 현재 모듈의 rsd주소를 만듬
|
// 현재 모듈의 rsd주소를 만듬
|
||||||
$rsd_url = sprintf('%s%s/api', Context::getRequestUri(), $this->mid);
|
$rsd_url = sprintf('%s%s/api', Context::getRequestUri(), $this->mid);
|
||||||
|
|
@ -19,12 +19,23 @@
|
||||||
Context::addHtmlHeader(" ".'<link rel="EditURI" type="application/rsd+xml" title="RSD" href="'.$rsd_url.'" />');
|
Context::addHtmlHeader(" ".'<link rel="EditURI" type="application/rsd+xml" title="RSD" href="'.$rsd_url.'" />');
|
||||||
}
|
}
|
||||||
|
|
||||||
// called_position가 before_module_proc일때 실행
|
// act가 api가 아니면 그냥 리턴~
|
||||||
if($called_position != 'before_module_proc' || $_REQUEST['act'] != 'api') return;
|
if($_REQUEST['act']!='api') return;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* blogapi의 경우 GET argument와 XML Content가 같이 오기에 제로보드XE의 경우 XML Content가 오면 이것만 처리하기에
|
||||||
|
* GET argument중에 mid값을 강제 설정해야 모듈을 정상적으로 찾는다
|
||||||
|
**/
|
||||||
|
if($called_position == 'before_module_init') {
|
||||||
|
$mid = $_REQUEST['mid'];
|
||||||
|
Context::set('mid', $mid, true);
|
||||||
|
$this->mid = $mid;
|
||||||
|
}
|
||||||
|
|
||||||
// 관련 func 파일 읽음
|
// 관련 func 파일 읽음
|
||||||
require_once('./addons/blogapi/blogapi.func.php');
|
require_once('./addons/blogapi/blogapi.func.php');
|
||||||
|
|
||||||
|
// xmlprc 파싱
|
||||||
// 요청된 xmlrpc를 파싱
|
// 요청된 xmlrpc를 파싱
|
||||||
$oXmlParser = new XmlParser();
|
$oXmlParser = new XmlParser();
|
||||||
$xmlDoc = $oXmlParser->parse();
|
$xmlDoc = $oXmlParser->parse();
|
||||||
|
|
@ -40,298 +51,330 @@
|
||||||
$user_id = trim($params[1]->value->string->body);
|
$user_id = trim($params[1]->value->string->body);
|
||||||
$password = trim($params[2]->value->string->body);
|
$password = trim($params[2]->value->string->body);
|
||||||
|
|
||||||
// member controller을 이용해서 로그인 시도
|
// 모듈 실행전이라면 인증을 처리한다.
|
||||||
if($user_id && $password) {
|
if($called_position == 'before_module_init') {
|
||||||
$oMemberController = &getController('member');
|
|
||||||
$output = $oMemberController->doLogin($user_id, $password);
|
// member controller을 이용해서 로그인 시도
|
||||||
// 로그인 실패시 에러 메시지 출력
|
if($user_id && $password) {
|
||||||
if(!$output->toBool()) {
|
$oMemberController = &getController('member');
|
||||||
$content = getXmlRpcFailure(1, $output->getMessage());
|
$output = $oMemberController->doLogin($user_id, $password);
|
||||||
|
// 로그인 실패시 에러 메시지 출력
|
||||||
|
if(!$output->toBool()) {
|
||||||
|
$content = getXmlRpcFailure(1, $output->getMessage());
|
||||||
|
printContent($content);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$content = getXmlRpcFailure(1, 'not logged');
|
||||||
printContent($content);
|
printContent($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 카테고리의 정보를 구해옴
|
// 모듈에서 무언가 작업을 하기 전에 blogapi tool의 요청에 대한 처리를 하고 강제 종료한다.
|
||||||
$oDocumentModel = &getModel('document');
|
if($called_position == 'before_module_proc') {
|
||||||
$category_list = $oDocumentModel->getCategoryList($this->module_srl);
|
|
||||||
|
|
||||||
// 임시 파일 저장 장소 지정
|
// 글쓰기 권한 체크 (권한명의 경우 약속이 필요할듯..)
|
||||||
$tmp_uploaded_path = sprintf('./files/cache/blogapi/%s/%s/', $this->mid, $user_id);
|
if(!$this->grant->write_document) {
|
||||||
$uploaded_target_path = sprintf('/files/cache/blogapi/%s/%s/', $this->mid, $user_id);
|
printContent( getXmlRpcFailure(1, 'no permission') );
|
||||||
|
}
|
||||||
|
|
||||||
switch($method_name) {
|
// 카테고리의 정보를 구해옴
|
||||||
// 블로그 정보
|
$oDocumentModel = &getModel('document');
|
||||||
case 'blogger.getUsersBlogs' :
|
$category_list = $oDocumentModel->getCategoryList($this->module_srl);
|
||||||
$obj->url = Context::getRequestUri().$this->mid;
|
|
||||||
$obj->blogid = $this->mid;
|
|
||||||
$obj->blogName = $this->module_info->browser_title;
|
|
||||||
$blog_list = array($obj);
|
|
||||||
|
|
||||||
$content = getXmlRpcResponse($blog_list);
|
// 임시 파일 저장 장소 지정
|
||||||
printContent($content);
|
$tmp_uploaded_path = sprintf('./files/cache/blogapi/%s/%s/', $this->mid, $user_id);
|
||||||
break;
|
$uploaded_target_path = sprintf('/files/cache/blogapi/%s/%s/', $this->mid, $user_id);
|
||||||
|
|
||||||
// 카테고리 목록 return
|
switch($method_name) {
|
||||||
case 'metaWeblog.getCategories' :
|
// 블로그 정보
|
||||||
$category_obj_list = array();
|
case 'blogger.getUsersBlogs' :
|
||||||
if($category_list) {
|
$obj->url = Context::getRequestUri().$this->mid;
|
||||||
foreach($category_list as $category_srl => $category_info) {
|
$obj->blogid = $this->mid;
|
||||||
unset($obj);
|
$obj->blogName = $this->module_info->browser_title;
|
||||||
$obj->description = $category_info->title;
|
$blog_list = array($obj);
|
||||||
//$obj->htmlUrl = Context::getRequestUri().$this->mid.'/1';
|
|
||||||
//$obj->rssUrl= Context::getRequestUri().'rss/'.$this->mid.'/1';
|
|
||||||
$obj->title = $category_info->title;
|
|
||||||
$obj->categoryid = $category_srl;
|
|
||||||
$category_obj_list[] = $obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = getXmlRpcResponse($category_obj_list);
|
$content = getXmlRpcResponse($blog_list);
|
||||||
printContent($content);
|
printContent($content);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 파일 업로드
|
// 카테고리 목록 return
|
||||||
case 'metaWeblog.newMediaObject' :
|
case 'metaWeblog.getCategories' :
|
||||||
$fileinfo = $params[3]->value->struct->member;
|
$category_obj_list = array();
|
||||||
foreach($fileinfo as $key => $val) {
|
if($category_list) {
|
||||||
$nodename = $val->name->body;
|
foreach($category_list as $category_srl => $category_info) {
|
||||||
if($nodename == 'bits') $filedata = base64_decode($val->value->base64->body);
|
unset($obj);
|
||||||
elseif($nodename == 'name') $filename = $val->value->string->body;
|
$obj->description = $category_info->title;
|
||||||
}
|
//$obj->htmlUrl = Context::getRequestUri().$this->mid.'/1';
|
||||||
|
//$obj->rssUrl= Context::getRequestUri().'rss/'.$this->mid.'/1';
|
||||||
$tmp_arr = explode('/',$filename);
|
$obj->title = $category_info->title;
|
||||||
$filename = array_pop($tmp_arr);
|
$obj->categoryid = $category_srl;
|
||||||
|
$category_obj_list[] = $obj;
|
||||||
if(!is_dir($tmp_uploaded_path)) FileHandler::makeDir($tmp_uploaded_path);
|
|
||||||
|
|
||||||
$target_filename = sprintf('%s%s', $tmp_uploaded_path, $filename);
|
|
||||||
FileHandler::writeFile($target_filename, $filedata);
|
|
||||||
$obj->url = 'http://blog.nzeo.com/'.$target_filename;
|
|
||||||
|
|
||||||
$content = getXmlRpcResponse($obj);
|
|
||||||
printContent($content);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 글작성
|
|
||||||
case 'metaWeblog.newPost' :
|
|
||||||
unset($obj);
|
|
||||||
$info = $params[3];
|
|
||||||
// 글, 제목, 카테고리 정보 구함
|
|
||||||
for($i=0;$i<count($info->value->struct->member);$i++) {
|
|
||||||
$val = $info->value->struct->member[$i];
|
|
||||||
switch($val->name->body) {
|
|
||||||
case 'title' :
|
|
||||||
$obj->title = $val->value->string->body;
|
|
||||||
break;
|
|
||||||
case 'description' :
|
|
||||||
$obj->content = $val->value->string->body;
|
|
||||||
break;
|
|
||||||
case 'categories' :
|
|
||||||
$categories = $val->value->array->data->value;
|
|
||||||
if(!is_array($categories)) $categories = array($categories);
|
|
||||||
$category = $categories[0]->string->body;
|
|
||||||
if($category && $category_list) {
|
|
||||||
foreach($category_list as $category_srl => $category_info) {
|
|
||||||
if($category_info->title == $category) $obj->category_srl = $category_srl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'tagwords' :
|
|
||||||
$tags = $val->value->array->data->value;
|
|
||||||
if(!is_array($tags)) $tags = array($tags);
|
|
||||||
for($j=0;$j<count($tags);$j++) {
|
|
||||||
$tag_list[] = $tags[$j]->string->body;
|
|
||||||
}
|
|
||||||
if(count($tag_list)) $obj->tags = implode(',',$tag_list);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 문서 번호 설정
|
|
||||||
$document_srl = getNextSequence();
|
|
||||||
$obj->document_srl = $document_srl;
|
|
||||||
$obj->module_srl = $this->module_srl;
|
|
||||||
|
|
||||||
// 첨부파일 정리
|
|
||||||
if(is_dir($tmp_uploaded_path)) {
|
|
||||||
$file_list = FileHandler::readDir($tmp_uploaded_path);
|
|
||||||
$file_count = count($file_list);
|
|
||||||
if($file_count) {
|
|
||||||
$oFileController = &getController('file');
|
|
||||||
for($i=0;$i<$file_count;$i++) {
|
|
||||||
$file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]);
|
|
||||||
$file_info['name'] = $file_list[$i];
|
|
||||||
$oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true);
|
|
||||||
}
|
}
|
||||||
$obj->uploaded_count = $file_count;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$obj->content = str_replace($uploaded_target_path,sprintf('/files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $filename), $obj->content);
|
|
||||||
|
|
||||||
$oDocumentController = &getController('document');
|
$content = getXmlRpcResponse($category_obj_list);
|
||||||
$obj->allow_comment = 'Y';
|
printContent($content);
|
||||||
$obj->allow_trackback = 'Y';
|
break;
|
||||||
$output = $oDocumentController->insertDocument($obj);
|
|
||||||
|
|
||||||
if(!$output->toBool()) {
|
// 파일 업로드
|
||||||
$content = getXmlRpcFailure(1, $output->getMessage());
|
case 'metaWeblog.newMediaObject' :
|
||||||
} else {
|
// 파일 업로드 권한 체크
|
||||||
//$content = getXmlRpcResponse(Context::getRequestUri().$this->mid.'/'.$document_srl);
|
if(!$this->grant->fileupload) {
|
||||||
$content = getXmlRpcResponse(''.$document_srl);
|
printContent( getXmlRpcFailure(1, 'no permission') );
|
||||||
}
|
}
|
||||||
FileHandler::removeDir($tmp_uploaded_path);
|
|
||||||
|
|
||||||
printContent($content);
|
$fileinfo = $params[3]->value->struct->member;
|
||||||
break;
|
foreach($fileinfo as $key => $val) {
|
||||||
|
$nodename = $val->name->body;
|
||||||
|
if($nodename == 'bits') $filedata = base64_decode($val->value->base64->body);
|
||||||
|
elseif($nodename == 'name') $filename = $val->value->string->body;
|
||||||
|
}
|
||||||
|
|
||||||
// 글 수정
|
$tmp_arr = explode('/',$filename);
|
||||||
case 'metaWeblog.editPost' :
|
$filename = array_pop($tmp_arr);
|
||||||
$tmp_val = $params[0]->value->string->body;
|
|
||||||
$tmp_arr = explode('/', $tmp_val);
|
|
||||||
$document_srl = array_pop($tmp_arr);
|
|
||||||
|
|
||||||
$oDocumentModel = &getModel('document');
|
if(!is_dir($tmp_uploaded_path)) FileHandler::makeDir($tmp_uploaded_path);
|
||||||
$oDocument = $oDocumentModel->getDocument($document_srl);
|
|
||||||
$obj = $oDocument->getObjectVars();
|
|
||||||
|
|
||||||
if(!$oDocument->isGranted()) {
|
$target_filename = sprintf('%s%s', $tmp_uploaded_path, $filename);
|
||||||
$content = getXmlRpcFailure(1, 'no permisstion');
|
FileHandler::writeFile($target_filename, $filedata);
|
||||||
break;
|
$obj->url = Context::getRequestUri().$target_filename;
|
||||||
}
|
|
||||||
|
|
||||||
$info = $params[3];
|
$content = getXmlRpcResponse($obj);
|
||||||
|
printContent($content);
|
||||||
|
break;
|
||||||
|
|
||||||
// 글, 제목, 카테고리 정보 구함
|
// 글작성
|
||||||
for($i=0;$i<count($info->value->struct->member);$i++) {
|
case 'metaWeblog.newPost' :
|
||||||
$val = $info->value->struct->member[$i];
|
unset($obj);
|
||||||
switch($val->name->body) {
|
$info = $params[3];
|
||||||
case 'title' :
|
// 글, 제목, 카테고리 정보 구함
|
||||||
$obj->title = $val->value->string->body;
|
for($i=0;$i<count($info->value->struct->member);$i++) {
|
||||||
break;
|
$val = $info->value->struct->member[$i];
|
||||||
case 'description' :
|
switch($val->name->body) {
|
||||||
$obj->content = $val->value->string->body;
|
case 'title' :
|
||||||
break;
|
$obj->title = $val->value->string->body;
|
||||||
case 'categories' :
|
break;
|
||||||
$categories = $val->value->array->data->value;
|
case 'description' :
|
||||||
if(!is_array($categories)) $categories = array($categories);
|
$obj->content = $val->value->string->body;
|
||||||
$category = $categories[0]->string->body;
|
break;
|
||||||
if($category && $category_list) {
|
case 'categories' :
|
||||||
foreach($category_list as $category_srl => $category_info) {
|
$categories = $val->value->array->data->value;
|
||||||
if($category_info->title == $category) $obj->category_srl = $category_srl;
|
if(!is_array($categories)) $categories = array($categories);
|
||||||
|
$category = $categories[0]->string->body;
|
||||||
|
if($category && $category_list) {
|
||||||
|
foreach($category_list as $category_srl => $category_info) {
|
||||||
|
if($category_info->title == $category) $obj->category_srl = $category_srl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case 'tagwords' :
|
||||||
case 'tagwords' :
|
$tags = $val->value->array->data->value;
|
||||||
$tags = $val->value->array->data->value;
|
if(!is_array($tags)) $tags = array($tags);
|
||||||
if(!is_array($tags)) $tags = array($tags);
|
for($j=0;$j<count($tags);$j++) {
|
||||||
for($j=0;$j<count($tags);$j++) {
|
$tag_list[] = $tags[$j]->string->body;
|
||||||
$tag_list[] = $tags[$j]->string->body;
|
}
|
||||||
}
|
if(count($tag_list)) $obj->tags = implode(',',$tag_list);
|
||||||
if(count($tag_list)) $obj->tags = implode(',',$tag_list);
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 문서 번호 설정
|
|
||||||
$obj->document_srl = $document_srl;
|
|
||||||
$obj->module_srl = $this->module_srl;
|
|
||||||
|
|
||||||
// 첨부파일 정리
|
|
||||||
if(is_dir($tmp_uploaded_path)) {
|
|
||||||
$file_list = FileHandler::readDir($tmp_uploaded_path);
|
|
||||||
$file_count = count($file_list);
|
|
||||||
if($file_count) {
|
|
||||||
$oFileController = &getController('file');
|
|
||||||
for($i=0;$i<$file_count;$i++) {
|
|
||||||
$file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]);
|
|
||||||
$file_info['name'] = $file_list[$i];
|
|
||||||
|
|
||||||
$moved_filename = sprintf('./files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $file_info['name']);
|
|
||||||
if(file_exists($moved_filename)) continue;
|
|
||||||
|
|
||||||
$oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true);
|
|
||||||
}
|
}
|
||||||
$obj->uploaded_count += $file_count;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$obj->content = str_replace($uploaded_target_path,sprintf('/files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $filename), $obj->content);
|
|
||||||
|
|
||||||
$oDocumentController = &getController('document');
|
// 문서 번호 설정
|
||||||
$output = $oDocumentController->updateDocument($oDocument,$obj);
|
$document_srl = getNextSequence();
|
||||||
|
$obj->document_srl = $document_srl;
|
||||||
|
$obj->module_srl = $this->module_srl;
|
||||||
|
|
||||||
if(!$output->toBool()) {
|
// 첨부파일 정리
|
||||||
$content = getXmlRpcFailure(1, $output->getMessage());
|
if(is_dir($tmp_uploaded_path)) {
|
||||||
} else {
|
$file_list = FileHandler::readDir($tmp_uploaded_path);
|
||||||
$content = getXmlRpcResponse(Context::getRequestUri().$this->mid.'/'.$document_srl);
|
$file_count = count($file_list);
|
||||||
|
if($file_count) {
|
||||||
|
$oFileController = &getController('file');
|
||||||
|
for($i=0;$i<$file_count;$i++) {
|
||||||
|
$file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]);
|
||||||
|
$file_info['name'] = $file_list[$i];
|
||||||
|
$oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true);
|
||||||
|
}
|
||||||
|
$obj->uploaded_count = $file_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$obj->content = str_replace($uploaded_target_path,sprintf('/files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $filename), $obj->content);
|
||||||
|
|
||||||
|
$oDocumentController = &getController('document');
|
||||||
|
$obj->allow_comment = 'Y';
|
||||||
|
$obj->allow_trackback = 'Y';
|
||||||
|
$output = $oDocumentController->insertDocument($obj);
|
||||||
|
|
||||||
|
if(!$output->toBool()) {
|
||||||
|
$content = getXmlRpcFailure(1, $output->getMessage());
|
||||||
|
} else {
|
||||||
|
//$content = getXmlRpcResponse(Context::getRequestUri().$this->mid.'/'.$document_srl);
|
||||||
|
$content = getXmlRpcResponse(''.$document_srl);
|
||||||
|
}
|
||||||
FileHandler::removeDir($tmp_uploaded_path);
|
FileHandler::removeDir($tmp_uploaded_path);
|
||||||
}
|
|
||||||
|
|
||||||
printContent($content);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 글삭제
|
|
||||||
case 'blogger.deletePost' :
|
|
||||||
$tmp_val = $params[0]->value->string->body;
|
|
||||||
$tmp_arr = explode('/', $tmp_val);
|
|
||||||
$document_srl = array_pop($tmp_arr);
|
|
||||||
|
|
||||||
$oDocumentController = &getController('document');
|
|
||||||
$output = $oDocumentController->deleteDocument($document_srl);
|
|
||||||
if(!$output->toBool()) $content = getXmlRpcFailure(1, $output->getMessage());
|
|
||||||
else $content = getXmlRpcResponse(true);
|
|
||||||
|
|
||||||
printContent($content);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 최신글 받기
|
|
||||||
case 'metaWeblog.getRecentPosts' :
|
|
||||||
// 목록을 구하기 위한 옵션
|
|
||||||
$args->module_srl = $this->module_srl; ///< 현재 모듈의 module_srl
|
|
||||||
$args->page = 1;
|
|
||||||
$args->list_count = 20;
|
|
||||||
$args->sort_index = 'list_order'; ///< 소팅 값
|
|
||||||
$output = $oDocumentModel->getDocumentList($args);
|
|
||||||
if(!$output->toBool() || !$output->data) {
|
|
||||||
$content = getXmlRpcFailure(1, 'post not founded');
|
|
||||||
printContent($content);
|
printContent($content);
|
||||||
} else {
|
break;
|
||||||
$oContext = &Context::getInstance();
|
|
||||||
|
|
||||||
|
// 글 수정
|
||||||
|
case 'metaWeblog.editPost' :
|
||||||
|
$tmp_val = $params[0]->value->string->body;
|
||||||
|
$tmp_arr = explode('/', $tmp_val);
|
||||||
|
$document_srl = array_pop($tmp_arr);
|
||||||
|
|
||||||
$posts = array();
|
$oDocumentModel = &getModel('document');
|
||||||
foreach($output->data as $key => $oDocument) {
|
$oDocument = $oDocumentModel->getDocument($document_srl);
|
||||||
$post = null;
|
|
||||||
$post->link = $post->permaLink = getUrl('','mid',$this->mid,'document_srl',$oDocument->document_srl);
|
|
||||||
$post->userid = $oDocument->get('user_id');
|
|
||||||
$post->mt_allow_pings = 0;
|
|
||||||
$post->mt_allow_comments = $oDocument->allowComment()=='Y'?1:0;
|
|
||||||
$post->description = htmlspecialchars($oContext->transContent($oDocument->get('content')));
|
|
||||||
$post->postid = $oDocument->document_srl;
|
|
||||||
$post->title = htmlspecialchars($oDocument->get('title'));
|
|
||||||
|
|
||||||
$year = substr($oDocument->get('regdate'),0,4);
|
// 글 수정 권한 체크
|
||||||
$month = substr($oDocument->get('regdate'),4,2);
|
if(!$oDocument->isGranted()) {
|
||||||
$day = substr($oDocument->get('regdate'),6,2);
|
$content = getXmlRpcFailure(1, 'no permission');
|
||||||
$hour = substr($oDocument->get('regdate'),8,2);
|
break;
|
||||||
$min = substr($oDocument->get('regdate'),10,2);
|
|
||||||
$sec = substr($oDocument->get('regdate'),12,2);
|
|
||||||
$time = mktime($hour,$min,$sec,$month,$day,$year);
|
|
||||||
$post->dateCreated = gmdate("D, d M Y H:i:s", $time);
|
|
||||||
$posts[] = $post;
|
|
||||||
}
|
}
|
||||||
$content = getXmlRpcResponse($posts);
|
|
||||||
|
$obj = $oDocument->getObjectVars();
|
||||||
|
|
||||||
|
$info = $params[3];
|
||||||
|
|
||||||
|
// 글, 제목, 카테고리 정보 구함
|
||||||
|
for($i=0;$i<count($info->value->struct->member);$i++) {
|
||||||
|
$val = $info->value->struct->member[$i];
|
||||||
|
switch($val->name->body) {
|
||||||
|
case 'title' :
|
||||||
|
$obj->title = $val->value->string->body;
|
||||||
|
break;
|
||||||
|
case 'description' :
|
||||||
|
$obj->content = $val->value->string->body;
|
||||||
|
break;
|
||||||
|
case 'categories' :
|
||||||
|
$categories = $val->value->array->data->value;
|
||||||
|
if(!is_array($categories)) $categories = array($categories);
|
||||||
|
$category = $categories[0]->string->body;
|
||||||
|
if($category && $category_list) {
|
||||||
|
foreach($category_list as $category_srl => $category_info) {
|
||||||
|
if($category_info->title == $category) $obj->category_srl = $category_srl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'tagwords' :
|
||||||
|
$tags = $val->value->array->data->value;
|
||||||
|
if(!is_array($tags)) $tags = array($tags);
|
||||||
|
for($j=0;$j<count($tags);$j++) {
|
||||||
|
$tag_list[] = $tags[$j]->string->body;
|
||||||
|
}
|
||||||
|
if(count($tag_list)) $obj->tags = implode(',',$tag_list);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 문서 번호 설정
|
||||||
|
$obj->document_srl = $document_srl;
|
||||||
|
$obj->module_srl = $this->module_srl;
|
||||||
|
|
||||||
|
// 첨부파일 정리
|
||||||
|
if(is_dir($tmp_uploaded_path)) {
|
||||||
|
$file_list = FileHandler::readDir($tmp_uploaded_path);
|
||||||
|
$file_count = count($file_list);
|
||||||
|
if($file_count) {
|
||||||
|
$oFileController = &getController('file');
|
||||||
|
for($i=0;$i<$file_count;$i++) {
|
||||||
|
$file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]);
|
||||||
|
$file_info['name'] = $file_list[$i];
|
||||||
|
|
||||||
|
$moved_filename = sprintf('./files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $file_info['name']);
|
||||||
|
if(file_exists($moved_filename)) continue;
|
||||||
|
|
||||||
|
$oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true);
|
||||||
|
}
|
||||||
|
$obj->uploaded_count += $file_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$obj->content = str_replace($uploaded_target_path,sprintf('/files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $filename), $obj->content);
|
||||||
|
|
||||||
|
$oDocumentController = &getController('document');
|
||||||
|
$output = $oDocumentController->updateDocument($oDocument,$obj);
|
||||||
|
|
||||||
|
if(!$output->toBool()) {
|
||||||
|
$content = getXmlRpcFailure(1, $output->getMessage());
|
||||||
|
} else {
|
||||||
|
$content = getXmlRpcResponse(Context::getRequestUri().$this->mid.'/'.$document_srl);
|
||||||
|
FileHandler::removeDir($tmp_uploaded_path);
|
||||||
|
}
|
||||||
|
|
||||||
printContent($content);
|
printContent($content);
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
// 아무런 요청이 없을 경우 RSD 출력
|
// 글삭제
|
||||||
default :
|
case 'blogger.deletePost' :
|
||||||
|
$tmp_val = $params[0]->value->string->body;
|
||||||
|
$tmp_arr = explode('/', $tmp_val);
|
||||||
|
$document_srl = array_pop($tmp_arr);
|
||||||
|
|
||||||
$homepagelink = getUrl('','mid',$this->mid);
|
// 글 받아오기
|
||||||
$api_url = sprintf('%s%s/api', Context::getRequestUri(), $this->mid);
|
$oDocumentModel = &getModel('document');
|
||||||
$content = <<<RSDContent
|
$oDocument = $oDocumentModel->getDocument($document_srl);
|
||||||
|
|
||||||
|
// 글 삭제 권한 체크
|
||||||
|
if(!$oDocument->isGranted()) {
|
||||||
|
$content = getXmlRpcFailure(1, 'no permission');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$oDocumentController = &getController('document');
|
||||||
|
$output = $oDocumentController->deleteDocument($document_srl);
|
||||||
|
if(!$output->toBool()) $content = getXmlRpcFailure(1, $output->getMessage());
|
||||||
|
else $content = getXmlRpcResponse(true);
|
||||||
|
|
||||||
|
printContent($content);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 최신글 받기
|
||||||
|
case 'metaWeblog.getRecentPosts' :
|
||||||
|
// 목록을 구하기 위한 옵션
|
||||||
|
$args->module_srl = $this->module_srl; ///< 현재 모듈의 module_srl
|
||||||
|
$args->page = 1;
|
||||||
|
$args->list_count = 20;
|
||||||
|
$args->sort_index = 'list_order'; ///< 소팅 값
|
||||||
|
$output = $oDocumentModel->getDocumentList($args);
|
||||||
|
if(!$output->toBool() || !$output->data) {
|
||||||
|
$content = getXmlRpcFailure(1, 'post not founded');
|
||||||
|
printContent($content);
|
||||||
|
} else {
|
||||||
|
$oContext = &Context::getInstance();
|
||||||
|
|
||||||
|
|
||||||
|
$posts = array();
|
||||||
|
foreach($output->data as $key => $oDocument) {
|
||||||
|
$post = null;
|
||||||
|
$post->link = $post->permaLink = getUrl('','mid',$this->mid,'document_srl',$oDocument->document_srl);
|
||||||
|
$post->userid = $oDocument->get('user_id');
|
||||||
|
$post->mt_allow_pings = 0;
|
||||||
|
$post->mt_allow_comments = $oDocument->allowComment()=='Y'?1:0;
|
||||||
|
$post->description = htmlspecialchars($oContext->transContent($oDocument->get('content')));
|
||||||
|
$post->postid = $oDocument->document_srl;
|
||||||
|
$post->title = htmlspecialchars($oDocument->get('title'));
|
||||||
|
|
||||||
|
$year = substr($oDocument->get('regdate'),0,4);
|
||||||
|
$month = substr($oDocument->get('regdate'),4,2);
|
||||||
|
$day = substr($oDocument->get('regdate'),6,2);
|
||||||
|
$hour = substr($oDocument->get('regdate'),8,2);
|
||||||
|
$min = substr($oDocument->get('regdate'),10,2);
|
||||||
|
$sec = substr($oDocument->get('regdate'),12,2);
|
||||||
|
$time = mktime($hour,$min,$sec,$month,$day,$year);
|
||||||
|
$post->dateCreated = gmdate("D, d M Y H:i:s", $time);
|
||||||
|
$posts[] = $post;
|
||||||
|
}
|
||||||
|
$content = getXmlRpcResponse($posts);
|
||||||
|
printContent($content);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 아무런 요청이 없을 경우 RSD 출력
|
||||||
|
default :
|
||||||
|
|
||||||
|
$homepagelink = getUrl('','mid',$this->mid);
|
||||||
|
$api_url = sprintf('%s%s/api', Context::getRequestUri(), $this->mid);
|
||||||
|
$content = <<<RSDContent
|
||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" ?>
|
||||||
<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd" >
|
<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd" >
|
||||||
<service>
|
<service>
|
||||||
|
|
@ -344,7 +387,8 @@
|
||||||
</service>
|
</service>
|
||||||
</rsd>
|
</rsd>
|
||||||
RSDContent;
|
RSDContent;
|
||||||
printContent($content);
|
printContent($content);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
* @brief blogapi구현을 위한 함수 모음집
|
* @brief blogapi구현을 위한 함수 모음집
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
// 오류 표시
|
||||||
function getXmlRpcFailure($error, $message) {
|
function getXmlRpcFailure($error, $message) {
|
||||||
return
|
return
|
||||||
sprintf(
|
sprintf(
|
||||||
|
|
@ -16,6 +17,7 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 결과 표시
|
||||||
function getXmlRpcResponse($params) {
|
function getXmlRpcResponse($params) {
|
||||||
$buff = '<?xml version="1.0" encoding="utf-8"?>'."\n<methodResponse><params>";
|
$buff = '<?xml version="1.0" encoding="utf-8"?>'."\n<methodResponse><params>";
|
||||||
$buff .= _getEncodedVal($params);
|
$buff .= _getEncodedVal($params);
|
||||||
|
|
@ -24,6 +26,7 @@
|
||||||
return $buff;
|
return $buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 인코딩 처리
|
||||||
function _getEncodedVal($val, $is_sub_set = false) {
|
function _getEncodedVal($val, $is_sub_set = false) {
|
||||||
if(is_int($val)) $buff = sprintf("<value><i4>%d</i4></value>", $val);
|
if(is_int($val)) $buff = sprintf("<value><i4>%d</i4></value>", $val);
|
||||||
elseif(is_double($val)) $buff = sprintf("<value><double>%f</double></value>", $val);
|
elseif(is_double($val)) $buff = sprintf("<value><double>%f</double></value>", $val);
|
||||||
|
|
@ -50,6 +53,7 @@
|
||||||
return $buff;
|
return $buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 결과 출력
|
||||||
function printContent($content) {
|
function printContent($content) {
|
||||||
header("Content-Type: text/xml; charset=UTF-8");
|
header("Content-Type: text/xml; charset=UTF-8");
|
||||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,7 @@
|
||||||
* @brief GET/POST방식일 경우 처리
|
* @brief GET/POST방식일 경우 처리
|
||||||
**/
|
**/
|
||||||
function _setRequestArgument() {
|
function _setRequestArgument() {
|
||||||
if($this->_getRequestMethod() == 'XMLRPC') return;
|
//if($this->_getRequestMethod() == 'XMLRPC') return;
|
||||||
if(!count($_REQUEST)) return;
|
if(!count($_REQUEST)) return;
|
||||||
|
|
||||||
foreach($_REQUEST as $key => $val) {
|
foreach($_REQUEST as $key => $val) {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* 0 : files/_debug_message.php 에 연결하여 출력
|
* 0 : files/_debug_message.php 에 연결하여 출력
|
||||||
* 1 : Response Method 가 XML 형식이 아닐 경우 브라우저에 최상단에 주석으로 표시
|
* 1 : Response Method 가 XML 형식이 아닐 경우 브라우저에 최상단에 주석으로 표시
|
||||||
**/
|
**/
|
||||||
define('__DEBUG_OUTPUT__', 1);
|
define('__DEBUG_OUTPUT__', 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 디버깅 메세지 출력
|
* @brief 디버깅 메세지 출력
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
* 2 : 1 + DB 쿼리
|
* 2 : 1 + DB 쿼리
|
||||||
* 3 : 모든 로그
|
* 3 : 모든 로그
|
||||||
**/
|
**/
|
||||||
define('__DEBUG__', 1);
|
define('__DEBUG__', 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 간단하게 사용하기 위한 함수 정의한 파일 require
|
* @brief 간단하게 사용하기 위한 함수 정의한 파일 require
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@
|
||||||
* tail -f ./files/_debug_message.php 하여 계속 살펴 볼 수 있다
|
* tail -f ./files/_debug_message.php 하여 계속 살펴 볼 수 있다
|
||||||
**/
|
**/
|
||||||
function debugPrint($buff = null, $display_line = true) {
|
function debugPrint($buff = null, $display_line = true) {
|
||||||
if(!$buff) return;
|
//if(!$buff) return;
|
||||||
|
|
||||||
if(__DEBUG_OUTPUT__==1) {
|
if(__DEBUG_OUTPUT__==1) {
|
||||||
print sprintf("<!--\n%s\n-->", print_r($buff,true));
|
print sprintf("<!--\n%s\n-->", print_r($buff,true));
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<form id="fo_insert_member" action="./" method="get" onsubmit="return procFilter(this, insert)">
|
<form id="fo_insert_member" action="./" method="get" onsubmit="return procFilter(this, insert)">
|
||||||
<input type="hidden" name="page" value="{$page}" />
|
<input type="hidden" name="page" value="{$page}" />
|
||||||
<input type="hidden" name="member_srl" value="{$member_srl}" />
|
<input type="hidden" name="member_srl" value="{$member_info->member_srl}" />
|
||||||
<input type="hidden" name="content" value="{htmlspecialchars($member_info->signature)}" />
|
<input type="hidden" name="content" value="{htmlspecialchars($member_info->signature)}" />
|
||||||
<!--@if($member_info->member_srl)-->
|
<!--@if($member_info->member_srl)-->
|
||||||
<input type="hidden" name="user_id" value="{htmlspecialchars($member_info->user_id)}" />
|
<input type="hidden" name="user_id" value="{htmlspecialchars($member_info->user_id)}" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue