redirect("news/list"); } public function actionView() { $cache = Yii::$app->memcache; $user = Yii::$app->user->identity->profile->name; $id = Yii::$app->user->identity->profile->user_id; $mduser = $id; $uactive = $cache->get(self::keylist); $html = ''; if( $uactive ){ $uactive = unserialize($uactive); $html = $this->renderPartial('_item',['users'=>$uactive, 'obj'=>$this, 'id'=>$id]); }else{ $html = ''; } return $this->render("view", ['html'=>$html]); } public function actionAuthorping() { $cache = Yii::$app->memcache; $user = Yii::$app->user->identity->profile->name; $id = Yii::$app->user->identity->profile->user_id; $mduser = $id; $uactive = $cache->get(self::keylist); $html = ''; if( $uactive ){ $uactive = unserialize($uactive); $uactive[$mduser] = ['name'=>$user, 'time' => time(), 'id' => $id]; $cache->set( self::keylist, serialize($uactive), self::dead ); $a = []; foreach($uactive as $userid => $data){ if( time()-$data['time'] < self::kill ){ $a[$userid] = $data; } } $uactive = $a; $html = $this->renderPartial('list',['users'=>$uactive, 'obj'=>$this, 'id'=>$id]); }else{ $uactive = []; $uactive[$mduser] = ['name'=>$user, 'time' => time(), 'id' => $id]; $cache->add( self::keylist, serialize($uactive), self::dead ); } return json_encode( ['status'=>'ok', 'html'=>$html, 'count' =>count($uactive)] ); } }