/** * 父类的Validate */ public function baseValidate(LJL_Request $input, LJL_Response $output) { //获取静态文件路径 $output->_SFP = LJL_Config::get(APP_NAME . "_App", 'staticPath'); //不是爬虫 if (!LJL_Http::isRobot()) { //防止恶意刷新 if ($input->cookie('whatareyou')) { echo 'what are you 弄啥嘞! ……robot-like'; die; } if ($input->cookie('emithsulf') || setcookie('emithsulf', API_Item_Security_Algos::fastEncode(array('value' => 1)), SYSTEM_TIME + 3, '/')) { if (API_Item_Security_Algos::fastDecode(array('value' => $input->cookie('emithsulf'))) > 10) { setcookie('whatareyou', 'ekil-tobor', SYSTEM_TIME + 120, '/'); } $nowNum = API_Item_Security_Algos::fastDecode(array('value' => $input->cookie('emithsulf'))) + 1; setcookie('emithsulf', API_Item_Security_Algos::fastEncode(array('value' => $nowNum)), SYSTEM_TIME + 3, '/'); } } //登录验证 // if($input->cookie('blog_ckid') && $input->cookie('blog_username')) { // if(false === Blog_Plugin_Common::loginAuth($input->cookie('blog_ckid'), $input->cookie('blog_username'))) { // echo '非法。。。登录。。。';die(); // } // } return true; }
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'); }
/** * 执行登录 */ public function doLogin(LJL_Request $input, LJL_Response $output) { $userName = $input->post('username'); $password = $input->post('password'); if (!$userName) { $msg = '请填写用户名'; } //if(!$password) $msg = '请填写密码'; if (preg_match('/@/', $userName)) { $userInfo = Helper_Blogconfig::getUserInfo(array('email' => $userName, 'password' => md5($password . '_'))); } else { $userInfo = Helper_Blogconfig::getUserInfo(array('username' => $userName, 'password' => md5($password . '_'))); } if (!$userInfo) { $msg = '用户不存在或密码错误'; } if (isset($msg)) { echo $msg; die; } $ipInfo = LJL_Http::ip2location(LJL_Http::getClientIp()); //插入用户登录数据 Helper_Blogconfig::insertLoginData(array('insertData' => array('username' => $userInfo['username'], 'loginIp' => $ipInfo['ip'], 'loginAddr' => $ipInfo['country'], 'userAgent' => $_SERVER['HTTP_USER_AGENT'], 'time' => SYSTEM_TIME))); setcookie('blog_username', urlencode($userInfo['username']), SYSTEM_TIME + 3600 * 24 * 3600, '/', "." . Blog_Plugin_Common::getHost()); setcookie('blog_ckid', Blog_Plugin_Common::ckid($userInfo['username']), SYSTEM_TIME + 3600 * 24 * 3600, '/', "." . Blog_Plugin_Common::getHost()); if (Helper_Blogconfig::getAdminInfo(array('username' => $userInfo['username'], 'password' => md5($password . '_'), 'website' => APP_BLOG_NAME))) { setcookie('mda_', '@#%^&', SYSTEM_TIME + 3600 * 24 * 30, '/'); echo $userInfo['username'] . '_ok_adm'; die; } else { echo $userInfo['username'] . '_ok'; die; } }
public function doShowerror(LJL_Request $input, LJL_Response $output) { LJL_Http::send404Header(); $output->setTemplate('404'); }
private function importArticle($webSite, $solrUrl) { //15.28.237.52:8983/solr/cui_blog/dataimport?command=delta-import&clean=false&commit=true $importUrl = str_replace('xxx', $webSite, $solrUrl); $importUrl .= '/dataimport?command=delta-import&clean=false&commit=true'; LJL_Http::curlPage(array('url' => $importUrl, 'timeout' => 5)); }
public function doTestdetail(LJL_Request $input) { $url = 'http://blog.csdn.net/erwin2012/article/details/46124639'; $this->dealDetailPage(LJL_Http::curlPage(array('url' => $url, 'timeout' => 6)), $url); exit; }
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'); }