ctms/admins/controllers/IndexController.php
2025-04-10 23:19:13 +08:00

66 lines
1.8 KiB
PHP
Executable File

<?php
/**
* @Author: fm453
* @Date: 2018-04-23 14:25:38
# @Last modified by: fm453
# @Last modified time: 2021-09-14T12:16:02+08:00
* @Email: fm453@lukegzs.com
*/
//主入口页
namespace backend\controllers;
use Yii;
use common\models\CLog;
use common\models\User;
use common\models\Member;
use common\models\Fans;
use backend\models\Menu;
use yii\data\Pagination;
use yii\web\Controller;
class IndexController extends Controller
{
// public $enableCsrfValidation = false;
public function actionIndex()
{
return $this->render('index');
}
public function actionWelcome()
{
//登录记录
$query = CLog::find();
$nowTable = CLog::tablename();
$count = $query->count();
$pages = new Pagination(['totalCount' => $count,'pageSize' => '10']);
$log = $query->offset($pages->offset)
->limit($pages->limit)
->orderBy('id desc')
->all();
$sql = "SELECT *,FROM_UNIXTIME(create_time,'%Y-%m') as period,COUNT(*) as times FROM ".$nowTable." GROUP BY period LIMIT 12";
$History = Yii::$app->db->createCommand($sql)->queryAll();
$HistoryMonthStr = '';
$HistoryMonthNum = '';
foreach($History as $val){
$HistoryMonthStr .= "'".$val['period']."',";
$HistoryMonthNum .= $val['times'].",";
}
$HistoryMonthStr = substr($HistoryMonthStr,0,-1);
$HistoryMonthNum = substr($HistoryMonthNum,0,-1);
$keywords = '';
$description = '';
return $this->render('welcome',[
'log' => $log,
'pages' => $pages,
'HistoryMonthStr' => $HistoryMonthStr,
'HistoryMonthNum' => $HistoryMonthNum,
'keywords' => $keywords,
'description' => $description,
]);
}
}