- 增加解析上传IP地址 (使用方法参考提示信息)

* 2023-02-01 v2.7.0 dev
- 增加上传历史记录
- 增加粘贴上传状态
- 增加广场非图片图标
- 增加前端显示缩略图链接
- 增加每日获取Bing图片背景
- 增加图片详细信息管理登录后显示更多信息
- 增加解析上传IP地址 (使用方法参考提示信息)
- 修复图片详细信息中随机图片排版混乱
- 替换访问生成缩略图代码
- 更新一些组件
- 调整前端显示
- 优化代码
This commit is contained in:
icret
2023-02-01 02:26:09 +08:00
parent a24bc892ff
commit ae21b70a13
12 changed files with 759 additions and 263 deletions

View File

@@ -10,10 +10,14 @@
include_once '../config/config.php';
$path = __DIR__ . '/..' . $config['path'] . $config['delDir']; // 设置图片缓存文件夹
$filename = date("Ymd") . '.jpg'; // 用年月日来命名新的文件名
if (!file_exists($path . $filename)) // 如果文件不存在,则说明今天还没有进行缓存
$path = '..' . $config['path'] . $config['delDir']; // 设置图片缓存文件夹
$filename = date("Ymd") . '.jpg'; // 用年月日来命名新的文件名
if (file_exists($path . $filename)) // 如果文件不存在,则说明今天还没有进行缓存
{
header("Content-type: image/jpeg");
exit(file_get_contents($path . $filename, true));
} else {
if (!file_exists($path)) //如果目录不存在
{
mkdir($path, 0777); //创建缓存目录
@@ -22,31 +26,6 @@ if (!file_exists($path . $filename)) // 如果文件不存在,则说明
$str = json_decode($str, true);
$imgurl = 'http://cn.bing.com' . $str['images'][0]['url']; //获取图片url
$img = grabImage($imgurl, $path . $filename); //读取并保存图片
/*
$handle = fopen("dat.txt", "a"); //用于存放图片信息,如果不需要保存图片的相关信息,可以把下面这些去掉。
if ($handle) {
$copyright = $str['images'][0]['copyright']; //说明
$startdate = $str['images'][0]['startdate'];
$fullstartdate = $str['images'][0]['fullstartdate'];
$enddate = $str['images'][0]['enddate'];
$urlbase = $str['images'][0]['urlbase'];
$copyrightlink = $str['images'][0]['copyrightlink'];
$quiz = $str['images'][0]['quiz'];
$wp = $str['images'][0]['wp'];
$hsh = $str['images'][0]['hsh'];
$drk = $str['images'][0]['drk'];
$top = $str['images'][0]['top'];
$bot = $str['images'][0]['bot'];
$tempArr = array(
"imgurl" => $imgurl, "copyright" => $copyright, "startdate" => $startdate,
"fullstartdate" => $fullstartdate, "enddate" => $enddate, "urlbase" => $urlbase,
"copyrightlink" => $copyrightlink, "quiz" => $quiz, "wp" => $wp,
"hsh" => $hsh, "drk" => $drk, "top" => $top, "bot" => $bot
); //将相关信息放进数组中
fwrite($handle, json_encode($tempArr) . "\r\n"); //最终以json格式保存在文本文档中
fclose($handle);
}
*/
}
/**
* 远程抓取图片并保存
@@ -65,8 +44,7 @@ function grabImage($url, $filename = "")
readfile($url); //输出图片文件
$img = ob_get_contents(); //得到浏览器输出
ob_end_clean(); //清除输出并关闭
$size = strlen($img); //得到图片大小
$fp2 = @fopen($filename, "a");
$fp2 = @fopen($filename, "w+");
fwrite($fp2, $img); //向当前目录写入图片文件,并重新命名
fclose($fp2);
return $filename; //返回新的文件名