XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
counter.controller.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
10 {
11 
17  function init()
18  {
19 
20  }
21 
28  function procCounterExecute()
29  {
30 
31  }
32 
38  function counterExecute()
39  {
40  $oDB = DB::getInstance();
41  $oDB->begin();
42 
43  $site_module_info = Context::get('site_module_info');
44  $site_srl = (int) $site_module_info->site_srl;
45 
46  // Check the logs
47  $oCounterModel = getModel('counter');
48 
49  if($oCounterModel->isInsertedTodayStatus($site_srl))
50  {
51  if($oCounterModel->isLogged($site_srl))
52  {
53  // Register pageview
54  $this->insertPageView($site_srl);
55  }
56  else // If unregistered IP
57  {
58  // Leave logs
59  $this->insertLog($site_srl);
60  // Register unique and pageview
61  $this->insertUniqueVisitor($site_srl);
62  }
63  }
64  else // Register today's row if not exist
65  {
66  $this->insertTodayStatus(0, $site_srl);
67  // check user if the previous row exists
68  }
69 
70  $oDB->commit();
71  }
72 
79  function insertLog($site_srl = 0)
80  {
81  $args = new stdClass();
82  $args->regdate = date("YmdHis");
83  $args->user_agent = substr($_SERVER['HTTP_USER_AGENT'], 0, 250);
84  $args->site_srl = $site_srl;
85 
86  return executeQuery('counter.insertCounterLog', $args);
87  }
88 
95  function insertUniqueVisitor($site_srl = 0)
96  {
97  $args = new stdClass();
98  $args->regdate = '0,' . date('Ymd');
99 
100  if($site_srl)
101  {
102  $args->site_srl = $site_srl;
103  $output = executeQuery('counter.updateSiteCounterUnique', $args);
104  }
105  else
106  {
107  $output = executeQuery('counter.updateCounterUnique', $args);
108  }
109  }
110 
117  function insertPageView($site_srl = 0)
118  {
119  $args = new stdClass;
120  $args->regdate = '0,' . date('Ymd');
121 
122  if($site_srl)
123  {
124  $args->site_srl = $site_srl;
125  executeQuery('counter.updateSiteCounterPageview', $args);
126  }
127  else
128  {
129  executeQuery('counter.updateCounterPageview', $args);
130  }
131  }
132 
139  function insertTotalStatus($site_srl = 0)
140  {
141  $args = new stdClass();
142  $args->regdate = 0;
143 
144  if($site_srl)
145  {
146  $args->site_srl = $site_srl;
147  executeQuery('counter.insertSiteTodayStatus', $args);
148  }
149  else
150  {
151  executeQuery('counter.insertTodayStatus', $args);
152  }
153  }
154 
162  function insertTodayStatus($regdate = 0, $site_srl = 0)
163  {
164  $args = new stdClass();
165  if($regdate)
166  {
167  $args->regdate = $regdate;
168  }
169  else
170  {
171  $args->regdate = date("Ymd");
172  }
173 
174  if($site_srl)
175  {
176  $args->site_srl = $site_srl;
177  $query_id = 'counter.insertSiteTodayStatus';
178 
179  $u_args->site_srl = $site_srl; // /< when inserting a daily row, attempt to inser total rows(where regdate=0) together
180  executeQuery($query_id, $u_args);
181  }
182  else
183  {
184  $query_id = 'counter.insertTodayStatus';
185  executeQuery($query_id); // /< when inserting a daily row, attempt to inser total rows(where regdate=0) together
186  }
187 
188  $output = executeQuery($query_id, $args);
189 
190  // Leave logs
191  $this->insertLog($site_srl);
192 
193  // Register unique and pageview
194  $this->insertUniqueVisitor($site_srl);
195  }
196 
203  function deleteSiteCounterLogs($site_srl)
204  {
205  $args = new stdClass();
206  $args->site_srl = $site_srl;
207  executeQuery('counter.deleteSiteCounter', $args);
208  executeQuery('counter.deleteSiteCounterLog', $args);
209  }
210 
211 }
212 /* End of file counter.controller.php */
213 /* Location: ./modules/counter/counter.controller.php */
insertTotalStatus($site_srl=0)
insertPageView($site_srl=0)
$output
Definition: ko.install.php:193
insertTodayStatus($regdate=0, $site_srl=0)
insertUniqueVisitor($site_srl=0)
$args
Definition: ko.install.php:185
deleteSiteCounterLogs($site_srl)
getInstance($db_type=NULL)
Definition: DB.class.php:142
getModel($module_name)
Definition: func.inc.php:145
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:203