注意

注意:确认php版本中已添加扩展:Redis

php文件代码

<?php
date_default_timezone_set("PRC");
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
// echo "Connection to server successfully";
// //查看服务是否运行
// echo "Server is running: " . $redis->ping();
$rilitu = $redis->get('rili');
if ($rilitu) {
    //echo "来自缓存";
} else {
    //echo "实时获取";
    $url = "https://img.owspace.com/Public/uploads/Download/" . date('Y/md') . ".jpg";
    $rilitu = getSslPage($url);
    $dayLeftSeconds = 86400 - (time() + 8 * 3600) % 86400;
    $redis->setex('rili', $dayLeftSeconds, $rilitu);
}
header('Content-Type:image/jpeg');
echo $rilitu;
function getSslPage($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

添加位置

<!-- 我选择的是右边栏广告位-handsome主题外观设置-开发者设置-全局右侧边栏广告位,添加以下代码: -->
<a href="此处添加日历的php文件(点击跳转链接)" target="_blank" ><img src="此处添加日历的php文件,后缀为php" alt="單向历" style="height: 240px"></a>

<!-- 或者直接用我的php文件,添加到侧边栏广告位(或你想放置的魔改侧边栏任意位置): -->
<a href="http://www.darktool.com/rili.php" target="_blank" ><img src="http://www.darktool.com/rili.php" alt="單向历" style="height: 240px"></a>
https://www.yoliliyo.com/share/438.html
最后修改:2023 年 05 月 04 日
如果觉得我的文章对你有用,请随意赞赏