添加完成后,记得去`handsome\component\footer.php`删除原有声明代码哦!
### 2、添加心知天气
使用方法:
1:知心天气官网www.seniverse.com注册申请免费API 密钥
2:将以下代码放入/usr/themes/handsome/component/headnav.php第55行之后并更换你的公钥秘钥即可
```html
```
### 3、添加访客总数统计和网站响应耗时
~~在主题的`function.php`文件中加入以下代码(添加在文件尾即可)~~
由于handsome6.0.0主题将`function.php`文件加密,所以将以下代码添加的位置改为~~`component/sidebar.php`~~
`lib/Content.php`文件中
```JavaScript
/**
* * 访客总数
* */
function theAllViews()
{
$db = Typecho_Db::get();
$row = $db->fetchAll('SELECT SUM(VIEWS) FROM `typecho_contents`');
echo number_format($row[0]['SUM(VIEWS)']);
}
/**
* 网站响应时间
* @return bool
*/
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;
}
```
然后打开`component/sidebar.php`文件,在约100行的位置添加如下代码
```HTML5
```
### 11、本站添加AliceStyle美化插件
网址:[AliceStyle美化插件](https://racns.com/374.html)

## 需要修改源文件
###1、底部页脚标签样式
将以下代码添加至后台主题设置自定义CSS
```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-blue {
background-color: #007ec6
}
.github-badge .bg-orange {
background-color: #ffa500
}
.github-badge .bg-red {
background-color: #f00
}
.github-badge .bg-green {
background-color: #3bca6e
}
.github-badge .bg-purple {
background-color: #ab34e9
}
```
将以下代码添加至后台主题设置`博客底部左侧信息`,信息修改成自己的
```HTML
```
将以下代码添加至后台主题设置`博客底部右侧信息`
```HTML
|
```
```
如图所示


### 4、为文章添加百度收录检测
[原文地址](https://wfblog.net/archives/baidu_check.html "原文地址")
1.在模板post.php加入
```HTML
```
2.还是在post.php内加入(必须引入jquery)
```JavaScript
```
该API代码文件如下
```PHP
false,
"msg" => "未传入请求参数!"
);
echo json_encode($data,JSON_UNESCAPED_UNICODE);
exit;
}
$data = checkBaidu($domain);
echo json_encode($data,JSON_UNESCAPED_UNICODE);
function checkBaidu($url){
$header = array(
"Host:www.baidu.com",
"Content-Type:application/x-www-form-urlencoded",//post请求
"Connection: keep-alive",
"Referer:https://www.baidu.com",
"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Safari/537.36"
);
$url = 'https://www.baidu.com/s?ie=UTF-8&wd='.urlencode($url).'&usm=3&rsv_idx=2&rsv_page=1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
if(strpos($output, '没有找到') || strpos($output, '很抱歉')){
$data = array(
"code" => 403,
"msg" => "该域名暂时未被百度收录!"
);
}else{
$number = GetBetween($output,'百度为您找到相关结果约','个');
if(empty($number) || $number == 0){
$number = GetBetween($output,'找到相关结果数约','个');
if(empty($number) || $number == 0){
$data = array(
"code" => false,
"msg" => "获取百度收录失败!"
);
return $data;
}
}
$data = array(
"code" => 200,
"msg" => "该域名已被百度收录!",
"number" => str_replace(',','',$number)
);
}
return $data;
}
function GetBetween($content,$start,$end){
$r = explode($start, $content);
if (isset($r[1])){
$r = explode($end, $r[1]);
return $r[0];
}
}
?>
```
最后修改:2021 年 03 月 06 日
© 允许规范转载
2 条评论
你的文章让我感受到了不一样的风景,谢谢分享。 https://www.yonboz.com/video/73942.html
你的文章让我感受到了不一样的风景,谢谢分享。 http://www.55baobei.com/3og8ZoS0nC.html