Exemplo n.º 1
0
 public function actionAdd_comment()
 {
     $discuss = new Discuss();
     $ip = Yii::$app->getRequest()->getUserIP();
     //echo $ip;
     date_default_timezone_set('Asia/Shanghai');
     $discuss->createTime = date('Y-m-d H:i:s');
     $discuss->message = $_POST['msg'];
     $discuss->ip = $ip;
     $discuss->save();
     $html = '<li>
                 <p>
                     <span class="username"></span>' . $ip . '<br />
                 </p>
                 <p>
                     <span >' . $discuss->message . '</span>
                 </p>
                 <p class="no-pad-bottom date-posted">Posted <span />' . $discuss->createTime . '</p>
             </li>';
     return $html;
     //$discusses = Discuss::find()->orderBy('createTime desc')->all();
     //  var_dump($news);
     //echo $news[0]->title;
     //return $this->actionIndex();
 }
Exemplo n.º 2
0
 public function actionCat()
 {
     $id = $_REQUEST['id'];
     $model = new Discuss();
     $arr['forum'] = $model->getCat(['_id' => "{$id}"]);
     return $this->renderPartial('forum', $arr);
 }
Exemplo n.º 3
0
 public function actionMain()
 {
     //用户统计
     $user = new User();
     $arr['user_count'] = $user->getCount();
     $before = strtotime(date('Y-m-d 00:00:00', time()));
     //今天凌晨时间
     $after = strtotime(date('Y-m-d 00:00:00', strtotime("-7 day")));
     //七天前
     $after6 = strtotime(date('Y-m-d 00:00:00', strtotime("-6 day")));
     //6天前
     $after5 = strtotime(date('Y-m-d 00:00:00', strtotime("-5 day")));
     //5天前
     $after4 = strtotime(date('Y-m-d 00:00:00', strtotime("-4 day")));
     //4天前
     $after3 = strtotime(date('Y-m-d 00:00:00', strtotime("-3 day")));
     //3天前
     $after2 = strtotime(date('Y-m-d 00:00:00', strtotime("-2 day")));
     //2天前
     $after1 = strtotime(date('Y-m-d 00:00:00', strtotime("-1 day")));
     //1天前
     $arr['day']['0'] = "'" . '昨天' . "'";
     //3天前
     $arr['day']['1'] = "'" . '前天' . "'";
     //3天前
     $arr['day']['2'] = "'" . date('m月d日', strtotime("-3 day")) . "'";
     //3天前
     $arr['day']['3'] = "'" . date('m月d日', strtotime("-4 day")) . "'";
     //4天前
     $arr['day']['4'] = "'" . date('m月d日', strtotime("-5 day")) . "'";
     //5天前
     $arr['day']['5'] = "'" . date('m月d日', strtotime("-6 day")) . "'";
     //6天前
     $arr['day']['6'] = "'" . date('m月d日', strtotime("-7 day")) . "'";
     //七天前
     $arr['user_register'] = $user->getCount(['between', 'reg_time', "{$after}", "{$before}"]);
     //获取最近七天注册的用户
     $arr['num']['0'] = $user->getCount(['between', 'reg_time', "{$after1}", "{$before}"]);
     $arr['num']['1'] = $user->getCount(['between', 'reg_time', "{$after2}", "{$after1}"]);
     $arr['num']['2'] = $user->getCount(['between', 'reg_time', "{$after3}", "{$after2}"]);
     $arr['num']['3'] = $user->getCount(['between', 'reg_time', "{$after4}", "{$after3}"]);
     $arr['num']['4'] = $user->getCount(['between', 'reg_time', "{$after5}", "{$after4}"]);
     $arr['num']['5'] = $user->getCount(['between', 'reg_time', "{$after6}", "{$after5}"]);
     $arr['num']['6'] = $user->getCount(['between', 'reg_time', "{$after}", "{$after6}"]);
     $arr['day'] = implode(',', $arr['day']);
     $arr['num'] = implode(',', $arr['num']);
     //话题统计
     $discuss = new Discuss();
     $arr['forum_count'] = $discuss->getCount();
     return $this->renderPartial('main', $arr);
 }