修正一堆bug

This commit is contained in:
liyukun 2022-01-23 21:36:52 +08:00
parent 635f436ac0
commit 53b1bcdc0c
9 changed files with 142 additions and 100 deletions

View File

@ -37,4 +37,11 @@ class Data
const USER_IS_ADMIN_YES = 1;
const USER_IS_ADMIN_NO = 0;
//评论key
const COOKIE_KEY_COMMENT_AUTHOR = 'comment_author';
const COOKIE_KEY_COMMENT_AUTHOR_EMAIL = 'comment_author_email';
const COOKIE_KEY_COMMENT_AUTHOR_URL = 'comment_author_url';
//评论
const COOKIE_KEY_COMMENT_EXPIRE = 7*24*60*60;
}

View File

@ -966,3 +966,19 @@ function file_load_face($path)
}
return $html;
}
function comment_face($incoming_comment,$path)
{
$pattern = '/\[f=(.*?)\]/';
$isMatched = preg_match_all($pattern, $incoming_comment, $match);
if ($isMatched == 0) {
return $incoming_comment;
}
foreach ($match[1] as $facename) {
if (file_exists( public_path() . $path . $facename . '.gif')) {
$incoming_comment = str_replace("[f={$facename}]", '<img src="' . $path . $facename . '.gif" width="24">', $incoming_comment);
}
}
return $incoming_comment;
}

View File

@ -187,14 +187,26 @@ class Article extends Base
['email', ''],
['content', ''],
]);
if ($data['document_id'] == "") $this->error("文章id不能为空");
if (!web_config('comment_close')){
$this->error('非法操作,请检查后重试', null);
}
if (web_config('comment_visitor')){
if ($data['author'] == "") $this->error("昵称不能为空");
if ($data['email'] == "") $this->error("邮箱不能为空");
if ($data['url'] == "") $this->error("url不能为空");
}else{
$data['author'] = $this->userInfo['nickname']?:$this->userInfo['username'];
$data['email'] = $this->userInfo['email']?:'';
$data['url'] = '';
}
if ($data['document_id'] == "") $this->error("文章id不能为空");
if ($data['content'] == "") $this->error("内容能为空");
$data['status'] = web_config('comment_review') ? 0 : 1;
$res = commentModel::create($data);
if ($res) {
cookie(Data::COOKIE_KEY_COMMENT_AUTHOR,$data['author'],Data::COOKIE_KEY_COMMENT_EXPIRE);
cookie(Data::COOKIE_KEY_COMMENT_AUTHOR_EMAIL,$data['email'],Data::COOKIE_KEY_COMMENT_EXPIRE);
cookie(Data::COOKIE_KEY_COMMENT_AUTHOR_URL,$data['url'],Data::COOKIE_KEY_COMMENT_EXPIRE);
$this->success('提交成功', url('detail', ['id' => $data['document_id']]));
} else {
$this->error('提交失败,请联系站长查看', null);

View File

@ -24,6 +24,9 @@ class User extends Base
*/
public function login()
{
if (!web_config('is_register')){
$this->error('登录未启用,请联系管理员!');
}
//清除可能存在的栏目分类树id
cache(Data::CURR_CATEGORY_PATENT_ID, false);
//模板兼容性标签
@ -41,6 +44,9 @@ class User extends Base
*/
public function verify()
{
if (!web_config('is_register')){
return app("json")->fail('非法操作!');
}
list($username, $password, $captcha) = Util::postMore(['username', 'password', 'captcha'], null, true);
if (empty($username) || empty($password)) return app("json")->fail("账号、密码和验证码不能为空!");
// 验证码验证
@ -57,6 +63,9 @@ class User extends Base
*/
public function register()
{
if (!web_config('is_register')){
$this->error('注册未启用,请联系管理员!');
}
//清除可能存在的栏目分类树id
cache(Data::CURR_CATEGORY_PATENT_ID, false);
//模板兼容性标签
@ -74,10 +83,17 @@ class User extends Base
*/
public function registerVerify()
{
if (!web_config('is_register')){
return app("json")->fail('非法操作!');
}
list($username, $email, $password,$captcha) = Util::postMore(['username','email', 'password', 'captcha'], null, true);
if (empty($username) || empty($email) || empty($password) || empty($captcha)) return app("json")->fail("账号、密码和验证码不能为空!");
// 验证码验证
if (!captcha_check($captcha)) return app("json")->fail("验证码不正确!");
// 验证码验证
if (!empty(web_config('register_black_list')) && in_array($username,explode(',',web_config('register_black_list')))){
return app("json")->fail("账号不合法,请更换后重试");
}
// 验证登录
if (!userModel::register($username,$email, $password)) return app("json")->fail(userModel::getErrorInfo());
return app("json")->success("注册成功!我们给您邮箱发送了一封激活邮件,请按照邮件提示激活用户");
@ -100,7 +116,7 @@ class User extends Base
*/
public function logout()
{
return userModel::clearLoginInfo() ? $this->success("操作成功", "/admin/login/login") : $this->error("操作失败", "/admin/index/index");
return userModel::clearLoginInfo() ? $this->success("操作成功", "/index/index/index") : $this->error("操作失败", "/index/index/index");
}
/**

View File

@ -534,7 +534,7 @@ INSERT INTO `ape_system_config` VALUES (29, 4, '注册开关', 'is_register', 'r
INSERT INTO `ape_system_config` VALUES (30, 4, '注册方式', 'register_type', 'radio', 'input', 0, '0=>普通\n1=>手机\n2=>邀请码', '0', '邀请码注册默认状态为已审核!', 91, 1, 1, '1', '1', 1583126643, 1582792265);
INSERT INTO `ape_system_config` VALUES (31, 4, '禁止注册', 'register_black_list', 'text', 'input', 0, '', 'www,bbs,ftp,mail,user,users,admin,administrator', '禁止注册的用户名!', 91, 1, 1, '1', '1', 1583126643, 1582792265);
INSERT INTO `ape_system_config` VALUES (32, 4, '评论开关', 'comment_close', 'radio', 'input', 0, '1=>开启\n0=>关闭', '1', '默认开启,如不需要可关闭。', 91, 1, 1, '1', '1', 1583126643, 1582792265);
INSERT INTO `ape_system_config` VALUES (33, 4, '游客评论', 'comment_need_login', 'radio', 'input', 0, '1=>是\n0=>否', '1', '开启后需要登录才能评论。', 91, 1, 1, '1', '1', 1583126643, 1582792265);
INSERT INTO `ape_system_config` VALUES (33, 4, '游客评论', 'comment_visitor', 'radio', 'input', 0, '1=>是\n0=>否', '1', '开启后需要登录才能评论。', 91, 1, 1, '1', '1', 1583126643, 1582792265);
INSERT INTO `ape_system_config` VALUES (34, 4, '评论审核', 'comment_review', 'radio', 'input', 0, '1=>开启\n0=>关闭', '1', '开启后需要审核评论才会展示。', 91, 1, 1, '1', '1', 1583126643, 1582792265);
INSERT INTO `ape_system_config` VALUES (35, 4, '脏话过滤', 'comment_sensitive_word', 'text', 'input', 0, '', '新疆,华为,她妈,它妈,他妈,你妈,去死,贱人', '多个逗号隔开', 81, 1, 1, '1', '1', 1582793305, 1582792265);

View File

@ -156,39 +156,49 @@
<form action="{:url('/index/article/create_comment')}" method="post" id="form_comment" class="comment-form">
<div class="comment-user-plane">
<div class="logged-in-as">
<img class="comment-user-avatar" width="48" height="auto" src="__IMG__/avatar.png" alt="">
<img class="comment-user-avatar" width="48" height="auto" src="__IMG__/avatar.png"
alt="">
</div>
<div class="comment_form_textarea_box">
<textarea class="comment_form_textarea" name="content" id="comment" placeholder="发表你的看法" rows="5"></textarea>
<textarea class="comment_form_textarea" name="content" id="comment"
placeholder="发表你的看法" rows="5"></textarea>
<div id="comment_addplane">
<button class="popover-btn popover-btn-face" type="button">
<i class="far fa-smile-wink">
</i>添加表情</button>
</i>添加表情
</button>
<div class="conment-face-plane">
{:file_load_face('__IMG__/face/')}
</div>
</div>
</div>
</div>
{if web_config('comment_visitor') && empty($user_id)}
<div class="comment_userinput">
<div class="comment-form-author">
<input id="author" name="author" placeholder="昵称(*)" type="text" value="" size="30" class="required" />
<input id="author" name="author" placeholder="昵称(*)" type="text" value="{$Request.cookie.comment_author}" size="30"
class="required"/>
</div>
<div class="comment-form-email">
<input id="email" name="email" type="text" placeholder="邮箱(*)" value="" class="required" />
<input id="email" name="email" type="text" placeholder="邮箱(*)" value="{$Request.cookie.comment_author_email}"
class="required"/>
</div>
<div class="comment-form-url">
<input id="url" placeholder="网址" name="url" type="text" value="" size="30" />
</div>
<input id="url" placeholder="网址" name="url" type="text" value="{$Request.cookie.comment_author_url}" size="30"/>
</div>
<div style="display: none" class="comment-form-cookies-consent">
<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes" checked="checked" />记住用户信息
<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent"
type="checkbox" value="yes" checked="checked"/>记住用户信息
</div>
</div>
{/if}
<div class="form-submit">
<div style="text-align: right">
<input name="submit" type="submit" id="submit" class="button primary-btn" value="发表评论">
<input name="submit" type="submit" id="commit_submit" class="button primary-btn"
value="发表评论">
</div>
<input type="hidden" name="document_id" value="{$apeField['id']}" id="comment_document_id">
<input type="hidden" name="document_id" value="{$apeField['id']}"
id="comment_document_id">
<input type="hidden" name="pid" id="comment_parent" value="0">
</div>
</form>
@ -214,7 +224,7 @@
<div class="media-body">
<p class="author_name">{$field['author']}<a href="{$field['url']}" rel="external nofollow ugc" target="_blank" class="url"></a><span class="comment-zhan"><img title="网站主" src="__IMG__/zhan.svg" alt=""></span></p>
<div class="comment-text">
<p>{$field['content']}</p>
<p>{:comment_face($field['content'],'__IMG__/face/')}</p>
</div>
</div>
<span class="comment-pub-time">{$field['create_time']}</span>
@ -236,7 +246,7 @@
<div class="media-body">
<p class="author_name">{$vo['author']}<span class="user-identity user-admin" title="{$vo['author']}"></span><span class="comment-from">@<a href="#comment-2264">{$field['author']}</a></span></p>
<div class="comment-text">
<p>{$vo['content']}</p>
<p>{:comment_face($vo['content'],'__IMG__/face/')}</p>
</div>
</div>
<span class="comment-pub-time">{$vo.create_time}</span>

View File

@ -1,6 +1,6 @@
<!doctype html>
<html lang="zh">
<head>
<!doctype html>
<html lang="zh">
<head>
<title>{:web_config('title')}</title>
<meta name="keywords" content="{:web_config('keywords')}">
<meta name="description" content="{:web_config('description')}">
@ -11,12 +11,13 @@
--MaincolorHover: #409EFF !important;
--fontSelectedColor: #3390ff !important;
}
#nprogress .bar {
background: var(--Maincolor) !important;
}
</style>
<link rel="stylesheet" href="__CSS__/page-links.css" />
<link rel="stylesheet" href="__CSS__/comment-module.css" />
<link rel="stylesheet" href="__CSS__/page-links.css"/>
<link rel="stylesheet" href="__CSS__/comment-module.css"/>
</head>
<body>
<script>NProgress.start();</script>
@ -47,92 +48,54 @@
<div id="respond" class="comment-respond">
<h3 id="reply-title" class="comment-reply-title">
<small>
<a rel="nofollow" id="cancel-comment-reply-link" href="/msg#respond" style="display:none;">取消回复</a>
<a rel="nofollow" id="cancel-comment-reply-link" href="/msg#respond"
style="display:none;">取消回复</a>
</small>
</h3>
<form action="{:url('msg')}" method="post" id="form_comment" class="comment-form">
<div class="comment-user-plane">
<div class="logged-in-as">
<img class="comment-user-avatar" width="48" height="auto" src="https://cravatar.cn/avatar/34be3c7c0655313619d9b91a7e6f1ee6?s=48&amp;d=mm&amp;r=g" alt="">
<img class="comment-user-avatar" width="48" height="auto"
src="https://cravatar.cn/avatar/34be3c7c0655313619d9b91a7e6f1ee6?s=48&amp;d=mm&amp;r=g"
alt="">
</div>
<div class="comment_form_textarea_box">
<textarea class="comment_form_textarea" name="content" id="comment" placeholder="发表你的看法" rows="5"></textarea>
<textarea class="comment_form_textarea" name="content" id="comment"
placeholder="发表你的看法" rows="5"></textarea>
<div id="comment_addplane">
<button class="popover-btn popover-btn-face" type="button">
<i class="far fa-smile-wink">
</i>添加表情</button>
</i>添加表情
</button>
<div class="conment-face-plane" style="opacity: 0; visibility: hidden;">
<img class="img-pace" src="__IMG__/face/yun.gif" width="30" facename="yun">
<img class="img-pace" src="__IMG__/face/youling.gif" width="30" facename="youling">
<img class="img-pace" src="__IMG__/face/yiwen.gif" width="30" facename="yiwen">
<img class="img-pace" src="__IMG__/face/yinxian.gif" width="30" facename="yinxian">
<img class="img-pace" src="__IMG__/face/xigua.gif" width="30" facename="xigua">
<img class="img-pace" src="__IMG__/face/xieyanxiao.gif" width="30" facename="xieyanxiao">
<img class="img-pace" src="__IMG__/face/xiaoku.gif" width="30" facename="xiaoku">
<img class="img-pace" src="__IMG__/face/xiaojiujie.gif" width="30" facename="xiaojiujie">
<img class="img-pace" src="__IMG__/face/wunai.gif" width="30" facename="wunai">
<img class="img-pace" src="__IMG__/face/wozuimei.gif" width="30" facename="wozuimei">
<img class="img-pace" src="__IMG__/face/woshou.gif" width="30" facename="woshou">
<img class="img-pace" src="__IMG__/face/weiqu.gif" width="30" facename="weiqu">
<img class="img-pace" src="__IMG__/face/tuosai.gif" width="30" facename="tuosai">
<img class="img-pace" src="__IMG__/face/touxiao.gif" width="30" facename="touxiao">
<img class="img-pace" src="__IMG__/face/tiaopi.gif" width="30" facename="tiaopi">
<img class="img-pace" src="__IMG__/face/shuai.gif" width="30" facename="shuai">
<img class="img-pace" src="__IMG__/face/shengli.gif" width="30" facename="shengli">
<img class="img-pace" src="__IMG__/face/se.gif" width="30" facename="se">
<img class="img-pace" src="__IMG__/face/quantou.gif" width="30" facename="quantou">
<img class="img-pace" src="__IMG__/face/qinqin.gif" width="30" facename="qinqin">
<img class="img-pace" src="__IMG__/face/qiang.gif" width="30" facename="qiang">
<img class="img-pace" src="__IMG__/face/piezui.gif" width="30" facename="piezui">
<img class="img-pace" src="__IMG__/face/penxue.gif" width="30" facename="penxue">
<img class="img-pace" src="__IMG__/face/nanguo.gif" width="30" facename="nanguo">
<img class="img-pace" src="__IMG__/face/liuhan.gif" width="30" facename="liuhan">
<img class="img-pace" src="__IMG__/face/lenghan.gif" width="30" facename="lenghan">
<img class="img-pace" src="__IMG__/face/leiben.gif" width="30" facename="leiben">
<img class="img-pace" src="__IMG__/face/ku.gif" width="30" facename="ku">
<img class="img-pace" src="__IMG__/face/koubi.gif" width="30" facename="koubi">
<img class="img-pace" src="__IMG__/face/keai.gif" width="30" facename="keai">
<img class="img-pace" src="__IMG__/face/jingkong.gif" width="30" facename="jingkong">
<img class="img-pace" src="__IMG__/face/jie.gif" width="30" facename="jie">
<img class="img-pace" src="__IMG__/face/huaixiao.gif" width="30" facename="huaixiao">
<img class="img-pace" src="__IMG__/face/hanxiao.gif" width="30" facename="hanxiao">
<img class="img-pace" src="__IMG__/face/haixiu.gif" width="30" facename="haixiu">
<img class="img-pace" src="__IMG__/face/guzhang.gif" width="30" facename="guzhang">
<img class="img-pace" src="__IMG__/face/ganga.gif" width="30" facename="ganga">
<img class="img-pace" src="__IMG__/face/fadai.gif" width="30" facename="fadai">
<img class="img-pace" src="__IMG__/face/doge.gif" width="30" facename="doge">
<img class="img-pace" src="__IMG__/face/dabing.gif" width="30" facename="dabing">
<img class="img-pace" src="__IMG__/face/ciya.gif" width="30" facename="ciya">
<img class="img-pace" src="__IMG__/face/caidao.gif" width="30" facename="caidao">
<img class="img-pace" src="__IMG__/face/cahan.gif" width="30" facename="cahan">
<img class="img-pace" src="__IMG__/face/bizui.gif" width="30" facename="bizui">
<img class="img-pace" src="__IMG__/face/baoquan.gif" width="30" facename="baoquan">
<img class="img-pace" src="__IMG__/face/aoman.gif" width="30" facename="aoman">
<img class="img-pace" src="__IMG__/face/aixin.gif" width="30" facename="aixin">
<img class="img-pace" src="__IMG__/face/OK.gif" width="30" facename="OK">
{:file_load_face('__IMG__/face/')}
</div>
</div>
</div>
</div>
<div class="comment_userinput">
<div class="comment-form-author">
<input id="author" name="name" placeholder="昵称(*)" type="text" value="" size="30" class="required">
<input id="author" name="name" placeholder="昵称(*)" type="text" value="" size="30"
class="required">
</div>
<div class="comment-form-email">
<input id="email" name="email" type="text" placeholder="邮箱(*)" value="" class="required">
<input id="email" name="email" type="text" placeholder="邮箱(*)" value=""
class="required">
</div>
<div class="comment-form-url">
<input id="tel" placeholder="网址(*)" name="tel" type="text" value="" size="30">
</div>
</div>
<div style="display: none" class="comment-form-cookies-consent">
<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes" checked="checked">
<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox"
value="yes" checked="checked">
</div>
<div class="form-submit">
<div style="text-align: right">
<input name="submit" type="submit" id="submit" class="button primary-btn" value="发表评论">
<input name="submit" type="submit" id="submit" class="button primary-btn"
value="发表评论">
</div>
<input type="hidden" name="comment_post_ID" value="428" id="comment_post_ID">
<input type="hidden" name="comment_post_ID" value="" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
</div>
</form>
@ -140,23 +103,23 @@
<script type='text/javascript' src='__JS__/comment-reply.min.js'></script>
<script type='text/javascript'>
$("body").on("click", ".comment-reply-link",
function(e) {
function (e) {
addComment.moveForm("li-comment-" + $(this).attr("data-commentid"), $(this).attr("data-commentid"), "respond", $(this).attr("data-postid"));
console.log("li-comment-" + $(this).attr("data-commentid"), $(this).attr("data-commentid"), "respond", $(this).attr("data-postid"));
e.stopPropagation();
return false;
});
$(document).click(function(e) {
$(document).click(function (e) {
$(".conment-face-plane").css("opacity", "0");
$(".conment-face-plane").css("visibility", "hidden");
e.stopPropagation();
});
$("body").on("click", ".img-pace",
function(e) {
function (e) {
$(".comment_form_textarea").val($(".comment_form_textarea").val() + "[f=" + $(this).attr("facename") + "]");
});
$("body").on("click", ".popover-btn-face",
function(e) {
function (e) {
if ($(".conment-face-plane").css("visibility") == "visible") {
$(".conment-face-plane").css("opacity", "0");
$(".conment-face-plane").css("visibility", "hidden");

View File

@ -85,4 +85,20 @@ if ($(".btn-copy-pwd").length > 0) {
});
}
if ($(".btn-copy-pwd").length > 0) {
var copy_pwd = new ClipboardJS('.btn-copy-pwd', {
text: function (trigger) {
copynotmsg = 1;
return $(trigger).parent().find('.c-downbtn-pwd-key').text();
}
});
copy_pwd.on('success', function (e) {
$(e.trigger).toggleClass('fal fa-clone')
$(e.trigger).toggleClass('fal fa-check')
setTimeout(function () {
$(e.trigger).toggleClass('fal fa-clone')
$(e.trigger).toggleClass('fal fa-check')
}, 2000);
});
}

View File

@ -120,6 +120,7 @@
<div class="user-menu-pc-dark" onclick="darkMode()" title="深色模式">
<i class="far fa-moon" id="darkModeicon"></i>
</div>
{if web_config('is_register')}
{notempty name="user_info"}
<ul class="user-menu">
<li>
@ -145,6 +146,7 @@
<a href="{:url('/index/user/login')}"><button class="login-btn-header">登录</button></a>
</span>
{/notempty}
{/if}
</div>
</div>
</div>