git-svn-id: http://xe-core.googlecode.com/svn/trunk@1498 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-05-29 08:17:51 +00:00
parent 96ebb942a0
commit 7f16030e4d
2 changed files with 36 additions and 20 deletions

View file

@ -48,12 +48,13 @@
// 임시 파일 저장 장소 지정 // 임시 파일 저장 장소 지정
$tmp_uploaded_path = sprintf('./files/cache/blogapi/%s/%s/', $this->mid, $user_id); $tmp_uploaded_path = sprintf('./files/cache/blogapi/%s/%s/', $this->mid, $user_id);
$uploaded_target_path = sprintf('/files/cache/blogapi/%s/%s/', $this->mid, $user_id);
switch($method_name) { switch($method_name) {
// 블로그 정보 // 블로그 정보
case 'blogger.getUsersBlogs' : case 'blogger.getUsersBlogs' :
$obj->blogid = $this->mid;
$obj->url = Context::getRequestUri().$this->mid; $obj->url = Context::getRequestUri().$this->mid;
$obj->blogid = $this->mid;
$obj->blogName = $this->module_info->browser_title; $obj->blogName = $this->module_info->browser_title;
$blog_list = array($obj); $blog_list = array($obj);
@ -80,16 +81,23 @@
// 파일 업로드 // 파일 업로드
case 'metaWeblog.newMediaObject' : case 'metaWeblog.newMediaObject' :
$fileinfo = $params[3]; $fileinfo = $params[3]->value->struct->member;
$filedata = base64_decode($fileinfo->value->struct->member[0]->value->base64->body); foreach($fileinfo as $key => $val) {
$filename = $fileinfo->value->struct->member[1]->value->string->body; $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);
$filename = array_pop($tmp_arr);
if(!is_dir($tmp_uploaded_path)) FileHandler::makeDir($tmp_uploaded_path); if(!is_dir($tmp_uploaded_path)) FileHandler::makeDir($tmp_uploaded_path);
$target_filename = sprintf('%s%s', $tmp_uploaded_path, $filename); $target_filename = sprintf('%s%s', $tmp_uploaded_path, $filename);
FileHandler::writeFile($target_filename, $filedata); FileHandler::writeFile($target_filename, $filedata);
$obj->url = 'http://blog.nzeo.com/'.$target_filename;
$content = getXmlRpcResponse('{UPLOADED_PATH}'.$filename); $content = getXmlRpcResponse($obj);
break; break;
// 글작성 // 글작성
@ -147,7 +155,7 @@
$obj->uploaded_count = $file_count; $obj->uploaded_count = $file_count;
} }
} }
$obj->content = str_replace($this->mid.'/{UPLOADED_PATH}',sprintf('./files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $filename), $obj->content); $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'); $oDocumentController = &getController('document');
$obj->allow_comment = 'Y'; $obj->allow_comment = 'Y';
@ -157,9 +165,10 @@
if(!$output->toBool()) { if(!$output->toBool()) {
$content = getXmlRpcFailure(1, $output->getMessage()); $content = getXmlRpcFailure(1, $output->getMessage());
} else { } else {
$content = getXmlRpcResponse(Context::getRequestUri().$this->mid.'/'.$document_srl); //$content = getXmlRpcResponse(Context::getRequestUri().$this->mid.'/'.$document_srl);
FileHandler::removeDir($tmp_uploaded_path); $content = getXmlRpcResponse(''.$document_srl);
} }
FileHandler::removeDir($tmp_uploaded_path);
break; break;
// 글 수정 // 글 수정
@ -224,12 +233,16 @@
for($i=0;$i<$file_count;$i++) { for($i=0;$i<$file_count;$i++) {
$file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]); $file_info['tmp_name'] = sprintf('%s%s', $tmp_uploaded_path, $file_list[$i]);
$file_info['name'] = $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); $oFileController->insertFile($file_info, $this->module_srl, $document_srl, 0, true);
} }
$obj->uploaded_count += $file_count; $obj->uploaded_count += $file_count;
} }
} }
$obj->content = str_replace($this->mid.'/{UPLOADED_PATH}',sprintf('./files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $filename), $obj->content); $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'); $oDocumentController = &getController('document');
$output = $oDocumentController->updateDocument($source_obj,$obj); $output = $oDocumentController->updateDocument($source_obj,$obj);

View file

@ -24,28 +24,31 @@
return $buff; return $buff;
} }
function _getEncodedVal($val) { function _getEncodedVal($val, $is_sub_set = false) {
if(is_int($val)) $buff = sprintf("<i4>%d</i4>\n", $val); if(is_int($val)) $buff = sprintf("<param><value><i4>%d</i4></value></param>\n", $val);
elseif(is_double($val)) $buff = sprintf("<double>%f</double>\n", $val); elseif(is_double($val)) $buff = sprintf("<param><value><double>%f</double></value></param>\n", $val);
elseif(is_bool($val)) $buff = sprintf("<boolean>%d</boolean>\n", $val?1:0); elseif(is_bool($val)) $buff = sprintf("<param><value><boolean>%d</boolean></value></param>\n", $val?1:0);
elseif(is_object($val)) { elseif(is_object($val)) {
$values = get_object_vars($val); $values = get_object_vars($val);
$val_count = count($values); $val_count = count($values);
$buff = "<struct>"; $buff = "<value><struct>";
foreach($values as $k => $v) { foreach($values as $k => $v) {
$buff .= sprintf("<member>\n<name>%s</name>\n<value>%s</value>\n</member>\n", htmlspecialchars($k), _getEncodedVal($v)); $buff .= sprintf("<member>\n<name>%s</name>\n<value>%s</value>\n</member>\n", htmlspecialchars($k), _getEncodedVal($v));
} }
$buff .= "</struct>\n"; $buff .= "</struct></value>\n";
if(!$is_sub_set) $buff = '<param>'.$buff.'</param>';
} elseif(is_array($val)) { } elseif(is_array($val)) {
$val_count = count($val); $val_count = count($val);
$buff = "<array>\n<data>"; $buff = "<param><value><array>\n<data>";
for($i=0;$i<$val_count;$i++) { for($i=0;$i<$val_count;$i++) {
$buff .= sprintf("<value>%s</value>\n", _getEncodedVal($val[$i])); $buff .= _getEncodedVal($val[$i], true);
//sprintf("<value>%s</value>\n", _getEncodedVal($val[$i]));
} }
$buff .= "</data>\n</array>"; $buff .= "</data>\n</array></value></param>";
} else { } else {
$buff = sprintf("<string>%s</string>\n", $val); $buff = sprintf("<param><value><string>%s</string></value></param>\n", $val);
} }
return sprintf("<param>\n<value>%s</value>\n</param>", $buff); //return sprintf("<param>\n<value>%s</value>\n</param>", $buff);
return $buff;
} }
?> ?>