Пример #1
0
            <div class="col col-sm-12">
                <h5>
                    <?php 
echo Yii::t('BbiiModule.bbii', '{0} guest(s) and {1} active member(s)', array($present - $members > 0 ?: 0, $members));
?>
                    <small><?php 
echo Yii::t('BbiiModule.bbii', '(in the past 15 minutes)');
?>
</small>
                </h5>
                <?php 
$members = BbiiMember::find()->present()->show()->findAll();
foreach ($members as $member) {
    echo Html::a($member->member_name, array('member/view', 'id' => $member->id), array('style' => 'color:#' . $member->group->color)) . '&nbsp;';
}
$spiders = BbiiSpider::find()->present()->findAll();
foreach ($spiders as $spider) {
    echo Html::a($spider->name, $spider->url, array('class' => 'spider', 'target' => '_new')) . '&nbsp;';
}
?>
                <br />
                <?php 
echo Yii::t('BbiiModule.bbii', '({0} anonymous member(s))', array(BbiiMember::find()->hidden()->present()->count()));
?>
            </div>
        </div>
        <div class="col-sm-12 col-md-4 statistics">
            <h4>
                <?php 
echo Yii::t('BbiiModule.bbii', 'Board Statistics');
?>
Пример #2
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * 
  * @param  [type] $params [description]
  * @return ActiveDataProvider The data provider that can return the models based on the search/filter conditions.
  */
 public function search($params = null)
 {
     $query = BbiiSpider::find();
     $dataProvider = new ActiveDataProvider(['pagination' => array('pageSize' => 50), 'query' => $query, 'sort' => array('defaultOrder' => 'last_visit DESC')]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->addCondition('id', $this->id, true);
     $this->addCondition('last_visit', $this->last_visit, true);
     $this->addCondition('name', $this->name, true);
     $this->addCondition('user_agent', $this->user_agent, true);
     return $dataProvider;
 }
Пример #3
0
 public function actionUpdatespider($id = null)
 {
     $id = is_numeric($id) ? $id : \Yii::$app->request->get('id');
     $model = BbiiSpider::find()->where(['id' => $id])->one();
     // set data
     if ($model->load(\Yii::$app->request->post())) {
         // validate and save
         if ($model->validate() && $model->save()) {
             \Yii::$app->getSession()->addFlash('success', Yii::t('BbiiModule.bbii', 'Change saved.'));
             return \Yii::$app->response->redirect('spider');
             // error when saving
         }
     } else {
         return $this->render('update/spider', ['model' => $model]);
     }
 }
Пример #4
0
 /**
  * this method is called before any module controller action is performed
  * you may place customized code here
  *
  * @version  2.2.0
  * @param  [type] $controller [description]
  * @param  [type] $action     [description]
  * @return [type]             [description]
  */
 public function beforeAction($controller, $action = null)
 {
     if (parent::beforeAction($controller, $action)) {
         // register last visit by member
         if (\Yii::$app->user->identity->id) {
             //$model = BbiiMember::find(\Yii::$app->user->identity->id );
             $model = BbiiMember::find()->where(['id' => \Yii::$app->user->identity->id])->one();
             if ($model !== null) {
                 $model->setAttribute('last_visit', date('Y-m-d H:i:s'));
                 $model->save();
             } else {
                 $userClass = new User();
                 $user = $userClass::find()->where([$this->userIdColumn => \Yii::$app->user->identity->id])->one();
                 $username = $user->getAttribute($this->userNameColumn);
                 $model = new BbiiMember();
                 $model->setAttribute('first_visit', date('Y-m-d H:i:s'));
                 $model->setAttribute('id', \Yii::$app->user->identity->id);
                 $model->setAttribute('last_visit', date('Y-m-d H:i:s'));
                 $model->setAttribute('member_name', $username);
                 $model->save();
             }
         }
         // register visits
         if (isset($_SERVER['HTTP_USER_AGENT'])) {
             // web spider visit
             $spider = BbiiSpider::find()->where(['user_agent' => $_SERVER['HTTP_USER_AGENT']])->one();
             if ($spider !== null) {
                 $spider->setScenario('visit');
                 $spider->hits++;
                 $spider->last_visit = null;
                 if (!$spider->validate() || !$spider->save()) {
                     // todo Some kind of logging when the spider model does not validate or save - DJE : 2015-07-20
                 }
                 // guest visit
             } else {
                 $model = BbiiSession::find()->where(['id' => \Yii::$app->session->getId()])->one();
                 $model = $model ?: new BbiiSession();
                 $model->id = \Yii::$app->session->getId();
                 if (!$model->validate() || !$model->save()) {
                     // todo Some kind of logging when the user model does not validate or save - DJE : 2015-07-20
                 }
             }
         }
         // delete older session entries
         BbiiSession::deleteAll('last_visit < \'' . date('Y-m-d H:i:s', time() - 24 * 3600) . '\'');
         return true;
     }
     return false;
 }