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@995 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
726efffe6f
commit
6f0e2d5df9
9 changed files with 388 additions and 31 deletions
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<module version="0.1">
|
||||
<title xml:lang="ko">엮인글</title>
|
||||
<title xml:lang="ko">설문조사</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">엮인글 관리 모듈</description>
|
||||
<description xml:lang="ko">설문조사 관리 모듈</description>
|
||||
</author>
|
||||
</module>
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
<module>
|
||||
<grants />
|
||||
<actions>
|
||||
<action name="dispTrackbackAdminList" type="view" admin_index="true" standalone="true" />
|
||||
<action name="procTrackbackAdminDeleteChecked" type="controller" standalone="true" />
|
||||
<action name="procTrackbackReceive" type="controller" standalone="true" />
|
||||
<action name="dispPollAdminList" type="view" admin_index="true" standalone="true" />
|
||||
</actions>
|
||||
</module>
|
||||
|
|
|
|||
|
|
@ -2,21 +2,11 @@
|
|||
/**
|
||||
* @file modules/trackback/lang/ko.lang.php
|
||||
* @author zero <zero@nzeo.com>
|
||||
* @brief 엮인글(trackback) 모듈의 기본 언어팩
|
||||
* @brief 설문조사 (poll) 모듈의 기본 언어팩
|
||||
**/
|
||||
|
||||
$lang->cmd_delete_checked_trackback = '선택항목 삭제';
|
||||
|
||||
$lang->msg_cart_is_null = '삭제할 글을 선택해주세요';
|
||||
$lang->msg_checked_trackback_is_deleted = '%d개의 엮인글이 삭제되었습니다';
|
||||
|
||||
$lang->search_target_list = array(
|
||||
'url' => '대상 URL',
|
||||
'blog_name' => '대상 사이트 이름',
|
||||
'title' => '제목',
|
||||
'excerpt' => '내용',
|
||||
'regdate' => '등록일',
|
||||
'ipaddress' => 'IP 주소',
|
||||
);
|
||||
|
||||
$lang->msg_checked_trackback_is_deleted = '%d개의 설문조사가 삭제되었습니다';
|
||||
?>
|
||||
|
|
|
|||
38
modules/poll/poll.class.php
Normal file
38
modules/poll/poll.class.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* @class trackback
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief trackback모듈의 high class
|
||||
**/
|
||||
|
||||
class trackback extends ModuleObject {
|
||||
|
||||
/**
|
||||
* @brief 설치시 추가 작업이 필요할시 구현
|
||||
**/
|
||||
function moduleInstall() {
|
||||
// action forward에 등록 (관리자 모드에서 사용하기 위함)
|
||||
$oModuleController = &getController('module');
|
||||
$oModuleController->insertActionForward('trackback', 'controller', 'procTrackbackReceive');
|
||||
$oModuleController->insertActionForward('trackback', 'view', 'dispTrackbackAdminList');
|
||||
$oModuleController->insertActionForward('trackback', 'controller', 'procTrackbackAdminDeleteChecked');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 설치가 이상이 없는지 체크하는 method
|
||||
**/
|
||||
function moduleIsInstalled() {
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 업데이트 실행
|
||||
**/
|
||||
function moduleUpdate() {
|
||||
return new Object();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
217
modules/poll/poll.controller.php
Normal file
217
modules/poll/poll.controller.php
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
<?php
|
||||
/**
|
||||
* @class trackbackController
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief trackback모듈의 Controller class
|
||||
**/
|
||||
|
||||
class trackbackController extends trackback {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 관리자 페이지에서 선택된 엮인글들을 삭제
|
||||
**/
|
||||
function procTrackbackAdminDeleteChecked() {
|
||||
// 선택된 글이 없으면 오류 표시
|
||||
$cart = Context::get('cart');
|
||||
if(!$cart) return $this->stop('msg_cart_is_null');
|
||||
$trackback_srl_list= explode('|@|', $cart);
|
||||
$trackback_count = count($trackback_srl_list);
|
||||
if(!$trackback_count) return $this->stop('msg_cart_is_null');
|
||||
|
||||
// 글삭제
|
||||
for($i=0;$i<$trackback_count;$i++) {
|
||||
$trackback_srl = trim($trackback_srl_list[$i]);
|
||||
if(!$trackback_srl) continue;
|
||||
|
||||
$this->deleteTrackback($trackback_srl, true);
|
||||
}
|
||||
|
||||
$this->setMessage( sprintf(Context::getLang('msg_checked_trackback_is_deleted'), $trackback_count) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 엮인글 입력
|
||||
**/
|
||||
function procTrackbackReceive() {
|
||||
Context::setRequestMethod("XMLRPC");
|
||||
|
||||
$obj = Context::gets('document_srl','url','title','excerpt');
|
||||
|
||||
// GET으로 넘어온 document_srl을 참조, 없으면 오류~
|
||||
$document_srl = $obj->document_srl;
|
||||
if(!$document_srl) return $this->stop('fail');
|
||||
|
||||
// document model 객체 생성후 원본글을 가져옴
|
||||
$oDocumentModel = &getModel('document');
|
||||
$document = $oDocumentModel->getDocument($document_srl);
|
||||
|
||||
// 원본글이 없거나 트랙백 허용을 하지 않으면 오류 표시
|
||||
if(!$document_srl) return $this->stop('fail');
|
||||
if($document->allow_trackback=='N') return $this->stop('fail');
|
||||
|
||||
// 엮인글 정리
|
||||
$obj = Context::convertEncoding($obj);
|
||||
if(!$obj->blog_name) $obj->blog_name = $obj->title;
|
||||
$obj->excerpt = strip_tags($obj->excerpt);
|
||||
|
||||
// 엮인글를 입력
|
||||
$obj->list_order = $obj->trackback_srl = getNextSequence();
|
||||
$obj->module_srl = $document->module_srl;
|
||||
$output = executeQuery('trackback.insertTrackback', $obj);
|
||||
|
||||
// 입력에 이상이 없으면 해당 글의 엮인글 수를 올림
|
||||
if(!$output->toBool()) return $this->stop( 'fail');
|
||||
|
||||
// trackback model 객체 생성
|
||||
$oTrackbackModel = &getModel('trackback');
|
||||
|
||||
// 해당 글의 전체 엮인글 수를 구해옴
|
||||
$trackback_count = $oTrackbackModel->getTrackbackCount($document_srl);
|
||||
|
||||
// document controller 객체 생성
|
||||
$oDocumentController = &getController('document');
|
||||
|
||||
// 해당글의 엮인글 수를 업데이트
|
||||
$output = $oDocumentController->updateTrackbackCount($document_srl, $trackback_count);
|
||||
|
||||
// 결과 return
|
||||
if(!$output->toBool()) return $this->stop('fail');
|
||||
|
||||
$this->setMessage('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 단일 엮인글 삭제
|
||||
**/
|
||||
function deleteTrackback($trackback_srl, $is_admin = false) {
|
||||
// trackback model 객체 생성
|
||||
$oTrackbackModel = &getModel('trackback');
|
||||
|
||||
// 삭제하려는 엮인글이 있는지 확인
|
||||
$trackback = $oTrackbackModel->getTrackback($trackback_srl);
|
||||
if($trackback->data->trackback_srl != $trackback_srl) return new Object(-1, 'msg_invalid_request');
|
||||
$document_srl = $trackback->data->document_srl;
|
||||
|
||||
// document model 객체 생성
|
||||
$oDocumentModel = &getModel('document');
|
||||
|
||||
// 권한이 있는지 확인
|
||||
if(!$is_admin && !$oDocumentModel->isGranted($document_srl)) return new Object(-1, 'msg_not_permitted');
|
||||
|
||||
$args->trackback_srl = $trackback_srl;
|
||||
$output = executeQuery('trackback.deleteTrackback', $args);
|
||||
if(!$output->toBool()) return new Object(-1, 'msg_error_occured');
|
||||
|
||||
// 엮인글 수를 구해서 업데이트
|
||||
$trackback_count = $oTrackbackModel->getTrackbackCount($document_srl);
|
||||
|
||||
// document controller 객체 생성
|
||||
$oDocumentController = &getController('document','controller');
|
||||
|
||||
// 해당글의 엮인글 수를 업데이트
|
||||
$output = $oDocumentController->updateTrackbackCount($document_srl, $trackback_count);
|
||||
$output->add('document_srl', $document_srl);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 글에 속한 모든 트랙백 삭제
|
||||
**/
|
||||
function deleteTrackbacks($document_srl) {
|
||||
// 삭제
|
||||
$args->document_srl = $document_srl;
|
||||
$output = executeQuery('trackback.deleteTrackbacks', $args);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모듈에 속한 모든 트랙백 삭제
|
||||
**/
|
||||
function deleteModuleTrackbacks($module_srl) {
|
||||
// 삭제
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQuery('trackback.deleteModuleTrackbacks', $args);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 엮인글을 발송
|
||||
*
|
||||
* 발송 후 결과처리는 하지 않는 구조임
|
||||
**/
|
||||
function sendTrackback($document, $trackback_url, $charset) {
|
||||
// 발송할 정보를 정리
|
||||
$http = parse_url($trackback_url);
|
||||
$obj->blog_name = Context::getBrowserTitle();
|
||||
$obj->title = $document->title;
|
||||
$obj->excerpt = cut_str($document->content, 240);
|
||||
$obj->url = sprintf("%s?document_srl=%d", Context::getRequestUri(), $document->document_srl);
|
||||
|
||||
// blog_name, title, excerpt, url의 문자열을 요청된 charset으로 변경
|
||||
if($charset && function_exists('iconv')) {
|
||||
foreach($obj as $key=>$val) {
|
||||
$obj->{$key} = iconv('UTF-8',$charset,$val);
|
||||
}
|
||||
}
|
||||
|
||||
// socket으로 발송할 내용 작성
|
||||
if($http['query']) $http['query'].="&";
|
||||
if(!$http['port']) $http['port'] = 80;
|
||||
|
||||
$content =
|
||||
sprintf(
|
||||
"title=%s&".
|
||||
"url=%s&".
|
||||
"blog_name=%s&".
|
||||
"excerpt=%s",
|
||||
urlencode($obj->title),
|
||||
urlencode($obj->url),
|
||||
urlencode($obj->blog_name),
|
||||
urlencode($obj->excerpt)
|
||||
);
|
||||
if($http['query']) $content .= '&'.$http['query'];
|
||||
$content_length = strlen($content);
|
||||
|
||||
// header 정리
|
||||
$header =
|
||||
sprintf(
|
||||
"POST %s HTTP/1.1\r\n".
|
||||
"Host: %s\r\n".
|
||||
"Content-Type: %s\r\n".
|
||||
"Content-Length: %s\r\n\r\n".
|
||||
"%s\r\n",
|
||||
$http['path'],
|
||||
$http['host'],
|
||||
"application/x-www-form-urlencoded",
|
||||
$content_length,
|
||||
$content
|
||||
);
|
||||
if(!$http['host']||!$http['port']) return;
|
||||
|
||||
// 발송하려는 대상 서버의 socket을 연다
|
||||
$fp = @fsockopen($http['host'], $http['port'], $errno, $errstr, 5);
|
||||
if(!$fp) return;
|
||||
|
||||
// 작성한 헤더 정보를 발송
|
||||
fputs($fp, $header);
|
||||
|
||||
// 결과를 기다림 (특정 서버의 경우 EOF가 떨어지지 않을 수가 있음
|
||||
while(!feof($fp)) {
|
||||
$line = trim(fgets($fp, 4096));
|
||||
if(eregi("^<error>",$line)) break;
|
||||
}
|
||||
|
||||
// socket 닫음
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
?>
|
||||
116
modules/poll/poll.model.php
Normal file
116
modules/poll/poll.model.php
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
/**
|
||||
* @class trackbackModel
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief trackback 모듈의 model class
|
||||
**/
|
||||
|
||||
class trackbackModel extends trackback {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 하나의 트랙백 정보를 구함
|
||||
**/
|
||||
function getTrackback($trackback_srl) {
|
||||
$args->trackback_srl = $trackback_srl;
|
||||
return executeQuery('trackback.getTrackback', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief document_srl 에 해당하는 엮인글의 전체 갯수를 가져옴
|
||||
**/
|
||||
function getTrackbackCount($document_srl) {
|
||||
$args->document_srl = $document_srl;
|
||||
$output = executeQuery('trackback.getTrackbackCount', $args);
|
||||
$total_count = $output->data->count;
|
||||
|
||||
return (int)$total_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 document에 특정 ip로 기록된 트랙백의 갯수
|
||||
* spamfilter 에서 사용할 method임
|
||||
**/
|
||||
function getTrackbackCountByIPAddress($document_srl, $ipaddress) {
|
||||
$args->document_srl = $document_srl;
|
||||
$args->ipaddress = $ipaddress;
|
||||
$output = executeQuery('trackback.getTrackbackCountByIPAddress', $args);
|
||||
$total_count = $output->data->count;
|
||||
|
||||
return (int)$total_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 문서에 속한 엮인글의 목록을 가져옴
|
||||
**/
|
||||
function getTrackbackList($document_srl) {
|
||||
$args->document_srl = $document_srl;
|
||||
$args->list_order = 'list_order';
|
||||
$output = executeQuery('trackback.getTrackbackList', $args);
|
||||
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
$trackback_list = $output->data;
|
||||
|
||||
if(!is_array($trackback_list)) $trackback_list = array($trackback_list);
|
||||
|
||||
return $trackback_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 모든 엮인글를 시간 역순으로 가져옴 (관리자용)
|
||||
**/
|
||||
function getTotalTrackbackList($obj) {
|
||||
// 검색 옵션 정리
|
||||
$search_target = trim(Context::get('search_target'));
|
||||
$search_keyword = trim(Context::get('search_keyword'));
|
||||
|
||||
if($search_target && $search_keyword) {
|
||||
switch($search_target) {
|
||||
case 'url' :
|
||||
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
|
||||
$args->s_url = $search_keyword;
|
||||
break;
|
||||
case 'title' :
|
||||
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
|
||||
$args->s_title= $search_keyword;
|
||||
break;
|
||||
case 'blog_name' :
|
||||
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
|
||||
$args->s_blog_name= $search_keyword;
|
||||
break;
|
||||
case 'excerpt' :
|
||||
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
|
||||
$args->s_excerpt = $search_keyword;
|
||||
break;
|
||||
case 'regdate' :
|
||||
$args->s_regdate = $search_keyword;
|
||||
break;
|
||||
case 'ipaddress' :
|
||||
$args->s_ipaddress= $search_keyword;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 변수 설정
|
||||
$args->sort_index = $obj->sort_index;
|
||||
$args->page = $obj->page?$obj->page:1;
|
||||
$args->list_count = $obj->list_count?$obj->list_count:20;
|
||||
$args->page_count = $obj->page_count?$obj->page_count:10;
|
||||
|
||||
// trackback.getTotalTrackbackList 쿼리 실행
|
||||
$output = executeQuery('trackback.getTotalTrackbackList', $args);
|
||||
|
||||
// 결과가 없거나 오류 발생시 그냥 return
|
||||
if(!$output->toBool()||!count($output->data)) return $output;
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
8
modules/poll/schemas/poll.xml
Normal file
8
modules/poll/schemas/poll.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<table name="poll">
|
||||
<column name="poll_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="member_srl" type="number" size="11" notnull="notnull" index="idx_member_srl" />
|
||||
<column name="ipaddress" type="varchar" size="128" notnull="notnull" index="idx_ipaddress" />
|
||||
<column name="stop_date" type="date" index="idx_regdate" />
|
||||
<column name="regdate" type="date" index="idx_regdate" />
|
||||
<column name="list_order" type="number" size="11" notnull="notnull" index="idx_list_order" />
|
||||
</table>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<table name="trackbacks">
|
||||
<column name="trackback_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="module_srl" type="number" size="11" default="0" notnull="notnull" index="idx_module_srl" />
|
||||
<column name="document_srl" type="number" size="11" default="0" notnull="notnull" index="idx_document_srl" />
|
||||
<column name="url" type="varchar" size="250" notnull="notnull" />
|
||||
<column name="title" type="varchar" size="250" notnull="notnull" />
|
||||
<column name="blog_name" type="varchar" size="250" notnull="notnull" />
|
||||
<column name="excerpt" type="text" notnull="notnull" />
|
||||
<column name="regdate" type="date" index="idx_regdate" />
|
||||
<column name="ipaddress" type="varchar" size="128" notnull="notnull" index="idx_ipaddress" />
|
||||
<column name="list_order" type="number" size="11" notnull="notnull" index="idx_list_order" />
|
||||
</table>
|
||||
Loading…
Add table
Add a link
Reference in a new issue