mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 03:32:00 +09:00
Clean up counter module
- 카운터 모듈을 정리하여 불필요한 쿼리 및 트랜잭션 제거 - 매일 첫 방문시 쿼리 오류 발생하는 문제 해결 - 더이상 사용하지 않는 $site_srl 기준의 테이블은 삭제
This commit is contained in:
parent
350d0cd20c
commit
8d2b105847
21 changed files with 83 additions and 379 deletions
|
|
@ -37,178 +37,98 @@ class counterController extends counter
|
|||
*/
|
||||
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');
|
||||
|
||||
if($oCounterModel->isInsertedTodayStatus($site_srl))
|
||||
if(CounterModel::isLogged())
|
||||
{
|
||||
if($oCounterModel->isLogged($site_srl))
|
||||
{
|
||||
// Register pageview
|
||||
$this->insertPageView($site_srl);
|
||||
}
|
||||
else // If unregistered IP
|
||||
{
|
||||
// Leave logs
|
||||
$this->insertLog($site_srl);
|
||||
// Register unique and pageview
|
||||
$this->insertUniqueVisitor($site_srl);
|
||||
}
|
||||
$this->insertPageView();
|
||||
}
|
||||
else // Register today's row if not exist
|
||||
else
|
||||
{
|
||||
$this->insertTodayStatus(0, $site_srl);
|
||||
// check user if the previous row exists
|
||||
$this->insertUniqueVisitor();
|
||||
}
|
||||
|
||||
$oDB->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave logs
|
||||
*
|
||||
* @param integer $site_srl
|
||||
* @return Object result of count query
|
||||
* @return void
|
||||
*/
|
||||
function insertLog($site_srl = 0)
|
||||
public function insertLog()
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->regdate = date("YmdHis");
|
||||
$args->regdate = date('YmdHis');
|
||||
$args->user_agent = substr($_SERVER['HTTP_USER_AGENT'], 0, 250);
|
||||
$args->site_srl = $site_srl;
|
||||
|
||||
return executeQuery('counter.insertCounterLog', $args);
|
||||
$args->site_srl = 0;
|
||||
executeQuery('counter.insertCounterLog', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the unique visitor
|
||||
*
|
||||
* @param integer $site_srl
|
||||
* @return void
|
||||
*/
|
||||
function insertUniqueVisitor($site_srl = 0)
|
||||
public function insertUniqueVisitor()
|
||||
{
|
||||
$oDB = DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
$args = new stdClass();
|
||||
$args->regdate = '0,' . date('Ymd');
|
||||
|
||||
if($site_srl)
|
||||
$args->regdate = [0, $date = date('Ymd')];
|
||||
executeQuery('counter.updateCounterUnique', $args);
|
||||
|
||||
$affected_rows = $oDB->getAffectedRows();
|
||||
if ($affected_rows == 1)
|
||||
{
|
||||
$args->site_srl = $site_srl;
|
||||
$output = executeQuery('counter.updateSiteCounterUnique', $args);
|
||||
$args = new stdClass;
|
||||
$args->regdate = $date;
|
||||
executeQuery('counter.insertTodayStatus', $args);
|
||||
}
|
||||
else
|
||||
if ($affected_rows == 0)
|
||||
{
|
||||
$output = executeQuery('counter.updateCounterUnique', $args);
|
||||
$args = new stdClass;
|
||||
$args->regdate = 0;
|
||||
executeQuery('counter.insertTodayStatus', $args);
|
||||
}
|
||||
|
||||
$this->insertLog();
|
||||
|
||||
$oDB->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register pageview
|
||||
*
|
||||
* @param integer $site_srl
|
||||
* @return void
|
||||
*/
|
||||
function insertPageView($site_srl = 0)
|
||||
public function insertPageView()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
$args->regdate = [0, date('Ymd')];
|
||||
executeQuery('counter.updateCounterPageview', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the total counter status
|
||||
*
|
||||
* @param integer $site_srl
|
||||
* @return void
|
||||
* @deprecated
|
||||
*/
|
||||
function insertTotalStatus($site_srl = 0)
|
||||
public function insertTodayStatus()
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->regdate = 0;
|
||||
|
||||
if($site_srl)
|
||||
{
|
||||
$args->site_srl = $site_srl;
|
||||
executeQuery('counter.insertSiteTodayStatus', $args);
|
||||
}
|
||||
else
|
||||
{
|
||||
executeQuery('counter.insertTodayStatus', $args);
|
||||
}
|
||||
$this->insertUniqueVisitor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add today's counter status
|
||||
*
|
||||
* @param integer $regdate date(YYYYMMDD) type
|
||||
* @param integer $site_srl
|
||||
* @return void
|
||||
* @deprecated
|
||||
*/
|
||||
function insertTodayStatus($regdate = 0, $site_srl = 0)
|
||||
public function insertTotalStatus()
|
||||
{
|
||||
$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 = 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete counter logs of the specific virtual site
|
||||
*
|
||||
* @param integer $site_srl
|
||||
* @return void
|
||||
* @deprecated
|
||||
*/
|
||||
function deleteSiteCounterLogs($site_srl)
|
||||
public function deleteSiteCounterLogs()
|
||||
{
|
||||
$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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue