mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@1486 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
76cc271240
commit
222720e4d4
6 changed files with 225 additions and 24 deletions
168
addons/blogapi/blogapi.addon.php
Normal file
168
addons/blogapi/blogapi.addon.php
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
if(!defined("__ZBXE__")) exit();
|
||||
|
||||
/**
|
||||
* @file blogapicounter.addon.php
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief blogAPI 애드온
|
||||
*
|
||||
* 파이어폭스의 performancing, zoundry 등의 외부 툴을 이용하여 글을 입력할 수 있게 합니다.
|
||||
* 모듈 실행 이전(before_module_proc)에 호출이 되어야 하며 정상동작후에는 모듈의 실행을 취소한다.
|
||||
**/
|
||||
|
||||
// called_position가 before_module_proc일때 실행
|
||||
if($called_position != 'before_module_proc' || $_REQUEST['act'] != 'blogapi') return;
|
||||
|
||||
// 관련 func 파일 읽음
|
||||
require_once('./addons/blogapi/blogapi.func.php');
|
||||
|
||||
// 요청된 xmlrpc를 파싱
|
||||
$oXmlParser = new XmlParser();
|
||||
$xmlDoc = $oXmlParser->parse();
|
||||
|
||||
$method_name = $xmlDoc->methodcall->methodname->body;
|
||||
$params = $xmlDoc->methodcall->params->param;
|
||||
if($params && !is_array($params)) $params = array($params);
|
||||
|
||||
// user_id, password를 구해서 로그인 시도
|
||||
$appkey = $params[0]->value->string->body;
|
||||
$user_id = $params[1]->value->string->body;
|
||||
$password = $params[2]->value->string->body;
|
||||
|
||||
// member controller을 이용해서 로그인 시도
|
||||
$oMemberController = &getController('member');
|
||||
$output = $oMemberController->doLogin($user_id, $password);
|
||||
|
||||
// 로그인 실패시 에러 메시지 출력
|
||||
if(!$output->toBool()) {
|
||||
$content = getXmlRpcFailure(1, $output->getMessage());
|
||||
|
||||
// 로그인 성공시 method name에 따른 실행
|
||||
} else {
|
||||
|
||||
// 카테고리의 정보를 구해옴
|
||||
$oDocumentModel = &getModel('document');
|
||||
$category_list = $oDocumentModel->getCategoryList($this->module_srl);
|
||||
|
||||
// 임시 파일 저장 장소 지정
|
||||
$tmp_uploaded_path = sprintf('./files/cache/blogapi/%s/%s/', $this->mid, $user_id);
|
||||
|
||||
switch($method_name) {
|
||||
// 블로그 정보
|
||||
case 'blogger.getUsersBlogs' :
|
||||
$obj->blogid = $this->mid;
|
||||
$obj->url = Context::getRequestUri().$this->mid;
|
||||
$obj->blogName = $this->module_info->browser_title;
|
||||
$blog_list = array($obj);
|
||||
|
||||
$content = getXmlRpcResponse($blog_list);
|
||||
break;
|
||||
|
||||
// 카테고리 목록 return
|
||||
case 'metaWeblog.getCategories' :
|
||||
$category_obj_list = array();
|
||||
if($category_list) {
|
||||
foreach($category_list as $category_srl => $category_info) {
|
||||
unset($obj);
|
||||
$obj->description = $category_info->title;
|
||||
//$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);
|
||||
break;
|
||||
|
||||
// 파일 업로드
|
||||
case 'metaWeblog.newMediaObject' :
|
||||
$fileinfo = $params[3];
|
||||
$filedata = base64_decode($fileinfo->value->struct->member[0]->value->base64->body);
|
||||
$filename = $fileinfo->value->struct->member[1]->value->string->body;
|
||||
|
||||
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);
|
||||
|
||||
$content = getXmlRpcResponse('{UPLOADED_PATH}'.$filename);
|
||||
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($this->mid.'/{UPLOADED_PATH}',sprintf('./files/attach/images/%s/%s/%s', $this->module_srl, $document_srl, $filename), $obj->content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$oDocumentController = &getController('document');
|
||||
$output = $oDocumentController->insertDocument($obj);
|
||||
|
||||
if(!$output->toBool()) {
|
||||
$content = getXmlRpcFailure(1, $output->getMessage());
|
||||
} else {
|
||||
$content = getXmlRpcResponse(Context::getRequestUri().$this->mid.'/'.$document_srl);
|
||||
FileHandler::removeDir($tmp_uploaded_path);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
header("Content-Type: text/xml; charset=UTF-8");
|
||||
print $content;
|
||||
|
||||
exit();
|
||||
?>
|
||||
51
addons/blogapi/blogapi.func.php
Normal file
51
addons/blogapi/blogapi.func.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
if(!defined("__ZBXE__")) exit();
|
||||
|
||||
/**
|
||||
* @file ./addons/blogapi/blogapi.func.php
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief blogapi구현을 위한 함수 모음집
|
||||
**/
|
||||
|
||||
function getXmlRpcFailure($error, $message) {
|
||||
return
|
||||
sprintf(
|
||||
"<methodResponse>\n<fault><value><struct>\n<member>\n<name>faultCode</name>\n<value><int>%d</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>%s</string></value>\n</member>\n</struct></value></fault>\n</methodResponse>\n",
|
||||
$error,
|
||||
htmlspecialchars($message)
|
||||
);
|
||||
}
|
||||
|
||||
function getXmlRpcResponse($params) {
|
||||
$buff = '<?xml version="1.0" encoding="utf-8"?>'."\n<methodResponse><params>";
|
||||
$buff .= _getEncodedVal($params);
|
||||
$buff .= "</params>\n</methodResponse>\n";
|
||||
|
||||
return $buff;
|
||||
}
|
||||
|
||||
function _getEncodedVal($val) {
|
||||
if(is_int($val)) $buff = sprintf("<i4>%d</i4>\n", $val);
|
||||
elseif(is_double($val)) $buff = sprintf("<double>%f</double>\n", $val);
|
||||
elseif(is_bool($val)) $buff = sprintf("<boolean>%d</boolean>\n", $val?1:0);
|
||||
elseif(is_object($val)) {
|
||||
$values = get_object_vars($val);
|
||||
$val_count = count($values);
|
||||
$buff = "<struct>";
|
||||
foreach($values as $k => $v) {
|
||||
$buff .= sprintf("<member>\n<name>%s</name>\n<value>%s</value>\n</member>\n", htmlspecialchars($k), _getEncodedVal($v));
|
||||
}
|
||||
$buff .= "</struct>\n";
|
||||
} elseif(is_array($val)) {
|
||||
$val_count = count($val);
|
||||
$buff = "<array>\n<data>";
|
||||
for($i=0;$i<$val_count;$i++) {
|
||||
$buff .= sprintf("<value>%s</value>\n", _getEncodedVal($val[$i]));
|
||||
}
|
||||
$buff .= "</data>\n</array>";
|
||||
} else {
|
||||
$buff = sprintf("<string>%s</string>\n", $val);
|
||||
}
|
||||
return sprintf("<param>\n<value>%s</value>\n</param>", $buff);
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<addon version="0.1">
|
||||
<title xml:lang="ko">기본 카운터 애드온</title>
|
||||
<title xml:lang="ko">BlogAPI 애드온</title>
|
||||
<author email_address="zero@zeroboard.com" link="http://www.zeroboard.com" date="2007. 2. 28">
|
||||
<name xml:lang="ko">제로</name>
|
||||
<description xml:lang="ko">
|
||||
제로보드XE의 기본 카운터 모듈을 이용하여 접속 정보를 기록합니다.
|
||||
이 애드온을 켜셔야 접속 정보 수집이 됩니다.
|
||||
외부 툴을 이용해서 글을 입력할 수 있는 BlogApi 애드온입니다.
|
||||
</description>
|
||||
</author>
|
||||
</addon>
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
if(!defined("__ZBXE__")) exit();
|
||||
|
||||
/**
|
||||
* @file counter.addon.php
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief 카운터 애드온
|
||||
*
|
||||
* 카운터 애드온은 제로보드XE의 기본 카운터(counter)모듈을 이용하여 로그를 남깁니다.
|
||||
* 검색 로봇이나 기타 툴의 접속을 방지하고 부하를 줄이기 위해서 페이지가 로드된 후에 javascript로 다시 로그를 남기도록 합니다.
|
||||
* 따라서 이 카운터 애드온은 카운터를 수집하게 하는 javascript 파일을 추가하는 동작만 하며 기본 카운터 모듈의 호출은 해당 javascript
|
||||
* 파일내에서 이루어집니다.
|
||||
**/
|
||||
|
||||
// called_position가 before_module_init 이고 module이 admin이 아닐 경우
|
||||
if($called_position == 'before_module_init' && !$GLOBALS['__counter_addon_called__']) {
|
||||
if($this->module != 'admin') Context::addJsFile('./modules/counter/tpl/js/counter.js');
|
||||
$GLOBALS['__counter_addon_called__'] = true;
|
||||
}
|
||||
?>
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* @brief error 코드를 return
|
||||
**/
|
||||
function getError() {
|
||||
return $this->error;
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -913,6 +913,9 @@
|
|||
$_SESSION['group_srls'] = $group_srl_list;
|
||||
$_SESSION['is_admin'] = $member_info->is_admin=='Y'?true:false;
|
||||
|
||||
Context::set('is_logged', true);
|
||||
Context::set('logged_info', $member_info);
|
||||
|
||||
// 사용자 정보의 최근 로그인 시간을 기록
|
||||
$args->member_srl = $member_info->member_srl;
|
||||
$output = executeQuery('member.updateLastLogin', $args);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue