diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php
index 7efaf6631..9c6c527b5 100644
--- a/classes/db/DB.class.php
+++ b/classes/db/DB.class.php
@@ -284,17 +284,17 @@
$value = preg_replace('/(^\'|\'$){1}/','',$value);
switch($operation) {
- case 'like_tail' :
+ case 'like_prefix' :
$value = $value.'%';
break;
- case 'like_prefix' :
+ case 'like_tail' :
$value = '%'.$value;
break;
case 'like' :
$value = '%'.$value.'%';
break;
case 'in' :
- return "'".$value."'";
+ return "'".$value."'";
break;
}
diff --git a/modules/counter/counter.model.php b/modules/counter/counter.model.php
index 29bce40da..419a684f0 100644
--- a/modules/counter/counter.model.php
+++ b/modules/counter/counter.model.php
@@ -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;
+ }
+
}
?>
diff --git a/modules/counter/counter.view.php b/modules/counter/counter.view.php
index 2c0981ce6..b16deeaf9 100644
--- a/modules/counter/counter.view.php
+++ b/modules/counter/counter.view.php
@@ -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');
diff --git a/modules/counter/lang/ko.lang.php b/modules/counter/lang/ko.lang.php
index 1b3cceb1e..ffd407077 100644
--- a/modules/counter/lang/ko.lang.php
+++ b/modules/counter/lang/ko.lang.php
@@ -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 = '시간별';
?>
diff --git a/modules/counter/queries/getCounterLog.xml b/modules/counter/queries/getCounterLog.xml
index 038c8a5a6..c71d3907a 100644
--- a/modules/counter/queries/getCounterLog.xml
+++ b/modules/counter/queries/getCounterLog.xml
@@ -6,7 +6,7 @@
+
| + + + {$key} {$lang->unit_year} + + {$key} {$lang->unit_month} + + {$key} {$lang->unit_day} + + {$key} {$lang->unit_hour} + + | +
+
+
+
+ {number_format($val)} ({$percent}%)
+
+ |
+
|---|