public function actionError() { AppLogService::addLog(); $reback_url = UrlService::buildWapUrl("/"); $this->layout = false; return $this->render("@blog/views/error/index.php", ["title" => "Page Not Found", "msg" => "404警告! 很不幸,您探索了一个未知领域!", "reback_url" => $reback_url]); }
private function search($params = []) { $p = isset($params['p']) ? $params['p'] : 1; $type = isset($params['type']) ? $params['type'] : 1; $offset = ($p - 1) * $this->page_size; $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; } $posts_info = $query->offset($offset)->limit($this->page_size)->all(); $data = []; if ($posts_info) { foreach ($posts_info as $_post) { $tmp_tags = explode(",", $_post['tags']); $data[] = ['title' => DataHelper::encode($_post['title']), 'content' => nl2br(UtilHelper::blog_short($_post['content'], 200)), "tags" => $tmp_tags, 'image_url' => $_post['image_url'], 'view_url' => UrlService::buildWapUrl("/default/info", ["id" => $_post['id']])]; } } return $data; }
public function actionError() { AppLogService::addLog(); $reback_url = UrlService::buildUrl("/"); if (preg_match("/^wap/", Yii::$app->request->getPathInfo())) { $reback_url = UrlService::buildWapUrl("/"); } $this->layout = false; return $this->render("index", ["title" => "Page Not Found", "msg" => "404警告! 很不幸,您探索了一个未知领域!", "reback_url" => $reback_url]); }
private function getAlbum() { $dir_path = \Yii::$app->params['upload']['pic3']; $album_list = []; if ($handle = opendir($dir_path)) { while (false !== ($entry = readdir($handle))) { if (in_array($entry, $this->ignore)) { continue; } $album_list[$entry] = ["name" => $entry, 'switch' => \Yii::$app->params['switch']['cdn']['pic3'] ? 1 : 0, "cover_src_url" => GlobalUrlService::buildPicStaticUrl("pic3", "/{$entry}/1.jpg"), "info_url" => UrlService::buildWapUrl("/gallery/list", ['album' => $entry])]; } closedir($handle); } return $album_list; }
public function actionCreate() { if (!$this->checkSignature()) { return false; } $from = $this->getSource(); $domains = Yii::$app->params['domains']; $domain_m = $domains['m']; $domain_blog = $domains['blog']; $menu = ["button" => [["name" => "博客", "sub_button" => [["type" => "click", "name" => "原创文章", "key" => "blog_original"], ["name" => "文章列表", "type" => "view", "url" => UrlService::buildWapUrl("/default/index", ["from" => $from])], ["type" => "view", "name" => "图书馆", "url" => UrlService::buildWapUrl("/library/index", ["from" => $from])], ["name" => "富媒体", "type" => "view", "url" => UrlService::buildWapUrl("/richmedia/index", ["from" => $from])]]], ["name" => "小玩意", "sub_button" => [["type" => "click", "name" => "点歌", "key" => "ktv"], ["type" => "view", "name" => "密码生成", "url" => UrlService::buildGameUrl("/tools/index", ['from' => $from])], ["type" => "view", "name" => "微信墙", "url" => UrlService::buildWapUrl("/wechat_wall/index", ['from' => $from])]]], ["name" => "关于", "sub_button" => [["type" => "view", "name" => "关于", "url" => UrlService::buildWapUrl("/my/about", ["from" => $from])], ["type" => "view", "name" => "赞助", "url" => UrlService::buildWapUrl("/my/about", ["from" => $from, "#" => "contact"])]]]]]; $access_token = WxrequestController::getAccessToken(); if (!$access_token) { $access_token = WxrequestController::getAccessToken(true); } return WxrequestController::send("menu/create?access_token=" . $access_token, json_encode($menu, JSON_UNESCAPED_UNICODE), 'POST'); }
public function actionInfo() { $song_id = $this->get("song_id", 1237792); $reback_url = UrlService::buildWapUrl("/default/index"); $type = intval($this->get("type", 2)); if (!$song_id) { return $this->redirect($reback_url); } $info = Music::findOne(['song_id' => $song_id, 'type' => $type, 'status' => 1]); if (!$info) { $info = QQMusicService::getSongInfo($song_id); QQMusicService::saveMusic($info); } $data = ["song_title" => DataHelper::encode($info['song_title']), "song_author" => DataHelper::encode($info['song_author']), "cover_image" => $info['cover_image'], "song_url" => $info['song_url'], "song_id" => $info['song_id']]; $this->setTitle("点歌台"); $this->setSubTitle("点歌台"); return $this->render("info", ["info" => $data]); }
public function beforeAction($action) { $this->setTitle(); $this->setDescription(); $this->setKeywords(); Yii::$app->response->getHeaders()->set("Content-Security-Policy", UtilHelper::getCspHeader(YII_ENV)); if (!UtilHelper::isPC() && !in_array($action->getUniqueId(), $this->ignoreRedirectAction)) { $url = UrlService::buildWapUrl("/" . $action->getUniqueId(), $_GET); $this->redirect($url); return false; } if (!in_array($action->getUniqueId(), $this->allowAllAction)) { } if (!$this->getUUID()) { $this->setUUID(); } return true; }
private function search($params = []) { $p = isset($params['p']) ? $params['p'] : 1; $offset = ($p - 1) * $this->page_size; $query = Book::find()->where(['status' => 1]); $books = $query->orderBy("id desc")->offset($offset)->limit($this->page_size)->all(); $data = []; if ($books) { foreach ($books as $_book) { $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, "(")); } $data[] = ["title" => DataHelper::encode($_book['subtitle']), 'author' => $tmp_author ? $tmp_author : " ", 'imager_url' => GlobalUrlService::buildPic1Static($_book['image_url']), 'view_url' => UrlService::buildWapUrl("/library/info", ["id" => $_book["id"]])]; } } return $data; }
public function actionDo() { $data = []; $kw = $this->get("kw", ""); if ($kw) { $this->setTitle($kw); $search_key = ['LIKE', 'search_key', '%' . strtr($kw, ['%' => '\\%', '_' => '\\_', '\\' => '\\\\']) . '%', false]; $query = IndexSearch::find()->where($search_key); $list = $query->orderBy("id desc")->all(); if ($list) { foreach ($list as $_item) { if ($_item['book_id']) { $tmp_title = DataHelper::encode($_item['title']); $tmp_view_url = UrlService::buildWapUrl("/library/info", ['id' => $_item['book_id']]); } else { $tmp_title = DataHelper::encode($_item['title']); $tmp_view_url = UrlService::buildWapUrl("/default/info", ['id' => $_item['post_id']]); } $data[] = ['title' => $tmp_title, 'content' => nl2br(UtilHelper::blog_short($_item['description'], 200)), 'image_url' => $_item['image'], 'view_url' => $tmp_view_url]; } } } return $this->render("do", ["post_list" => $data, 'kw' => $kw]); }
public function actionSitemap() { $data = []; $tags = []; $type = $this->get("type", "blog"); switch ($type) { case "m": $domain_host = Yii::$app->params['domains']['m']; $sitemap_filename = "m_sitemap.xml"; break; default: $domain_host = Yii::$app->params['domains']['blog']; $sitemap_filename = "sitemap.xml"; break; } $index_urls = ['m' => ["/default/index?type=1", "/default/index?type=2", "/default/index?type=3", "/library/index", "/richmedia/index", "/my/about", "http://www.vincentguo.cn"], 'blog' => ["/default/index?type=1", "/default/index?type=2", "/default/index?type=3", "/library/index", "/richmedia/index", "/default/donation", "/default/about", "http://m.vincentguo.cn"]]; if (isset($index_urls[$type])) { foreach ($index_urls[$type] as $_index_url) { if (preg_match("/^http/", $_index_url)) { $tmp_url = $_index_url; } else { if ($type == "m") { $tmp_url = UrlService::buildWapUrl($_index_url); } else { $tmp_url = UrlService::buildUrl($_index_url); } } $data[] = ["loc" => $tmp_url, "priority" => 1.0, "lastmod" => date("Y-m-d"), "changefreq" => "daily"]; } } $post_list = Posts::find()->where(["status" => 1])->orderBy("id desc")->all(); if ($post_list) { foreach ($post_list as $_post_info) { if ($type == "m") { $tmp_url = UrlService::buildWapUrl("/default/info", ["id" => $_post_info['id']]); } else { $tmp_url = UrlService::buildUrl("/default/info", ["id" => $_post_info['id']]); } $data[] = ["loc" => $tmp_url, "priority" => 1.0, "lastmod" => date("Y-m-d", strtotime($_post_info['updated_time'])), "changefreq" => "daily"]; $tmp_tags = explode(",", $_post_info['tags']); $tags = array_merge($tags, $tmp_tags); } } $book_list = Book::find()->where(['status' => 1])->orderBy("id desc")->all(); if ($book_list) { foreach ($book_list as $_book_info) { if ($type == "m") { $tmp_url = UrlService::buildWapUrl("/library/info", ["id" => $_book_info['id']]); } else { $tmp_url = UrlService::buildUrl("/library/info", ["id" => $_book_info['id']]); } $data[] = ["loc" => $tmp_url, "priority" => 1.0, "lastmod" => date("Y-m-d", strtotime($_book_info['updated_time'])), "changefreq" => "daily"]; $tmp_tags = explode(",", $_book_info['tags']); $tags = array_merge($tags, $tmp_tags); } } $tags = array_unique($tags); if ($tags) { foreach ($tags as $_tag) { if ($type == "m") { $tmp_url = UrlService::buildWapUrl("/search/do", ["kw" => $_tag]); } else { $tmp_url = UrlService::buildUrl("/search/do", ["kw" => $_tag]); } $data[] = ["loc" => $tmp_url, "priority" => 1.0, "lastmod" => date("Y-m-d", time()), "changefreq" => "daily"]; } } $xml_content = $this->renderPartial("sitemap", ["data" => $data]); $app_root = Yii::$app->getBasePath(); $file_path = $app_root . "/web/{$sitemap_filename}"; file_put_contents($file_path, $xml_content); $this->layout = false; return "ok"; }
<?php use blog\components\StaticService; use blog\components\UrlService; StaticService::includeAppCssStatic("/css/wap/richmedia/index.css", \blog\assets\WapAsset::className()); StaticService::includeAppJsStatic("/js/wap/richmedia/index.js", \blog\assets\WapAsset::className()); ?> <div class="am-g" id="se_btn"> <a href="javascript:void(0);" class="am-btn am-btn-default am-u-sm-6 am-u-md-6 am-u-lg-6 am-btn-primary"> 看今朝 </a> <a href="<?php echo UrlService::buildWapUrl("/gallery/index"); ?> " class="am-btn am-btn-default am-u-sm-6 am-u-md-6 am-u-lg-6"> 想当年 </a> </div> <ul data-am-widget="gallery" class="am-gallery am-avg-sm-1 am-gallery-overlay"> <?php echo $media_list_html; ?> </ul> <div class="am-g"> <div class="loading"> <div class="bubble"> <div class="bubble1"></div> <div class="bubble2"></div> </div> <p class="loading_txt">富媒体马上来</p> </div>
echo UrlService::buildWapUrl("/default/index", ["type" => 1]); ?> " class="am-btn am-btn-default am-u-sm-3 am-u-md-3">文章</a> <a href="<?php echo UrlService::buildWapUrl("/default/index", ["type" => 2]); ?> " class="am-btn am-btn-default am-u-sm-3 am-u-md-3">热门</a> <a href="<?php echo UrlService::buildWapUrl("/default/index", ["type" => 3]); ?> " class="am-btn am-btn-default am-u-sm-3 am-u-md-3">原创</a> <a href="<?php echo UrlService::buildWapUrl("/search/do"); ?> " class="am-btn am-btn-default am-u-sm-3 am-u-md-3"><span class="am-icon-search"></span></a> </div> <div data-am-widget="list_news" class="am-list-news am-list-news-default"> <div class="am-list-news-bd"> <ul class="am-list"> <?php echo $post_list_html; ?> </ul> </div> <div class="loading"> <div class="bubble"> <div class="bubble1"></div>
<?php } ?> </div> <?php } ?> <div class="am-panel am-panel-default" style="margin-top: 10px;"> <div class="am-panel-hd">智能推荐</div> <ul class="am-list"> <?php foreach ($recommend_blogs as $_recommend_blog_info) { ?> <li> <a href="<?php echo UrlService::buildWapUrl("/default/info", ["id" => $_recommend_blog_info["id"], "flag" => "recommend"]); ?> "><?php echo $_recommend_blog_info["title"]; ?> </a> </li> <?php } ?> </ul> </div> <div class="am-article-bd text-right" style="display: none;"> <i class="am-icon-btn am-warning am-icon-thumbs-up"></i> 喜欢
<?php use blog\components\StaticService; use blog\components\UrlService; StaticService::includeAppJsStatic("/js/wap/gallery/index.js", \blog\assets\WapAsset::className()); ?> <div class="am-g" id="se_btn"> <a href="<?php echo UrlService::buildWapUrl("/richmedia/index"); ?> " class="am-btn am-btn-default am-u-sm-6 am-u-md-6 am-u-lg-6"> 看今朝 </a> <a href="javascript:void(0);" class="am-btn am-btn-default am-u-sm-6 am-u-md-6 am-u-lg-6 am-btn-primary"> 想当年 </a> </div> <ul data-am-widget="gallery" class="am-gallery am-avg-sm-1 am-gallery-overlay am-no-layout" > <?php foreach ($gallery_list as $_item) { ?> <li> <div class="am-gallery-item"> <a href="<?php echo $_item["info_url"]; ?> "> <img data="<?php echo $_item["switch"]; ?> " data-src="<?php
<span class="am-icon-book"></span> <span class="am-navbar-label">图书馆</span> </a> </li> <li> <a href="<?php echo UrlService::buildWapUrl("/richmedia/index"); ?> " class="am-btn-default"> <span class="am-icon-picture-o"></span> <span class="am-navbar-label">富媒体</span> </a> </li> <li> <a href="<?php echo UrlService::buildWapUrl("/my/about"); ?> " class="am-btn-default"> <span class="am-icon-user"></span> <span class="am-navbar-label">关于</span> </a> </li> <li> <a href="<?php echo UrlService::buildGameUrl("/tools/index"); ?> " class="am-btn-default"> <span class="am-icon-gamepad"></span> <span class="am-navbar-label">小玩意</span> </a> </li>
<?php echo $_post_info['content']; ?> </div> </div> <?php if ($_post_info['tags']) { ?> <div class="am-g" style="display: none;"> <div class="am-u-sm-12" style="padding: 0;margin-top: 5px;"> <i class="am-icon-tags"></i> <?php foreach ($_post_info['tags'] as $_tag) { ?> <a href="<?php echo UrlService::buildWapUrl("/search/do", ['kw' => $_tag]); ?> "><?php echo $_tag; ?> </a> <?php } ?> </div> </div> <?php } ?> </li> <?php
public function actionWechat() { return $this->redirect(UrlService::buildWapUrl("/my/about#contact")); }
public function goLibraryHome() { return $this->redirect(UrlService::buildWapUrl("/library/index")); }
public function actionClear() { $this->removeAuthToken(); $url_blog = UrlService::buildWapUrl("/default/index"); $url_game = UrlService::buildGameUrl("/mv/index"); return <<<EOT <style> body{ font-size:3em; } </style> <a href="{$url_blog}">博客首页</a> <a href="{$url_game}">游戏中心</a> EOT; }