示例#1
0
 /**
  * 评论处理函数
  *
  * @throws Typecho_Widget_Exception
  * @throws Exception
  * @throws Typecho_Exception
  */
 private function comment()
 {
     // modified_by_jiangmuzi 2015.09.23
     // 必须登录后才可以回复
     if (!$this->user->hasLogin()) {
         $this->widget('Widget_Notice')->set(_t('请先<a href="%s">登录</a>', $this->options->someUrl('login', null, false) . '?redir=' . $this->request->getRequestUrl()), NULL, 'success');
         $this->response->goBack();
     }
     // end modified
     // 使用安全模块保护
     $this->security->protect();
     $comment = array('cid' => $this->_content->cid, 'created' => $this->options->gmtTime, 'agent' => $this->request->getAgent(), 'ip' => $this->request->getIp(), 'ownerId' => $this->_content->author->uid, 'type' => 'comment', 'status' => !$this->_content->allow('edit') && $this->options->commentsRequireModeration ? 'waiting' : 'approved');
     //检验格式
     $validator = new Typecho_Validate();
     $validator->addRule('text', 'required', _t('必须填写评论内容'));
     $comment['text'] = $this->request->text;
     /** 记录登录用户的id */
     $comment['authorId'] = $this->user->uid;
     if ($error = $validator->run($comment)) {
         /** 记录文字 */
         Typecho_Cookie::set('__some_remember_text', $comment['text']);
         throw new Typecho_Widget_Exception(implode("\n", $error));
     }
     /** 生成过滤器 */
     try {
         $comment = $this->pluginHandle()->comment($comment, $this->_content);
     } catch (Typecho_Exception $e) {
         Typecho_Cookie::set('__some_remember_text', $comment['text']);
         throw $e;
     }
     // modified_by_jiangmuzi 2015.09.23
     // 解析@数据
     $atArr = $this->searchAt($comment);
     // end modified
     /** 添加评论 */
     $commentId = $this->insert($comment);
     Typecho_Cookie::delete('__some_remember_text');
     $this->db->fetchRow($this->select()->where('coid = ?', $commentId)->limit(1), array($this, 'push'));
     //更新最后评论人及时间
     $this->db->query($this->db->update('table.contents')->rows(array('lastUid' => $this->authorId, 'lastComment' => $this->created))->where('cid = ?', $this->cid));
     //提醒主题作者
     if ($comment['authorId'] != $comment['ownerId']) {
         $atArr[] = array('uid' => $comment['ownerId'], 'type' => 'comment');
     }
     if (!empty($atArr)) {
         foreach ($atArr as $v) {
             $this->widget('Widget_Users_Messages')->addMessage($v['uid'], $commentId, $v['type']);
         }
     }
     //触发评论积分规则
     Widget_Common::credits('reply', null, $commentId);
     /** 评论完成接口 */
     $this->pluginHandle()->finishComment($this);
     $this->response->goBack('#' . $this->theId);
 }
示例#2
0
文件: header.php 项目: rootml/jianshu
/**
 * 获取提示消息
 */
function getNotice()
{
    $notice = Typecho_Cookie::get('__typecho_notice');
    if (empty($notice)) {
        echo "''";
        return;
    }
    $notice = json_decode($notice, true);
    $rs = array('msg' => $notice[0], 'type' => Typecho_Cookie::get('__typecho_notice_type'));
    Typecho_Cookie::delete('__typecho_notice');
    Typecho_Cookie::delete('__typecho_notice_type');
    echo json_encode($rs);
}
示例#3
0
 /**
  * 执行函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     if (NULL !== Typecho_Cookie::get('__typecho_notice')) {
         $this->noticeType = Typecho_Cookie::get('__typecho_notice_type');
         $this->push(Typecho_Cookie::get('__typecho_notice'));
         Typecho_Cookie::delete('__typecho_notice', $this->widget('Widget_Options')->siteUrl);
         Typecho_Cookie::delete('__typecho_notice_type', $this->widget('Widget_Options')->siteUrl);
     }
     if (NULL !== Typecho_Cookie::get('__typecho_notice_highlight')) {
         $this->highlight = Typecho_Cookie::get('__typecho_notice_highlight');
         Typecho_Cookie::delete('__typecho_notice_highlight', $this->widget('Widget_Options')->siteUrl);
     }
 }
示例#4
0
 /**
  * 初始化函数
  *
  * @access public
  * @return void
  */
 public function action()
 {
     // protect
     $this->security->protect();
     /** 如果已经登录 */
     if ($this->user->hasLogin() || !$this->options->allowRegister) {
         /** 直接返回 */
         $this->response->redirect($this->options->index);
     }
     /** 初始化验证类 */
     $validator = new Typecho_Validate();
     $validator->addRule('name', 'required', _t('必须填写用户名称'));
     $validator->addRule('name', 'minLength', _t('用户名至少包含2个字符'), 2);
     $validator->addRule('name', 'maxLength', _t('用户名最多包含32个字符'), 32);
     $validator->addRule('name', 'xssCheck', _t('请不要在用户名中使用特殊字符'));
     $validator->addRule('name', array($this, 'nameExists'), _t('用户名已经存在'));
     $validator->addRule('mail', 'required', _t('必须填写电子邮箱'));
     $validator->addRule('mail', array($this, 'mailExists'), _t('电子邮箱地址已经存在'));
     $validator->addRule('mail', 'email', _t('电子邮箱格式错误'));
     $validator->addRule('mail', 'maxLength', _t('电子邮箱最多包含200个字符'), 200);
     /** 如果请求中有password */
     if (array_key_exists('password', $_REQUEST)) {
         $validator->addRule('password', 'required', _t('必须填写密码'));
         $validator->addRule('password', 'minLength', _t('为了保证账户安全, 请输入至少六位的密码'), 6);
         $validator->addRule('password', 'maxLength', _t('为了便于记忆, 密码长度请不要超过十八位'), 18);
         $validator->addRule('confirm', 'confirm', _t('两次输入的密码不一致'), 'password');
     }
     /** 截获验证异常 */
     if ($error = $validator->run($this->request->from('name', 'password', 'mail', 'confirm'))) {
         Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
         Typecho_Cookie::set('__typecho_remember_mail', $this->request->mail);
         /** 设置提示信息 */
         $this->widget('Widget_Notice')->set($error);
         $this->response->goBack();
     }
     $hasher = new PasswordHash(8, true);
     $generatedPassword = Typecho_Common::randString(7);
     $dataStruct = array('name' => $this->request->name, 'mail' => $this->request->mail, 'screenName' => $this->request->name, 'password' => $hasher->HashPassword($generatedPassword), 'created' => $this->options->gmtTime, 'group' => 'subscriber');
     $dataStruct = $this->pluginHandle()->register($dataStruct);
     $insertId = $this->insert($dataStruct);
     $this->db->fetchRow($this->select()->where('uid = ?', $insertId)->limit(1), array($this, 'push'));
     $this->pluginHandle()->finishRegister($this);
     $this->user->login($this->request->name, $generatedPassword);
     Typecho_Cookie::delete('__typecho_first_run');
     Typecho_Cookie::delete('__typecho_remember_name');
     Typecho_Cookie::delete('__typecho_remember_mail');
     $this->widget('Widget_Notice')->set(_t('用户 <strong>%s</strong> 已经成功注册, 密码为 <strong>%s</strong>', $this->screenName, $generatedPassword), 'success');
     $this->response->redirect($this->options->adminUrl);
 }
示例#5
0
if (!defined('__TYPECHO_ROOT_DIR__')) {
    exit;
}
$this->need('header.php');
?>
<style>.user-page .page-title,.user-page footer{display:none;}</style>
<?php 
$rememberName = htmlspecialchars(Typecho_Cookie::get('__some_remember_name'));
$rememberMail = htmlspecialchars(Typecho_Cookie::get('__some_remember_mail'));
$notice = Typecho_Cookie::get('__some_notice');
if (!empty($notice)) {
    $notice = json_decode($notice, true);
}
Typecho_Cookie::delete('__some_remember_name');
Typecho_Cookie::delete('__some_remember_mail');
?>
<div id="sidebar">
    <?php 
$this->need('user/widget_login.php');
?>
</div>
<div class="box" id="main">
    <div class="head">
        <div class="location">
            <a href="<?php 
$this->options->siteUrl();
?>
"><?php 
$this->options->title();
?>
示例#6
0
             foreach ($tableArray as $table) {
                 if ($type == 'Mysql') {
                     $installDb->query("DROP TABLE IF EXISTS `{$table}`");
                 } elseif ($type == 'Pgsql') {
                     $installDb->query("DROP TABLE {$table}");
                 } elseif ($type == 'SQLite') {
                     $installDb->query("DROP TABLE {$table}");
                 }
             }
             echo '<p class="message success">' . _t('已经删除完原有数据') . '<br /><br /><button type="submit" class="primary">' . _t('继续安装 &raquo;') . '</button></p>';
         } elseif (_r('goahead')) {
             //使用原有数据
             //但是要更新用户网站
             $installDb->query($installDb->update('table.options')->rows(array('value' => $config['siteUrl']))->where('name = ?', 'siteUrl'));
             unset($_SESSION['typecho']);
             Typecho_Cookie::delete('__typecho_config');
             header('Location: ./install.php?finish&use_old');
             exit;
         } else {
             echo '<p class="message error">' . _t('安装程序检查到原有数据表已经存在.') . '<br /><br />' . '<button type="submit" name="delete" value="1" class="btn-warn">' . _t('删除原有数据') . '</button> ' . _t('或者') . ' <button type="submit" name="goahead" value="1" class="primary">' . _t('使用原有数据') . '</button></p>';
         }
     } else {
         echo '<p class="message error">' . _t('安装程序捕捉到以下错误: "%s". 程序被终止, 请检查您的配置信息.', $e->getMessage()) . '</p>';
     }
     ?>
             </form>
         </div>
                                 <?php 
 }
 ?>
         <?php 
示例#7
0
 /**
  * 评论处理函数
  *
  * @throws Typecho_Widget_Exception
  * @throws Exception
  * @throws Typecho_Exception
  */
 private function comment()
 {
     // modified_by_jiangmuzi 2015.09.23
     // 必须登录后才可以回复
     if (!$this->user->hasLogin()) {
         $this->widget('Widget_Notice')->set(_t('请先<a href="%s">登录</a>', $this->options->someUrl('login', null, false) . '?redir=' . $this->request->getRequestUrl()), NULL, 'success');
         $this->response->goBack();
     }
     // end modified
     // 使用安全模块保护
     $this->security->protect();
     $comment = array('cid' => $this->_content->cid, 'created' => $this->options->gmtTime, 'agent' => $this->request->getAgent(), 'ip' => $this->request->getIp(), 'ownerId' => $this->_content->author->uid, 'type' => 'comment', 'status' => !$this->_content->allow('edit') && $this->options->commentsRequireModeration ? 'waiting' : 'approved');
     /** 判断父节点 */
     if ($parentId = $this->request->filter('int')->get('parent')) {
         if ($this->options->commentsThreaded && ($parent = $this->db->fetchRow($this->db->select('coid', 'cid')->from('table.comments')->where('coid = ?', $parentId))) && $this->_content->cid == $parent['cid']) {
             $comment['parent'] = $parentId;
         } else {
             throw new Typecho_Widget_Exception(_t('父级评论不存在'));
         }
     }
     //检验格式
     $validator = new Typecho_Validate();
     $validator->addRule('author', 'required', _t('必须填写用户名'));
     $validator->addRule('author', 'xssCheck', _t('请不要在用户名中使用特殊字符'));
     $validator->addRule('author', array($this, 'requireUserLogin'), _t('您所使用的用户名已经被注册,请登录后再次提交'));
     $validator->addRule('author', 'maxLength', _t('用户名最多包含200个字符'), 200);
     if ($this->options->commentsRequireMail && !$this->user->hasLogin()) {
         $validator->addRule('mail', 'required', _t('必须填写电子邮箱地址'));
     }
     $validator->addRule('mail', 'email', _t('邮箱地址不合法'));
     $validator->addRule('mail', 'maxLength', _t('电子邮箱最多包含200个字符'), 200);
     if ($this->options->commentsRequireUrl && !$this->user->hasLogin()) {
         $validator->addRule('url', 'required', _t('必须填写个人主页'));
     }
     $validator->addRule('url', 'url', _t('个人主页地址格式错误'));
     $validator->addRule('url', 'maxLength', _t('个人主页地址最多包含200个字符'), 200);
     $validator->addRule('text', 'required', _t('必须填写评论内容'));
     $comment['text'] = $this->request->text;
     /** 对一般匿名访问者,将用户数据保存一个月 */
     if (!$this->user->hasLogin()) {
         /** Anti-XSS */
         $comment['author'] = $this->request->filter('trim')->author;
         $comment['mail'] = $this->request->filter('trim')->mail;
         $comment['url'] = $this->request->filter('trim')->url;
         /** 修正用户提交的url */
         if (!empty($comment['url'])) {
             $urlParams = parse_url($comment['url']);
             if (!isset($urlParams['scheme'])) {
                 $comment['url'] = 'http://' . $comment['url'];
             }
         }
         $expire = $this->options->gmtTime + $this->options->timezone + 30 * 24 * 3600;
         Typecho_Cookie::set('__typecho_remember_author', $comment['author'], $expire);
         Typecho_Cookie::set('__typecho_remember_mail', $comment['mail'], $expire);
         Typecho_Cookie::set('__typecho_remember_url', $comment['url'], $expire);
     } else {
         $comment['author'] = $this->user->screenName;
         $comment['mail'] = $this->user->mail;
         $comment['url'] = $this->user->url;
         /** 记录登录用户的id */
         $comment['authorId'] = $this->user->uid;
     }
     /** 评论者之前须有评论通过了审核 */
     if (!$this->options->commentsRequireModeration && $this->options->commentsWhitelist) {
         if ($commentApprovedNum = $this->size($this->select()->where('author = ? AND mail = ? AND status = ?', $comment['author'], $comment['mail'], 'approved'))) {
             $comment['status'] = 'approved';
         } else {
             $comment['status'] = 'waiting';
         }
     }
     if ($error = $validator->run($comment)) {
         /** 记录文字 */
         Typecho_Cookie::set('__typecho_remember_text', $comment['text']);
         throw new Typecho_Widget_Exception(implode("\n", $error));
     }
     /** 生成过滤器 */
     try {
         $comment = $this->pluginHandle()->comment($comment, $this->_content);
     } catch (Typecho_Exception $e) {
         Typecho_Cookie::set('__typecho_remember_text', $comment['text']);
         throw $e;
     }
     // modified_by_jiangmuzi 2015.09.23
     // 解析@数据
     $search = $replace = $atMsg = array();
     $pattern = "/@([^@^\\s^:]{1,})([\\s\\:\\,\\;]{0,1})/";
     preg_match_all($pattern, $comment['text'], $matches);
     if (!empty($matches[1])) {
         $matches[1] = array_unique($matches[1]);
         foreach ($matches[1] as $name) {
             if (empty($name)) {
                 continue;
             }
             $atUser = $this->widget('Forum_Query_User@name_' . $name, array('name' => $name));
             if (!$atUser->have()) {
                 continue;
             }
             $search[] = '@' . $name;
             $replace[] = '<a href="' . $atUser->ucenter . '" target="_blank">@' . $name . '</a>';
             //提醒at用户
             if ($comment['authorId'] != $atUser->uid && $atUser->uid != $comment['ownerId']) {
                 $atMsg[] = array('uid' => $atUser->uid, 'type' => 'at');
             }
         }
         if (!empty($search)) {
             $comment['text'] = str_replace(@$search, @$replace, $comment['text']);
         }
     }
     // end modified
     /** 添加评论 */
     $commentId = $this->insert($comment);
     Typecho_Cookie::delete('__typecho_remember_text');
     $this->db->fetchRow($this->select()->where('coid = ?', $commentId)->limit(1), array($this, 'push'));
     //提醒主题作者
     if ($comment['authorId'] != $comment['ownerId']) {
         $atMsg[] = array('uid' => $comment['ownerId'], 'type' => 'comment');
     }
     if (!empty($atMsg)) {
         foreach ($atMsg as $v) {
             $this->widget('Forum_Messages')->addMessage($v['uid'], $commentId, $v['type']);
         }
     }
     /** 评论完成接口 */
     $this->pluginHandle()->finishComment($this);
     $this->response->goBack('#' . $this->theId);
 }
示例#8
0
 /**
  * 用户登出函数
  *
  * @access public
  * @return void
  */
 public function logout()
 {
     $this->pluginHandle()->trigger($logoutPluggable)->logout();
     if ($logoutPluggable) {
         return;
     }
     Typecho_Cookie::delete('__typecho_uid');
     Typecho_Cookie::delete('__typecho_authCode');
 }
示例#9
0
<?php

include 'common.php';
if ($user->hasLogin() || !$options->allowRegister) {
    $response->redirect($options->siteUrl);
}
$rememberName = htmlspecialchars(Typecho_Cookie::get('__typecho_remember_name'));
$rememberMail = htmlspecialchars(Typecho_Cookie::get('__typecho_remember_mail'));
Typecho_Cookie::delete('__typecho_remember_name');
Typecho_Cookie::delete('__typecho_remember_mail');
$bodyClass = 'body-100';
include 'header.php';
?>
<div class="typecho-login-wrap">
    <div class="typecho-login">
        
        <form action="<?php 
$options->registerAction();
?>
" method="post" name="register" role="form">
            <p>
                <label for="name" class="sr-only"><?php 
_e('用户名');
?>
</label>
                <input type="text" id="name" name="name" placeholder="<?php 
_e('用户名');
?>
" value="<?php 
echo $rememberName;
?>
示例#10
0
 /**
  * 插件实现方法
  *
  * @access public
  * @return void
  */
 public static function setTheme($widget)
 {
     $cookie = array('name' => '__typecho_theme', 'expire' => 86400);
     $options = Typecho_Widget::widget('Widget_Options');
     if (isset($widget->request->theme) && $widget->request->isGet()) {
         if ($widget->request->theme) {
             $theme = $widget->request->theme;
             if (static::check($theme)) {
                 Typecho_Cookie::set($cookie['name'], $widget->request->theme, $options->gmtTime + $cookie['expire'], $options->siteUrl);
             } else {
                 $widget->response->redirect(Typecho_Common::url($widget->request->getPathInfo(), $options->siteUrl));
             }
         } else {
             Typecho_Cookie::delete($cookie['name']);
             //直接提交?theme将删除cookie,恢复默认主题
             return;
         }
     } else {
         $theme = Typecho_Cookie::get($cookie['name']);
         if (!$theme) {
             return;
         }
         if (!static::check($theme)) {
             Typecho_Cookie::delete($cookie['name']);
             return;
         }
     }
     /** 删除旧主题的相关设置 */
     $themeRow = 'theme:' . $options->theme;
     if (isset($options->{$themeRow})) {
         $config = unserialize($options->{$themeRow});
         $options->{$themeRow} = '';
         foreach ($config as $row => $value) {
             $options->{$row} = '';
         }
     }
     /** 载入新主题的相关设置 参考var/Widget/Themes/Edit.php */
     $themeDir = __TYPECHO_ROOT_DIR__ . __TYPECHO_THEME_DIR__ . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR;
     $configFile = $themeDir . 'functions.php';
     if (file_exists($configFile)) {
         require_once $configFile;
         if (function_exists('themeConfig')) {
             $form = new Typecho_Widget_Helper_Form();
             themeConfig($form);
             $config = $form->getValues();
             if ($config) {
                 $options->{'theme:' . $theme} = serialize($config);
                 foreach ($config as $row => $value) {
                     $options->{$row} = $value;
                 }
             }
         }
     }
     /** 修改$this->options->theme */
     $options->theme = $theme;
     /** 修改$this->_themeDir */
     $widget->setThemeDir($themeDir);
 }
示例#11
0
文件: Feedback.php 项目: rptec/sisome
 /**
  * 评论处理函数
  *
  * @throws Typecho_Widget_Exception
  * @throws Exception
  * @throws Typecho_Exception
  */
 private function comment()
 {
     // modified_by_jiangmuzi 2015.09.23
     // 必须登录后才可以回复
     if (!$this->user->hasLogin()) {
         $this->widget('Widget_Notice')->set(_t('请先<a href="%s">登录</a>', $this->options->someUrl('login', null, false) . '?redir=' . $this->request->getRequestUrl()), NULL, 'success');
         $this->response->goBack();
     }
     // end modified
     // 使用安全模块保护
     $this->security->protect();
     $comment = array('cid' => $this->_content->cid, 'created' => $this->options->gmtTime, 'agent' => $this->request->getAgent(), 'ip' => $this->request->getIp(), 'ownerId' => $this->_content->author->uid, 'type' => 'comment', 'status' => !$this->_content->allow('edit') && $this->options->commentsRequireModeration ? 'waiting' : 'approved');
     /** 判断父节点 */
     /*
             if ($parentId = $this->request->filter('int')->get('parent')) {
                 if ($this->options->commentsThreaded && ($parent = $this->db->fetchRow($this->db->select('coid', 'cid')->from('table.comments')
                 ->where('coid = ?', $parentId))) && $this->_content->cid == $parent['cid']) {
                     $comment['parent'] = $parentId;
                 } else {
                     throw new Typecho_Widget_Exception(_t('父级评论不存在'));
                 }
             }*/
     //检验格式
     $validator = new Typecho_Validate();
     $validator->addRule('text', 'required', _t('必须填写评论内容'));
     $comment['text'] = $this->request->text;
     /** 记录登录用户的id */
     $comment['authorId'] = $this->user->uid;
     if ($error = $validator->run($comment)) {
         /** 记录文字 */
         Typecho_Cookie::set('__some_remember_text', $comment['text']);
         throw new Typecho_Widget_Exception(implode("\n", $error));
     }
     /** 生成过滤器 */
     try {
         $comment = $this->pluginHandle()->comment($comment, $this->_content);
     } catch (Typecho_Exception $e) {
         Typecho_Cookie::set('__some_remember_text', $comment['text']);
         throw $e;
     }
     // modified_by_jiangmuzi 2015.09.23
     // 解析@数据
     $search = $replace = $atMsg = array();
     $pattern = "/@([^@^\\s^:]{1,})([\\s\\:\\,\\;]{0,1})/";
     preg_match_all($pattern, $comment['text'], $matches);
     if (!empty($matches[1])) {
         $matches[1] = array_unique($matches[1]);
         foreach ($matches[1] as $name) {
             if (empty($name)) {
                 continue;
             }
             $atUser = $this->widget('Widget_Users_Query@name_' . $name, array('name' => $name));
             if (!$atUser->have()) {
                 continue;
             }
             $search[] = '@' . $name;
             $replace[] = '<a href="' . $atUser->ucenter . '" target="_blank">@' . $name . '</a>';
             //提醒at用户
             if ($comment['authorId'] != $atUser->uid && $atUser->uid != $comment['ownerId']) {
                 $atMsg[] = array('uid' => $atUser->uid, 'type' => 'at');
             }
         }
         if (!empty($search)) {
             $comment['text'] = str_replace(@$search, @$replace, $comment['text']);
         }
     }
     // end modified
     /** 添加评论 */
     $commentId = $this->insert($comment);
     Typecho_Cookie::delete('__some_remember_text');
     $this->db->fetchRow($this->select()->where('coid = ?', $commentId)->limit(1), array($this, 'push'));
     //更新最后评论人及时间
     $this->db->query($this->db->update('table.contents')->rows(array('lastUid' => $this->authorId, 'lastComment' => $this->created))->where('cid = ?', $this->cid));
     //提醒主题作者
     if ($comment['authorId'] != $comment['ownerId']) {
         $atMsg[] = array('uid' => $comment['ownerId'], 'type' => 'comment');
     }
     if (!empty($atMsg)) {
         foreach ($atMsg as $v) {
             $this->widget('Widget_Users_Messages')->addMessage($v['uid'], $commentId, $v['type']);
         }
     }
     //触发评论积分规则
     Widget_Common::credits('reply');
     /** 评论完成接口 */
     $this->pluginHandle()->finishComment($this);
     $this->response->goBack('#' . $this->theId);
 }
示例#12
0
 /**
  * 执行升级程序
  *
  * @access public
  * @return void
  */
 public function upgrade()
 {
     list($prefix, $this->_currentVersion) = explode('/', $this->options->generator);
     $packages = get_class_methods('Upgrade');
     $packages = array_filter($packages, array($this, 'filterPackage'));
     usort($packages, array($this, 'sortPackage'));
     $message = array();
     foreach ($packages as $package) {
         $options = $this->widget('Widget_Options@' . $package);
         /** 执行升级脚本 */
         try {
             $result = call_user_func(array('Upgrade', $package), $this->db, $options);
             if (!empty($result)) {
                 $message[] = $result;
             }
         } catch (Typecho_Exception $e) {
             $this->widget('Widget_Notice')->set($e->getMessage(), 'error');
             $this->response->goBack();
             return;
         }
         list($ver, $rev) = explode('r', $package);
         $ver = substr(str_replace('_', '.', $ver), 1);
         $rev = str_replace('_', '.', $rev);
         /** 更新版本号 */
         $this->update(array('value' => 'Typecho ' . $ver . '/' . $rev), $this->db->sql()->where('name = ?', 'generator'));
         $this->destory('Widget_Options@' . $package);
     }
     /** 更新版本号 */
     $this->update(array('value' => 'Typecho ' . Typecho_Common::VERSION), $this->db->sql()->where('name = ?', 'generator'));
     /** 删除更新cookie */
     Typecho_Cookie::delete('__typecho_check_version');
     $this->widget('Widget_Notice')->set(empty($message) ? _t("升级已经完成") : $message, empty($message) ? 'success' : 'notice');
 }
示例#13
0
文件: Form.php 项目: raindali/express
 /**
  * 显示表单
  *
  * @access public
  * @return void
  */
 public function render()
 {
     $id = md5(implode('"', array_keys($this->_inputs)));
     /** 恢复表单值 */
     if ($record = Typecho_Cookie::get('__typecho_form_record_' . $id)) {
         $message = Typecho_Cookie::get('__typecho_form_message_' . $id);
         foreach ($this->_inputs as $name => $input) {
             $input->value(isset($record[$name]) ? $record[$name] : $input->value);
             /** 显示错误消息 */
             if (isset($message[$name])) {
                 $input->message($message[$name]);
             }
         }
         Typecho_Cookie::delete('__typecho_form_record_' . $id);
     }
     parent::render();
     Typecho_Cookie::delete('__typecho_form_message_' . $id);
 }
示例#14
0
 /**
  * 评论处理函数
  *
  * @throws Typecho_Widget_Exception
  * @throws Exception
  * @throws Typecho_Exception
  */
 private function comment()
 {
     // 使用安全模块保护
     $this->security->protect();
     $comment = array('cid' => $this->_content->cid, 'created' => $this->options->gmtTime, 'agent' => $this->request->getAgent(), 'ip' => $this->request->getIp(), 'ownerId' => $this->_content->author->uid, 'type' => 'comment', 'status' => !$this->_content->allow('edit') && $this->options->commentsRequireModeration ? 'waiting' : 'approved');
     /** 判断父节点 */
     if ($parentId = $this->request->filter('int')->get('parent')) {
         if ($this->options->commentsThreaded && ($parent = $this->db->fetchRow($this->db->select('coid', 'cid')->from('table.comments')->where('coid = ?', $parentId))) && $this->_content->cid == $parent['cid']) {
             $comment['parent'] = $parentId;
         } else {
             throw new Typecho_Widget_Exception(_t('父级评论不存在'));
         }
     }
     //检验格式
     $validator = new Typecho_Validate();
     $validator->addRule('author', 'required', _t('必须填写用户名'));
     $validator->addRule('author', 'xssCheck', _t('请不要在用户名中使用特殊字符'));
     $validator->addRule('author', array($this, 'requireUserLogin'), _t('您所使用的用户名已经被注册,请登录后再次提交'));
     $validator->addRule('author', 'maxLength', _t('用户名最多包含200个字符'), 200);
     if ($this->options->commentsRequireMail && !$this->user->hasLogin()) {
         $validator->addRule('mail', 'required', _t('必须填写电子邮箱地址'));
     }
     $validator->addRule('mail', 'email', _t('邮箱地址不合法'));
     $validator->addRule('mail', 'maxLength', _t('电子邮箱最多包含200个字符'), 200);
     if ($this->options->commentsRequireUrl && !$this->user->hasLogin()) {
         $validator->addRule('url', 'required', _t('必须填写个人主页'));
     }
     $validator->addRule('url', 'url', _t('个人主页地址格式错误'));
     $validator->addRule('url', 'maxLength', _t('个人主页地址最多包含200个字符'), 200);
     $validator->addRule('text', 'required', _t('必须填写评论内容'));
     $comment['text'] = $this->request->text;
     /** 对一般匿名访问者,将用户数据保存一个月 */
     if (!$this->user->hasLogin()) {
         /** Anti-XSS */
         $comment['author'] = $this->request->filter('trim')->author;
         $comment['mail'] = $this->request->filter('trim')->mail;
         $comment['url'] = $this->request->filter('trim')->url;
         /** 修正用户提交的url */
         if (!empty($comment['url'])) {
             $urlParams = parse_url($comment['url']);
             if (!isset($urlParams['scheme'])) {
                 $comment['url'] = 'http://' . $comment['url'];
             }
         }
         $expire = $this->options->gmtTime + $this->options->timezone + 30 * 24 * 3600;
         Typecho_Cookie::set('__typecho_remember_author', $comment['author'], $expire);
         Typecho_Cookie::set('__typecho_remember_mail', $comment['mail'], $expire);
         Typecho_Cookie::set('__typecho_remember_url', $comment['url'], $expire);
     } else {
         $comment['author'] = $this->user->screenName;
         $comment['mail'] = $this->user->mail;
         $comment['url'] = $this->user->url;
         /** 记录登录用户的id */
         $comment['authorId'] = $this->user->uid;
     }
     /** 评论者之前须有评论通过了审核 */
     if (!$this->options->commentsRequireModeration && $this->options->commentsWhitelist) {
         if ($this->size($this->select()->where('author = ? AND mail = ? AND status = ?', $comment['author'], $comment['mail'], 'approved'))) {
             $comment['status'] = 'approved';
         } else {
             $comment['status'] = 'waiting';
         }
     }
     if ($error = $validator->run($comment)) {
         /** 记录文字 */
         Typecho_Cookie::set('__typecho_remember_text', $comment['text']);
         throw new Typecho_Widget_Exception(implode("\n", $error));
     }
     /** 生成过滤器 */
     try {
         $comment = $this->pluginHandle()->comment($comment, $this->_content);
     } catch (Typecho_Exception $e) {
         Typecho_Cookie::set('__typecho_remember_text', $comment['text']);
         throw $e;
     }
     /** 添加评论 */
     $commentId = $this->insert($comment);
     Typecho_Cookie::delete('__typecho_remember_text');
     $this->db->fetchRow($this->select()->where('coid = ?', $commentId)->limit(1), array($this, 'push'));
     /** 评论完成接口 */
     $this->pluginHandle()->finishComment($this);
     $this->response->goBack('#' . $this->theId);
 }
示例#15
0
文件: User.php 项目: raindali/express
 /**
  * 用户登出函数
  *
  * @access public
  * @return void
  */
 public function logout()
 {
     $this->pluginHandle()->trigger($logoutPluggable)->logout();
     if ($logoutPluggable) {
         return;
     }
     Typecho_Cookie::delete('__typecho_uid', $this->options->siteUrl);
     Typecho_Cookie::delete('__typecho_authCode', $this->options->siteUrl);
     Typecho_Cookie::delete('__typecho_feed');
     Typecho_Cookie::delete('__typecho_check_version');
 }
示例#16
0
 public static function hasLogin()
 {
     $cookieUid = Typecho_Cookie::get('__typecho_uid');
     if (null !== $cookieUid) {
         $db = Typecho_Db::get();
         $user = $db->fetchRow($db->select()->from('table.users')->where('uid = ?', intval($cookieUid))->limit(1));
         $cookieAuthCode = Typecho_Cookie::get('__typecho_authCode');
         if ($user && Typecho_Common::hashValidate($user['authCode'], $cookieAuthCode)) {
             return true;
         }
         Typecho_Cookie::delete('__typecho_uid');
         Typecho_Cookie::delete('__typecho_authCode');
     }
     return false;
 }
示例#17
0
                    <form method="post" action="?config" name="config">
                    <p class="message error"><?php 
        _e('您没有执行安装步骤,请您重新安装!');
        ?>
 <button class="btn primary" type="submit"><?php 
        _e('重新安装 &raquo;');
        ?>
</button></p>
                    </form>
                </div>
                <?php 
    } else {
        ?>
                    <?php 
        $config = unserialize(base64_decode(Typecho_Cookie::get('__some_config')));
        Typecho_Cookie::delete('__some_config');
        $db = new Typecho_Db($config['adapter'], $config['prefix']);
        $db->addServer($config, Typecho_Db::READ | Typecho_Db::WRITE);
        Typecho_Db::set($db);
        ?>
                <h1 class="typecho-install-title"><?php 
        _e('安装成功!');
        ?>
</h1>
                <div class="typecho-install-body">
                    <div class="message success">
                    <?php 
        if (isset($_GET['use_old'])) {
            ?>
                    <?php 
            _e('您选择了使用原有的数据, 您的用户名和密码和原来的一致');
示例#18
0
文件: Oauth.php 项目: dccecc/typecho
 protected function doBindRegister()
 {
     $validator = new Typecho_Validate();
     $validator->addRule('mail', 'required', _t('必须填写电子邮箱'));
     $validator->addRule('mail', array($this, 'mailExists'), _t('电子邮箱地址已经存在'));
     $validator->addRule('mail', 'email', _t('电子邮箱格式错误'));
     $validator->addRule('mail', 'maxLength', _t('电子邮箱最多包含200个字符'), 200);
     $validator->addRule('nickname', 'required', _t('必须填写昵称'));
     $validator->addRule('nickname', 'xssCheck', _t('请不要在昵称中使用特殊字符'));
     $validator->addRule('nickname', array($this, 'screenNameExists'), _t('昵称已经存在'));
     /** 截获验证异常 */
     if ($error = $validator->run($this->request->from('mail', 'nickname'))) {
         /** 设置提示信息 */
         $this->widget('Widget_Notice')->set($error, 'error');
         $this->response->goBack();
     }
     $mail = $this->request->get('mail');
     $nickname = $this->request->get('nickname');
     $data = array('mail' => $mail, 'screenName' => $nickname, 'created' => $this->options->gmtTime, 'group' => 'subscriber');
     $uid = $this->insert($data);
     $this->bindAuthUser($this->auth['openid'], $this->auth['type'], $uid);
     Typecho_Cookie::delete('__user_auth');
     $this->autoLogin($this->auth['openid'], $this->auth['type']);
 }
示例#19
0
 /**
  * 输出表单结构
  *
  * @access public
  * @return Typecho_Widget_Helper_Form
  */
 public function form()
 {
     /** 构建表格 */
     $form = new Typecho_Widget_Helper_Form(Typecho_Common::url('index.php/action/options-permalink', $this->options->siteUrl), Typecho_Widget_Helper_Form::POST_METHOD);
     /** 是否使用地址重写功能 */
     $rewrite = new Typecho_Widget_Helper_Form_Element_Radio('rewrite', array('0' => _t('不启用'), '1' => _t('启用')), $this->options->rewrite, _t('是否使用地址重写功能'), _t('地址重写即rewrite功能是某些服务器软件提供的优化内部连接的功能.<br />
     打开此功能可以让你的链接看上去完全是静态地址.'));
     $errorStr = _t('重写功能检测失败, 请检查你的服务器设置');
     /** 如果是apache服务器, 可能存在无法写入.htaccess文件的现象 */
     if ((isset($_SERVER['SERVER_SOFTWARE']) && false !== strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'apache') || function_exists('apache_get_version')) && !file_exists(__TYPECHO_ROOT_DIR__ . '/.htaccess') && !is_writeable(__TYPECHO_ROOT_DIR__)) {
         $errorStr .= '<br /><strong>' . _t('我们检测到你使用了apache服务器, 但是程序无法在根目录创建.htaccess文件, 这可能是产生这个错误的原因.
         请调整你的目录权限, 或者手动创建一个.htaccess文件.') . '</strong>';
     }
     $errorStr .= _t('<br />如果你仍然想启用此功能, <a href="%s">请点击这里</a>', Typecho_Common::url('index.php/action/options-permalink?do=enableRewriteAnyway', $this->options->siteUrl));
     $form->addInput($rewrite->addRule(array($this, 'checkRewrite'), $errorStr));
     $patterns = array('/archives/[cid:digital]/' => _t('默认风格') . ' <strong><small>/archives/{cid}/</small></strong>', '/archives/[slug].html' => _t('wordpress风格') . ' <strong><small>/archives/{slug}.html</small></strong>', '/[year:digital:4]/[month:digital:2]/[day:digital:2]/[slug].html' => _t('按日期归档') . ' <strong><small>/archives/{year}/{month}/{day}/{slug}.html</small></strong>', '/[category]/[slug].html' => _t('按分类归档') . ' <strong><small>/{category}/{slug}.html</small></strong>');
     /** 自定义文章路径 */
     $postPatternValue = $this->options->routingTable['post']['url'];
     /** 增加个性化路径 */
     $customPatternValue = NULL;
     if (isset($this->request->__typecho_form_item_postPattern)) {
         $customPatternValue = $this->request->__typecho_form_item_postPattern;
         Typecho_Cookie::delete('__typecho_form_item_postPattern');
     } else {
         if (!isset($patterns[$postPatternValue])) {
             $customPatternValue = $this->decodeRule($postPatternValue);
         }
     }
     $patterns['custom'] = _t('个性化定义') . ' <input type="text" style="width: 250px;" name="customPattern" value="' . $customPatternValue . '" />';
     $postPattern = new Typecho_Widget_Helper_Form_Element_Radio('postPattern', $patterns, $postPatternValue, _t('自定义文章路径'), _t('可用参数:{cid} 日志ID、{slug} 日志缩略名、{category} 分类、{year} 年、{month} 月、{day} 日<br />选择一种合适的文章静态路径风格, 使得你的网站链接更加友好.<br />
     一旦你选择了某种链接风格请不要轻易修改它.'));
     if ($customPatternValue) {
         $postPattern->value('custom');
     }
     $form->addInput($postPattern->multiMode());
     /** 独立页面后缀名 */
     $pageSuffixValue = false !== ($pos = strrpos($this->options->routingTable['page']['url'], '.')) ? substr($this->options->routingTable['page']['url'], $pos) : '/';
     $pageSuffix = new Typecho_Widget_Helper_Form_Element_Radio('pageSuffix', array('/' => '<strong>' . _t('无') . '</strong>', '.html' => '<strong>html</strong>', '.htm' => '<strong>htm</strong>', '.php' => '<strong>php</strong>'), $pageSuffixValue, _t('独立页面后缀名'), _t('给独立页面设置一种文件后缀名, 使得它看起来像
     <br /><strong>%s</strong>', Typecho_Common::url('example.html', $this->options->index)));
     $form->addInput($pageSuffix);
     /** 提交按钮 */
     $submit = new Typecho_Widget_Helper_Form_Element_Submit('submit', NULL, _t('保存设置'));
     $form->addItem($submit);
     return $form;
 }
示例#20
0
<?php

include 'common.php';
if ($user->hasLogin()) {
    $response->redirect($options->adminUrl);
}
$rememberName = htmlspecialchars(Typecho_Cookie::get('__typecho_remember_name'));
Typecho_Cookie::delete('__typecho_remember_name');
$bodyClass = 'body-100';
include 'header.php';
?>
<div class="typecho-login-wrap">
    <div class="typecho-login">
        <h1><a href="http://typecho.org" class="i-logo">Typecho</a></h1>
        <form action="<?php 
$options->loginAction();
?>
" method="post" name="login" role="form">
            <p>
                <label for="name" class="sr-only"><?php 
_e('用户名');
?>
</label>
                <input type="text" id="name" name="name" value="<?php 
echo $rememberName;
?>
" placeholder="<?php 
_e('用户名');
?>
" class="text-l w-100" autofocus />
            </p>
示例#21
0
 public function action()
 {
     // protect
     $this->security->protect();
     /** 如果已经登录 */
     if ($this->user->hasLogin()) {
         /** 直接返回 */
         $this->response->redirect($this->options->index);
     }
     /** 如果未开启注册 */
     if (!$this->options->allowRegister) {
         /** 直接返回 */
         $this->widget('Widget_Notice')->set('未开启注册!', 'error');
         $this->response->redirect($this->options->index);
     }
     /** 初始化验证类 */
     $validator = new Typecho_Validate();
     $validator->addRule('captcha', 'required', _t('必须填写验证码'));
     $validator->addRule('captcha', array($this, 'checkCaptcha'), _t('验证码错误'));
     $validator->addRule('name', 'required', _t('必须填写用户名称'));
     $validator->addRule('name', 'minLength', _t('用户名至少包含2个字符'), 2);
     $validator->addRule('name', 'maxLength', _t('用户名最多包含32个字符'), 32);
     $validator->addRule('name', 'xssCheck', _t('请不要在用户名中使用特殊字符'));
     $validator->addRule('name', array($this, 'nameExists'), _t('用户名已经存在'));
     $validator->addRule('mail', 'required', _t('必须填写电子邮箱'));
     $validator->addRule('mail', array($this, 'mailExists'), _t('电子邮箱地址已经存在'));
     $validator->addRule('mail', 'email', _t('电子邮箱格式错误'));
     $validator->addRule('mail', 'maxLength', _t('电子邮箱最多包含200个字符'), 200);
     /** 如果请求中有password */
     $validator->addRule('password', 'required', _t('必须填写密码'));
     $validator->addRule('password', 'minLength', _t('为了保证账户安全, 请输入至少六位的密码'), 6);
     $validator->addRule('password', 'maxLength', _t('为了便于记忆, 密码长度请不要超过十八位'), 18);
     $validator->addRule('confirm', 'confirm', _t('两次输入的密码不一致'), 'password');
     /** 截获验证异常 */
     if ($error = $validator->run($this->request->from('captcha', 'name', 'password', 'mail', 'confirm'))) {
         Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
         Typecho_Cookie::set('__typecho_remember_mail', $this->request->mail);
         /** 设置提示信息 */
         $this->widget('Widget_Notice')->set($error, 'error');
         $this->response->goBack();
     }
     $hasher = new PasswordHash(8, true);
     //$generatedPassword = Typecho_Common::randString(7);
     $extend = array();
     $inviter = Typecho_Cookie::get('__typecho_inviter');
     if (!empty($inviter)) {
         $inviter = $this->widget('Widget_Users_Query@name_' . $inviter, 'name=' . $inviter);
         if ($inviter->have()) {
             $extend['inviter'] = $inviter->name;
         }
         Typecho_Cookie::delete('__typecho_inviter');
     }
     $dataStruct = array('name' => $this->request->name, 'mail' => $this->request->mail, 'screenName' => $this->request->name, 'password' => $hasher->HashPassword($this->request->password), 'created' => $this->options->gmtTime, 'group' => 'subscriber', 'extend' => empty($extend) ? '' : serialize($extend));
     $insertId = $this->insert($dataStruct);
     $this->db->fetchRow($this->select()->where('uid = ?', $insertId)->limit(1), array($this, 'push'));
     $this->user->login($this->request->name, $this->request->password);
     $params = array('uid' => $this->user->uid, 'confirm' => $this->user->mail, 'name' => $this->user->screenName, 'type' => 'register');
     //发送验证信息
     Widget_Common::sendVerify($params);
     //注册积分
     Widget_Common::credits('register');
     $this->widget('Widget_Notice')->set(_t('用户 <strong>%s</strong> 已经成功注册,请及时验证邮件', $this->screenName), 'success');
     $this->response->redirect($this->options->index);
 }
示例#22
0
 /**
  * 输出表单结构
  *
  * @access public
  * @return Typecho_Widget_Helper_Form
  */
 public function form()
 {
     /** 构建表格 */
     $form = new Typecho_Widget_Helper_Form($this->security->getRootUrl('index.php/action/options-permalink'), Typecho_Widget_Helper_Form::POST_METHOD);
     if (!defined('__TYPECHO_REWRITE__')) {
         /** 是否使用地址重写功能 */
         $rewrite = new Typecho_Widget_Helper_Form_Element_Radio('rewrite', array('0' => _t('不启用'), '1' => _t('启用')), $this->options->rewrite, _t('是否使用地址重写功能'), _t('地址重写即 rewrite 功能是某些服务器软件提供的优化内部连接的功能.') . '<br />' . _t('打开此功能可以让你的链接看上去完全是静态地址.'));
         // disable rewrite check when rewrite opened
         if (!$this->options->rewrite && !$this->request->is('enableRewriteAnyway=1')) {
             $errorStr = _t('重写功能检测失败, 请检查你的服务器设置');
             /** 如果是apache服务器, 可能存在无法写入.htaccess文件的现象 */
             if ((isset($_SERVER['SERVER_SOFTWARE']) && false !== strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'apache') || function_exists('apache_get_version')) && !file_exists(__TYPECHO_ROOT_DIR__ . '/.htaccess') && !is_writeable(__TYPECHO_ROOT_DIR__)) {
                 $errorStr .= '<br /><strong>' . _t('我们检测到你使用了apache服务器, 但是程序无法在根目录创建.htaccess文件, 这可能是产生这个错误的原因.') . _t('请调整你的目录权限, 或者手动创建一个.htaccess文件.') . '</strong>';
             }
             $errorStr .= '<br /><input type="checkbox" name="enableRewriteAnyway" id="enableRewriteAnyway" value="1" />' . ' <label for="enableRewriteAnyway">' . _t('如果你仍然想启用此功能, 请勾选这里') . '</label>';
             $rewrite->addRule(array($this, 'checkRewrite'), $errorStr);
         }
         $form->addInput($rewrite);
     }
     $patterns = array('/archives/[cid:digital]/' => _t('默认风格') . ' <code>/archives/{cid}/</code>', '/archives/[slug].html' => _t('wordpress风格') . ' <code>/archives/{slug}.html</code>', '/[year:digital:4]/[month:digital:2]/[day:digital:2]/[slug].html' => _t('按日期归档') . ' <code>/archives/{year}/{month}/{day}/{slug}.html</code>', '/[category]/[slug].html' => _t('按分类归档') . ' <code>/{category}/{slug}.html</code>');
     /** 自定义文章路径 */
     $postPatternValue = $this->options->routingTable['post']['url'];
     /** 增加个性化路径 */
     $customPatternValue = NULL;
     if (isset($this->request->__typecho_form_item_postPattern)) {
         $customPatternValue = $this->request->__typecho_form_item_postPattern;
         Typecho_Cookie::delete('__typecho_form_item_postPattern');
     } else {
         if (!isset($patterns[$postPatternValue])) {
             $customPatternValue = $this->decodeRule($postPatternValue);
         }
     }
     $patterns['custom'] = _t('个性化定义') . ' <input type="text" class="w-50 text-s mono" name="customPattern" value="' . $customPatternValue . '" />';
     $postPattern = new Typecho_Widget_Helper_Form_Element_Radio('postPattern', $patterns, $postPatternValue, _t('自定义文章路径'), _t('可用参数: <code>{cid}</code> 日志 ID, <code>{slug}</code> 日志缩略名, <code>{category}</code> 分类, <code>{directory}</code> 多级分类, <code>{year}</code> 年, <code>{month}</code> 月, <code>{day}</code> 日') . '<br />' . _t('选择一种合适的文章静态路径风格, 使得你的网站链接更加友好.') . '<br />' . _t('一旦你选择了某种链接风格请不要轻易修改它.'));
     if ($customPatternValue) {
         $postPattern->value('custom');
     }
     $form->addInput($postPattern->multiMode());
     /** 独立页面后缀名 */
     $pagePattern = new Typecho_Widget_Helper_Form_Element_Text('pagePattern', NULL, $this->decodeRule($this->options->routingTable['page']['url']), _t('独立页面路径'), _t('可用参数: <code>{cid}</code> 页面 ID, <code>{slug}</code> 页面缩略名') . '<br />' . _t('请在路径中至少包含上述的一项参数.'));
     $pagePattern->input->setAttribute('class', 'mono w-60');
     $form->addInput($pagePattern->addRule(array($this, 'checkPagePattern'), _t('独立页面路径中没有包含 {cid} 或者 {slug} ')));
     /** 分类页面 */
     $categoryPattern = new Typecho_Widget_Helper_Form_Element_Text('categoryPattern', NULL, $this->decodeRule($this->options->routingTable['category']['url']), _t('分类路径'), _t('可用参数: <code>{mid}</code> 分类 ID, <code>{slug}</code> 分类缩略名, <code>{directory}</code> 多级分类') . '<br />' . _t('请在路径中至少包含上述的一项参数.'));
     $categoryPattern->input->setAttribute('class', 'mono w-60');
     $form->addInput($categoryPattern->addRule(array($this, 'checkCategoryPattern'), _t('分类路径中没有包含 {mid} 或者 {slug} ')));
     /** 提交按钮 */
     $submit = new Typecho_Widget_Helper_Form_Element_Submit('submit', NULL, _t('保存设置'));
     $submit->input->setAttribute('class', 'btn primary');
     $form->addItem($submit);
     return $form;
 }
示例#23
0
文件: login.php 项目: dccecc/typecho
<?php

include 'common.php';
if ($user->hasLogin()) {
    $response->redirect($options->adminUrl);
}
$rememberName = htmlspecialchars(Typecho_Cookie::get('__some_remember_name'));
Typecho_Cookie::delete('__some_remember_name');
$bodyClass = 'body-100';
include 'header.php';
?>
<div class="typecho-login-wrap">
    <div class="typecho-login">
        <h1><a href="http://typecho.org" class="i-logo">Typecho</a></h1>
        <form action="<?php 
$options->loginAction();
?>
" method="post" name="login" role="form">
            <p>
                <label for="name" class="sr-only"><?php 
_e('用户名');
?>
</label>
                <input type="text" id="name" name="name" value="<?php 
echo $rememberName;
?>
" placeholder="<?php 
_e('用户名');
?>
" class="text-l w-100" autofocus />
            </p>