merge from 1.7.3.5(r13153:r13167)

git-svn-id: http://xe-core.googlecode.com/svn/trunk@13168 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ngleader 2013-09-29 23:32:39 +00:00
parent cc47d2b247
commit 2d3f149b5a
2042 changed files with 129266 additions and 126243 deletions

View file

@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<module>
<grants />
<permissions />
<permissions>
<permission action="getWeeklyUniqueVisitor" target="manager" />
<permission action="getWeeklyPageView" target="manager" />
</permissions>
<actions>
<action name="dispCounterAdminIndex" type="view" standalone="true" admin_index="true" />
<action name="procCounterExecute" type="controller" standalone="true" />
<action name="getWeeklyUniqueVisitor" type="model" standalone="true" />
<action name="getWeeklyPageView" type="model" standalone="true" />
</actions>
</module>

View file

@ -1,51 +1,67 @@
<?php
/**
* Admin view class of counter module
/**
* Admin view class of counter module
*
* @author NHN (developers@xpressengine.com)
*/
class counterAdminView extends counter
{
/**
* Initialization
*
* @author NHN (developers@xpressengine.com)
**/
* @return void
*/
function init()
{
// set the template path
$this->setTemplatePath($this->module_path . 'tpl');
}
class counterAdminView extends counter {
/**
* Admin page
*
* @return Object
*/
function dispCounterAdminIndex()
{
// set today's if no date is given
$selected_date = Context::get('selected_date');
/**
* Initialization
*
* @return void
**/
function init() {
// set the template path
$this->setTemplatePath($this->module_path.'tpl');
}
if(!$selected_date)
{
$selected_date = date("Ymd");
}
/**
* Admin page
*
* @return Object
**/
function dispCounterAdminIndex() {
// set today's if no date is given
$selected_date = Context::get('selected_date');
if(!$selected_date) $selected_date = date("Ymd");
Context::set('selected_date', $selected_date);
// create the counter model object
$oCounterModel = &getModel('counter');
// get a total count and daily count
$site_module_info = Context::get('site_module_info');
$status = $oCounterModel->getStatus(array(0,$selected_date),$site_module_info->site_srl);
Context::set('total_counter', $status[0]);
Context::set('selected_day_counter', $status[$selected_date]);
// get data by time, day, month, and year
$type = Context::get('type');
if(!$type) {
$type = 'day';
Context::set('type',$type);
}
$detail_status = $oCounterModel->getHourlyStatus($type, $selected_date, $site_module_info->site_srl);
Context::set('detail_status', $detail_status);
// display
$this->setTemplateFile('index');
}
Context::set('selected_date', $selected_date);
}
?>
// create the counter model object
$oCounterModel = getModel('counter');
// get a total count and daily count
$site_module_info = Context::get('site_module_info');
$status = $oCounterModel->getStatus(array(0, $selected_date), $site_module_info->site_srl);
Context::set('total_counter', $status[0]);
Context::set('selected_day_counter', $status[$selected_date]);
// get data by time, day, month, and year
$type = Context::get('type');
if(!$type)
{
$type = 'day';
Context::set('type', $type);
}
$detail_status = $oCounterModel->getHourlyStatus($type, $selected_date, $site_module_info->site_srl);
Context::set('detail_status', $detail_status);
// display
$this->setTemplateFile('index');
}
}
/* End of file counter.admin.view.php */
/* Location: ./modules/counter/counter.admin.view.php */

View file

@ -1,60 +1,85 @@
<?php
/**
* High class of counter module
/**
* High class of counter module
*
* @author NHN (developers@xpressengine.com)
*/
class counter extends ModuleObject
{
/**
* Implement if additional tasks are necessary when installing
* @return Object
*/
function moduleInstall()
{
$oCounterController = getController('counter');
// add a row for the total visit history
//$oCounterController->insertTotalStatus();
// add a row for today's status
//$oCounterController->insertTodayStatus();
return new Object();
}
/**
* method if successfully installed
*
* @author NHN (developers@xpressengine.com)
**/
* @return bool
*/
function checkUpdate()
{
// Add site_srl to the counter
$oDB = DB::getInstance();
if(!$oDB->isColumnExists('counter_log', 'site_srl'))
{
return TRUE;
}
class counter extends ModuleObject {
if(!$oDB->isIndexExists('counter_log', 'idx_site_counter_log'))
{
return TRUE;
}
/**
* Implement if additional tasks are necessary when installing
* @return Object
**/
function moduleInstall() {
$oCounterController = &getController('counter');
// add a row for the total visit history
//$oCounterController->insertTotalStatus();
// add a row for today's status
//$oCounterController->insertTodayStatus();
return FALSE;
}
return new Object();
}
/**
* Module update
*
* @return Object
*/
function moduleUpdate()
{
// Add site_srl to the counter
$oDB = DB::getInstance();
/**
* method if successfully installed
*
* @return bool
**/
function checkUpdate() {
// Add site_srl to the counter
$oDB = &DB::getInstance();
if(!$oDB->isColumnExists('counter_log', 'site_srl')) return true;
if(!$oDB->isIndexExists('counter_log','idx_site_counter_log')) return true;
return false;
}
if(!$oDB->isColumnExists('counter_log', 'site_srl'))
{
$oDB->addColumn('counter_log', 'site_srl', 'number', 11, 0, TRUE);
}
/**
* Module update
*
* @return Object
**/
function moduleUpdate() {
// Add site_srl to the counter
$oDB = &DB::getInstance();
if(!$oDB->isColumnExists('counter_log', 'site_srl')) $oDB->addColumn('counter_log','site_srl','number',11,0,true);
if(!$oDB->isIndexExists('counter_log','idx_site_counter_log')) $oDB->addIndex('counter_log','idx_site_counter_log',array('site_srl','ipaddress'),false);
if(!$oDB->isIndexExists('counter_log', 'idx_site_counter_log'))
{
$oDB->addIndex('counter_log', 'idx_site_counter_log', array('site_srl', 'ipaddress'), FALSE);
}
return new Object(0, 'success_updated');
}
return new Object(0, 'success_updated');
}
/**
* re-generate the cache file
*
* @return Object
**/
function recompileCache() {
}
}
?>
/**
* re-generate the cache file
*
* @return Object
*/
function recompileCache()
{
}
}
/* End of file counter.class.php */
/* Location: ./modules/counter/counter.class.php */

View file

@ -1,170 +1,215 @@
<?php
/**
* Counter module's controller class
/**
* Counter module's controller class
*
* @author NHN (developers@xpressengine.com)
*/
class counterController extends counter
{
/**
* Initialization
*
* @author NHN (developers@xpressengine.com)
**/
* @return void
*/
function init()
{
class counterController extends counter {
}
/**
* Initialization
*
* @return void
**/
function init() {
}
/**
* Counter logs.
* If want use below function, you can use 'counterExecute' function instead this function
*
* @return void
*/
function procCounterExecute()
{
/**
* Counter logs.
* If want use below function, you can use 'counterExecute' function instead this function
*
* @return void
**/
function procCounterExecute() {
}
}
/**
* Counter logs
*
* @return void
**/
function counterExecute() {
$oDB = &DB::getInstance();
$oDB->begin();
/**
* Counter logs
*
* @return void
*/
function counterExecute()
{
$oDB = DB::getInstance();
$oDB->begin();
$site_module_info = Context::get('site_module_info');
$site_srl = (int)$site_module_info->site_srl;
// Check the logs
$oCounterModel = &getModel('counter');
// Register today's row if not exist
if(!$oCounterModel->isInsertedTodayStatus($site_srl)) {
$this->insertTodayStatus(0,$site_srl);
// check user if the previous row exists
} else {
// If unregistered IP
if(!$oCounterModel->isLogged($site_srl)) {
// Leave logs
$this->insertLog($site_srl);
// Register unique and pageview
$this->insertUniqueVisitor($site_srl);
} else {
// Register pageview
$this->insertPageView($site_srl);
}
}
$site_module_info = Context::get('site_module_info');
$site_srl = (int) $site_module_info->site_srl;
$oDB->commit();
}
// Check the logs
$oCounterModel = getModel('counter');
/**
* Leave logs
*
* @param integer $site_srl
* @return Object result of count query
**/
function insertLog($site_srl=0) {
$args->regdate = date("YmdHis");
$args->user_agent = substr ($_SERVER['HTTP_USER_AGENT'], 0, 250);
$args->site_srl = $site_srl;
return executeQuery('counter.insertCounterLog', $args);
}
// Register today's row if not exist
if(!$oCounterModel->isInsertedTodayStatus($site_srl))
{
$this->insertTodayStatus(0, $site_srl);
// check user if the previous row exists
}
else
{
// If unregistered IP
if(!$oCounterModel->isLogged($site_srl))
{
// Leave logs
$this->insertLog($site_srl);
// Register unique and pageview
$this->insertUniqueVisitor($site_srl);
}
else
{
// Register pageview
$this->insertPageView($site_srl);
}
}
/**
* Register the unique visitor
*
* @param integer $site_srl
* @return void
**/
function insertUniqueVisitor($site_srl=0) {
if($site_srl) {
$args->regdate = '0';
$args->site_srl = $site_srl;
$output = executeQuery('counter.updateSiteCounterUnique', $args);
$args->regdate = date('Ymd');
$output = executeQuery('counter.updateSiteCounterUnique', $args);
} else {
$args->regdate = '0';
$output = executeQuery('counter.updateCounterUnique', $args);
$args->regdate = date('Ymd');
$output = executeQuery('counter.updateCounterUnique', $args);
}
}
$oDB->commit();
}
/**
* Register pageview
*
* @param integer $site_srl
* @return void
**/
function insertPageView($site_srl=0) {
if($site_srl) {
$args->regdate = '0';
$args->site_srl = $site_srl;
executeQuery('counter.updateSiteCounterPageview', $args);
$args->regdate = date('Ymd');
executeQuery('counter.updateSiteCounterPageview', $args);
} else {
$args->regdate = '0';
executeQuery('counter.updateCounterPageview', $args);
$args->regdate = date('Ymd');
executeQuery('counter.updateCounterPageview', $args);
}
}
/**
* Leave logs
*
* @param integer $site_srl
* @return Object result of count query
*/
function insertLog($site_srl = 0)
{
$args = new stdClass();
$args->regdate = date("YmdHis");
$args->user_agent = substr($_SERVER['HTTP_USER_AGENT'], 0, 250);
$args->site_srl = $site_srl;
/**
* Add the total counter status
*
* @param integer $site_srl
* @return void
**/
function insertTotalStatus($site_srl=0) {
$args->regdate = 0;
if($site_srl) {
$args->site_srl = $site_srl;
executeQuery('counter.insertSiteTodayStatus', $args);
} else {
executeQuery('counter.insertTodayStatus', $args);
}
}
return executeQuery('counter.insertCounterLog', $args);
}
/**
* Add today's counter status
*
* @param integer $regdate date(YYYYMMDD) type
* @param integer $site_srl
* @return void
**/
function insertTodayStatus($regdate = 0, $site_srl=0) {
if($regdate) $args->regdate = $regdate;
else $args->regdate = date("Ymd");
if($site_srl) {
$args->site_srl = $site_srl;
$query_id = 'counter.insertSiteTodayStatus';
/**
* Register the unique visitor
*
* @param integer $site_srl
* @return void
*/
function insertUniqueVisitor($site_srl = 0)
{
$args = new stdClass();
$u_args->site_srl = $site_srl; // /< when inserting a daily row, attempt to inser total rows(where regdate=0) together
executeQuery($query_id, $u_args);
} else {
$query_id = 'counter.insertTodayStatus';
executeQuery($query_id); // /< when inserting a daily row, attempt to inser total rows(where regdate=0) together
}
$output = executeQuery($query_id, $args);
// Leave logs
$this->insertLog($site_srl);
// Register unique and pageview
$this->insertUniqueVisitor($site_srl);
}
if($site_srl)
{
$args->regdate = '0,' . date('Ymd');
$args->site_srl = $site_srl;
$output = executeQuery('counter.updateSiteCounterUnique', $args);
}
else
{
$args->regdate = '0,' . date('Ymd');
$output = executeQuery('counter.updateCounterUnique', $args);
}
}
/**
* Delete counter logs of the specific virtual site
*
* @param integer $site_srl
* @return void
**/
function deleteSiteCounterLogs($site_srl) {
$args->site_srl = $site_srl;
executeQuery('counter.deleteSiteCounter',$args);
executeQuery('counter.deleteSiteCounterLog',$args);
}
}
?>
/**
* Register pageview
*
* @param integer $site_srl
* @return void
*/
function insertPageView($site_srl = 0)
{
$args = new stdClass;
$args->regdate = '0,' . date('Ymd');
if($site_srl)
{
$args->site_srl = $site_srl;
executeQuery('counter.updateSiteCounterPageview', $args);
}
else
{
executeQuery('counter.updateCounterPageview', $args);
}
}
/**
* Add the total counter status
*
* @param integer $site_srl
* @return void
*/
function insertTotalStatus($site_srl = 0)
{
$args = new stdClass();
$args->regdate = 0;
if($site_srl)
{
$args->site_srl = $site_srl;
executeQuery('counter.insertSiteTodayStatus', $args);
}
else
{
executeQuery('counter.insertTodayStatus', $args);
}
}
/**
* Add today's counter status
*
* @param integer $regdate date(YYYYMMDD) type
* @param integer $site_srl
* @return void
*/
function insertTodayStatus($regdate = 0, $site_srl = 0)
{
$args = new stdClass();
if($regdate)
{
$args->regdate = $regdate;
}
else
{
$args->regdate = date("Ymd");
}
if($site_srl)
{
$args->site_srl = $site_srl;
$query_id = 'counter.insertSiteTodayStatus';
$u_args->site_srl = $site_srl; // /< when inserting a daily row, attempt to inser total rows(where regdate=0) together
executeQuery($query_id, $u_args);
}
else
{
$query_id = 'counter.insertTodayStatus';
executeQuery($query_id); // /< when inserting a daily row, attempt to inser total rows(where regdate=0) together
}
$output = executeQuery($query_id, $args);
// Leave logs
$this->insertLog($site_srl);
// Register unique and pageview
$this->insertUniqueVisitor($site_srl);
}
/**
* Delete counter logs of the specific virtual site
*
* @param integer $site_srl
* @return void
*/
function deleteSiteCounterLogs($site_srl)
{
$args = new stdClass();
$args->site_srl = $site_srl;
executeQuery('counter.deleteSiteCounter', $args);
executeQuery('counter.deleteSiteCounterLog', $args);
}
}
/* End of file counter.controller.php */
/* Location: ./modules/counter/counter.controller.php */

View file

@ -1,217 +1,458 @@
<?php
/**
* Model class of counter module
/**
* Model class of counter module
*
* @author NHN (developers@xpressengine.com)
*/
class counterModel extends counter
{
/**
* Initialization
*
* @author NHN (developers@xpressengine.com)
**/
* @return void
*/
function init()
{
class counterModel extends counter {
}
/**
* Initialization
*
* @return void
**/
function init() {
}
/**
* Verify logs
*
* @param integer $site_srl Site_srl
* @return bool
*/
function isLogged($site_srl = 0)
{
$args = new stdClass();
$args->regdate = date('Ymd');
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
$args->site_srl = $site_srl;
/**
* Verify logs
*
* @param integer $site_srl Site_srl
* @return bool
**/
function isLogged($site_srl=0) {
$args->regdate = date("Ymd");
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
$args->site_srl = $site_srl;
$output = executeQuery('counter.getCounterLog', $args);
return $output->data->count?true:false;
}
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$object_key = 'object:' . $site_srl . '_' . str_replace('.', '-', $args->ipaddress);
$cache_key = $oCacheHandler->getGroupKey('counterIpLogged_' . $args->regdate, $object_key);
if($oCacheHandler->isValid($cache_key))
{
return $oCacheHandler->get($cache_key);
}
}
/**
* Check if a row of today's counter status exists
*
* @param integer $site_srl Site_srl
* @return bool
**/
function isInsertedTodayStatus($site_srl=0) {
$args->regdate = date("Ymd");
if($site_srl) {
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteTodayStatus', $args);
} else {
$output = executeQuery('counter.getTodayStatus', $args);
}
return $output->data->count?true:false;
}
$output = executeQuery('counter.getCounterLog', $args);
/**
* Get access statistics for a given date
*
* @param mixed $selected_date Date(YYYYMMDD) list
* @param integer $site_srl Site_srl
* @return Object
**/
function getStatus($selected_date, $site_srl = 0) {
// If more than one date logs are selected
if(is_array($selected_date)) {
$date_count = count($selected_date);
$args->regdate = implode(',',$selected_date);
// If a single date log is selected
} else {
if(strlen($selected_date) == 8) $selected_date = $selected_date;
$args->regdate = $selected_date;
}
$result = $output->data->count ? TRUE : FALSE;
if($result && $oCacheHandler->isSupport())
{
$oCacheHandler->put($cache_key, $result);
}
if($site_srl) {
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatusDays', $args);
} else {
$output = executeQuery('counter.getCounterStatusDays', $args);
}
$status = $output->data;
return $result;
}
if(!is_array($selected_date)) return $status;
/**
* Check if a row of today's counter status exists
*
* @param integer $site_srl Site_srl
* @return bool
*/
function isInsertedTodayStatus($site_srl = 0)
{
$args = new stdClass;
$args->regdate = date('Ymd');
if(!is_array($status)) $status = array($status);
unset($output);
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$cache_key = 'object:insertedTodayStatus:' . $site_srl . '_' . $args->regdate;
if($oCacheHandler->isValid($cache_key))
{
return $oCacheHandler->get($cache_key);
}
}
foreach($status as $key => $val) {
$output[substr($val->regdate,0,8)] = $val;
}
return $output;
}
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteTodayStatus', $args);
}
else
{
$output = executeQuery('counter.getTodayStatus', $args);
}
/**
* Select hourly logs of a given date
*
* @param string $type Choice time interval (year, week, month, hour or DEFAULT)
* @param integer $selected_date Date(YYYYMMDD)
* @param integer $site_srl Site_srl
* @return Object
**/
function getHourlyStatus($type='hour', $selected_date, $site_srl=0) {
$max = 0;
$sum = 0;
switch($type) {
case 'year' :
// Get a date to start counting
if($site_srl) {
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteStartLogDate', $args);
} else {
$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->start_date = sprintf('%04d0000', $i);
$args->end_date = sprintf('%04d1231', $i);
if($site_srl) {
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
} else {
$output = executeQuery('counter.getCounterStatus', $args);
}
$count = (int)$output->data->unique_visitor;
$status->list[$i] = $count;
if($count>$max) $max = $count;
$sum += $count;
}
break;
case 'week' :
$time = strtotime($selected_date);
$w = date("D");
while(date("D",$time) != "Sun") {
$time += 60*60*24;
}
$time -= 60*60*24;
while(date("D",$time)!="Sun") {
$thisWeek[] = date("Ymd",$time);
$time -= 60*60*24;
}
$thisWeek[] = date("Ymd",$time);
asort($thisWeek);
foreach($thisWeek as $day) {
unset($args);
$args->start_date = $day;
$args->end_date = $day;
if($site_srl) {
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
} else {
$output = executeQuery('counter.getCounterStatus', $args);
}
$count = (int)$output->data->unique_visitor;
$status->list[$day] = (int)$count;
if($count>$max) $max = $count;
$sum += $count;
}
break;
case 'month' :
$year = substr($selected_date, 0, 4);
for($i=1;$i<=12;$i++) {
unset($args);
$args->start_date = sprintf('%04d%02d00', $year, $i);
$args->end_date = sprintf('%04d%02d31', $year, $i);
if($site_srl) {
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
} else {
$output = executeQuery('counter.getCounterStatus', $args);
}
$count = (int)$output->data->unique_visitor;
$status->list[$i] = (int)$count;
if($count>$max) $max = $count;
$sum += $count;
}
break;
case 'hour' :
for($i=0;$i<24;$i++) {
unset($args);
$args->start_date = sprintf('%08d%02d0000', $selected_date, $i);
$args->end_date = sprintf('%08d%02d5959', $selected_date, $i);
if($site_srl) {
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterLogStatus', $args);
} else {
$args->site_srl = 0;
$output = executeQuery('counter.getCounterLogStatus', $args);
}
$count = (int)$output->data->count;
$status->list[$i] = $count;
if($count>$max) $max = $count;
$sum += $count;
}
break;
default :
$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->start_date = sprintf('%04d%02d%02d', $year, $month, $i);
$args->end_date = sprintf('%04d%02d%02d', $year, $month, $i);
if($site_srl) {
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
} else {
$output = executeQuery('counter.getCounterStatus', $args);
}
$count = (int)$output->data->unique_visitor;
$status->list[$i] = $count;
if($count>$max) $max = $count;
$sum += $count;
}
break;
}
$result = $output->data->count ? TRUE : FALSE;
if($result && $oCacheHandler->isSupport())
{
$oCacheHandler->put($cache_key, $result);
$_old_date = date('Ymd', strtotime('-1 day'));
$oCacheHandler->delete('object:insertedTodayStatus:' . $site_srl . '_' . $_old_date);
}
$status->max = $max;
$status->sum = $sum;
return $status;
}
return $result;
}
}
?>
/**
* Get access statistics for a given date
*
* @param mixed $selected_date Date(YYYYMMDD) list
* @param integer $site_srl Site_srl
* @return Object
*/
function getStatus($selected_date, $site_srl = 0)
{
// If more than one date logs are selected
if(is_array($selected_date))
{
$date_count = count($selected_date);
$args = new stdClass();
$args->regdate = implode(',', $selected_date);
// If a single date log is selected
}
else
{
if(strlen($selected_date) == 8)
{
$selected_date = $selected_date;
}
$args->regdate = $selected_date;
}
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatusDays', $args);
}
else
{
$output = executeQuery('counter.getCounterStatusDays', $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;
}
/**
* Select hourly logs of a given date
*
* @param string $type Choice time interval (year, week, month, hour or DEFAULT)
* @param integer $selected_date Date(YYYYMMDD)
* @param integer $site_srl Site_srl
* @return Object
*/
function getHourlyStatus($type = 'hour', $selected_date, $site_srl = 0, $isPageView = false)
{
$max = 0;
$sum = 0;
switch($type)
{
case 'year' :
// Get a date to start counting
if($site_srl)
{
$args = new stdClass();
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteStartLogDate', $args);
}
else
{
$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++)
{
$args = new stdClass();
$args->start_date = sprintf('%04d0000', $i);
$args->end_date = sprintf('%04d1231', $i);
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
}
else
{
$output = executeQuery('counter.getCounterStatus', $args);
}
if(!$isPageView)
{
$count = (int) $output->data->unique_visitor;
}
else
{
$count = (int) $output->data->pageview;
}
$status->list[$i] = $count;
if($count > $max)
{
$max = $count;
}
$sum += $count;
}
break;
case 'week' :
$time = strtotime($selected_date);
$w = date("D");
while(date("D", $time) != "Sun")
{
$time += 60 * 60 * 24;
}
$time -= 60 * 60 * 24;
while(date("D", $time) != "Sun")
{
$thisWeek[] = date("Ymd", $time);
$time -= 60 * 60 * 24;
}
$thisWeek[] = date("Ymd", $time);
asort($thisWeek);
foreach($thisWeek as $day)
{
$args = new stdClass();
$args->start_date = $day;
$args->end_date = $day;
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
}
else
{
$output = executeQuery('counter.getCounterStatus', $args);
}
if(!$isPageView)
{
$count = (int) $output->data->unique_visitor;
}
else
{
$count = (int) $output->data->pageview;
}
$status->list[$day] = (int) $count;
if($count > $max)
{
$max = $count;
}
$sum += $count;
}
break;
case 'month' :
$year = substr($selected_date, 0, 4);
for($i = 1; $i <= 12; $i++)
{
$args = new stdClass();
$args->start_date = sprintf('%04d%02d00', $year, $i);
$args->end_date = sprintf('%04d%02d31', $year, $i);
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
}
else
{
$output = executeQuery('counter.getCounterStatus', $args);
}
if(!$isPageView)
{
$count = (int) $output->data->unique_visitor;
}
else
{
$count = (int) $output->data->pageview;
}
$status->list[$i] = (int) $count;
if($count > $max)
{
$max = $count;
}
$sum += $count;
}
break;
case 'hour' :
for($i = 0; $i < 24; $i++)
{
$args = new stdClass();
$args->start_date = sprintf('%08d%02d0000', $selected_date, $i);
$args->end_date = sprintf('%08d%02d5959', $selected_date, $i);
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterLogStatus', $args);
}
else
{
$args->site_srl = 0;
$output = executeQuery('counter.getCounterLogStatus', $args);
}
$count = (int) $output->data->count;
$status->list[$i] = $count;
if($count > $max)
{
$max = $count;
}
$sum += $count;
}
break;
default :
$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++)
{
$args = new stdClass();
$args->start_date = sprintf('%04d%02d%02d', $year, $month, $i);
$args->end_date = sprintf('%04d%02d%02d', $year, $month, $i);
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
}
else
{
$output = executeQuery('counter.getCounterStatus', $args);
}
if(!$isPageView)
{
$count = (int) $output->data->unique_visitor;
}
else
{
$count = (int) $output->data->pageview;
}
$status->list[$i] = $count;
if($count > $max)
{
$max = $count;
}
$sum += $count;
}
break;
}
$status->max = $max;
$status->sum = $sum;
return $status;
}
public function getWeeklyUniqueVisitor()
{
//for last week
$date1 = date('Ymd', strtotime('-1 week'));
$output1 = $this->getHourlyStatus('week', $date1);
$tmp = array();
foreach($output1->list AS $key => $value)
{
$tmp["'" . $key . "'"] = $value;
}
$output1->list = $tmp;
//for this week
$date2 = date('Ymd');
$output2 = $this->getHourlyStatus('week', $date2);
$tmp = array();
foreach($output2->list AS $key => $value)
{
$tmp["'" . $key . "'"] = $value;
}
$output2->list = $tmp;
$this->add('last_week', $output1);
$this->add('this_week', $output2);
}
public function getWeeklyPageView()
{
//for last week
$date1 = date('Ymd', strtotime('-1 week'));
$output1 = $this->getHourlyStatus('week', $date1, 0, TRUE);
$tmp = array();
foreach($output1->list AS $key => $value)
{
$tmp["'" . $key . "'"] = $value;
}
$output1->list = $tmp;
//for this week
$date2 = date('Ymd');
$output2 = $this->getHourlyStatus('week', $date2, 0, TRUE);
$tmp = array();
foreach($output2->list AS $key => $value)
{
$tmp["'" . $key . "'"] = $value;
}
$output2->list = $tmp;
$this->add('last_week', $output1);
$this->add('this_week', $output2);
}
}
/* End of file counter.model.php */
/* Location: ./modules/counter/counter.model.php */

View file

@ -6,6 +6,6 @@
<column name="pageview" default="plus(1)" />
</columns>
<conditions>
<condition operation="equal" column="regdate" var="regdate" notnull="notnull" />
<condition operation="in" column="regdate" var="regdate" notnull="notnull" />
</conditions>
</query>

View file

@ -7,6 +7,6 @@
<column name="pageview" default="plus(1)" />
</columns>
<conditions>
<condition operation="equal" column="regdate" var="regdate" notnull="notnull" />
<condition operation="in" column="regdate" var="regdate" notnull="notnull" />
</conditions>
</query>

View file

@ -7,6 +7,6 @@
</columns>
<conditions>
<condition operation="equal" column="site_srl" var="site_srl" default="0" />
<condition operation="equal" column="regdate" var="regdate" notnull="notnull" pipe="and" />
<condition operation="in" column="regdate" var="regdate" notnull="notnull" pipe="and" />
</conditions>
</query>

View file

@ -8,6 +8,6 @@
</columns>
<conditions>
<condition operation="equal" column="site_srl" var="site_srl" notnull="notnull" />
<condition operation="equal" column="regdate" var="regdate" notnull="notnull" pipe="and" />
<condition operation="in" column="regdate" var="regdate" notnull="notnull" pipe="and" />
</conditions>
</query>

View file

@ -1,3 +1,3 @@
.barContainer{margin-right:103px;position:relative;height:100%;}
.graphHr{position:relative; display:inline-block; background:transparent url(images/iconBar.gif) 4px 0 repeat-x; top:5px; height:5px; }
.graphHr span{position:absolute; top:-5px; left:100%; padding-left:3px; width:100px; }
.graphHr{position:relative; display:inline-block; background:transparent url(images/iconBar.gif) 4px 0 repeat-x;height:5px}
.graphHr>span{position:absolute;top:-7px;left:100%;padding-left:4px;width:100px}

View file

@ -4,80 +4,84 @@
<!--// datepicker javascript plugin load -->
<!--%load_js_plugin("ui.datepicker")-->
<script type="text/javascript">
<script>
function moveDate() {
document.forms['calendar'].submit();
return true;
}
</script>
<h3 class="h3">{$lang->counter} {$lang->cmd_management}</h3>
<form action="./index.php" method="get" name="calendar" id="fo_calendar">
<div class="x_page-header">
<h1>{$lang->counter} {$lang->cmd_management}</h1>
</div>
<form action="./index.php" method="get" name="calendar" id="fo_calendar" style="margin-bottom:30px">
<input type="hidden" name="module" value="{$module}" />
<input type="hidden" name="act" value="{$act}" />
<input type="hidden" name="selected_date" id="selected_date" value="{zDate('Ymd',$selected_date)}" />
<div class="table">
<table width="100%" border="1" cellspacing="0">
<thead>
<table class="x_table x_table-striped x_table-hover">
<thead>
<tr>
<th scope="row">{$lang->total_counter}</th>
<th scope="row"> <span id="str_selected_date">{zdate($selected_date, "Y-m-d")}</span>
<input type="hidden" class="inputDate" value="{zdate($selected_date,'Y-m-d')}" />
<script type="text/javascript">
(function($){
$(function(){
var option = {
changeMonth: true
,changeYear: true
,gotoCurrent: false
,dateFormat:'yy-mm-dd'
,yearRange:'-100:+10'
,showOn:"button"
,buttonImage:"./modules/counter/tpl/images/buttonCalendar.gif"
,buttonImageOnly:true
,mandatory:true
,onSelect:function(){
$("#str_selected_date").html(this.value);
$("#selected_date").val(this.value.replace(/-/g,''));
moveDate();
}
};
<th scope="row">
<span id="str_selected_date">{zdate($selected_date, "Y-m-d")}</span>
<input type="hidden" class="inputDate" value="{zdate($selected_date,'Y-m-d')}" />
<script>
(function($){
$(function(){
var option = {
changeMonth: true
,changeYear: true
,gotoCurrent: false
,dateFormat:'yy-mm-dd'
,yearRange:'-100:+10'
,showOn:"button"
,buttonImage:"./modules/counter/tpl/images/buttonCalendar.gif"
,buttonImageOnly:false
,mandatory:true
,onSelect:function(){
$("#str_selected_date").html(this.value);
$("#selected_date").val(this.value.replace(/-/g,''));
moveDate();
}
};
$.extend(option,$.datepicker.regional['{$lang_type}']);
$(".inputDate").datepicker(option);
});
})(jQuery);
</script> </th>
$.extend(option,$.datepicker.regional['{$lang_type}']);
$(".inputDate").datepicker(option);
});
})(jQuery);
</script>
<style scoped>
.ui-datepicker-trigger{cursor:pointer;border:0;background:none;padding:0}
</style>
</th>
</tr>
</thead>
<tbody>
</thead>
<tbody>
<tr>
<td>Visitor <strong>{number_format($total_counter->unique_visitor)}</strong> &nbsp;/&nbsp; Pageview : <strong>{number_format($total_counter->pageview)}</strong></td>
<td>Visitor : <strong>{number_format($selected_day_counter->unique_visitor)}</strong> &nbsp;/&nbsp; Pageview : <strong>{number_format($selected_day_counter->pageview)}</strong></td>
</tr>
</tbody>
</table>
</div>
</form>
<div class="cnb">
<ul>
<!--@foreach($lang->cmd_select_counter_type as $key => $val)-->
<li <!--@if($type==$key || (!$type && $key == "hour"))-->class="active"<!--@end-->><a href="{getUrl('type',$key)}">{$val}</a></li>
<!--@end-->
</ul>
</div>
</tbody>
</table>
</form>
<ul class="x_nav x_nav-tabs">
<li loop="$lang->cmd_select_counter_type => $key, $val" class="x_active"|cond="$type==$key || (!$type && $key == 'hour')">
<a href="{getUrl('type',$key)}">{$val}</a>
</li>
</ul>
<!-- 일자를 옮기는 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}" />
<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 그래프 -->
<div class="table">
<table width="100%" border="1" cellspacing="0">
<table class="x_table x_table-striped x_table-hover">
<!--@foreach($detail_status->list as $key => $val)-->
<!--@if($detail_status->sum>0)-->
{@$percent = sprintf("%0.2f", $val / $detail_status->sum * 100 )}
@ -87,31 +91,30 @@
{@$img_width = 1}
<!--@end-->
<tr>
<!--@if(Context::getLangType()=='en')-->
<th scope="row"> <!--// 시간대별 -->
<th scope="row" cond="Context::getLangType()=='en'"> <!--// 시간대별 -->
<!--@if($type == 'year')-->
<em>{$key}</em>
{$key}
<!--@elseif($type == 'month')-->
<em>{$key}</em>
{$key}
<!--@elseif($type == 'day')-->
<em>{$key}</em> {$lang->unit_day}
{$key} {$lang->unit_day}
<!--@else-->
<em>{$key}</em>
<!--@end--> </th>
<!--@else-->
<th scope="row"> <!--// 시간대별 -->
{$key}
<!--@end-->
</th>
<th scope="row" cond="Context::getLangType()!='en'"> <!--// 시간대별 -->
<!--@if($type == 'year')-->
<em>{$key}</em> {$lang->unit_year}
{$key} {$lang->unit_year}
<!--@elseif($type == 'month')-->
<em>{$key}</em> {$lang->unit_month}
{$key} {$lang->unit_month}
<!--@elseif($type == 'day')-->
<em>{$key}</em> {$lang->unit_day}
{$key} {$lang->unit_day}
<!--@else-->
<em>{$key}</em> {$lang->unit_hour}
<!--@end--> </th>
<!--@end-->
{$key} {$lang->unit_hour}
<!--@end-->
</th>
{@ $img_width = (int)$percent; $img_width = $img_width?$img_width.'%':'3px'; }
<td >
<td>
<div class="barContainer">
<span class="graphHr" style="width:{$img_width}">
<span>{number_format($val)}({$percent}%)</span>
@ -120,5 +123,4 @@
</td>
</tr>
<!--@end-->
</table>
</div>
</table>