git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2327 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-08-12 03:59:52 +00:00
commit 8326004cb2
2773 changed files with 91485 additions and 0 deletions

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<module version="0.1">
<title xml:lang="ko">기본 카운터</title>
<title xml:lang="zh-CN">访问统计</title>
<title xml:lang="en">Basic Counter</title>
<title xml:lang="es">Taquilla Basico</title>
<title xml:lang="jp">接続カウンター</title>
<author email_address="zero@zeroboard.com" link="http://www.zeroboard.com" date="2007. 2. 28">
<name xml:lang="ko">제로</name>
<name xml:lang="zh-CN">zero</name>
<name xml:lang="en">Zero</name>
<name xml:lang="es">zero</name>
<name xml:lang="jp">Zero</name>
<description xml:lang="ko">기본 접속 통계 프로그램입니다.</description>
<description xml:lang="zh-CN">默认访问统计程序。</description>
<description xml:lang="en">Basic connection statistics program.</description>
<description xml:lang="es">Es la programa basica para conecciónes estaticos.</description>
<description xml:lang="jp">接続統計のプログラムです。</description>
</author>
</module>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<module>
<grants />
<actions>
<action name="dispCounterAdminIndex" type="view" standalone="true" admin_index="true" />
<action name="procCounterExecute" type="controller" standalone="true" />
</actions>
</module>

View file

@ -0,0 +1,46 @@
<?php
/**
* @class counterAdminView
* @author zero (zero@nzeo.com)
* @brief counter 모듈의 Admin view class
**/
class counterAdminView extends counter {
/**
* @brief 초기화
**/
function init() {
// 템플릿 경로 지정
$this->setTemplatePath($this->module_path.'tpl');
}
/**
* @brief 관리자 페이지 초기화면
**/
function dispCounterAdminIndex() {
// 정해진 일자가 없으면 오늘자로 설정
$selected_date = Context::get('selected_date');
if(!$selected_date) $selected_date = date("Ymd");
Context::set('selected_date', $selected_date);
// counter model 객체 생성
$oCounterModel = &getModel('counter');
// 전체 카운터 및 지정된 일자의 현황 가져오기
$status = $oCounterModel->getStatus(array(0,$selected_date));
Context::set('total_counter', $status[0]);
Context::set('selected_day_counter', $status[$selected_date]);
// 시간, 일, 월, 년도별로 데이터 가져오기
$type = Context::get('type');
if(!$type) $type = 'hour';
$detail_status = $oCounterModel->getHourlyStatus($type, $selected_date);
Context::set('detail_status', $detail_status);
// 표시
$this->setTemplateFile('index');
}
}
?>

View file

@ -0,0 +1,44 @@
<?php
/**
* @class counter
* @author zero (zero@nzeo.com)
* @brief counter 모듈의 high class
**/
class counter extends ModuleObject {
/**
* @brief 설치시 추가 작업이 필요할시 구현
**/
function moduleInstall() {
// action forward에 등록 (관리자 모드에서 사용하기 위함)
$oModuleController = &getController('module');
$oModuleController->insertActionForward('counter', 'view', 'dispCounterAdminIndex');
$oCounterController = &getController('counter');
// 0 일자로 기록될 전체 방문 기록 row 추가
$oCounterController->insertTotalStatus();
// 오늘자 row입력
$oCounterController->insertTodayStatus();
return new Object();
}
/**
* @brief 설치가 이상이 없는지 체크하는 method
**/
function checkUpdate() {
return false;
}
/**
* @brief 업데이트 실행
**/
function moduleUpdate() {
return new Object();
}
}
?>

View file

@ -0,0 +1,100 @@
<?php
/**
* @class counterController
* @author zero (zero@nzeo.com)
* @brief counter 모듈의 controller class
**/
class counterController extends counter {
/**
* @brief 초기화
**/
function init() {
}
/**
* @brief 카운터 기록
**/
function procCounterExecute() {
$oDB = &DB::getInstance();
$oDB->begin();
// 로그를 검사
$oCounterModel = &getModel('counter');
// 오늘자 row가 있는지 체크하여 없으면 등록
if(!$oCounterModel->isInsertedTodayStatus()) {
$this->insertTodayStatus();
// 기존 row가 있으면 사용자 체크
} else {
// 등록되어 있지 않은 아이피일 경우
if(!$oCounterModel->isLogged()) {
// 로그 등록
$this->insertLog();
// unique 및 pageview 등록
$this->insertUniqueVisitor();
} else {
// pageview 등록
$this->insertPageView();
}
}
$oDB->commit();
}
/**
* @brief 로그 등록
**/
function insertLog() {
$args->regdate = date("YmdHis");
$args->user_agent = $_SERVER['HTTP_USER_AGENT'];
return executeQuery('counter.insertCounterLog', $args);
}
/**
* @brief unique visitor 등록
**/
function insertUniqueVisitor() {
$args->regdate = date("Ymd");
executeQuery('counter.updateCounterUnique', $args);
executeQuery('counter.updateTotalCounterUnique');
}
/**
* @brief pageview 등록
**/
function insertPageView() {
$args->regdate = date("Ymd");
executeQuery('counter.updateCounterPageview', $args);
executeQuery('counter.updateTotalCounterPageview');
}
/**
* @brief 전체 카운터 status 추가
**/
function insertTotalStatus() {
$args->regdate = 0;
executeQuery('counter.insertTodayStatus', $args);
}
/**
* @brief 오늘자 카운터 status 추가
**/
function insertTodayStatus($regdate = 0) {
if($regdate) $args->regdate = $regdate;
else $args->regdate = date("Ymd");
executeQuery('counter.insertTodayStatus', $args);
// 로그 등록
$this->insertLog();
// unique 및 pageview 등록
$this->insertUniqueVisitor();
}
}
?>

View file

@ -0,0 +1,132 @@
<?php
/**
* @class counterModel
* @author zero (zero@nzeo.com)
* @brief counter 모듈의 Model class
**/
class counterModel extends counter {
/**
* @brief 초기화
**/
function init() {
}
/**
* @brief 로그 검사
**/
function isLogged() {
$args->regdate = date("Ymd");
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
$output = executeQuery('counter.getCounterLog', $args);
return $output->data->count?true:false;
}
/**
* @brief 오늘자 카운터 현황 row 있는지 체크
**/
function isInsertedTodayStatus() {
$args->regdate = date("Ymd");
$output = executeQuery('counter.getTodayStatus', $args);
return $output->data->count?true:false;
}
/**
* @brief 특정 일의 접속 통계를 가져옴
**/
function getStatus($selected_date) {
// 여러개의 날짜 로그를 가져올 경우
if(is_array($selected_date)) {
$date_count = count($selected_date);
$args->regdate = implode(',',$selected_date);
// 단일 날짜의 로그를 가져올 경우
} else {
if(strlen($selected_date)==8) $selected_date = $selected_date;
$args->regdate = $selected_date;
}
$output = executeQuery('counter.getCounterStatus', $args);
$status = $output->data;
if(!is_array($selected_date)) return $status;
if(!is_array($status)) $status = array($status);
unset($output);
foreach($status as $key => $val) {
$output[substr($val->regdate,0,8)] = $val;
}
return $output;
}
/**
* @brief 지정된 일자의 시간대별 로그 가져오기
**/
function getHourlyStatus($type='hour', $selected_date) {
$max = 0;
$sum = 0;
switch($type) {
case 'year' :
// 카운터 시작일 구함
$output = executeQuery('counter.getStartLogDate');
$start_year = substr($output->data->regdate,0,4);
if(!$start_year) $start_year = date("Y");
for($i=$start_year;$i<=date("Y");$i++) {
unset($args);
$args->regdate = sprintf('%04d', $i);
$output = executeQuery('counter.getCounterLog', $args);
$count = (int)$output->data->count;
$status->list[$i] = $count;
if($count>$max) $max = $count;
$sum += $count;
}
break;
break;
case 'month' :
$year = substr($selected_date, 0, 4);
for($i=1;$i<=12;$i++) {
unset($args);
$args->regdate = sprintf('%04d%02d', $year, $i);
$output = executeQuery('counter.getCounterLog', $args);
$count = (int)$output->data->count;
$status->list[$i] = $count;
if($count>$max) $max = $count;
$sum += $count;
}
break;
case 'day' :
$year = substr($selected_date, 0, 4);
$month = substr($selected_date, 4, 2);
$end_day = date('t', mktime(0,0,0,$month,1,$year));
for($i=1;$i<=$end_day;$i++) {
unset($args);
$args->regdate = sprintf('%04d%02d%02d', $year, $month, $i);
$output = executeQuery('counter.getCounterLog', $args);
$count = (int)$output->data->count;
$status->list[$i] = $count;
if($count>$max) $max = $count;
$sum += $count;
}
break;
default :
for($i=0;$i<24;$i++) {
unset($args);
$args->regdate = sprintf('%08d%02d', $selected_date, $i);
$output = executeQuery('counter.getCounterLog', $args);
$count = (int)$output->data->count;
$status->list[$i] = $count;
if($count>$max) $max = $count;
$sum += $count;
}
break;
}
$status->max = $max;
$status->sum = $sum;
return $status;
}
}
?>

View file

@ -0,0 +1,22 @@
<?php
/**
* @file modules/counter/lang/en.lang.php
* @author zero <zero@nzeo.com>
* @brief English Language Pack (Only basic contents are listed)
**/
$lang->counter = "Counter";
$lang->cmd_select_date = 'Select date';
$lang->cmd_select_counter_type = array(
'hour' => 'By hour',
'day' => 'By day',
'month' => 'By month',
'year' => 'By year',
);
$lang->total_counter = 'Total status';
$lang->selected_day_counter = 'Selected day status';
$lang->unique_visitor = 'Visitor';
$lang->pageview = 'Pageview';
?>

View file

@ -0,0 +1,22 @@
<?php
/**
* @file modules/counter/lang/es.lang.php
* @author zero <zero@nzeo.com>
* @brief Paquete lingual de taquilla
**/
$lang->counter = "Taquilla";
$lang->cmd_select_date = 'Seleccióna Fecha';
$lang->cmd_select_counter_type = array(
'hour' => 'horas',
'day' => 'dias',
'month' => 'mes',
'year' => 'año',
);
$lang->total_counter = 'Visitantes en total';
$lang->selected_day_counter = 'Visitantes en diario';
$lang->unique_visitor = 'Visitas unicos';
$lang->pageview = 'Páginas/visita';
?>

View file

@ -0,0 +1,22 @@
<?php
/**
* @file modules/counter/lang/ko.lang.php
* @author zero <zero@nzeo.com> 翻訳RisaPapa
* @brief 日本語言語パッケージ(基本的な内容のみ)
**/
$lang->counter = "カウンター";
$lang->cmd_select_date = '年月日選択';
$lang->cmd_select_counter_type = array(
'hour' => '時間帯別',
'day' => '日別',
'month' => '月別',
'year' => '年度別',
);
$lang->total_counter = 'トータル';
$lang->selected_day_counter = '選択日の情報';
$lang->unique_visitor = '訪問者';
$lang->pageview = 'ページビュー';
?>

View file

@ -0,0 +1,22 @@
<?php
/**
* @file modules/counter/lang/ko.lang.php
* @author zero <zero@nzeo.com>
* @brief 한국어 언어팩 (기본적인 내용만 수록)
**/
$lang->counter = "카운터";
$lang->cmd_select_date = '날짜 선택';
$lang->cmd_select_counter_type = array(
'hour' => '시간대별',
'day' => '일별',
'month' => '월별',
'year' => '년도별',
);
$lang->total_counter = '전체현황';
$lang->selected_day_counter = '선택일 현황';
$lang->unique_visitor = '방문자';
$lang->pageview = '페이지뷰';
?>

View file

@ -0,0 +1,22 @@
<?php
/**
* @file modules/counter/lang/zh-CN.lang.php
* @author zero <zero@nzeo.com>
* @brief 简体中文语言包
**/
$lang->counter = "访问统计";
$lang->cmd_select_date = '选择日期';
$lang->cmd_select_counter_type = array(
'hour' => '按时',
'day' => '按天',
'month' => '按月',
'year' => '按年度',
);
$lang->total_counter = '总揽';
$lang->selected_day_counter = '指定日概况';
$lang->unique_visitor = '访问者';
$lang->pageview = '页面浏览';
?>

View file

@ -0,0 +1,12 @@
<query id="getCounterLog" action="select">
<tables>
<table name="counter_log" />
</tables>
<columns>
<column name="count(*)" alias="count"/>
</columns>
<conditions>
<condition operation="equal" column="ipaddress" var="ipaddress" />
<condition operation="like_prefix" column="regdate" var="regdate" notnull="notnull" pipe="and" />
</conditions>
</query>

View file

@ -0,0 +1,11 @@
<query id="getCounterStatus" action="select">
<tables>
<table name="counter_status" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="in" column="regdate" var="regdate" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,11 @@
<query id="getStartLogDate" action="select">
<tables>
<table name="counter_status" />
</tables>
<columns>
<column name="min(regdate)" alias="regdate" />
</columns>
<conditions>
<condition operation="excess" column="regdate" default="1" notnull="notnull" />
</conditions>
</query>

View file

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

View file

@ -0,0 +1,10 @@
<query id="insertCounterLog" action="insert">
<tables>
<table name="counter_log" />
</tables>
<columns>
<column name="regdate" var="regdate" default="curdate()" notnull="notnull"/>
<column name="ipaddress" var="ipaddress" notnull="notnull" default="ipaddress()" />
<column name="user_agent" var="user_agent" />
</columns>
</query>

View file

@ -0,0 +1,10 @@
<query id="insertTodayStatus" action="insert">
<tables>
<table name="counter_status" />
</tables>
<columns>
<column name="regdate" var="regdate" notnull="notnull" />
<column name="unique_visitor" default="0" />
<column name="pageview" default="0" />
</columns>
</query>

View file

@ -0,0 +1,11 @@
<query id="updateCounterPageview" action="update">
<tables>
<table name="counter_status" />
</tables>
<columns>
<column name="pageview" default="plus(1)" />
</columns>
<conditions>
<condition operation="equal" column="regdate" var="regdate" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,12 @@
<query id="updateCounterUnique" action="update">
<tables>
<table name="counter_status" />
</tables>
<columns>
<column name="unique_visitor" default="plus(1)" />
<column name="pageview" default="plus(1)" />
</columns>
<conditions>
<condition operation="equal" column="regdate" var="regdate" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,11 @@
<query id="updateTotalCounterPageview" action="update">
<tables>
<table name="counter_status" />
</tables>
<columns>
<column name="pageview" default="plus(1)" />
</columns>
<conditions>
<condition operation="equal" column="regdate" default="00000000" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,12 @@
<query id="updateTotalCounterUnique" action="update">
<tables>
<table name="counter_status" />
</tables>
<columns>
<column name="unique_visitor" default="plus(1)" />
<column name="pageview" default="plus(1)" />
</columns>
<conditions>
<condition operation="in" column="regdate" default="00000000" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,5 @@
<table name="counter_log">
<column name="ipaddress" type="varchar" size="250" notnull="notnull" index="idx_counter_log" />
<column name="regdate" type="date" index="idx_counter_log" />
<column name="user_agent" type="varchar" size="250" />
</table>

View file

@ -0,0 +1,5 @@
<table name="counter_status">
<column name="regdate" type="number" size="11" notnull="notnull" primary_key="primary_key" />
<column name="unique_visitor" type="number" size="11" default="0" />
<column name="pageview" type="number" size="11" default="0" />
</table>

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 B

View file

@ -0,0 +1,71 @@
<!--%import("js/counter_admin.js")-->
<h3>{$lang->counter} <span class="gray">{$lang->cmd_management}</span></h3>
<div class="header4">
<table cellspacing="0" class="summary">
<col width="124" />
<col />
<col width="164" />
<col />
<tr>
<th scope="row">{$lang->total_counter}</th>
<td>Visitor <strong>{number_format($total_counter->unique_visitor)}</strong> &nbsp;/&nbsp; Pageview : <strong>{number_format($total_counter->pageview)}</strong></td>
<th scope="row">{zdate($selected_date, "Y-m-d")} <span class="vr">|</span> <a href="#" onclick="open_calendar(null, '{$selected_date}', 'changeSelectedDate');return false;"><img src="./images/buttonCalendar.gif" alt="calendar" width="16" height="13" /></a></th>
<td>Visitor : <strong>{number_format($selected_day_counter->unique_visitor)}</strong> &nbsp;/&nbsp; Pageview : <strong>{number_format($selected_day_counter->pageview)}</strong></td>
</tr>
</table>
<ul class="localNavigation">
<!--@foreach($lang->cmd_select_counter_type as $key => $val)-->
<li <!--@if($type==$key || (!$type && $key == "hour"))-->class="on"<!--@end-->><a href="{getUrl('type',$key)}">{$val}</a></li>
<!--@end-->
</ul>
</div>
<!-- 일자를 옮기는 form -->
<form action="./" method="get" id="fo_counter">
<input type="hidden" name="module" value="{$module}" />
<input type="hidden" name="act" value="{$act}" />
<input type="hidden" name="selected_date" value="{$selected_date}" />
</form>
<!-- unique visitor 그래프 -->
<table cellspacing="0" class="tableType4 counter">
<col width="124" />
<col />
<!--@foreach($detail_status->list as $key => $val)-->
<!--@if($detail_status->sum>0)-->
{@$percent = sprintf("%0.2f", $val / $detail_status->sum * 100 )}
{@$img_width = sprintf("%0.0f", $val / $detail_status->max * 100 )}
<!--@else-->
{@$percent = 0}
{@$img_width = 1}
<!--@end-->
<tr>
<th scope="row">
<!-- 시간대별 -->
<!--@if($type == 'year')-->
<em>{$key}</em> {$lang->unit_year}
<!--@elseif($type == 'month')-->
<em>{$key}</em> {$lang->unit_month}
<!--@elseif($type == 'day')-->
<em>{$key}</em> {$lang->unit_day}
<!--@else-->
<em>{$key}</em> {$lang->unit_hour}
<!--@end-->
</th>
<td>
<div class="graph">
<img src="./images/iconBar.gif" alt="" width="12" height="6" class="bar" />
<div class="num" style="left:{$percent}%;">
<strong>{number_format($val)}</strong> ({$percent}%)
</div>
</div>
</td>
</tr>
<!--@end-->
</table>

View file

@ -0,0 +1,14 @@
/**
* @brief 카운터 정보 수집 javascript
* window.onload 이벤트 후에 counter 모듈을 호출한다.
**/
// 이벤트 등록
xAddEventListener(window,'load',doCallCounter);
// counter 모듈을 호출하는 함수
function doCallCounter() {
show_waiting_message = false;
exec_xml('counter','procCounterExecute');
show_waiting_message = true;
}

View file

@ -0,0 +1,6 @@
// 관리자 페이지에서 날짜 이동
function changeSelectedDate(selected_date) {
var fo_obj = xGetElementById('fo_counter');
fo_obj.selected_date.value = selected_date;
fo_obj.submit();
}