mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
issue 2662 counter, document
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12241 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
e665650392
commit
77a1c3e89f
12 changed files with 4563 additions and 4059 deletions
|
|
@ -1,51 +1,53 @@
|
|||
<?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');
|
||||
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);
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function init() {
|
||||
// set the template path
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
// display
|
||||
$this->setTemplateFile('index');
|
||||
}
|
||||
}
|
||||
/* End of file counter.admin.view.php */
|
||||
/* Location: ./modules/counter/counter.admin.view.php */
|
||||
|
|
|
|||
|
|
@ -1,60 +1,64 @@
|
|||
<?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;
|
||||
if(!$oDB->isIndexExists('counter_log','idx_site_counter_log')) return true;
|
||||
|
||||
class counter extends ModuleObject {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
/**
|
||||
* 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);
|
||||
|
||||
return new Object();
|
||||
}
|
||||
return new Object(0, 'success_updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
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 */
|
||||
|
|
|
|||
|
|
@ -1,170 +1,197 @@
|
|||
<?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 {
|
||||
/**
|
||||
* Counter logs.
|
||||
* If want use below function, you can use 'counterExecute' function instead this function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function procCounterExecute()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
/**
|
||||
* Counter logs
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function counterExecute()
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
/**
|
||||
* Counter logs.
|
||||
* If want use below function, you can use 'counterExecute' function instead this function
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function procCounterExecute() {
|
||||
}
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Counter logs
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function counterExecute() {
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->begin();
|
||||
$oDB->commit();
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
$oDB->commit();
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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';
|
||||
|
||||
$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->site_srl = $site_srl;
|
||||
executeQuery('counter.deleteSiteCounter',$args);
|
||||
executeQuery('counter.deleteSiteCounterLog',$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);
|
||||
}
|
||||
}
|
||||
/* End of file counter.controller.php */
|
||||
/* Location: ./modules/counter/counter.controller.php */
|
||||
|
|
|
|||
|
|
@ -1,217 +1,258 @@
|
|||
<?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 {
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
if($site_srl)
|
||||
{
|
||||
$args->site_srl = $site_srl;
|
||||
$output = executeQuery('counter.getSiteCounterStatusDays', $args);
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = executeQuery('counter.getCounterStatusDays', $args);
|
||||
}
|
||||
$status = $output->data;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
if(!is_array($selected_date)) return $status;
|
||||
|
||||
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($status)) $status = array($status);
|
||||
unset($output);
|
||||
|
||||
if(!is_array($selected_date)) return $status;
|
||||
foreach($status as $key => $val)
|
||||
{
|
||||
$output[substr($val->regdate,0,8)] = $val;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
if(!is_array($status)) $status = array($status);
|
||||
unset($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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
foreach($status as $key => $val) {
|
||||
$output[substr($val->regdate,0,8)] = $val;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
$status->max = $max;
|
||||
$status->sum = $sum;
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
$status->max = $max;
|
||||
$status->sum = $sum;
|
||||
return $status;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
}
|
||||
/* End of file counter.model.php */
|
||||
/* Location: ./modules/counter/counter.model.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue