예제 #1
0
 /**
  * Lists all log models.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new LogSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if (strcasecmp(Yii::$app->request->method, 'delete') == 0) {
         Log::deleteAll($dataProvider->query->where);
         return $this->refresh();
     }
     $dataProvider->sort = ['defaultOrder' => ['log_time' => SORT_DESC]];
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied.
  *
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Log::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 60]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'level' => $this->level, 'log_time' => $this->log_time, 'message' => $this->message]);
     $query->andFilterWhere(['like', 'category', $this->category])->andFilterWhere(['like', 'prefix', $this->prefix]);
     return $dataProvider;
 }
예제 #3
0
 /**
  * Lists all Advert models.
  * @return mixed
  */
 public function actionDb()
 {
     $query = Log::find()->orderBy(['log_time' => SORT_DESC]);
     // Если задан интервал
     if ($interval = Yii::$app->request->get('interval')) {
         switch ($interval) {
             case 'today':
                 $query->andWhere(['>=', 'log_time', strtotime(date('Y-m-d') . ' 00:00:00')]);
                 break;
             case 'hour':
                 $query->andWhere(['>=', 'log_time', strtotime(date('Y-m-d H:i:s')) - 3600]);
                 break;
         }
     }
     // Постраничная навигация
     $countPosts = clone $query;
     $pages = new Pagination(['totalCount' => $countPosts->count(), 'route' => 'logs/db']);
     $messages = $query->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('db', ['messages' => $messages, 'pages' => $pages]);
 }
예제 #4
0
 public static function getSiteSummary()
 {
     $today_begin = date("Y-m-d") . " 00:00:00";
     $today_end = date("Y-m-d") . " 23:59:59";
     $yesterday_begin = date("Y-m-d 00:00:00", time() - 86400);
     $yesterday_end = date("Y-m-d 23:59:59", time() - 86400);
     // Статьи
     $summary['postsCount'] = Post::find()->count();
     $summary['postsToday'] = Post::find()->where(['between', 'date', $today_begin, $today_end])->count();
     $summary['postsYesterday'] = Post::find()->where(['between', 'date', $yesterday_begin, $yesterday_end])->count();
     // Пользователи
     $summary['usersCount'] = User::find()->count();
     $summary['usersToday'] = User::find()->where(['between', 'created_at', strtotime($today_begin), strtotime($today_end)])->count();
     $summary['usersYesterday'] = User::find()->where(['between', 'created_at', strtotime($yesterday_begin), strtotime($yesterday_end)])->count();
     // Комментарии
     $summary['commentsCount'] = Comment::find()->count();
     $summary['commentsToday'] = Comment::find()->where(['between', 'date', $today_begin, $today_end])->count();
     $summary['commentsYesterday'] = Comment::find()->where(['between', 'date', $yesterday_begin, $yesterday_end])->count();
     // Ошибки
     $summary['errorsCount'] = Log::find()->count();
     $summary['errorsToday'] = Log::find()->where(['between', 'log_time', strtotime($today_begin), strtotime($today_end)])->count();
     $summary['errorsYesterday'] = Log::find()->where(['between', 'log_time', strtotime($yesterday_begin), strtotime($yesterday_end)])->count();
     return $summary;
 }
예제 #5
0
<?php

use backend\models\Log;
use backend\widgets\Menu;
/* @var $this \yii\web\View */
?>
<aside class="main-sidebar">
    <section class="sidebar">
        <?php 
echo Menu::widget(['options' => ['class' => 'sidebar-menu'], 'items' => [['label' => Yii::t('backend', 'Main'), 'options' => ['class' => 'header']], ['label' => Yii::t('backend', 'Menu'), 'url' => ['/menu/index'], 'icon' => '<i class="fa fa-sitemap"></i>'], ['label' => Yii::t('backend', 'Tags'), 'url' => ['/tag/index'], 'icon' => '<i class="fa fa-tags"></i>'], ['label' => Yii::t('backend', 'Content'), 'url' => '#', 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'Static pages'), 'url' => ['/page/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Articles'), 'url' => ['/article/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Article categories'), 'url' => ['/article-category/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>']]], ['label' => Yii::t('backend', 'System'), 'options' => ['class' => 'header']], ['label' => Yii::t('backend', 'Users'), 'url' => ['/user/index'], 'icon' => '<i class="fa fa-users"></i>', 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('backend', 'Other'), 'url' => '#', 'icon' => '<i class="fa fa-terminal"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => 'Gii', 'url' => ['/gii'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'visible' => YII_ENV_DEV], ['label' => 'Web shell', 'url' => ['/webshell'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('backend', 'File manager'), 'url' => ['/file-manager/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'DB manager'), 'url' => ['/db-manager/default/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('backend', 'Key storage'), 'url' => ['/key-storage/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Cache'), 'url' => ['/cache/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Logs'), 'url' => ['/log/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'badge' => Log::find()->count(), 'badgeBgClass' => 'label-danger']]]]]);
?>
    </section>
</aside>
예제 #6
0
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-warning"></i>
                        <span class="label label-danger"><?php 
echo Log::find()->count();
?>
</span>
                    </a>
                    <ul class="dropdown-menu">
                        <li class="header"><?php 
echo Yii::t('backend', 'You have {num} log items', ['num' => Log::find()->count()]);
?>
</li>
                        <li>
                            <ul class="menu">
                                <?php 
foreach (Log::find()->orderBy(['log_time' => SORT_DESC])->limit(5)->all() as $logEntry) {
    ?>
                                    <li>
                                        <a href="<?php 
    echo Url::to(['/log/view', 'id' => $logEntry->id]);
    ?>
">
                                            <i class="fa fa-warning <?php 
    echo $logEntry->level == Logger::LEVEL_ERROR ? 'text-red' : 'text-yellow';
    ?>
"></i>
                                            <?php 
    echo $logEntry->category;
    ?>
                                        </a>
                                    </li>