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@1280 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
ad2754314c
commit
210ebdbc26
8 changed files with 151 additions and 20 deletions
|
|
@ -18,6 +18,7 @@
|
|||
**/
|
||||
function isLogged() {
|
||||
$args->regdate = date("Ymd");
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
$output = executeQuery('counter.getCounterLog', $args);
|
||||
return $output->data->count?true:false;
|
||||
}
|
||||
|
|
@ -34,22 +35,22 @@
|
|||
/**
|
||||
* @brief 특정 일의 접속 통계를 가져옴
|
||||
**/
|
||||
function getStatus($regdate) {
|
||||
function getStatus($selected_date) {
|
||||
// 여러개의 날자 로그를 가져올 경우
|
||||
if(is_array($regdate)) {
|
||||
$date_count = count($regdate);
|
||||
$args->regdate = implode(',',$regdate);
|
||||
if(is_array($selected_date)) {
|
||||
$date_count = count($selected_date);
|
||||
$args->regdate = implode(',',$selected_date);
|
||||
|
||||
// 단일 날자의 로그를 가져올 경우
|
||||
} else {
|
||||
if(strlen($regdate)==8) $regdate = $regdate;
|
||||
$args->regdate = $regdate;
|
||||
if(strlen($selected_date)==8) $selected_date = $selected_date;
|
||||
$args->regdate = $selected_date;
|
||||
}
|
||||
|
||||
$output = executeQuery('counter.getCounterStatus', $args);
|
||||
$status = $output->data;
|
||||
|
||||
if(!is_array($regdate)) return $status;
|
||||
if(!is_array($selected_date)) return $status;
|
||||
|
||||
if(!is_array($status)) $status = array($status);
|
||||
unset($output);
|
||||
|
|
@ -60,5 +61,72 @@
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -27,15 +27,16 @@
|
|||
// 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');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@
|
|||
**/
|
||||
|
||||
$lang->cmd_select_date = '날자 선택';
|
||||
$lang->cmd_select_counter_type = array(
|
||||
'hour' => '시간대별',
|
||||
'day' => '일별',
|
||||
'month' => '월별',
|
||||
'year' => '년도별',
|
||||
);
|
||||
|
||||
$lang->total_counter = '전체현황';
|
||||
$lang->selected_day_counter = '선택일 현황';
|
||||
|
|
@ -13,8 +19,4 @@
|
|||
$lang->unique_visitor = '방문자';
|
||||
$lang->pageview = '페이지뷰';
|
||||
|
||||
$lang->unit_time = '시간별';
|
||||
$lang->unit_day = '시간별';
|
||||
$lang->unit_month = '시간별';
|
||||
$lang->unit_year = '시간별';
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<column name="count(*)" alias="count"/>
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="ipaddress" var="ipaddress" default="ipaddress()" notnull="notnull" />
|
||||
<condition operation="like_tail" column="regdate" var="regdate" notnull="notnull" pipe="and" />
|
||||
<condition operation="equal" column="ipaddress" var="ipaddress" />
|
||||
<condition operation="like_prefix" column="regdate" var="regdate" notnull="notnull" pipe="and" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
|
|||
11
modules/counter/queries/getStartLogDate.xml
Normal file
11
modules/counter/queries/getStartLogDate.xml
Normal 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>
|
||||
BIN
modules/counter/tpl/images/blank.gif
Normal file
BIN
modules/counter/tpl/images/blank.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 B |
|
|
@ -26,3 +26,52 @@
|
|||
<li>{$lang->pageview} : {number_format($selected_day_counter->pageview)}</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- 시간대별, 일자별, 월별, 년별 로그 보기 -->
|
||||
<div>
|
||||
<h3>
|
||||
{$lang->unique_visitor}
|
||||
<!--@foreach($lang->cmd_select_counter_type as $key => $val)-->
|
||||
<a href="#" onclick="location.href='{getUrl('type',$key)}';return false;">{$val}</a>
|
||||
<!--@end-->
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<!-- unique visitor 그래프 -->
|
||||
<div>
|
||||
<table border="1" width="100%">
|
||||
<col width="80" />
|
||||
<col width="*" />
|
||||
<!--@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>
|
||||
<!-- 시간대별 -->
|
||||
<!--@if($type == 'year')-->
|
||||
{$key} {$lang->unit_year}
|
||||
<!--@elseif($type == 'month')-->
|
||||
{$key} {$lang->unit_month}
|
||||
<!--@elseif($type == 'day')-->
|
||||
{$key} {$lang->unit_day}
|
||||
<!--@else-->
|
||||
{$key} {$lang->unit_hour}
|
||||
<!--@end-->
|
||||
</th>
|
||||
<td>
|
||||
<div style="width:400px;float:left;padding-top:5px;">
|
||||
<img src="./images/blank.gif" height="3" width="{$img_width}%" alt="{$percent}%" style="background-color:blue;border:1px solid darkblue;"/>
|
||||
</div>
|
||||
<div style="float:left;margin-left:20px;">
|
||||
{number_format($val)} ({$percent}%)
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!--@end-->
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue