/**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Statistics::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 2
0
 /**
  * 访问结束时更新相关数据
  * Enter description here ...
  */
 public function actionVisitEnd()
 {
     UtilHelper::writeToFile($_GET);
     $id = $_GET['id'];
     $aid = $_GET['aid'];
     $model = $this->loadModel($aid);
     try {
         $model->online--;
         if ($model->save()) {
             echo "YES";
         } else {
             UtilHelper::writeToFile(CHtml::errorSummary($model), 'a+');
         }
     } catch (Exception $e) {
         echo $e->getFile() . $e->getLine() . $e->getMessage();
     }
     Statistics::model()->VisitEnd($id);
 }
Esempio n. 3
0
 public function agentStatistics()
 {
     $result = array();
     $model = Statistics::model()->findAll();
     foreach ($model as $data) {
         $agent = $data->terminal;
         $browser = new Browser();
         $browser->setUserAgent($agent);
         $browserinfo = str_replace(array(' ', '.'), array('_', '-'), $browser->getBrowser());
         $version = str_replace(array(' ', '.'), array('_', '-'), $browser->getVersion());
         $platform = str_replace(array(' ', '.'), array('_', '-'), $browser->getPlatform());
         //			$aolversion = str_replace(array(' ','.'), array('_','-'),$browser->getAolVersion());
         $result['Agent'][$browserinfo][$version] += 1;
         $result['Platform'][$platform] += 1;
     }
     return $result;
 }
Esempio n. 4
0
		<!-- JiaThis Button BEGIN -->
		<div id="ckepop">
			<span class="jiathis_txt">分享到:</span>
			<a class="jiathis_button_tools_1"></a>
			<a class="jiathis_button_tools_2"></a>
			<a class="jiathis_button_tools_3"></a>
			<a class="jiathis_button_tools_4"></a>
			<a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank">更多</a>
			<a class="jiathis_counter_style"></a>
		</div>
		<script type="text/javascript" src="http://v2.jiathis.com/code/jia.js" charset="utf-8"></script>
		<!-- JiaThis Button END -->
				
		<hr class="space" />
		<?php 
$this->widget('ext.links.prenext.PreNextWidget', array('id' => $model->id));
?>
		<hr class="space" />
		<div id="friends_view">
			
		</div>
		<?php 
$ids = Statistics::model()->historyViewStatistics($model);
?>
		
	</div>
	<hr class="space" />
	<br />	
</section>
<?php 
$this->widget('ext.syntaxhighlighter.syntaxhighlighterWidget');
Esempio n. 5
0
 /**
  * 统计
  *
  * @param string $action
  * @param string $view
  * @param string $timestamp   //2014-03-10 12:12:12
  * @param int    $user_id*
  * @param string $target_id*
  * @param string $result*
  */
 public function actionStatistics()
 {
     // 参数检查
     if (empty($_REQUEST['action']) || empty($_REQUEST['view']) || empty($_REQUEST['timestamp'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $action = trim(Yii::app()->request->getParam('action'));
     $view = trim(Yii::app()->request->getParam('view'));
     $timestamp = trim(Yii::app()->request->getParam('timestamp'));
     $user_id = trim(Yii::app()->request->getParam('user_id'));
     $target_id = trim(Yii::app()->request->getParam('target_id'));
     $result = trim(Yii::app()->request->getParam('result'));
     $time = strtotime($timestamp);
     //传入时间不能转换城时间戳返回参数错误
     if ($time === false) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     if (!is_numeric($user_id)) {
         $user_id = 0;
     }
     $year = date('Y', $time);
     $month = date('m', $time);
     $day = date('d', $time);
     $param = array('action' => $action, 'view' => $view, 'timestamp' => $timestamp, 'user_id' => $user_id, 'target_id' => $target_id, 'result' => $result, 'year' => $year, 'month' => $month, 'day' => $day, 'version' => $GLOBALS['__VERSION'], 'device_id' => $GLOBALS['__DEVICEID'], 'platform' => $GLOBALS['__PLATFORM'], 'channel' => $GLOBALS['__CHANNEL'], 'app_version' => $GLOBALS['__APPVERSION'], 'os_version' => $GLOBALS['__OSVERSION'], 'app_id' => $GLOBALS['__APPID'], 'ip' => $GLOBALS['__IP']);
     try {
         Statistics::model()->push($time, $param);
     } catch (Exception $e) {
         error_log($e);
         $this->_return('MSG_ERR_UNKOWN');
     }
     return $this->_return('MSG_SUCCESS');
 }