public function doHome(LJL_Request $input, LJL_Response $output) { $error = 0; if (!$input->post('submit')) { $output->error = $error; $output->setTemplate('Apply'); return; } $webName = $input->post('webName'); $adminName = $input->post('adminName'); $adminPassword = $input->post('adminPassword'); $webDesc = $input->post('webDesc'); $webSite = $input->post('webSite'); $weiboUid = $input->post('weiboUid'); $email = $input->post('email'); $cate = $input->post('cate'); if (!trim($webName) || !trim($adminName) || !trim($adminPassword) || !trim($webDesc) || !trim($webSite) || !trim($cate) || !trim($email)) { //信息不完整 $error = 2; } if (Helper_Blogconfig::getAdminInfo(array('website' => $webSite, 'status' => 0)) || Helper_Blogconfig::getAdminInfo(array('webname' => $webName, 'status' => 0))) { //网站已存在 $error = 1; } if (!$error) { Helper_Blogconfig::insertAdminInfo(array('insertData' => array('webName' => $webName, 'adminName' => $adminName, 'adminPassword' => md5($adminPassword . '_'), 'webDesc' => $webDesc, 'webSite' => $webSite, 'weiboUid' => $weiboUid, 'email' => $email, 'cate' => $cate, 'status' => 0))); $error = 'noerror'; } $output->error = $error; $output->setTemplate('Apply'); }
public function validate(LJL_Request $input, LJL_Response $output) { $output->pageType = 'Admin'; if (!parent::baseValidate($input, $output)) { return false; } //判断是否是管理员 if (!Helper_Blogconfig::getAdminInfo(array('username' => urldecode($input->cookie('blog_username')), 'ckid' => $input->cookie('blog_ckid'), 'website' => APP_BLOG_NAME))) { die('sorry hack~'); } return true; }
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; }
/** * 插入评论 */ public function doComment(LJL_Request $input, LJL_Response $output) { $articleId = $input->post('articleId'); $message = $input->post('message'); if (!Helper_Blogconfig::getUserInfo(array('username' => urldecode($input->cookie('blog_username'))))) { echo 'error'; die; } $message = $this->ubbReplace($message); $touser = preg_match('/回复 (.*?):/', $message, $mathes) ? trim($mathes[1]) : ''; if ($touser) { $message = str_replace($mathes[0], '<a class="ds-comment-context">' . $mathes[0] . '</a>', $message); } $lastId = Helper_Blog::insertComment(array('insertData' => array('articleId' => $articleId, 'user' => urldecode($input->cookie('blog_username')), 'touser' => $touser, 'time' => SYSTEM_TIME, 'comment' => $message))); if ($lastId) { echo $message; } die; }
public function doPublishsitemap(LJL_Request $input) { $pageSize = 10; $adminCount = Helper_Blogconfig::getAdminList(array('isCount' => 1)); $maxPage = ceil($adminCount / $pageSize); for ($page = 1; $page <= $maxPage; $page++) { $adminList = Helper_Blogconfig::getAdminList(array('page' => $page, 'pageSize' => $pageSize, 'fields' => array('webSite'), 'status' => 1, 'order' => 'order by id')); if ($adminList) { foreach ($adminList as $APP_BLOG_NAME) { //写入sitemap $this->makeSitemap('blog_' . $APP_BLOG_NAME['webSite']); $this->saveasSitemapIndex('Blog_' . $APP_BLOG_NAME['webSite']); $this->sitemapIndexAddr = array(); Db_Blog::destory(); //清除实例 sleep(1); echo 'blog_' . $APP_BLOG_NAME['webSite'] . ' sitemap is ok' . PHP_EOL; } } sleep(1); } exit; }
/** * 执行登录 */ 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 doHome(LJL_Request $input, LJL_Response $output) { //echo Blog_Plugin_Common::ckid('胡国庆');die; //echo 111;die; //setcookie('userProvinceId', 'aaa', SYSTEM_TIME + 86400, '/'); // setcookie('userProvinceId2', 'aaa', SYSTEM_TIME + 86400, '/', '.zhbor.com'); // die(); LJL_Http::setExpires(3600); $nearTime = SYSTEM_TIME - 30 * 24 * 3600; //最热10篇 $hotList = Helper_Blogconfig::getBlogRankList(array('fields' => array('webSite', 'articleId', 'title', 'cate', 'cateVal', 'score', 'publishTime'), 'pageSize' => 15, 'order' => 'order by score desc', 'publishTime' => $nearTime)); if (count($hotList) < 10) { $hotList = Helper_Blogconfig::getBlogRankList(array('fields' => array('webSite', 'articleId', 'title', 'cate', 'cateVal', 'score', 'publishTime'), 'pageSize' => 15, 'order' => 'order by score desc')); } //最新10篇 $newList = Helper_Blogconfig::getBlogRankList(array('fields' => array('webSite', 'articleId', 'title', 'cate', 'cateVal', 'score', 'publishTime'), 'pageSize' => 15, 'order' => 'order by publishTime desc', 'publishTime' => $nearTime)); if (count($newList) < 10) { $newList = Helper_Blogconfig::getBlogRankList(array('fields' => array('webSite', 'articleId', 'title', 'cate', 'cateVal', 'score', 'publishTime'), 'pageSize' => 15, 'order' => 'order by publishTime desc')); } //推荐10篇 $recommendList = Helper_Blogconfig::getBlogRankList(array('fields' => array('webSite', 'articleId', 'title', 'descript', 'cate', 'cateVal', 'score', 'publishTime'), 'pageSize' => 10, 'order' => 'order by isRecommend desc,score desc,publishTime desc')); //博主100个 $bloggerList = Helper_Blogconfig::getAdminList(array('page' => 1, 'pageSize' => 100, 'fields' => array('webName', 'webSite'), 'status' => 1, 'order' => 'order by score desc')); //自定义(关于本博1篇) //seo $output->seoArr = array('title' => BLOG_SEO_TITTLE . ' | 最红博 '); $output->pageType = 'webHome'; $output->hotList = $hotList; $output->newList = $newList; $output->recommendList = $recommendList; $output->bloggerList = $bloggerList; $output->header = $output->fetchCol("Part/Main/Header"); $output->footer = $output->fetchCol("Part/Main/Footer"); $output->setTemplate('Home'); }
/** * 更新 最新最热 博文列表 每个博主下各抽取5条,最新的、最热的 * 推荐的文章也是依据这个表,会依据 表中的推荐权重字段 */ private function updateTopNewBlog($database) { $db = Db_Blog::instance(null, $database); //最新5篇 $newList = Helper_Blog::getArticleList(array('pageSize' => 5, 'isPublished' => 1, 'fields' => array('id', 'view', 'cate', 'title', 'descript', 'insertTime'), 'order' => 'order by insertTime desc')); //最热5篇 $hotList = Helper_Blog::getArticleList(array('pageSize' => 5, 'isPublished' => 1, 'fields' => array('id', 'view', 'cate', 'title', 'descript', 'insertTime'), 'order' => 'order by view desc')); if (is_array($newList) && is_array($hotList)) { $newHotList = array_merge($newList, $hotList); $webSite = str_replace('blog_', '', $database); foreach ($newHotList as $articleInfo) { //查询推荐权重 $isRecommend = Helper_Blogconfig::getArticleInfo(array('articleId' => $articleInfo['id'], 'webSite' => $webSite, 'fileds' => array('isRecommend'))); $isRecommend = $isRecommend['isRecommend'] ? $isRecommend['isRecommend'] : 0; Helper_Blogconfig::insertHotnew(array('insertData' => array('webSite' => $webSite, 'articleId' => $articleInfo['id'], 'title' => $articleInfo['title'], 'descript' => $articleInfo['descript'], 'cate' => $articleInfo['cate'], 'cateVal' => LJL_Config::get('Blog_' . ucfirst($webSite) . '_Cate', 'CATE')[$articleInfo['cate']][0], 'view' => $articleInfo['view'], 'score' => $articleInfo['view'], 'publishTime' => $articleInfo['insertTime'], 'isRecommend' => $isRecommend))); } } echo $database . ' hot and new blog publish over' . PHP_EOL; }