宝塔面板登录页面比较单调,不过可以通过简单设置来调用bing每日一图 ,让你的登录页面酷炫起来。
这篇文章就来简单说说如何设置,如果你还没有宝塔面板可以关注下(宝塔服务器面板,一键全能部署及管理,送你3188元礼包,点我领取
1、修改login.html
1)修改路径:/www/server/panel/BTPanel/templates/default/login.html
2)我们修改login.html这个文件,将以下代码添加到图中位置:
此处为隐藏的内容!
发表评论并刷新,方可查看
看图:
2、清除面板缓存
为了正常显示,我们需要清除面板缓存。
利用ssh工具连接到服务器,先输入BT,再输入序号9,清除面板缓存即可。
3、效果
1)原来的登录页
2)增加bing每日一图后的效果
3、关于api
这api接口是网上找的,这里罗列几个,防止不好用可以换。
https://api.7-89.cn/bing/today
https://api.kdcc.cn/img/
https://api.kdcc.cn/img/rand.php(随机)
https://api.kdcc.cn/img/jump.php
https://open.saintic.com/api/bingPic/
http://47.103.144.215:2020/showtoday
https://www.talklee.com/api/bing
https://api.dujin.org/bing/1920.php
4、自建api 一
自己搭建一个api是最稳的,这里简单说下。
1)首先在网站根目录新建一个php文件,例如:bing.php、api.php,然后粘贴如下代码:<?php
//判断是否随机调用
if ($_GET['rand']==='true') {
$gettime = rand(-1,7);
}else{
//若不为随机调用则判断是否指定日期
$gettimebase = $_GET['day'];
if (empty($gettimebase)) {
$gettime = 0;
}else{
$gettime = $gettimebase;
}
}
//获取Bing Json信息
$json_string = file_get_contents('https://www.bing.com/HPImageArchive.aspx?format=js&idx='.$gettime.'&n=1');
//转换为PHP数组
$data = json_decode($json_string);
//提取基础url
$imgurlbase = "https://www.bing.com".$data->{"images"}[0]->{"urlbase"};
//判断是否指定图片大小
$imgsizebase = $_GET['size'];
if (empty($imgsizebase)){
$imgsize = "1920x1080";
}else{
$imgsize = $imgsizebase;
}
//建立完整url
$imgurl = $imgurlbase."_".$imgsize.".jpg";
//获取其他信息
$imgtime = $data->{"images"}[0]->{"startdate"};
$imgtitle = $data->{"images"}[0]->{"copyright"};
$imglink = $data->{"images"}[0]->{"copyrightlink"};
//判断是否只获取图片信息
if ($_GET['info']==='true') {
echo "{title:".$imgtitle.",url:".$imgurl.",link:".$imglink.",time:".$imgtime."}";
}else{
//若不是则跳转url
header("Location: $imgurl");
}
2)简单用法
如果有不同需求网址后面加“?参数代码=true(或者false)”,参考上面的参数表格,完整代码就是(以随机为例):https://网址/api.php?rand=true
举例随机调用: (刷新后,图片随机显示,只是举例,链接可能会失效。)https://ee.fdao.xyz/api.php?rand=true
5、自建api 二
1)项目:
https://github.com/chengjunchao/bing-pic-api/
2)准备
宝塔面板最新版本
PM2管理器安装好
安装axios、 body-parser 、express 这几个模块
3)安装
安装基于宝塔安装。git clone https://github.com/chengjunchao/bing-pic-api.git
npm install #安装依赖项
npm start #运行
4)PM2管理器安装项目
注意:启动文件写app.js
访问地址:IP:2020/showtoday
如果不能打开注意在安全中开启2020端口
如果设置域名访问,可以点击后面的映射,就会搞定。
或者自建设置“戴笠”也可以,可以看教程(
6、最后
折腾一个小东西,最后竟然搞出这么多东西出来,真是喝多了。
参考资料:https://www.6r9.net/1684.html
https://www.talklee.com/blog/501.html