public function run() { $this->publishAssets(); // $this->importQQWry(); // $ip = '125.68.45.237'; // // echo UtilTools::getClientIp().'lllll'; // // $qq = new QQWry($ip); // // echo $ip.ip2long($ip).$qq->getDetailInfo().$this->queryID; $visitors = Visitors::model()->getArticleVisitors($this->queryID); // UtilTools::dump($visitors); $this->render('visitors', array('visitors' => $visitors)); }
<?php //UtilTools::dump($visitors); ?> <?php if (!Yii::app()->user->isGuest) { ?> 最近访客:<br /> <?php foreach ($visitors as $vdata) { ?> <?php //UtilTools::dump($vdata->attributes); ?> <?php //echo $vdata->visitors_ip; ?> <?php echo Visitors::model()->getVisitorHead($vdata->visitors_ip, array('style' => 'width:50px;'), '最后访问时间:' . date('Y-m-d h:i:s', $vdata->visitors_lasttime)); ?> <?php } ?> <?php }
/** * 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 $id the ID of the model to be loaded * @return Visitors the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Visitors::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }