Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public function actionInfo($id)
 {
     $id = intval($id);
     if (!$id) {
         return $this->goLibraryHome();
     }
     $book_info = Book::find()->where(['id' => $id, 'status' => 1])->one();
     if (!$book_info) {
         return $this->goLibraryHome();
     }
     $data = [];
     $author = json_decode($book_info['creator'], true);
     $data['name'] = DataHelper::encode($book_info['name']);
     $data['title'] = DataHelper::encode($book_info['subtitle']);
     $data['summary'] = nl2br(DataHelper::encode($book_info['summary']));
     $data['publish_date'] = $book_info['publish_date'];
     $data['author'] = implode(" ~ ", $author);
     $data['tags'] = explode(",", $book_info['tags']);
     $data['read_status_info'] = Constant::$read_desc[$book_info['read_status']];
     $data['image_url'] = GlobalUrlService::buildPic1Static($book_info['image_url'], ['w' => 500]);
     $data['isbn'] = $book_info['isbn'];
     $prev_info = Book::find()->where(["<", "id", $id])->andWhere(['status' => 1])->orderBy("id desc")->one();
     $next_info = Book::find()->where([">", "id", $id])->andWhere(['status' => 1])->orderBy("id asc")->one();
     $this->setTitle($book_info['subtitle']);
     return $this->render("detail", ["info" => $data, "prev_info" => $prev_info, "next_info" => $next_info]);
 }
Exemplo n.º 3
0
    public function actionGet_latest_message()
    {
        $max_id = intval($this->post("max_id", 0));
        if (!$max_id) {
            return $this->renderJSON([], "", -1);
        }
        $info = UserMessageHistory::find()->where(['status' => 1])->andWhere([">", "id", $max_id])->orderBy("id desc")->limit(1)->one();
        if (!$info) {
            return $this->renderJSON();
        }
        $user_info = User::findOne(['uid' => $info['uid']]);
        $data = ["id" => $info['id'], "nickname" => DataHelper::encode($user_info['nickname']), "avatar" => $user_info['avatar'] ? $user_info['avatar'] : GlobalUrlService::buildStaticUrl("/images/wap/no_avatar.png"), "content" => DataHelper::encode($info['content']), "created_time" => date("Y-m-d H:i", strtotime($info['created_time']))];
        $html = <<<EOT
<li class="am-comment" data_id="{$data['id']}">
                <a href="javascript:void(0);">
                    <img src="{$data['avatar']}" alt="" class="am-comment-avatar" width="48" height="48"/>
                </a>
                <div class="am-comment-main">
                    <header class="am-comment-hd">
                        <div class="am-comment-meta">
                            <a href="javascript:void(0);" class="am-comment-author">{$data['nickname']}</a>
                            上墙于 <time>{$data['created_time']}</time>
                        </div>
                    </header>
                    <div class="am-comment-bd">
                        {$data['content']}
                    </div>
                </div>
            </li>
EOT;
        return $this->renderJSON(['message' => $html]);
    }
Exemplo n.º 4
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]);
 }
Exemplo n.º 5
0
 public function actionIndex()
 {
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $pagesize = 10;
     $query = Doubanmz::find();
     $total_count = $query->count();
     $total_page = ceil($total_count / $pagesize);
     $offset = ($p - 1) * $pagesize;
     $mz_list = $query->orderBy("id desc")->offset($offset)->limit($pagesize)->all();
     $data = [];
     if ($mz_list) {
         foreach ($mz_list as $_mz_info) {
             $data[] = ["id" => $_mz_info["id"], "title" => DataHelper::encode($_mz_info["title"]), "src_url" => $_mz_info['src_url']];
         }
     }
     $has_pre = $has_next = false;
     if (count($data) >= $pagesize && $p <= $total_page) {
         $has_next = true;
     }
     if ($p > 1) {
         $has_pre = true;
     }
     $this->setTitle("美女也耍流氓 -- 一睹眼福");
     $this->setSubTitle("美女耍流氓");
     return $this->render("index", ["list" => $data, "p" => $p, "urls" => ["has_pre" => $has_pre, "has_next" => $has_next]]);
 }
Exemplo n.º 6
0
 public function actionList()
 {
     $data = [];
     $list = MateList::find()->orderBy("id desc")->all();
     foreach ($list as $_item) {
         $data[] = ["nickname" => DataHelper::encode($_item['nickname']), "mobile" => $_item['mobile'] ? substr_replace($_item['mobile'], '****', 3, 4) : "", "person_num" => $_item['person_num']];
     }
     return $this->render("list", ["data" => $data]);
 }
Exemplo n.º 7
0
 public function actionIndex()
 {
     $query = Account::find();
     $list = $query->orderBy(['id' => SORT_DESC])->all();
     $data = [];
     if ($list) {
         $idx = 1;
         foreach ($list as $_item) {
             $tmp_decrypt_pwd = $this->decrypt($_item['pwd']);
             $data[] = ['idx' => $idx, 'id' => $_item['id'], 'title' => DataHelper::encode($_item['title']), 'account' => DataHelper::encode($_item['account']), 'pwd' => $tmp_decrypt_pwd, 'description' => nl2br(DataHelper::encode($_item['description']))];
             $idx++;
         }
     }
     return $this->render("index", ['list' => $data]);
 }
Exemplo n.º 8
0
 public static function getRecommendBlog($blog_id, $page_size = 5)
 {
     //推荐相关
     $relation_blog_ids = PostsRecommend::find()->select("relation_blog_id")->where(['blog_id' => $blog_id])->orderBy("score desc")->limit($page_size)->asArray()->column();
     $recommend_blogs = [];
     if ($relation_blog_ids) {
         $relation_post_list = Posts::findAll(['id' => $relation_blog_ids, 'status' => 1]);
         if ($relation_post_list) {
             foreach ($relation_post_list as $_relation_blog_info) {
                 $recommend_blogs[] = ["title" => DataHelper::encode($_relation_blog_info['title']), "id" => $_relation_blog_info['id'], 'source_id' => $blog_id];
             }
         }
     }
     return $recommend_blogs;
 }
Exemplo n.º 9
0
 public function actionDologin()
 {
     $key = trim($this->getCookie("qrcode", ""));
     if (!$key || $key == "no") {
         return $this->renderJSON([], "扫描登录失败!{$key}", -1);
     }
     if (!$this->existCache($key)) {
         return $this->renderJSON([], "刷新页面!", 201);
     }
     $cache_status = $this->getCache($key);
     if ($cache_status < 1) {
         return $this->renderJSON([], "还没有登录!", -1);
     }
     $user_info = User::findOne(['uid' => $cache_status]);
     $data = ["nickname" => DataHelper::encode($user_info["nickname"]), "email" => "*****@*****.**"];
     return $this->renderJSON($data, "", 200);
 }
Exemplo n.º 10
0
 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]);
 }
Exemplo n.º 11
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"]);
 }
Exemplo n.º 12
0
 public function actionInfo($id)
 {
     $id = intval($id);
     if (!$id) {
         return $this->goHome();
     }
     $book_info = Book::find()->where(['id' => $id])->one();
     if (!$book_info) {
         return $this->goHome();
     }
     $data = [];
     $author = json_decode($book_info['creator'], true);
     $data['name'] = DataHelper::encode($book_info['name']);
     $data['title'] = DataHelper::encode($book_info['subtitle']);
     $data['summary'] = nl2br(DataHelper::encode($book_info['summary']));
     $data['publish_date'] = $book_info['publish_date'];
     $data['author'] = implode(" ~ ", $author);
     $data['tags'] = explode(",", $book_info['tags']);
     $data['image_url'] = $book_info['origin_image_url'];
     return $this->render("info", ["info" => $data]);
 }
Exemplo n.º 13
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])]]);
 }
Exemplo n.º 14
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)]);
 }
Exemplo n.º 15
0
 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] : '&nbsp;';
             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 : "&nbsp;", 'imager_url' => GlobalUrlService::buildPic1Static($_book['image_url']), 'view_url' => UrlService::buildWapUrl("/library/info", ["id" => $_book["id"]])];
         }
     }
     return $data;
 }
Exemplo n.º 16
0
 public static function buildFront($refresh = false)
 {
     $cache = new FileCache();
     $cache_key = "tag_post";
     $root_path = UtilHelper::getRootPath();
     $cache->cachePath = $root_path . '/common/logs/cache';
     $data = $cache[$cache_key];
     if (!$data || $refresh) {
         $data = ["tag" => [], "post_hot" => [], "post_origin" => [], "post_latest" => []];
         $tags = PostsTags::find()->select("tag,count(*) as num ")->groupBy("tag")->orderBy("num desc")->limit(20)->all();
         if ($tags) {
             foreach ($tags as $_tag) {
                 $data['tag'][] = $_tag['tag'];
             }
         }
         $post_hot = Posts::find()->where(['status' => 1])->orderBy(['view_count' => SORT_DESC])->limit(10)->all();
         if ($post_hot) {
             foreach ($post_hot as $_post_info) {
                 $data['post_hot'][] = ["id" => $_post_info['id'], "title" => DataHelper::encode($_post_info["title"]), "detail_url" => UrlService::buildUrl("/default/info", ["id" => $_post_info['id']])];
             }
         }
         $post_origin = Posts::find()->where(['status' => 1, 'original' => 1])->orderBy(['id' => SORT_DESC])->limit(10)->all();
         if ($post_origin) {
             foreach ($post_origin as $_post_info) {
                 $data['post_origin'][] = ["id" => $_post_info['id'], "title" => DataHelper::encode($_post_info["title"]), "detail_url" => UrlService::buildUrl("/default/info", ["id" => $_post_info['id']])];
             }
         }
         $post_latest = Posts::find()->where(['status' => 1])->orderBy(['id' => SORT_DESC])->limit(10)->all();
         if ($post_latest) {
             foreach ($post_latest as $_post_info) {
                 $data['post_latest'][] = ["id" => $_post_info['id'], "title" => DataHelper::encode($_post_info["title"]), "detail_url" => UrlService::buildUrl("/default/info", ["id" => $_post_info['id']])];
             }
         }
         $data = json_encode($data);
         $cache[$cache_key] = $data;
     }
     return $data;
 }
Exemplo n.º 17
0
 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]);
 }
Exemplo n.º 18
0
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="description" content="<?php 
echo DataHelper::encode($this->params['seo']['description']);
?>
"/>
    <meta name="keywords" content="<?php 
echo DataHelper::encode($this->params['seo']['keywords']);
?>
">
    <title><?php 
echo DataHelper::encode($this->title);
?>
</title>
    <meta name="HandheldFriendly" content="True"/>
    <meta name="google-site-verification" content="c_1LAxAX-8MMoXntjVS1kCu5JnGhVIlcgLT6idZpgq4" />
    <link rel="shortcut icon" href="<?php 
echo GlobalUrlService::buildStaticUrl("/images/icon.png");
?>
">
    <link rel="icon" href="<?php 
echo GlobalUrlService::buildStaticUrl("/images/icon.png");
?>
">
    <?php 
$this->head();
?>
Exemplo n.º 19
0
Arquivo: set.php Projeto: apanly/dream
                <div class="input-wrap">
                    <input type="text" class="input-1" name="pwd" value="<?php 
echo $info ? DataHelper::encode($info['pwd']) : '';
?>
"/>
                </div>
            </div>
            <div class="columns-4">
                <button class="btn-small gene_pwd" type="button">生成密码!</button>
            </div>
            <div class="columns-5 text-right">
                <label class="label-name inline"><i class="mark">*</i>备注:</label>
            </div>
            <div class="columns-19">
                <div class="input-wrap">
                    <textarea name="description" class="textarea-1" rows="5"><?php 
echo $info ? DataHelper::encode($info['description']) : '';
?>
</textarea>
                </div>
            </div>
            <div class="columns-4 offset-5">
                <input type="hidden" name="account_id" value="<?php 
echo $info ? $info['id'] : 0;
?>
">
                <button class="btn-small save" type="button">保存</button>
            </div>
        </div>
    </div>
</div>
Exemplo n.º 20
0
            <a class="btn btn-default" href="/library/detail/<?php 
    echo $prev_info['id'];
    ?>
"><i
                    class="fa fa-angle-left fa-fw"></i> <?php 
    echo DataHelper::encode($prev_info['subtitle']);
    ?>
</a>
        <?php 
}
?>
        &nbsp;
        <?php 
if ($next_info) {
    ?>
            <a class="btn btn-default"
               href="/library/detail/<?php 
    echo $next_info['id'];
    ?>
"><?php 
    echo DataHelper::encode($next_info['subtitle']);
    ?>
 <i
                    class="fa fa-angle-right fa-fw"></i></a>
        <?php 
}
?>
    </div>


</main>
Exemplo n.º 21
0
 public function actionSet()
 {
     $request = Yii::$app->request;
     if ($request->isGet) {
         $id = trim($this->get("id", 0));
         $info = [];
         if ($id) {
             $post_info = Posts::findOne(['id' => $id]);
             if ($post_info) {
                 $domains = Yii::$app->params['domains'];
                 $info = ["id" => $post_info['id'], "title" => DataHelper::encode($post_info['title']), "content" => DataHelper::encode($post_info['content']), "type" => $post_info['type'], "status" => $post_info['status'], "original" => $post_info['original'], "tags" => DataHelper::encode($post_info['tags']), 'view_url' => $domains['blog'] . Url::toRoute("/default/{$post_info['id']}")];
             }
         }
         //set or add
         return $this->render("set", ["info" => $info, "posts_type" => Constant::$posts_type, "status_desc" => Constant::$status_desc, "original_desc" => Constant::$original_desc]);
     }
     $uid = $this->current_user->uid;
     $id = trim($this->post("id", 0));
     $title = trim($this->post("title"));
     $content = trim($this->post("content"));
     $tags = trim($this->post("tags"));
     $type = trim($this->post("type"));
     $status = trim($this->post("status", 0));
     $original = trim($this->post("original", 0));
     if (mb_strlen($title, "utf-8") <= 0 || mb_strlen($title, "utf-8") > 100) {
         return $this->renderJSON([], "请输入博文标题并且少于100个字符", -1);
     }
     if (mb_strlen($content, "utf-8") <= 0) {
         return $this->renderJSON([], "请输入更多点博文内容", -1);
     }
     if (mb_strlen($tags, "utf-8") <= 0) {
         return $this->renderJSON([], "请输入博文tags", -1);
     }
     if (intval($type) <= 0) {
         return $this->renderJSON([], "请选择类型", -1);
     }
     $date_now = date("Y-m-d H:i:s");
     if ($id) {
         $model_posts = Posts::findOne(['id' => $id]);
     } else {
         $model_posts = new Posts();
         $model_posts->uid = $uid;
         $model_posts->created_time = $date_now;
     }
     $tags_arr = [];
     $tags = explode(",", $tags);
     if ($tags) {
         foreach ($tags as $_tag) {
             if (!in_array($_tag, $tags_arr)) {
                 $tags_arr[] = $_tag;
             }
         }
     }
     preg_match('/<\\s*img\\s+[^>]*?src\\s*=\\s*(\'|\\")(.*?)\\1[^>]*?\\/?\\s*>/i', $content, $match_img);
     if ($match_img && count($match_img) == 3) {
         $model_posts->image_url = $match_img[2];
     } else {
         $model_posts->image_url = "";
     }
     $model_posts->title = $title;
     $model_posts->content = $content;
     $model_posts->type = $type;
     $model_posts->original = $original;
     $model_posts->status = $status;
     $model_posts->tags = $tags_arr ? implode(",", $tags_arr) : "";
     $model_posts->updated_time = $date_now;
     $model_posts->save(0);
     $post_id = $model_posts->id;
     BlogService::buildTags($post_id);
     CacheHelperService::buildFront(true);
     if ($status == 1) {
         //只有在线的才进入同步队列
         SyncBlogService::addQueue($post_id);
         RecommendService::addQueue($post_id);
     }
     return $this->renderJSON(['post_id' => $post_id], "博文发布成功");
 }
Exemplo n.º 22
0
<?php

use blog\components\StaticService;
use blog\components\UrlService;
use common\components\DataHelper;
StaticService::includeAppCssStatic("/css/wap/wechat_wall/sign.css", \blog\assets\MarketAsset::className());
StaticService::includeAppJsStatic("http://res.wx.qq.com/open/js/jweixin-1.0.0.js", \blog\assets\MarketAsset::className());
StaticService::includeAppJsStatic("/js/wap/wechat_wall/sign.js", \blog\assets\MarketAsset::className());
?>
<div class="user_info">
    <p><img src="<?php 
echo $user_info['avatar'];
?>
" alt="" /></p>
    <p><?php 
echo DataHelper::encode($user_info['nickname']);
?>
</p>
</div>
<div class="checkin_info">
    <p class="t1">恭喜您上墙成功!</p>
    <p class="t2">关闭本页面直接发送“<span style="font-weight: bold;color: #ff0000;font-size: large;">#消息内容</span>”即可参与互动哦!</p>
</div>
<a href="javascript:void(0)" id="close_checkin_window" class="button">关闭本页面</a>

<input type="hidden" name="can_award_user" value="">
Exemplo n.º 23
0
?>
</head>
<body>
<div class="am-g">
    <section>
        <?php 
echo $content;
?>
    </section>
    <?php 
if (isset($this->params['current_user'])) {
    ?>
    <footer data-am-widget="footer"  class="am-footer am-footer-default">
        <div class="am-footer-miscs ">
            <p>欢迎您,<?php 
    echo DataHelper::encode($this->params['current_user']['nickname']);
    ?>
</p>
            <p>由 编程浪子 提供技术支持</p>
        </div>
    </footer>
    <?php 
}
?>
    <div data-am-widget="navbar" class="am-navbar am-cf am-navbar-default" style="display: none;">
        <ul class="am-navbar-nav am-cf am-avg-sm-4">
            <li>
                <a href="<?php 
echo UrlService::buildMateUrl("/gallary/index");
?>
" class="am-btn-warning">
Exemplo n.º 24
0
 public function actionTopSearch()
 {
     $data = [];
     $kw = trim($this->get("q", ''));
     $query = Posts::find();
     $query->andWhere(['LIKE', 'title', '%' . strtr($kw, ['%' => '\\%', '_' => '\\_', '\\' => '\\\\']) . '%', false]);
     $list = $query->orderBy(['view_count' => SORT_DESC])->asArray()->limit(10)->all();
     if ($list) {
         foreach ($list as $_item) {
             $data[] = ['id' => $_item['id'], 'title' => DataHelper::encode($_item['title']), 'url' => AdminUrlService::buildUrl("/posts/set", ['id' => $_item['id']])];
         }
     }
     return $this->renderJSON($data);
 }
Exemplo n.º 25
0
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title><?php 
echo DataHelper::encode($this->title);
?>
</title>
    <meta name="description" content="<?php 
echo DataHelper::encode($this->params['seo']['description']);
?>
"/>
    <meta name="keywords" content="<?php 
echo DataHelper::encode($this->params['seo']['keywords']);
?>
">
    <meta name="HandheldFriendly" content="True"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link rel="shortcut icon" href="<?php 
echo GlobalUrlService::buildStaticUrl("/images/icon.png");
?>
">
    <link rel="icon" href="<?php 
echo GlobalUrlService::buildStaticUrl("/images/icon.png");
?>
">
    <?php 
$this->head();
?>