需要修改PHP
文件,
然后修改第12行md5key(非常重要,不然别人可以看见你的服务器信息再丢入/usr/themes/handsome/下然后添加一个独立页面,选择模板Server Status
最后添加自定义字段
bt_url 宝塔地址(要带上http和末尾/) *必填
bt_key 宝塔API的密匙 *必填
file_url status.php的网址 *选填
ajax_time 数据刷新时间(最低1s,低于1s则为1s,为空则默认10s) *选填
刷新博客,进入新增的页面内,就可以看到效果啦!
/usr/themes/handsome/functions.php
(新版本functions.php
文件已加密,但依旧可以使用,使用前请先备份
!)尾部添加以下代码
/* 加载时间 */
function timer_start() {
global $timestart;
$mtime = explode( ' ', microtime() );
$timestart = $mtime[1] + $mtime[0];
return true;
}
timer_start();
function timer_stop( $display = 0, $precision = 3 )
{
global $timestart, $timeend;
$mtime = explode( ' ', microtime() );
$timeend = $mtime[1] + $mtime[0];
$timetotal = number_format( $timeend - $timestart, $precision );
$r = $timetotal < 1 ? $timetotal * 1000 . " ms" : $timetotal . " s";
if ( $display )
{
echo $r;
}
return $r;
}
然后打开usr/themes/handsome/component/sidebar.php
在合适位置添加以下代码
<li class="list-group-item"> <i class="glyphicon glyphicon-flash text-muted"></i>
<span class="badge
pull-right"><?php echo timer_stop();?></span><?php _me("响应耗时") ?></li>
然后刷新网页就能看到效果了。
/usr/themes/handsome/functions.php
(新版本functions.php
文件已加密,但依旧可以使用,使用前请先备份
!)尾部添加以下代码
//总访问量
function theAllViews()
{
$db = Typecho_Db::get();
$row = $db->fetchAll('SELECT SUM(VIEWS) FROM `typecho_contents`');
echo number_format($row[0]['SUM(VIEWS)']);
}
然后打开usr/themes/handsome/component/sidebar.php
在合适位置添加以下代码
<li class="list-group-item"> <i class="glyphicon glyphicon-user text-muted"></i>
<span class="badge
pull-right"><?php echo theAllViews();?></span><?php _me("访客总数") ?></li>
然后刷新网页就能看到效果了。
修改Handsome主题,component目录下的comments.php代码文件,大概第60~80行左右:
<span class="comment-author vcard">
<b class="fn"><?php echo $author; ?></b><?php echo $Identity; ?>
</span>
添加代码
<?php UserAgent_Plugin::get_useragent($comments->agent,$comments->ip); ?>
修改后代码如下:
<span class="comment-author vcard">
<b class="fn"><?php echo $author; ?></b><?php echo $Identity; ?><?php UserAgent_Plugin::get_useragent($comments->agent,$comments->ip); ?>
</span>
Typecho开启CDN后,可能无法获取访客真实IP,只能取得CDN节点IP,为此可以在Typecho博客网站的根目录的config.inc.php
插入下面的代码:
//** 防止CDN造成无法获取客户真实IP地址 */
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
$_SERVER['REMOTE_ADDR'] = $list[0];
}
Handsome主题的搜索框按钮一直有问题,按不下去不能正常使用,可以按以下方法修复
打开
/usr/themes/handsome/component/headnav.php
文件搜索
search_submit
然后将整行替换成如下代码<span id="search_submit" class="transparent input-group-btn" onclick=jumpForSearch(search_input.value)>
然后在文件的最后面添加如下代码后保存即可
<!--/开始修复搜索按钮-->
<script type="text/javascript">
function jumpForSearch(search_ct){
if(search_ct.length>0){
$.pjax({
url: "https://"+document.domain+'/search/'+search_ct,
container: '#content',
fragment: '#content',
timeout: 8000
});
}
}
</script>
<!--/修复搜索按钮结束-->
主题设置 - 开发者设置 - 自定义JavaScript 和 PJAX回调函数 均添加上以下代码
function a(a, b, c) {
if (document.selection) a.focus(), sel = document.selection.createRange(), c ? sel.text = b + sel.text + c : sel.text = b, a.focus();
else if (a.selectionStart || "0" == a.selectionStart) {
var l = a.selectionStart,
m = a.selectionEnd,
n = m;
c ? a.value = a.value.substring(0, l) + b + a.value.substring(l, m) + c + a.value.substring(m, a.value.length) : a.value = a.value.substring(0, l) + b + a.value.substring(m, a.value.length);
c ? n += b.length + c.length : n += b.length - m + l;
l == m && c && (n -= c.length);
a.focus();
a.selectionStart = n;
a.selectionEnd = n
} else a.value += b + c, a.focus()
}
var b = (new Date).toLocaleTimeString(),
c = document.getElementById("comment") || 0;
window.SIMPALED = {};
window.SIMPALED.Editor = {
daka: function() {
a(c, "滴!学生卡!打卡时间:" + b, ",请上车的乘客系好安全带~")
},
zan: function() {
a(c, " 写得好好哟,我要给你生猴子!::funny:04:: ")
},
cai: function() {
a(c, "骚年,我怀疑你写了一篇假的文章!::funny:03:: ")
}
};
主题目录的component/comments.php
里面的130行左右参照下面代码进行修改
<label for="comment"><?php _me("评论") ?>
<span class="required text-danger">*</span></label>
<textarea id="comment" class="textarea form-control OwO-textarea" name="text" rows="5" placeholder="<?php _me("说点什么吧……") ?>" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('submit').click();return false};"><?php $this->remember('text'); ?></textarea>
<div class="OwO" style="display: inline;"></div>
<div class="OwO" title="打卡" style="display: inline;" onclick="javascript:SIMPALED.Editor.daka();this.style.display='none'"><div class="OwO-logo"><i class="fontello-pencil"></i><span class="OwOlogotext">打卡</span></div></div>
<div class="OwO" title="赞" style="display: inline;" onclick="javascript:SIMPALED.Editor.zan();this.style.display='none'"><div class="OwO-logo"><i class="glyphicon glyphicon-thumbs-up"></i><span class="OwOlogotext"></span></div></div>
<div class="OwO" title="踩" style="display: inline;" onclick="javascript:SIMPALED.Editor.cai();this.style.display='none'"><div class="OwO-logo"><i class="glyphicon glyphicon-thumbs-down"></i><span class="OwOlogotext"></span></div></div>
<div class="secret_comment" id="secret_comment" data-toggle="tooltip"
data-original-title="<?php _me("开启该功能,您的评论仅作者和评论双方可见") ?>">
主题设置 - 开发者设置 - 自定义CSS 添加以下代码
/*评论添加一键打卡*/
.secret_comment {
top: 5px;
}
.OwO.OwO-open .OwO-body {
display:table
}
需要修改CSS和Javascript
- 先去把
/usr/themes/handsome/component/footer.php
中原有版权信息,将注释之前的代码替换即可
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php Content::outputCommentJS($this, $this->security); ?>
</div><!-- /content -->
<footer id="footer" class="app-footer" role="footer">
<div class="wrapper bg-light">
<span class="pull-right hidden-xs text-ellipsis">
<?php $this->options->BottomInfo(); ?>
</span>
<span class="text-ellipsis"> <?php
$this->options->BottomleftInfo(); ?></span>
</div>
<!--可以去除主题版权信息,最好保留版权信息或者添加主题信息到友链,谢谢你的理解-->
- 将以下代码添加至后台-开发者设置-博客底部右侧信息(左侧类似)。
<div class="github-badge">
<a rel="license" href="http://www.typecho.org" target="_blank" title="由Typecho强力驱动">
<span class="badge-subject">Powered</span><span class="badge-value bg-blue">Typecho</span></a>
</div>
<div class="github-badge">
<a rel="license" href="https://www.ihewro.com/archives/489/" target="_blank" title="站点使用 handsome 主题,作者:友人C">
<span class="badge-subject">Theme</span><span class="badge-value bg-orange">Handsome</span></a>
</div>
- 将以下代码添加至后台-开发者设置-
自定义CSS
/*底部版权*/
.github-badge {
display: inline-block;
border-radius: 4px;
text-shadow: none;
font-size: 12px;
color: #fff;
line-height: 15px;
background-color: #ABBAC3;
margin-bottom: 5px;
}
.github-badge .badge-subject {
display: inline-block;
background-color: #4D4D4D;
padding: 4px 4px 4px 6px;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.github-badge .badge-value {
display: inline-block;
padding: 4px 6px 4px 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.github-badge .bg-brightgreen {
background-color: #4DC820 !important;
}
.github-badge .bg-orange {
background-color: #FFA500 !important;
}
.github-badge .bg-blueviolet {
background-color: #8833D7 !important;
}
.github-badge .bg-firebrick {
background-color: #EE2C2C !important;
}
.github-badge .bg-blue {
background-color: #007EC6 !important;
}
.github-badge .bg-lightgrey {
background-color: #9F9F9F !important;
}
.github-badge .bg-grey, .github-badge .bg-gray {
background-color: #555 !important;
}
.github-badge .bg-lightgrey, .github-badge .bg-lightgray {
background-color: #9f9f9f !important;
}
在主题 functions.php 文件最下方新增
/**
* 提示文章百度是否收录
*
*/
function baidu_record()
{
$url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if(checkBaidu($url)==1)
{
echo "百度已收录";
}
else
{
echo "<a style=\"color:red;\" rel=\"external nofollow\" title=\"点击提交收录!\" target=\"_blank\" href=\"http://zhanzhang.baidu.com/sitesubmit/index?sitename=$url\">百度未收录</a>";
}
}
function checkBaidu($url)
{
$url = 'http://www.baidu.com/s?wd=' . urlencode($url);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$rs = curl_exec($curl);
curl_close($curl);
if (!strpos($rs, '没有找到'))
{ //没有找到说明已被百度收录
return 1;
} else
{
return -1;
}
}
然后在主题 post.php
文件想显示的地方增加
<!--百度收录-->
<li class="meta-categories"><i class="glyphicon glyphicon-ok-circle" aria-hidden="true"></i>
<span class="sr-only"><?php _me("百度收录") ?>:</span> <span class="meta-value"><?php echo
baidu_record() ?></span></li>
/* 开发者设置——自定义css里面添加这个即可*/
#toc {
background: rgba(255, 255, 255, 0.3);
}
.img-circle {
transition: all 0.3s;
}
.img-circle:hover {
transform: rotate(360deg);
}
其它设置
2.打开你选择的目录文件夹,新建一个目录名为 "你的版本号"
3.把主题中的assets文件夹复制到这个目录中
4.提交这个仓库
5.等待他上传完成后你就拥有了你的jsDelivr CDN加速地址:https://cdn.jsdelivr.net/gh/你的GitHub用户名/储存库名@你的版本号/GitHub项目中图片目录