onenav/controller/bing.php
2024-11-27 16:31:46 +08:00

28 lines
705 B
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* name:bing壁纸
*/
header('Content-Type:application/json; charset=utf-8');
// 载入辅助函数
require('functions/helper.php');
//获取当前主机名
$host = $_SERVER['HTTP_HOST'];
//获取reffrer
$referer = $_SERVER['HTTP_REFERER'];
//如果referer和主机名不匹配则禁止调用
if ( ( !empty($referer) ) && ( !strstr($referer,$host) ) ) {
exit('调用失败');
}
session_start();
//如果session不为空则使用session数据
if ( empty( $_SESSION['bing_data'] ) ) {
$bing_data = curl_get("https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=8",8);
$_SESSION['bing_data'] = $bing_data;
echo $bing_data;
}
else{
echo $_SESSION['bing_data'];
}