示例#1
0
 public function actionIndex()
 {
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $data = [];
     $pagesize = 20;
     $query = RichMedia::find()->where(['status' => [0, 1]]);
     $total_count = $query->count();
     $offset = ($p - 1) * $pagesize;
     $rich_list = $query->orderBy("id desc")->offset($offset)->limit($pagesize)->all();
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $pagesize, "page" => $p, "display" => 10]);
     if ($rich_list) {
         $idx = 1;
         $domains = Yii::$app->params['domains'];
         foreach ($rich_list as $_rich_info) {
             $tmp_small_pic_url = GlobalUrlService::buildPic1Static($_rich_info['src_url'], ['h' => 100]);
             $tmp_big_pic_url = GlobalUrlService::buildPic1Static($_rich_info['src_url'], ['w' => 600]);
             $data[] = ['idx' => $idx, 'id' => $_rich_info['id'], 'small_src_url' => $tmp_small_pic_url, 'big_src_url' => $tmp_big_pic_url, 'src_url' => $tmp_small_pic_url, 'thumb_url' => $_rich_info['thumb_url'] ? $_rich_info['thumb_url'] : $domains['static'] . "/wx/video_cover.jpg", 'type' => $_rich_info['type'], 'address' => $_rich_info['address'], 'status' => $_rich_info['status'], 'status_info' => $this->status_desc[$_rich_info['status']], 'created' => $_rich_info['created_time']];
             $idx++;
         }
     }
     return $this->render("index", ["data" => $data, "page_info" => $page_info]);
 }
示例#2
0
 public function actionError()
 {
     $type = intval($this->get("type", 0));
     $log_type_mapping = $this->log_type_mapping;
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $data = [];
     $query = AppLogs::find();
     if (isset($log_type_mapping[$type])) {
         $query->andWhere(['app_name' => $log_type_mapping[$type]]);
     }
     $total_count = $query->count();
     $offset = ($p - 1) * $this->page_size;
     $access_list = $query->orderBy("id desc")->offset($offset)->limit($this->page_size)->all();
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $this->page_size, "page" => $p, "display" => 10]);
     if ($access_list) {
         $idx = 1;
         foreach ($access_list as $_item_access) {
             $data[] = ['idx' => $idx, 'app_name' => $_item_access['app_name'], 'request_uri' => $_item_access['request_uri'], 'content' => mb_strlen($_item_access['content'], "utf-8") > 150 ? DataHelper::encode(mb_substr($_item_access['content'], 0, 150, "utf-8")) : DataHelper::encode($_item_access['content']), 'ua' => $_item_access['ua'], 'ip' => $_item_access['ip'], 'cookies' => DataHelper::encode($_item_access['cookies']), 'created_time' => $_item_access['created_time']];
             $idx++;
         }
     }
     $search_conditions = ['type' => $type];
     return $this->render("error", ["data" => $data, "page_info" => $page_info, 'search_conditions' => $search_conditions, 'log_type_mapping' => $log_type_mapping]);
 }
示例#3
0
 public function actionIndex()
 {
     $this->setTitle("图书馆");
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $data = [];
     $pagesize = 20;
     $offset = ($p - 1) * $pagesize;
     $query = Book::find()->where(['status' => 1]);
     $total_count = $query->count();
     $books = $query->orderBy("id desc")->offset($offset)->limit($pagesize)->all();
     if ($books) {
         foreach ($books as $_book) {
             $tmp_title = DataHelper::encode($_book['subtitle']);
             $tmp_title = mb_substr($tmp_title, 0, 10, "utf-8");
             $tmp_author = @json_decode($_book['creator'], true);
             $tmp_author = $tmp_author ? $tmp_author[0] : ' ';
             if (stripos($tmp_author, "(") !== false) {
                 $tmp_author = substr($tmp_author, 0, stripos($tmp_author, "("));
             }
             if (stripos($tmp_author, "(") !== false) {
                 $tmp_author = substr($tmp_author, 0, stripos($tmp_author, "("));
             }
             $tmp_small_pic_url = GlobalUrlService::buildPic1Static($_book['image_url'], ['h' => 200]);
             switch ($_book['read_status']) {
                 case 1:
                     $tmp_icon_imager_url = GlobalUrlService::buildStaticUrl("/images/web/readed.png");
                     break;
                 case -1:
                     $tmp_icon_imager_url = GlobalUrlService::buildStaticUrl("/images/web/reading.png");
                     break;
                 default:
                     $tmp_icon_imager_url = GlobalUrlService::buildStaticUrl("/images/web/unread.png");
                     break;
             }
             $data[] = ['id' => $_book['id'], 'short_title' => $tmp_title, "title" => DataHelper::encode($_book['subtitle']), 'author' => $tmp_author ? $tmp_author : " ", 'imager_url' => $tmp_small_pic_url, 'icon_imager_url' => $tmp_icon_imager_url, 'view_url' => Url::toRoute(["/library/info", "id" => $_book["id"]])];
         }
     }
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $pagesize, "page" => $p, "display" => 5]);
     return $this->render("index", ["data" => $data, "page_info" => $page_info]);
 }
示例#4
0
 public function actionMz()
 {
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $pagesize = 20;
     $query = Doubanmz::find();
     $total_count = $query->count();
     $offset = ($p - 1) * $pagesize;
     $mz_list = $query->orderBy("id desc")->offset($offset)->limit($pagesize)->all();
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $pagesize, "page" => $p, "display" => 10]);
     $data = [];
     if ($mz_list) {
         foreach ($mz_list as $_mz_info) {
             $data[] = ["id" => $_mz_info["id"], "title" => mb_substr(DataHelper::encode($_mz_info["title"]), 0, 10, "utf-8"), "src_url" => $_mz_info['src_url']];
         }
     }
     return $this->render("mz", ["mz_list" => $data, "page_info" => $page_info, "page_url" => "/douban/mz"]);
 }
示例#5
0
 public function actionIndex()
 {
     $p = intval($this->get("p", 1));
     $status = intval($this->get("status", -99));
     $order_by = $this->get("order_by", '');
     $kw = trim($this->get("kw", ''));
     if (!$p) {
         $p = 1;
     }
     $data = [];
     $query = Posts::find();
     if ($status >= -2) {
         $query->andWhere(['status' => $status]);
     }
     if ($kw) {
         $query->andWhere(['LIKE', 'title', '%' . strtr($kw, ['%' => '\\%', '_' => '\\_', '\\' => '\\\\']) . '%', false]);
     }
     $total_count = $query->count();
     if ($order_by) {
         $query->orderBy([$order_by => $this->get($order_by) ? SORT_DESC : SORT_ASC]);
     } else {
         $query->orderBy(['id' => SORT_DESC]);
     }
     $offset = ($p - 1) * $this->page_size;
     $posts_info = $query->offset($offset)->limit($this->page_size)->asArray()->all();
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $this->page_size, "page" => $p, "display" => 10]);
     if ($posts_info) {
         $idx = 1;
         $domains = Yii::$app->params['domains'];
         foreach ($posts_info as $_post) {
             $tmp_title = $_post['title'];
             if (mb_strlen($tmp_title, "utf-8") > 30) {
                 $tmp_title = mb_substr($_post['title'], 0, 30, 'utf-8') . "...";
             }
             $data[] = ['idx' => $idx, 'id' => $_post['id'], 'title' => DataHelper::encode($tmp_title), 'status' => $_post['status'], 'hot' => $_post['hot'], 'view_count' => $_post['view_count'], 'status_info' => Constant::$status_desc[$_post['status']], "original_info" => Constant::$original_desc[$_post['original']], "hot_info" => Constant::$hot_desc[$_post['hot']], 'created' => $_post['created_time'], 'edit_url' => Url::toRoute("/posts/set?id={$_post['id']}"), 'view_url' => $domains['blog'] . Url::toRoute("/default/{$_post['id']}")];
             $idx++;
         }
     }
     $search_conditions = ['kw' => $kw, 'status' => $status, 'order_by' => $order_by, $order_by => $this->get($order_by)];
     return $this->render("index", ["data" => $data, "page_info" => $page_info, "search_conditions" => $search_conditions, 'status_mapping' => Constant::$status_desc]);
 }
示例#6
0
 public function actionDo()
 {
     $kw = trim($this->get("kw", ""));
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $data = [];
     if (!$kw) {
         return $this->redirect("/");
     }
     $this->setTitle($kw);
     $pagesize = 10;
     $offset = ($p - 1) * $pagesize;
     $search_key = ['LIKE', 'search_key', '%' . strtr($kw, ['%' => '\\%', '_' => '\\_', '\\' => '\\\\']) . '%', false];
     $query = IndexSearch::find()->where($search_key);
     $total_count = $query->count();
     $list = $query->orderBy("id desc")->limit($pagesize)->offset($offset)->all();
     if ($list) {
         $book_mapping = DataHelper::getDicByRelateID($list, Book::className(), "book_id", "id", ["subtitle", "summary", "origin_image_url", "tags"]);
         $post_mapping = DataHelper::getDicByRelateID($list, Posts::className(), "post_id", "id", ["title", "content", "tags"]);
         foreach ($list as $_item) {
             if ($_item['book_id']) {
                 $tmp_target = $book_mapping[$_item['book_id']];
                 $tmp_content = mb_substr($tmp_target['summary'], 0, 105, "utf-8");
                 $tmp_title = DataHelper::encode($tmp_target['subtitle']);
                 $tmp_view_url = Url::toRoute("/library/detail/{$_item['book_id']}");
             } else {
                 $tmp_target = $post_mapping[$_item['post_id']];
                 $tmp_content = UtilHelper::blog_summary($tmp_target['content'], 105);
                 $tmp_title = DataHelper::encode($tmp_target['title']);
                 $tmp_view_url = Url::toRoute("/default/{$_item['post_id']}");
             }
             $tags = explode(",", $tmp_target['tags']);
             $data[] = ['title' => $tmp_title, 'content' => nl2br($tmp_content), 'tags' => $tags, 'date' => date("Y年m月d日"), 'view_url' => $tmp_view_url];
         }
     }
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $pagesize, "page" => $p, "display" => 5]);
     return $this->render("result", ["data" => $data, "page_info" => $page_info, "urls" => ["page_base" => Url::toRoute(["/search/do", "kw" => $kw])]]);
 }
示例#7
0
 public function actionIndex()
 {
     $type = intval($this->get("type", 1));
     $type = in_array($type, [1, 2, 3]) ? $type : 1;
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $data = [];
     $pagesize = 10;
     $offset = ($p - 1) * $pagesize;
     $query = Posts::find()->where(['status' => 1]);
     switch ($type) {
         case 2:
             $query->orderBy(['view_count' => SORT_DESC]);
             break;
         case 3:
             $query->andWhere(['original' => 1]);
             $query->orderBy(['id' => SORT_DESC]);
             break;
         default:
             $query->orderBy(['id' => SORT_DESC]);
             break;
     }
     $total_count = $query->count();
     $posts_info = $query->offset($offset)->limit($pagesize)->all();
     if ($posts_info) {
         $idx = 1;
         $author = Yii::$app->params['author'];
         foreach ($posts_info as $_post) {
             $tmp_content = UtilHelper::blog_summary($_post['content'], 105);
             $tags = explode(",", $_post['tags']);
             $data[] = ['idx' => $idx, 'id' => $_post['id'], 'title' => DataHelper::encode($_post['title']), 'content' => nl2br($tmp_content), 'original' => $_post['original'], 'view_count' => $_post['view_count'], 'author' => $author, 'tags' => $tags, 'date' => date("Y.m.d", strtotime($_post['updated_time'])), 'view_url' => UrlService::buildUrl("/default/info", ["id" => $_post['id']])];
         }
     }
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $pagesize, "page" => $p, "display" => 5]);
     $tags = CacheHelperService::getFrontCache("tag");
     return $this->render("index", ["data" => $data, "page_info" => $page_info, "type" => $type, "hot_kws" => array_slice($tags, 0, 5)]);
 }
示例#8
0
 public function actionIndex()
 {
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $data = [];
     $pagesize = 20;
     $query = Book::find();
     $total_count = $query->count();
     $offset = ($p - 1) * $pagesize;
     $book_info = $query->orderBy("id desc")->offset($offset)->limit($pagesize)->all();
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $pagesize, "page" => $p, "display" => 10]);
     if ($book_info) {
         $idx = 1;
         $domains = Yii::$app->params['domains'];
         foreach ($book_info as $_book) {
             $tmp_title = $_book['subtitle'];
             $data[] = ['idx' => $idx, 'id' => $_book['id'], 'title' => DataHelper::encode($tmp_title), 'read_status' => $_book['read_status'], 'read_status_info' => Constant::$read_desc[$_book['read_status']], 'read_start_time' => date("Y-m-d", strtotime($_book['read_start_time'])), 'read_end_time' => date("Y-m-d", strtotime($_book['read_end_time'])), 'status' => $_book['status'], 'status_info' => Constant::$status_desc[$_book['status']], 'created' => $_book['created_time'], 'edit_url' => AdminUrlService::buildUrl("/library/info", ["id" => $_book['id']]), 'view_url' => $domains['blog'] . Url::toRoute("/library/detail/{$_book['id']}")];
             $idx++;
         }
     }
     return $this->render("index", ["data" => $data, "read_status" => Constant::$read_desc, "page_info" => $page_info, "page_url" => "/library/index"]);
 }
示例#9
0
 public function actionIndex()
 {
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $data = [];
     $pagesize = 20;
     $query = Images::find();
     $total_count = $query->count();
     $offset = ($p - 1) * $pagesize;
     $image_list = $query->orderBy("id desc")->offset($offset)->limit($pagesize)->all();
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $pagesize, "page" => $p, "display" => 10]);
     if ($image_list) {
         $idx = 1;
         foreach ($image_list as $_image_info) {
             $tmp_small_pic_url = GlobalUrlService::buildPicStatic($_image_info['filepath'], ['h' => 100, 'w' => 200], $_image_info['bucket']);
             $tmp_big_pic_url = GlobalUrlService::buildPicStatic($_image_info['filepath'], ['w' => 600], $_image_info['bucket']);
             $data[] = ['idx' => $idx, 'id' => $_image_info['id'], 'small_pic_url' => $tmp_small_pic_url, 'big_pic_url' => $tmp_big_pic_url];
             $idx++;
         }
     }
     return $this->render("index", ["data" => $data, "page_info" => $page_info, "page_url" => "/file/index"]);
 }
示例#10
0
 public function actionCsp()
 {
     $date_from = $this->get("date_from", date("Y-m-d"));
     $date_to = $this->get("date_to", date("Y-m-d"));
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $query = AdCspReport::find();
     if ($date_from) {
         $query->andWhere(['>=', 'created_time', date("Y-m-d", strtotime($date_from))]);
     }
     if ($date_from) {
         $query->andWhere(['<=', 'created_time', date("Y-m-d 23:59:59", strtotime($date_to))]);
     }
     $total_count = $query->count();
     $offset = ($p - 1) * $this->page_size;
     $list = $query->orderBy(['id' => SORT_DESC])->offset($offset)->limit($this->page_size)->all();
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $this->page_size, "page" => $p, "display" => 10]);
     $data = [];
     if ($list) {
         $idx = 1;
         foreach ($list as $_item) {
             $data[] = ['idx' => $idx, 'created_time' => $_item['created_time'], 'blocked_uri' => $_item['blocked_uri'], 'source_file' => $_item['source_file']];
             $idx++;
         }
     }
     $search_conditions = ['date_from' => $date_from, 'date_to' => $date_to];
     return $this->render("csp", ["data" => $data, "page_info" => $page_info, 'search_conditions' => $search_conditions]);
 }