/**
  * @brief showSearch 显示搜索结果
  *
  * @param $params 传入参数
  *
  * @return void
  */
 public function showSearch($params)
 {
     if (!isset($params['word'])) {
         if (!($word = Request::P('word', 'string'))) {
             Response::back();
         } else {
             Response::redirect(Router::patch('SearchWord', array('word' => urlencode(trim($word)))));
         }
         return;
     }
     // 获取文章数据
     Widget::initWidget('Post');
     Widget::getWidget('Post')->setPerPage(8);
     Widget::getWidget('Post')->setCurrentPage(isset($params['page']) ? $params['page'] : 1);
     // 未来支持分类内搜索
     // Widget::getWidget('Post')->setCurrentMeta( $m[0]['mid'] );
     Widget::getWidget('Post')->setSearchWord(urldecode(trim($params['word'])));
     Widget::getWidget('Post')->query();
     // 设置标题、描述、关键词
     Widget::getWidget('Global')->title = urldecode($params['word']);
     // Widget::getWidget('Global')->description = $m[0]['description'];
     Widget::getWidget('Global')->keywords = urldecode($params['word']);
     $this->display('index.php');
 }
 /**
  * @brief autoLogin 自动登录
  *
  * @return void
  */
 public function autoLogin()
 {
     $uid = Request::C('userid') ? Request::C('userid') : Request::P('userid');
     $password = Request::C('password', 'string') ? Request::C('password', 'string') : Request::P('password', 'string');
     if ($uid == NULL || $password == NULL) {
         return;
     }
     $user = new UserLibrary();
     $user->setUID($uid);
     if ($u = $user->getUser()) {
         if (md5($u['auth'] . $u['password']) != $password) {
             return;
         }
         $this->user['uid'] = $u['uid'];
         $this->user['username'] = $u['username'];
         $this->user['group'] = $u['group'];
         $this->user['email'] = $u['email'];
         $this->user['website'] = $u['website'];
     }
 }
 /**
  * @brief censorComment 审核一条评论
  *
  * @return void
  */
 public function censorComment()
 {
     $cid = Request::P('cid');
     // 删除评论
     $comment = new CommentLibrary();
     $comment->censorComment($cid);
     $r = array('success' => TRUE);
     Response::ajaxReturn($r);
 }
		</form>
<?php 
        showFoot();
        break;
    case 5:
        if (Request::P('submit', 'string')) {
            if (Request::P('password', 'string') != Request::P('repassword', 'string')) {
                showError('<strong>您两次输入的密码不一致</strong><br />请返回重新输入。', 'install.php?step=4');
            }
            if (!Request::P('username', 'string') || !Request::P('password', 'string') || !Request::P('email', 'string')) {
                showError('<strong>用户名、邮箱、密码均为必填</strong><br />请返回重新输入。', 'install.php?step=4');
            }
            $info = Cache::get('InstallInfomation');
            $info['admin'] = Request::P('username', 'string');
            $info['email'] = Request::P('email', 'string');
            $info['adminpw'] = md5(Request::P('password', 'string'));
            $info['domain'] = Request::getDomain();
            Cache::delete('InstallInfomation');
            // 连接到数据库
            Database::connect($info['host'], $info['user'], $info['pw'], $info['name']);
            // 构建数据库
            $scripts = file_get_contents(LOGX_ROOT . 'install.php');
            preg_match('/-- Database ' . 'Structure Begin --(.*)-- Database ' . 'Structure End --/s', $scripts, $match);
            $scripts = $match[1];
            $scripts = str_replace('logx_', $info['prefix'], $scripts);
            $scripts = explode(';', $scripts);
            foreach ($scripts as $script) {
                $script = str_replace(array('{time}', '{blogname}', '{admin}', '{adminpw}', '{domain}', '{email}'), array(time(), $info['blog'], $info['admin'], $info['adminpw'], $info['domain'], $info['email']), trim($script));
                if ($script) {
                    Database::query($script);
                }
 /**
  * @brief delMeta 删除 Meta
  *
  * @return void
  */
 public function delMeta()
 {
     $mid = Request::P('mid');
     $meta = new MetaLibrary();
     if ($meta->delMeta($mid)) {
         $r = array('success' => TRUE, 'message' => _t('Delete Meta complete.'));
     } else {
         $r = array('success' => FALSE, 'message' => _t('Delete Meta failed.'));
     }
     Response::ajaxReturn($r);
 }
 /**
  * @brief deletePost 删除一篇文章
  *
  * @return void
  */
 public function deletePost()
 {
     $pid = Request::P('pid');
     // 删除文章
     $post = new PostLibrary();
     $post->deletePost($pid);
     // 删除 Meta 关系
     $meta = new MetaLibrary();
     $meta->setPID($pid);
     $metas = $meta->getMeta();
     foreach ($metas as $m) {
         if ($m['type'] == 1 || $m['type'] == 2) {
             $meta->delRelation($m['mid'], $pid);
         } elseif ($m['type'] == 3) {
             $meta->movRelation($m['mid'], $pid, 1000000000);
         }
     }
     // 删除评论
     $comment = new CommentLibrary();
     $comment->deleteComments($pid);
     $r = array('success' => TRUE);
     Response::ajaxReturn($r);
 }
 /**
  * @brief advancedSettingsDo 保存高级设置
  *
  * @return void
  */
 private function advancedSettingsDo()
 {
     // 验证用户权限
     if (!Widget::getWidget('User')->isAdmin()) {
         Response::ajaxReturn(array('success' => FALSE, 'message' => _t('Permission denied.')));
         return;
     }
     $rewrite = Request::P('rewrite', 'string');
     $timezone = Request::P('timezone', 'string');
     $register = Request::P('register', 'string');
     if (!$rewrite || !$timezone || !$register) {
         $r = array('success' => FALSE, 'message' => _t('Option can not be null.'));
         Response::ajaxReturn($r);
     } else {
         if ($rewrite == 'close') {
             if (file_exists(LOGX_ROOT . '.htaccess') && !@unlink(LOGX_ROOT . '.htaccess')) {
                 $r = array('success' => FALSE, 'message' => _t('Can not delete .htaccess file.'));
                 Response::ajaxReturn($r);
                 return;
             }
         } else {
             $content = "# BEGIN LogX\n\n<IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteBase " . LOGX_PATH . "\nRewriteCond \$1 ^(index\\.php)?\$ [OR]\nRewriteCond \$1 \\.(gif|jpg|png|css|js|ico)\$ [NC,OR]\nRewriteCond %{REQUEST_FILENAME} -f [OR]\nRewriteCond %{REQUEST_FILENAME} -d\nRewriteRule ^(.*)\$ - [S=1]\nRewriteRule . " . LOGX_PATH . "index.php [L]\n</IfModule>\n\n# END LogX";
             if (!file_exists(LOGX_ROOT . '.htaccess') && !@file_put_contents(LOGX_ROOT . '.htaccess', $content)) {
                 $r = array('success' => FALSE, 'message' => _t('Can not create .htaccess file.'));
                 Response::ajaxReturn($r);
                 return;
             }
         }
         OptionLibrary::set('rewrite', $rewrite);
         OptionLibrary::set('timezone', $timezone);
         OptionLibrary::set('register', $register);
         $r = array('success' => TRUE, 'message' => _t('Settings Saved.'));
         Response::ajaxReturn($r);
     }
 }