/** * 父类的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 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; }