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'); }
/** * 父类的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 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 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'); }
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)); }
public function doDefault(LJL_Request $input, LJL_Response $output) { #如果是提交 //var_dump($input->dopost);die; if ($input->dopost && $input->funName) { #获得所有需要参数的值 $iparam = $output->helpCfgArr2[$input->funName]['param']; //var_dump($iparam);die; $paramVal = array(); if ($iparam) { foreach ($iparam as $p) { $paramValArr[$p[0]] = $input->post($p[0]); } } if (isset($paramValArr)) { foreach ($paramValArr as $k => $v) { if ($v == '') { unset($paramValArr[$k]); } } $paramValArr = $output->paramValArr = $paramValArr; // array_filter($paramValArr); } else { $paramValArr = array(); $output->paramValArr = $paramValArr; } #获得结果 $tmpArr = explode("::", $input->funName); $className = "Helper_" . $tmpArr[0]; //var_dump($className);die; $classMethod = $tmpArr[1]; #特殊处理 if ('Helper_Blog' == $className && in_array($classMethod, array('getArticleList', 'getArticleInfo'))) { Db_Blog::instance(null, 'blog_laura'); } if (isset($output->helpCfgArr2[$input->funName]['norun'])) { $output->htmlVarStr = $output->helpCfgArr2[$input->funName]['norun']; } else { $data = call_user_func(array($className, $classMethod), $paramValArr); $output->htmlVarStr = Libs_Tools_VarDump::showVar($data); } } $output->setTemplate('HelperManage'); }
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 doSinalogin(LJL_Request $input, LJL_Response $output) { // $userInfo = LJL_Api::run('Open.Sina.getWeiboByUrl' , array( // //'apiuid' => '2004858905', // //'appuid' => '20', // //'name' => '崔洪波同学', // 'url' => 'http://cui.zhbor.com/article/13.html#0-tsina-1-38138-397232819ff9a47a7b7e80a40613cfe1', // )); // var_dump($userInfo);die; $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if ($input->get('code')) { $tokenInfo = LJL_Api::run('Open.Sina.getLoginTokens', array('code' => $input->get('code'), 'redirect_uri' => $redirect_uri)); $userInfo = LJL_Api::run('Open.Sina.getUserInfo', array('uid' => $tokenInfo['uid'], 'accessToken' => $tokenInfo['access_token'])); var_dump($tokenInfo); var_dump($userInfo); die; } $loginurl = LJL_Api::run('Open.Sina.getAuthorizeURL', array('redirect_uri' => $redirect_uri)); echo '<a href="' . $loginurl . '">微博登陆</a>'; die; }
public static function handler($exception) { if ($exception instanceof Exception) { $debugging = defined('IS_DEBUGGING') ? IS_DEBUGGING : false; $production = defined('IS_PRODUCTION') ? IS_PRODUCTION : false; if (true == $debugging) { if (true == $production) { LJL_Log::write(API_String::clean($exception), LJL_Log::TYPE_EXCEPTION); } else { echo LJL_Request::resolveType() == LJL_Request::CLI ? API_String::clean($exception) : $exception; } } else { header('location: ' . SYSTEM_HOMEPAGE); } } }
public static function handler($level, $errorMsg, $file, $line, $context = null) { if ('.tpl.php' == substr($file, -8)) { return; } $str = new LJL_Exception($errorMsg, $level, $file, $line); $debugging = IS_DEBUGGING; $production = IS_PRODUCTION; if ($debugging) { $content = "<br />\n<h2>Error Info:</h2>\n" . '<b>MESSAGE:</b> ' . $errorMsg . "<br />\n" . '<b>TYPE:</b> ' . (isset(self::$levels[$level]) ? self::$levels[$level] : $level) . "<br />\n" . '<b>FILE:</b> ' . $file . "<br />\n" . '<b>LINE:</b> ' . $line . "<br />\n" . $str; if ($production) { LJL_Log::write(API_String::clean($content), LJL_Log::TYPE_ERROR); } else { echo LJL_Request::resolveType() == LJL_Request::CLI ? API_String::clean($content) : $content; } } }
/** * 执行登录 */ 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 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>'; } }
public function doDing(LJL_Request $input, LJL_Response $output) { $commentId = (int) $input->get('commentid'); Helper_Blog::updateComment(array('commentid' => $commentId)); exit; }
/** * 导入标签,如果指定了天数,则就从指定前几天,如果没有指定天数,则从上一次插入的时间开始 * @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; }
/** * 搜索 */ public function doSearch(LJL_Request $input, LJL_Response $output) { $output->type = $type = $input->get('type'); if ($type === 'tags') { $this->doDefault($input, $output); } else { $this->_fulltextSearch($input, $output); } }