#18312526 처리.(referer 모듈이 XE Core에 없으나 Core 외 프로젝트로도 보이지 않아서 이쪽으로 커밋합니다.)

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6791 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ysnglee2000 2009-09-17 20:29:46 +00:00
parent 9e510a9601
commit 6a7f82bfaf
29 changed files with 531 additions and 0 deletions

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="0.2">
<title xml:lang="ko">리퍼러 통계</title>
<title xml:lang="jp">リファラー統計</title>
<title xml:lang="zh-CN">反向链接</title>
<title xml:lang="en">Referer Statistics</title>
<title xml:lang="ru">Статистика рефералов</title>
<title xml:lang="zh-TW">反向連結統計</title>
<description xml:lang="ko">기본 리퍼러 통계 프로그램입니다.</description>
<description xml:lang="jp">デフォルトのリファラー統計プログラムです。</description>
<description xml:lang="zh-CN">反向链接统计模块。</description>
<description xml:lang="en">Basic referer statistics program.</description>
<description xml:lang="ru">Базовая программа статистики рефералов.</description>
<description xml:lang="zh-TW">反向連結統計模組。</description>
<version>0.15</version>
<date>2007-11-29</date>
<category>statistics</category>
<author email_address="haneul0318@gmail.com" link="http://seungyeop.kr">
<name xml:lang="ko">haneul</name>
<name xml:lang="jp">haneul</name>
<name xml:lang="zh-CN">haneul</name>
<name xml:lang="en">haneul</name>
<name xml:lang="ru">haneul</name>
<name xml:lang="zh-TW">haneul</name>
</author>
</module>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<module>
<grants />
<permissions />
<actions>
<action name="procRefererExecute" type="controller" standalone="true" />
<action name="dispRefererAdminIndex" type="view" standalone="true" admin_index="true" />
<action name="dispRefererAdminDeleteStat" type="view" standalone="true" />
<action name="procRefererAdminDeleteStat" type="controller" standalone="true" />
</actions>
</module>

View file

@ -0,0 +1,10 @@
<?php
/**
* @file module/referer/lang/ko.lang.php
* @author haneul <haneul0318@gmail.com>
* @brief English language pack
*/
$lang->referer = "Referer";
$lang->ranking = "Ranking";
?>

View file

@ -0,0 +1,10 @@
<?php
/**
* @file module/referer/lang/ko.lang.php
* @author haneul <haneul0318@gmail.com>
* @brief English language pack
*/
$lang->referer = "Referer";
$lang->ranking = "Ranking";
?>

View file

@ -0,0 +1,10 @@
<?php
/**
* @file module/referer/lang/fr.lang.php
* @author haneul <haneul0318@gmail.com> Traduit par Pierre Duvent <PierreDuvent@gmail.com>
* @brief Paquet du langage en français pour le Module de référeur
*/
$lang->referer = "Référeur";
$lang->ranking = "Rang";
?>

View file

@ -0,0 +1,10 @@
<?php
/**
* @file module/referer/lang/jp.lang.php
* @author haneul <haneul0318@gmail.com>
* @brief 日本語言語パッケージ 翻訳RisaPapa
*/
$lang->referer = 'レファラー';
$lang->ranking = '順位';
?>

View file

@ -0,0 +1,10 @@
<?php
/**
* @file module/referer/lang/ko.lang.php
* @author haneul <haneul0318@gmail.com>
* @brief Korean language pack
*/
$lang->referer = '리퍼러';
$lang->ranking = '순위';
?>

View file

@ -0,0 +1,10 @@
<?php
/**
* @file ru.lang.php
* @author zero <zero@nzeo.com> | translation by Maslennikov Evgeny aka X-[Vr]bL1s5 | e-mail: x-bliss[a]tut.by; ICQ: 225035467;
* @brief Russian basic language pack
**/
$lang->referer = "Реферал";
$lang->ranking = "Рейтинг";
?>

View file

@ -0,0 +1,10 @@
<?php
/**
* @file module/referer/lang/zh-CN.lang.php
* @author haneul <haneul0318@gmail.com>
* @brief Korean language pack
*/
$lang->referer = "用户来源";
$lang->ranking = "排名";
?>

View file

@ -0,0 +1,10 @@
<?php
/**
* @file module/referer/lang/zh-TW.lang.php
* @author haneul <haneul0318@gmail.com> 翻譯royallin
* @brief 反向連結(referer)模組正體中文語言
**/
$lang->referer = "用戶來源";
$lang->ranking = "排名";
?>

View file

@ -0,0 +1,8 @@
<query id="deleteOlddatedLogs" action="delete">
<tables>
<table name="referer_log" />
</tables>
<conditions>
<condition operation="less" column="regdate" var="regdate" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,8 @@
<query id="deleteRefererStat" action="delete">
<tables>
<table name="referer_statistics" />
</tables>
<conditions>
<condition operation="equal" column="host" var="host" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,11 @@
<query id="getHostStatus" action="select">
<tables>
<table name="referer_statistics" />
</tables>
<columns>
<column name="count(*)" alias="count"/>
</columns>
<conditions>
<condition operation="equal" column="host" var="host" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,16 @@
<query id="getRefererLogList" action="select">
<tables>
<table name="referer_log" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
</conditions>
<navigation>
<index var="sort_index" default="regdate" order="desc" />
<list_count var="list_count" default="20" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
</query>

View file

@ -0,0 +1,17 @@
<query id="getRefererStatistics" action="select">
<tables>
<table name="referer_statistics" />
</tables>
<columns>
<column name="host" />
<column name="count" alias="cnt" />
</columns>
<conditions>
</conditions>
<navigation>
<index var="sort_index" default="cnt" order="desc" />
<list_count var="list_count" default="20" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
</query>

View file

@ -0,0 +1,10 @@
<query id="insertRefererLog" action="insert">
<tables>
<table name="referer_log" />
</tables>
<columns>
<column name="regdate" var="regdate" default="curdate()" notnull="notnull"/>
<column name="host" var="host" notnull="notnull" />
<column name="url" var="url" />
</columns>
</query>

View file

@ -0,0 +1,9 @@
<query id="insertRefererStatistics" action="insert">
<tables>
<table name="referer_statistics" />
</tables>
<columns>
<column name="host" var="host" notnull="notnull" />
<column name="count" var="count" default="1" />
</columns>
</query>

View file

@ -0,0 +1,11 @@
<query id="updateRefererStatistics" action="update">
<tables>
<table name="referer_statistics" />
</tables>
<columns>
<column name="count" var="count" default="plus(1)" />
</columns>
<conditions>
<condition operation="equal" column="host" var="host" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,25 @@
<?php
/**
* @class refererAdminController
* @author haneul (haneul0318@gmail.com)
* @brief referer 모듈의 admin controller class
**/
class refererAdminController extends referer {
/**
* @brief 초기화
**/
function init() {
}
function procRefererAdminDeleteStat() {
$args->host = Context::get('host');
$output = executeQuery('referer.deleteRefererStat', $args);
if(!$output->toBool()) return $output;
$this->setMessage('success_deleted');
}
}
?>

View file

@ -0,0 +1,57 @@
<?php
/**
* @class refererAdminView
* @author haneul (haneul0318@gmail.com)
* @brief referer 모듈의 Admin view class
**/
class refererAdminView extends referer {
/**
* @brief 초기화
**/
function init() {
// 템플릿 경로 지정
$this->setTemplatePath($this->module_path.'tpl');
}
/**
* @brief 관리자 페이지 초기화면
**/
function dispRefererAdminIndex() {
$this->dispRefererAdminList();
}
function dispRefererAdminDeleteStat () {
if(!Context::get('host')) return $this->dispRefererAdminIndex();
$this->setTemplateFile('delete_stat');
}
function dispRefererAdminList() {
// 목록을 구하기 위한 옵션
$args->page = Context::get('page'); ///< 페이지
$args->sort_index = 'regdate'; ///< 소팅 값
$oRefererModel = &getModel('referer');
$output = $oRefererModel->getLogList($args);
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('referer_list', $output->data);
Context::set('page_navigation', $output->page_navigation);
$args2->sort_index = 'cnt';
$output2 = $oRefererModel->getRefererStatus($args2);
Context::set('referer_status', $output2->data);
// 템플릿 지정
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('referer_list');
}
}
?>

View file

@ -0,0 +1,37 @@
<?php
/**
* @class referer
* @author haneul (haneul0318@gmail.com)
* @brief referer module's class
**/
class referer extends ModuleObject {
/**
* @brief Install referer module
**/
function moduleInstall() {
return new Object();
}
/**
* @brief 설치가 이상이 없는지 체크하는 method
**/
function checkUpdate() {
return false;
}
/**
* @brief 업데이트 실행
**/
function moduleUpdate() {
return new Object(0, 'success_updated');
}
/**
* @brief 캐시 파일 재생성
**/
function recompileCache() {
}
}
?>

View file

@ -0,0 +1,60 @@
<?php
/**
* @class refererController
* @author haneul (haneul0318@gmail.com)
* @brief referer 모듈의 controller class
**/
class refererController extends referer {
/**
* @brief initialization
**/
function init() {
}
function procRefererExecute() {
if(empty($_SERVER["HTTP_REFERER"])) return;
// Log only from different hosts
$referer = parse_url($_SERVER["HTTP_REFERER"]);
if($referer['host'] == $_SERVER['HTTP_HOST']) return;
$oDB = &DB::getInstance();
$oDB -> begin();
$this->insertRefererLog($referer['host'], removeHackTag($_SERVER["HTTP_REFERER"]));
$this->deleteOlddatedRefererLogs();
$this->updateRefererStatistics($referer['host']);
$oDB -> commit();
}
function updateRefererStatistics($host)
{
$oRefererModel = &getModel('referer');
$args->host = $host;
if($oRefererModel->isInsertedHost($host))
{
$output = executeQuery('referer.updateRefererStatistics', $args);
}
else
{
$output = executeQuery('referer.insertRefererStatistics', $args);
}
return $output;
}
function insertRefererLog($host, $url)
{
$args->regdate = date("YmdHis");
$args->host = $host;
$args->url = $url;
return executeQuery('referer.insertRefererLog', $args);
}
function deleteOlddatedRefererLogs()
{
$args->regdate = date("YmdHis", strtotime("-1 week"));
return executeQuery('referer.deleteOlddatedLogs', $args);
}
}
?>

View file

@ -0,0 +1,41 @@
<?php
/**
* @class refererModel
* @author haneul (haneul0318@gmail.com)
* @brief referer 모듈의 Model class
**/
class refererModel extends referer {
function init() {
}
function isInsertedHost($host) {
$args->host = $host;
$output = executeQuery('referer.getHostStatus', $args);
return $output->data->count?true:false;
}
function getLogList($obj) {
$query_id = 'referer.getRefererLogList';
$args->sort_index = 'regdate';
$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;
$output = executeQuery($query_id, $args);
// 결과가 없거나 오류 발생시 그냥 return
if(!$output->toBool()||!count($output->data)) return $output;
return $output;
}
function getRefererStatus() {
$args->sort_index = 'cnt';
return executeQuery("referer.getRefererStatistics", $args);
}
}
?>

View file

@ -0,0 +1,5 @@
<table name="referer_log">
<column name="host" type="varchar" size="64" notnull="notnull" />
<column name="url" type="varchar" size="250" notnull="notnull" />
<column name="regdate" type="date" index="idx_referer_log" />
</table>

View file

@ -0,0 +1,4 @@
<table name="referer_statistics">
<column name="host" type="varchar" size="64" notnull="notnull" primary_key="primary_key" />
<column name="count" type="number" size="11" default="0" index="idx_referer_counter" />
</table>

View file

@ -0,0 +1,23 @@
<!--%import("filter/delete_stat.xml")-->
<!--%import("js/referer_admin.js")-->
<!--%import("css/referer.css")-->
<h3 class="xeAdmin">{$lang->referer} <span class="gray">{$lang->cmd_management}</span></h3>
<form action="./" method="get" onsubmit="return procFilter(this, delete_stat)">
<input type="hidden" name="host" value="{$host}" />
<table cellspacing="0" class="adminTable topGap">
<caption>{$lang->confirm_delete}</caption>
<tr>
<th scope="row"><div>Host Name</div></th>
<td>{$host}</td>
</tr>
<tr>
<td colspan="2" class="right">
<a href="{getUrl('act','dispRefererAdminIndex')}" class="button"><span>{$lang->cmd_back}</span></a>
<span class="button"><input type="submit" value="{$lang->cmd_delete}" /></span>
</td>
</tr>
</table>
</form>

View file

@ -0,0 +1,10 @@
<filter name="delete_stat" module="referer" act="procRefererAdminDeleteStat">
<form>
<node target="host" required="true" />
</form>
<response callback_func="completeDeleteStat">
<tag name="error" />
<tag name="message" />
<tag name="page" />
</response>
</filter>

View file

@ -0,0 +1,16 @@
/**
* @file modules/referer/js/referer_admin.js
* @author haneul
* @brief referer 모듈의 관리자용 javascript
**/
/* stat 삭제 후 */
function completeDeleteStat(ret_obj) {
var error = ret_obj['error'];
var message = ret_obj['message'];
var page = ret_obj['page'];
alert(message);
var url = current_url.setQuery('act','dispRefererAdminIndex').setQuery('host','');
location.href = url;
}

View file

@ -0,0 +1,45 @@
<!--%import("css/referer.css")-->
<h3 class="xeAdmin">{$lang->referer} <span class="gray">{$lang->cmd_management}</span></h3>
<table cellspacing="0" class="rowTable ">
<caption>Total {number_format($total_count)} Page {number_format($page)}/{number_format($total_page)}</caption>
<tbody>
<!--@foreach($referer_list as $no => $val)-->
<tr class="row{$cycle_idx}">
<td class="tahoma">{zdate($val->regdate,"Y-m-d")}</td>
<td class="tahoma">{$val->host}</td>
<td class="tahoma refererUrl"><a href="{$val->url}">{$val->url}</a></td>
</tr>
<!--@end-->
</tbody>
</table>
<!-- 페이지 네비게이션 -->
<div class="pagination a1">
<a href="{getUrl('page','','module_srl','')}" class="prevEnd">{$lang->first_page}</a>
<!--@while($page_no = $page_navigation->getNextPage())-->
<!--@if($page == $page_no)-->
<strong>{$page_no}</strong>
<!--@else-->
<a href="{getUrl('page',$page_no,'module_srl','')}">{$page_no}</a>
<!--@end-->
<!--@end-->
<a href="{getUrl('page',$page_navigation->last_page,'module_srl','')}" class="nextEnd">{$lang->last_page}</a>
</div>
<h4 class="xeAdmin">{$lang->ranking}</h4>
<table cellspacing="0" class="rowTable">
<tbody>
<!--{$rank = 1}-->
<!--@foreach($referer_status as $no => $val)-->
<tr class="row{$cycle_idx}">
<td class="number center">{$rank} </td>
<td class="wide">{$val->host}</td>
<td class="number center">{$val->count}</td>
<td class="delete center"><a href="{getUrl('act','dispRefererAdminDeleteStat','host',$val->host)}" title="{$lang->cmd_delete}" class="buttonSet buttonDelete"><span>{$lang->cmd_delete}</span></a></td>
</tr>
<!--{$rank += 1} -->
<!--@end-->
</tbody>
</table>