Skip to content

Commit

Permalink
update 1.7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
wehaox committed Mar 2, 2023
1 parent 01d2062 commit 7a5d981
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 14 deletions.
7 changes: 6 additions & 1 deletion comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
<div class="commentsFormArea" style="text-align: right;">
<button class="submit" type="submit" ><?php _e('评论'); ?></button>
</div>
<?php if($this->options->siteKey !== "" && $this->options->siteKey !== ""){RecapOutPut($this->user->hasLogin()) ;?><script>$(document).ready(function(){if($("#comment_keys").length == 0){$(".g-recaptcha").css({"position":"relative","top":"-40px"})}})</script> <?php }?>
<?php if($this->options->siteKey !== "" && $this->options->siteKey !== ""){RecapOutPut($this->user->hasLogin()) ;?><script>$(document).ready(function(){if($("#comment_keys").length == 0){$(".g-recaptcha").css({"position":"relative","top":"-40px"})}})</script> <?php }?>

<?php if($this->options->hcaptchaSecretKey !== "" && $this->options->hcaptchaAPIKey !== ""){
RecapOutPut($this->user->hasLogin());?>
<script>$(document).ready(function(){if($("#comment_keys").length == 0){$(".h-captcha").css({"position":"relative","top":"-40px"})}})</script>
<?php }?>
</form>
<?php if(!$this->user->hasLogin() && $this->options->EnableCommentsLogin === 'on'): ?>
<div id="comment_login" style="display:none">
Expand Down
2 changes: 1 addition & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ code[class*="language-"], pre[class*="language-"] {
}
/*懒加载结束*/
.comment-ua .iconfont{font-size: 14px!important;}
.g-recaptcha {transform:scale(0.77);transform-origin:0 0;margin-top:10px;}
.g-recaptcha,.h-captcha {transform:scale(0.77);transform-origin:0 0;margin-top:10px;}
.OwO-logo{border:none!important;background:none!important}
.OwO-logo span .iconfont{font-size:25px}

Expand Down
54 changes: 49 additions & 5 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ function themeConfig($form) {

$sidebarBlock = new Typecho_Widget_Helper_Form_Element_Checkbox('sidebarBlock',
array(
'ShowAuthorInfo' => _t('显示作者信息'),
'ShowAnnounce' => _t('显示公告'),
'ShowRecentPosts' => _t('显示最新文章'),
'ShowRecentComments' => _t('显示最近回复'),
Expand All @@ -299,7 +300,7 @@ function themeConfig($form) {
'ShowMobileSide' => _t('手机端显示侧栏'),
'ShowWeiboHot' => _t('显示微博热搜')
),
array('ShowAnnounce','ShowRecentPosts', 'ShowRecentComments', 'ShowCategory','ShowTag', 'ShowArchive', 'ShowWebinfo', 'ShowOther','ShowMobileSide'), _t('侧边栏显示'));
array('ShowAuthorInfo','ShowAnnounce','ShowRecentPosts', 'ShowRecentComments', 'ShowCategory','ShowTag', 'ShowArchive', 'ShowWebinfo', 'ShowOther','ShowMobileSide'), _t('侧边栏显示'));
$sidebarBlock->setAttribute('id', 'aside');
$form->addInput($sidebarBlock->multiMode());
// 在线人数显示
Expand All @@ -320,14 +321,14 @@ function themeConfig($form) {
// 文章侧边栏设置
$PostSidebarBlock = new Typecho_Widget_Helper_Form_Element_Checkbox('PostSidebarBlock',
array(
// 'ShowAuthorInfo' => _t('显示作者信息'),
// 'ShowAnnounce' => _t('显示公告'),
'ShowAuthorInfo' => _t('显示作者信息'),
'ShowAnnounce' => _t('显示公告'),
'ShowRecentPosts' => _t('显示最新文章'),
'ShowWebinfo' => _t('显示网站咨询'),
'ShowOther' => _t('显示其它杂项'),
'ShowWeiboHot' => _t('显示微博热搜')
),
array('ShowRecentPosts', 'ShowWebinfo', 'ShowOther'), _t('文章侧边栏显示'),_t('说明:单独设置文章内侧栏'));
array('ShowAuthorInfo','ShowAnnounce','ShowRecentPosts', 'ShowWebinfo', 'ShowOther'), _t('文章侧边栏显示'),_t('说明:单独设置文章内侧栏'));
$form->addInput($PostSidebarBlock->multiMode());

// 美化选项
Expand Down Expand Up @@ -567,6 +568,21 @@ function themeConfig($form) {
$secretKey = new Typecho_Widget_Helper_Form_Element_Text('secretKey', NULL, null, _t('Serect Key for reCAPTCHAv2:'), _t('填写两处密钥评论区自动开启谷歌验证码'));
$form->addInput($siteKey);
$form->addInput($secretKey);


$hcaptchaSecretKey = new Typecho_Widget_Helper_Form_Element_Text('hcaptchaSecretKey',
NULL,
null,
'<hr> 评论区hcaptch人机验证 <br> 密钥(sietkey)- 使用它作为 secret 来检查用户令牌:',
'<a href="https://dashboard.hcaptcha.com/welcome">点击获取密钥</a>'
);

$hcaptchaAPIKey = new Typecho_Widget_Helper_Form_Element_Text('hcaptchaAPIKey', NULL, null, _t('API 密钥:'), _t('填写两处密钥评论区自动开启hcaptch人机验证'));

$form->addInput($hcaptchaSecretKey);
$form->addInput($hcaptchaAPIKey);




$db = Typecho_Db::get();
Expand Down Expand Up @@ -1183,7 +1199,9 @@ function themeInit($archive) {
if(Helper::options()->siteKey !== "" && Helper::options()->secretKey !=="" && !$loginStatus){
comments_filter($archive);
}
;
if (Helper::options()->hcaptchaSecretKey !== "" && Helper::options()->hcaptchaAPIKey !== "" && !$loginStatus) {
hcaptcha_filter($archive);
}
if ($archive->is('index')) {
// echo '<script src="'..'"></script>';
}
Expand Down Expand Up @@ -1730,8 +1748,12 @@ function RecapOutPut($login) {
if ($siteKey !== "" && $secretKey !== "" && !$login) {
echo '<script src="https://recaptcha.net/recaptcha/api.js" async defer data-no-instant></script>
<div class="g-recaptcha" data-sitekey=' . $siteKey . '></div>';
}
if (Helper::options()->hcaptchaSecretKey !== "" && Helper::options()->hcaptchaAPIKey !== "" && !$login) {
echo '<script src="https://www.hCaptcha.com/1/api.js" async defer></script><div class="h-captcha" data-sitekey='. Helper::options()->hcaptchaSecretKey .'></div>';
}
}

function comments_filter($comment) {
if (isset($_REQUEST['text']) != null) {
if($_POST['g-recaptcha-response'] == null) {
Expand Down Expand Up @@ -1768,6 +1790,28 @@ function getCaptcha($recaptcha_response, $secretKey) {
return $comment;
}


function hcaptcha_filter($comment){
if (isset($_REQUEST['text']) != null) {
if($_POST['h-captcha-response'] == null) {
throw new Typecho_Widget_Exception(_t('人机验证失败,确认你加载了hcaptcha人机验证并通过验证'));
}else{
if(isset($_POST['h-captcha-response']) && !empty($_POST['h-captcha-response'])){
$secret = Helper::options()->hcaptchaAPIKey;
$verifyResponse = file_get_contents('https://hcaptcha.com/siteverify?secret='.$secret.'&response='.$_POST['h-captcha-response'].'&remoteip='.$_SERVER['REMOTE_ADDR']);
$responseData = json_decode($verifyResponse);
if($responseData->success == true)
{
return $comments;
}else{
throw new Typecho_Widget_Exception(_t($responseData->error-codes));
}
}
}
}
return $comment;
}

// 微博热搜
function weibohot(){
$api = file_get_contents('https://weibo.com/ajax/side/hotSearch');
Expand Down
2 changes: 1 addition & 1 deletion header_com.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<link rel="preconnect" href="//cdn.staticfile.org" />
<!--<link rel="stylesheet" href="https://gcore.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css">-->
<link rel="stylesheet" href="<?php $this->options->themeUrl('index.css?v1.7.3'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('css/style.css?v1.7.3'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('css/style.css?v1.7.4'); ?>">
<!--魔改美化-->
<?php if (!empty($this->options->beautifyBlock) && in_array('ShowBeautifyChange',$this->options->beautifyBlock)): ?>
<link rel="stylesheet" href="<?php $this->options->themeUrl('css/custom.css?v1.5.9'); ?>">
Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* <a href="https://www.wehaox.com">个人网站</a> | <a href="https://blog.wehaox.com/archives/typecho-butterfly.html">主题使用文档</a>
* @package Typecho-Butterfly
* @author b站:wehao-
* @version 1.7.4
* @version 1.7.5
* @link https://space.bilibili.com/34174433
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
Expand Down Expand Up @@ -112,7 +112,7 @@ function ver() {console.log(`
# # # # # # # # # # # #
##### #### # # ###### # # # ###### #

1.7.4
1.7.5
===================================================================
`);}
</script>
7 changes: 4 additions & 3 deletions post_sidebar.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<div class="aside-content" id="aside-content" role="complementary">
<?php if (!empty($this->options->PostSidebarBlock) && in_array('ShowAuthorInfo', $this->options->PostSidebarBlock)): ?>
<div class="card-widget card-info">
<div class="card-info-avatar is-center">
<div class="avatar-img">
Expand Down Expand Up @@ -46,7 +47,8 @@
<?php elseif(!$this->options->author_bottom) : ?>
<?php endif; ?>
</div>
<?php if (!empty($this->options->sidebarBlock) && in_array('ShowAnnounce', $this->options->sidebarBlock)): ?>
<?php endif; ?>
<?php if (!empty($this->options->PostSidebarBlock) && in_array('ShowAnnounce', $this->options->PostSidebarBlock)): ?>
<div class="card-widget card-announcement"><div class="item-headline">
<i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div>
<div class="announcement_content"><?php $this->options->announcement() ?></div></div>
Expand Down Expand Up @@ -168,6 +170,5 @@
</div >
</div>
<?php endif; ?>

</div>
</div>
</div><!-- end #sidebar -->
4 changes: 3 additions & 1 deletion sidebar.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<div class="aside-content" id="aside-content">
<div class="card-widget card-info">
<?php if (!empty($this->options->sidebarBlock) && in_array('ShowAuthorInfo', $this->options->sidebarBlock)): ?>
<div class="card-widget card-info">
<div class="card-info-avatar is-center">
<div class="avatar-img">
<img data-lazy-src="<?php $this->options->logoUrl() ?>" onerror="this.onerror=null;this.src='/usr/themes/butterfly/img/friend_404.gif'" src="<?php echo GetLazyLoad() ?>" alt="avatar">
Expand Down Expand Up @@ -46,6 +47,7 @@
<?php elseif(!$this->options->author_bottom) : ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if (!empty($this->options->sidebarBlock) && in_array('ShowAnnounce', $this->options->sidebarBlock)): ?>
<div class="card-widget card-announcement"><div class="item-headline">
<i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div>
Expand Down

0 comments on commit 7a5d981

Please sign in to comment.