Beispiel #1
0
 public function doList(LJL_Request $input, LJL_Response $output)
 {
     $page = $input->get('page') ? intval($input->get('page')) : 1;
     $cate = $input->get('cate');
     $articleList = array();
     //与搜索标签方法融合
     $tag = $input->get('tag') ? urldecode(trim($input->get('tag'))) : urldecode(trim($input->get('keyword')));
     if ($cate === 'meinv') {
         $arr = array('清纯美女', '美女', '性感美女', '模特', '美女写真', '长腿美女', '大胸美女', '校花');
         shuffle($arr);
         $url = 'http://image.baidu.com/search/index?tn=baiduimage&word=' . array_pop($arr);
         //$url = 'https://www.baidu.com';
         $content = file_get_contents($url);
         preg_match_all('/hoverURL\\"\\:\\"(.*?)\\"/is', $content, $mathes);
         shuffle($mathes[1]);
         $outArr = array_slice($mathes[1], 1, 5);
         foreach ((array) $outArr as $key => $src) {
             $articleList[$key]['src'] = $src;
         }
         exit(json_encode($articleList));
     }
     //文章列表
     $articleList = Helper_Blog::getArticleList(array('page' => $page, 'pageSize' => $this->pageSize, 'fields' => array('id', 'firstImgId', 'title', 'descript'), 'cate' => $cate, 'tag' => $tag));
     if (is_array($articleList)) {
         foreach ($articleList as $key => $val) {
             if (!$val['firstImgId']) {
                 $articleList[$key]['src'] = '';
                 continue;
             }
             $imgInfo = Helper_Blog::getPicInfo(array('picId' => $val['firstImgId']));
             $articleList[$key]['src'] = Helper_Blog::getPicWebPath(array('imgName' => $imgInfo['picName'], 'imgExt' => $imgInfo['picExt'], 'time' => $imgInfo['time'], 'rootdir' => UPLOAD_IMG_PATH . 'blog_' . APP_BLOG_NAME . '/', 'size' => '110x66_'));
         }
     }
     exit(json_encode($articleList));
 }
Beispiel #2
0
 public function doAddtagview(LJL_Request $input, LJL_Response $output)
 {
     $tag = $input->get('tag');
     $cate = $input->get('cate');
     //搜索
     if (!$cate) {
         Helper_Blogconfig::searchRecord(APP_BLOG_NAME, $tag);
         //标签
     } else {
         Helper_Blog::addTagView($tag, $cate);
     }
     exit;
 }
Beispiel #3
0
 /**
  * 个人站首页
  */
 public function doDefault(LJL_Request $input, LJL_Response $output)
 {
     LJL_Http::setExpires(3600);
     #设置缓存时间
     $page = $input->get('page') ? intval($input->get('page')) : 1;
     //文章列表
     $articleList = Helper_Blog::getArticleList(array('page' => $page, 'pageSize' => $this->pageSize, 'fields' => array('id', 'firstImgId', 'title', 'descript')));
     $articleCount = Helper_Blog::getArticleList(array('isCount' => 1));
     //分页相关
     $totalPage = ceil($articleCount / $this->pageSize);
     $pageStr = Libs_Global_Page::getPageString(array('page' => $page, 'pageTotal' => $totalPage, 'urlClass' => 'Blog_Plugin_Urls', 'urlFunc' => 'getIndexUrl', 'args' => array('page' => $page)));
     $cateList = LJL_Config::get('Blog_' . ucfirst(APP_BLOG_NAME) . '_Cate', 'CATE');
     //面包屑导航
     $nav[0]['title'] = '首页';
     $pageTitle = $page > 1 ? '-第' . $page . '页' : '';
     //首页展示图片
     $showImgs = '';
     $imgStrFile = '/tmp/' . APP_BLOG_NAME . '.php';
     if (file_exists($imgStrFile) && $page < 2) {
         $imgStr = file_get_contents($imgStrFile);
         $imgArr = json_decode($imgStr);
         $showImgs = '<div id="img-scroll">';
         foreach ((array) $imgArr as $key => $urlsrc) {
             $active = $key === 0 ? 'class="active"' : '';
             $us = explode('#', $urlsrc);
             $showImgs .= '<a target="_blank" href="' . $us[0] . '"><img ' . $active . ' src="' . $us[1] . '"></a>';
         }
         $showImgs .= '</div>';
     }
     //seo
     $output->seoArr = array('title' => BLOG_SEO_TITTLE . $pageTitle . ' | 最红博 ');
     $output->nav = $nav;
     $output->cate = '';
     $output->tag = '';
     $output->cateList = $cateList;
     $output->pageStr = $pageStr;
     $output->articleList = $articleList;
     $output->showImgs = $showImgs;
     $output->header = $output->fetchCol("Part/Main/Header");
     $output->footer = $output->fetchCol("Part/Main/Footer");
     $output->navbarTpl = $output->fetchCol("Part/Navbar");
     $output->leftsideCate = $output->fetchCol("Part/LeftsideCate");
     $output->navGuideTpl = $output->fetchCol("Part/Navguide");
     $output->newArticleTpl = $output->fetchCol("Part/NewArticle");
     $output->searchTpl = $output->fetchCol("Part/Search");
     $output->setTemplate('List');
 }
Beispiel #4
0
 public function doDefault(LJL_Request $input, LJL_Response $output)
 {
     //http://hongbo.com/index.php?c=detail&a=default&articleid=67
     LJL_Http::setExpires(3600);
     #设置缓存时间
     $articleId = $input->get('articleid');
     $articleInfo = Helper_Blog::getArticleInfo(array('articleId' => $articleId, 'fileds' => array('firstImgId', 'cate', 'title', 'descript', 'tags', 'source', 'insertTime', 'view', 'content')));
     if (count($articleInfo) < 5) {
         LJL_Http::send404Header();
         $output->setTemplate('404');
         return;
     }
     $articleInfo['id'] = $articleId;
     $articleTags = explode(',', $articleInfo['tags']);
     $cateList = LJL_Config::get('Blog_' . ucfirst(APP_BLOG_NAME) . '_Cate', 'CATE');
     $prevNext = Helper_Blog::getPreNextArticle(array('articleId' => $articleId, 'fileds' => array('id', 'title')));
     $prevNext = $this->formatPrevNext($prevNext);
     //面包屑导航
     $nav[0]['title'] = '首页';
     $nav[0]['url'] = WWW_WEB;
     $nav[1]['title'] = $cateList[$articleInfo['cate']][0];
     $nav[1]['url'] = Blog_Plugin_Urls::getListUrl(array('cate' => $articleInfo['cate']));
     $nav[2]['title'] = $articleInfo['title'];
     //seo
     $output->seoArr = array('title' => $articleInfo['title'] . ' - ' . BLOG_SEO_TITTLE . ' | 最红博', 'description' => $articleInfo['descript'], 'keywords' => implode(',', $articleTags));
     $output->cateList = $cateList;
     $output->articleInfo = $articleInfo;
     $output->articleTags = $articleTags;
     $output->prevNext = $prevNext;
     $output->nav = $nav;
     $output->cate = $articleInfo['cate'];
     $output->header = $output->fetchCol("Part/Main/Header");
     $output->footer = $output->fetchCol("Part/Main/Footer");
     $output->navbarTpl = $output->fetchCol("Part/Navbar");
     $output->leftsideCate = $output->fetchCol("Part/LeftsideCate");
     $output->navGuideTpl = $output->fetchCol("Part/Navguide");
     $output->newArticleTpl = $output->fetchCol("Part/NewArticle");
     $output->commentTpl = $output->fetchCol("Part/Comment");
     $output->searchTpl = $output->fetchCol("Part/Search");
     $output->setTemplate('Detail');
 }
Beispiel #5
0
 private function makeDetailPage($database, $catekey)
 {
     if (!$catekey) {
         return;
     }
     Db_Blog::instance(null, $database);
     $website = substr($database, 5);
     //获取文章总数
     $count = Helper_Blog::getArticleList(array('isCount' => 1));
     $page = 1;
     $pageSize = 100;
     $totalPage = ceil($count / $pageSize);
     while ($totalPage >= $page) {
         $articleInfo = Helper_Blog::getArticleList(array('page' => $page, 'pageSize' => $pageSize, 'fields' => array('id'), 'isPublished' => 1, 'cate' => $catekey));
         if ($articleInfo) {
             foreach ($articleInfo as $val) {
                 $this->stobj->urlItem('http://' . $website . '.' . MAIN_PAGE . '/article/' . $val['id'] . '.html');
             }
         }
         $page++;
         if ($page * $pageSize % 5000 == 0) {
             //每5000条生成新的sitemap文件
             $this->saveasSiemap($database, $catekey, $page);
         }
         if ($page % 10 === 0) {
             //每10页sleep
             sleep(1);
         }
     }
     $this->saveasSiemap($database, $catekey);
 }
Beispiel #6
0
 public function DoUploadImg(LJL_Request $input, LJL_Response $output)
 {
     $upfile = $input->files('uppic');
     //客户端传过来的文件
     $pos = strpos($upfile['name'], '.') + 1;
     $ext = substr($upfile['name'], $pos);
     //获取后缀名
     $typelist = array("gif", "jpg", "png");
     //限制图片类型
     $imgInfo = LJL_Api::run("Image.DFS.imgStorage", array('rootdir' => UPLOAD_IMG_PATH . 'blog_' . APP_BLOG_NAME . '/'));
     $path = $imgInfo[2];
     //上传到该文件夹
     $webPath = Helper_Blog::getImgWebPath($imgInfo[2]);
     if (!is_dir($path)) {
         LJL_File::mkdir($path);
     }
     //获取图片名
     $picName = $imgInfo[0];
     $result = $this->uploadFile($upfile, $path, $picName, $webPath, $typelist);
     //图片上传函数
     if ($result['status']) {
         //图片表中插入数据
         $imgid = Helper_Blog::insertPic(array('picName' => $picName, 'picExt' => $ext, 'time' => $imgInfo[1]));
         echo '<script language="javascript">window.parent.addPic("' . $result['info'] . '","' . $imgid . '");</script>';
     } else {
         echo '<script language="javascript">window.parent.addPic("error","0");</script>';
     }
 }
Beispiel #7
0
 public function doDing(LJL_Request $input, LJL_Response $output)
 {
     $commentId = (int) $input->get('commentid');
     Helper_Blog::updateComment(array('commentid' => $commentId));
     exit;
 }
Beispiel #8
0
<?php

$newList = Helper_Blog::getArticleList(array('fields' => array('id', 'title'), 'cate' => $cate, 'order' => 'order by id desc'));
//最近30天最热的
$fiveDayHot = SYSTEM_TIME - 30 * 24 * 3600;
$hotList = Helper_Blog::getArticleList(array('fields' => array('id', 'title'), 'cate' => $cate, 'order' => 'order by view desc', 'updateTime' => $fiveDayHot));
if (count($hotList) < 5) {
    $hotList = Helper_Blog::getArticleList(array('fields' => array('id', 'title'), 'cate' => $cate, 'order' => 'order by view desc'));
}
//最新评论文章
$newComments = Helper_Blog::getCommentsArticles(array('limit' => '10'));
$newCommentsList = array();
foreach ((array) $newComments as $aid) {
    $newCommentsList[] = Helper_Blog::getArticleList(array('fields' => array('id', 'title'), 'articleid' => $aid))[0];
}
if ($newList) {
    ?>
<div class="yard cm_mb" style="margin-top:10px;">
    <div class="ydtitle">
        <h3>
            <?php 
    if (!empty($cate)) {
        echo $cateList[$cate][0];
    }
    ?>
最新更新文章
        </h3>
    </div>
    <div class="ydcontent">
        <div style="margin-left: 2em" class="c5">
            <ul>
Beispiel #9
0
 /**
  * 导入标签,如果指定了天数,则就从指定前几天,如果没有指定天数,则从上一次插入的时间开始
  * @param LJL_Request $input
  * @param unknown $database
  */
 private function importTag(LJL_Request $input, $database)
 {
     $db = Db_Blog::instance(null, $database);
     if ($input->get('day')) {
         $day = $input->get('day') ? $input->get('day') : 1;
         //默认1天
         $fromInsertTime = SYSTEM_TIME - $day * 24 * 3600;
     } else {
         $sql = "select updateTime from blog_tags order by id desc limit 1";
         $fromInsertTime = $db->getOne($sql);
         $fromInsertTime = $fromInsertTime ? $fromInsertTime : 0;
     }
     //获取总数
     $sql = "select count(*) from blog_article_info where isPublished=1 and updateTime>{$fromInsertTime}";
     $count = $db->getOne($sql);
     $page = 1;
     $pageSize = 100;
     $totalPage = ceil($count / $pageSize);
     while ($totalPage >= $page) {
         $articleInfo = Helper_Blog::getArticleList(array('page' => $page, 'pageSize' => $pageSize, 'fields' => array('id', 'cate', 'tags'), 'updateTime' => $fromInsertTime));
         if ($articleInfo) {
             foreach ($articleInfo as $val) {
                 if (!$val['tags']) {
                     continue;
                 }
                 $tagArr = explode(',', trim(trim($val['tags'], ' '), ','));
                 foreach ($tagArr as $tag) {
                     Helper_Blog::insertTag(array('insertData' => array('articleId' => $val['id'], 'cate' => $val['cate'], 'tag' => $tag, 'updateTime' => SYSTEM_TIME)));
                 }
             }
         }
         $page++;
     }
     echo $database . ' tags import over' . PHP_EOL;
 }
Beispiel #10
0
 /**
  * 插入文章
  */
 private function insertArticle($url, $title, $content)
 {
     if (!$title || !$content) {
         return;
     }
     $db = Db_Blog::instance(null, $this->website);
     //已有该文章则退出
     $title = htmlspecialchars(strip_tags(addslashes(str_replace("'", '"', $title))));
     if (Helper_Blog::ishasArticle('', $title)) {
         return;
     }
     //echo $title;die;
     //对于有图片的文章进行搬运图片处理
     preg_match_all("/<img src=\"(.*?)\"/", $content, $matches, PREG_SET_ORDER);
     $imgidArr = array();
     if ($matches) {
         if (count($matches) > 10) {
             return;
         }
         foreach ((array) $matches as $imgsrc) {
             $imgInfo = $this->getImgNameDir();
             if (!$imgsrc[1]) {
                 continue;
             }
             //1、移动图片
             exec('wget -q --tries=3 -O ' . rtrim($imgInfo[1], '/') . '/' . $imgInfo[0] . '.jpg ' . $imgsrc[1]);
             //2、向自己库中插入图片
             $imgidArr[] = Helper_Blog::insertPic(array('picName' => $imgInfo[0], 'picExt' => 'jpg', 'time' => $imgInfo[3]));
             //3、图片地址字符串替换
             $content = str_replace($imgsrc[1], $imgInfo[2] . '/' . $imgInfo[0] . '.jpg', $content);
         }
     }
     //插入文章
     $firstImgId = $imgidArr ? $imgidArr[0] : 0;
     $desc = $firstImgId ? API_Item_Base_String::getShort(array('str' => strip_tags($content), 'length' => 120)) : API_Item_Base_String::getShort(array('str' => strip_tags($content), 'length' => 150));
     $articleId = Helper_Blog::insertArticleInfo(array('insertData' => array('firstImgId' => $firstImgId, 'insertTime' => SYSTEM_TIME, 'isPublished' => 0, 'cate' => $this->cate, 'tags' => $this->tags, 'title' => $title, 'descript' => ' ' . strip_tags(addslashes(str_replace("'", '"', $desc))) . ' ', 'source' => $url, 'content' => ' ' . htmlspecialchars(addslashes(preg_replace("/<script[\\s]*.*?<\\/script>/si", '', $content))) . ' ', 'imgArr' => $imgidArr)));
     echo 'article ' . $articleId . ' is ok' . PHP_EOL;
 }
Beispiel #11
0
 private function _robotAnswer($words)
 {
     $url = 'http://www.tuling123.com/openapi/api?key=f422678a1cf9064fbd11bdeb4f481715&info=' . $words;
     $res = (array) json_decode(file_get_contents($url));
     if ($res['code'] == 100000) {
         $content = $words . '---' . $res['text'];
         Helper_Blog::insertRobotAnswer(array('insertData' => array('content' => $content, 'tm' => date('Y-m-d H:i:s'))));
         self::_notice($res['text']);
     } else {
         self::_notice();
     }
 }
Beispiel #12
0
 /**
  * 修改文章状态,改变时间,进行发布
  */
 public function publish($articleIds)
 {
     foreach ((array) $articleIds as $aid) {
         $publishTime = $this->getPubishTime();
         Helper_Blog::updateArticleInfo(array('articleId' => $aid, 'updateData' => array('insertTime' => $publishTime, 'updateTime' => $publishTime, 'isPublished' => 1)));
     }
 }
Beispiel #13
0
 private function _fulltextSearch($input, $output)
 {
     LJL_Http::setExpires(3600);
     #设置缓存时间
     $tag = $keyword = trim($input->get('keyword'));
     $page = $input->get('page') ? intval($input->get('page')) : 1;
     $start = ($page - 1) * $this->pageSize;
     $query = array('q' => $keyword ? $keyword : '*', 'wt' => 'json', 'rows' => $this->pageSize, 'start' => $start, 'hl' => 'true', 'hl.fl' => 'title,descript', "hl.simple.pre" => '<font color="red">', "hl.simple.post" => '</font>');
     $solrServer = LJL_Config::get('Blog_Solr', 'SOLR');
     $url = $solrServer['url'] . '/select?' . http_build_query($query);
     //echo $url;die;
     $solrRes = LJL_Http::curlPage(array('url' => $url, 'timeout' => 5));
     $searchRes = json_decode($solrRes, true);
     //var_dump($searchRes);
     $cateList = LJL_Config::get('Blog_' . ucfirst(APP_BLOG_NAME) . '_Cate', 'CATE');
     //文章列表
     $articleList = $searchRes['response']['docs'];
     $articleCount = $searchRes['response']['numFound'];
     $articleHl = $searchRes['highlighting'];
     unset($searchRes);
     //组织高亮部分
     //var_dump($articleHl);die;
     foreach ((array) $articleList as $akey => $aval) {
         if (key_exists($aval['id'], $articleHl)) {
             if (isset($articleHl[$aval['id']]['title'])) {
                 $articleList[$akey]['title'] = $articleHl[$aval['id']]['title'][0];
             }
             if (isset($articleHl[$aval['id']]['descript'])) {
                 $articleList[$akey]['descript'] = $articleHl[$aval['id']]['descript'][0];
             }
         }
     }
     //分页相关
     $totalPage = ceil($articleCount / $this->pageSize);
     $pageStr = Libs_Global_Page::getPageString(array('page' => $page, 'pageTotal' => $totalPage, 'urlClass' => 'Blog_Plugin_Urls', 'urlFunc' => 'getSearchUrl', 'args' => array('type' => $input->get('type'), 'keyword' => $keyword, 'page' => $page)));
     //获取各分类下tag标签
     if ($cateList) {
         $tagsArr = [];
         foreach ($cateList as $cateKey => $cateV) {
             $tagsArr[$cateKey] = Helper_Blog::getTags(array('cate' => $cateKey));
         }
     }
     //面包屑导航
     $nav[0]['title'] = '首页';
     $nav[0]['url'] = WWW_WEB;
     $nav[1]['title'] = $keyword;
     //seo
     $output->seoArr = array('title' => $keyword . '搜索-第' . $page . '页  - ' . BLOG_SEO_TITTLE . ' | 最红博 ');
     $output->tagsArr = $tagsArr;
     $output->tag = $keyword;
     $output->cate = '';
     $output->nav = $nav;
     $output->cateList = $cateList;
     $output->pageStr = $pageStr;
     $output->articleList = $articleList;
     $output->header = $output->fetchCol("Part/Main/Header");
     $output->footer = $output->fetchCol("Part/Main/Footer");
     $output->navbarTpl = $output->fetchCol("Part/Navbar");
     $output->leftsideCate = $output->fetchCol("Part/LeftsideCate");
     $output->navGuideTpl = $output->fetchCol("Part/Navguide");
     $output->newArticleTpl = $output->fetchCol("Part/NewArticle");
     $output->searchTpl = $output->fetchCol("Part/Search");
     $output->setTemplate('List');
 }
Beispiel #14
0
<?php

$commentsList = Helper_Blog::getCommentsList(array('articleId' => $articleInfo['id']));
?>
<div id="comment" articleId="<?php 
echo $articleInfo['id'];
?>
" class="bm vw pl">
    <div class="ds-thread" id="ds-thread">
        <div id="ds-reset">
            <div class="ds-comments-info">
                <div class="ds-sort">
<!--                     <a class="ds-order-desc">最新</a><a class="ds-order-asc ds-current">最早</a><a class="ds-order-hot">最热</a> -->
                </div>
                <ul class="ds-comments-tabs">
                    <li class="ds-tab">
                        <a class="ds-comments-tab-duoshuo ds-current" href="javascript:void(0);"><span class="ds-highlight"><?php 
echo count($commentsList);
?>
</span>条评论</a>
                    </li>
                </ul>
            </div>
            <ul class="ds-comments">
                <?php 
if ($commentsList) {
    foreach ($commentsList as $val) {
        ?>
                <li class="ds-post">
                    <div class="ds-post-self">
                        <div class="ds-avatar">
Beispiel #15
0
        echo htmlspecialchars_decode($articleInfo['title']);
        ?>
</a></h2>
    					              	<p>
    					              		<?php 
        if ($articleInfo['firstImgId']) {
            $imgInfo = Helper_Blog::getPicInfo(array('picId' => $articleInfo['firstImgId']));
            ?>
    					              		    <a href="<?php 
            echo Blog_Plugin_Urls::getDetailUrl(array('articleid' => $articleInfo['id']));
            ?>
" title="<?php 
            echo $articleInfo['title'];
            ?>
"><img src="<?php 
            echo Helper_Blog::getPicWebPath(array('imgName' => $imgInfo['picName'], 'imgExt' => $imgInfo['picExt'], 'time' => $imgInfo['time'], 'rootdir' => UPLOAD_IMG_PATH . 'blog_' . APP_BLOG_NAME . '/', 'size' => '110x66_'));
            ?>
" width="50" height="50" alt="<?php 
            echo $articleInfo['title'];
            ?>
"></a>
    					              		    <?php 
        }
        echo $articleInfo['descript'];
        ?>
...
    									</p></div></div>
                           <?php 
    }
} else {
    ?>
Beispiel #16
0
<?php

if ($cateList && $pageType != 'List') {
    $tagsArr = array();
    foreach ($cateList as $cateKey => $cateV) {
        $tagsArr[$cateKey] = Helper_Blog::getTags(array('cate' => $cateKey));
    }
}
?>

<?php 
if (defined('WEIBO_UID')) {
    ?>
    <div class="yard cm_mb" style="margin-top:10px;">
        <div class="ydtitle"><h3><span style="color: #40AA53">About me</span></h3></div>
        <div class="ydcontent index_gtag">
            <iframe width="100%" height="22" frameborder="0" allowtransparency="true" marginwidth="0" marginheight="0" scrolling="no" border="0" src="http://widget.weibo.com/relationship/followbutton.php?language=zh_cn&uid=<?php 
    echo WEIBO_UID;
    ?>
&style=3&btn=red&dpc=0"></iframe>
        </div> 
    </div>
<?php 
}
?>
        
<?php 
if ($tagsArr) {
    foreach ($tagsArr as $cateid => $tagArr) {
        if (isset($cate) && $cateid === $cate && $pageType === 'List') {
            continue;