BOSh
文章81
标签26
分类5

一言

文章归档

zz.ac上部署高清壁纸站点

zz.ac上部署高清壁纸站点

CT8高清壁纸站

登陆zz.ac运行php-v :

1
2
3
4
5
php -v
PHP 8.4.5 (cli) (built: Mar 17 2025 20:35:32) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.5, Copyright (c) Zend Technologies
with Zend OPcache v8.4.5, Copyright (c), by Zend Technologies

看来zz.ac主机上已经默认安装了php

上传源码:

建立文件夹,上传源码并解压:

1
2
3
4
5
6
7
8
mkdir -p pictrues

cd pictrues/

unzip pic.zip

rm YYDS源码网.html 必读资源说明.txt

运行服务器

1
2
 php -S localhost:9000
[Thu Jan 8 02:07:38 2026] PHP 8.4.5 Development Server (http://localhost:9000) started

设置域名

登陆https://desec.io/domains,设置域名解析:

image.png

设置caddy反代:

在Caddyfile文件中加入一下内容:

1
2
3
http://pic.bosh.zz.ac:8080 {
reverse_proxy 127.0.0.1:9000
}

重新启动caddy 服务:

1
systemctl --user restart caddy

访问https://pic.bosh.zz.ac/,网页界面显示:

努力加载中,但是却没有出来图片。

我想起来了应该还是代理的问题,查看后台php运行日志:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
bosh@h1:~/pictrues$ php -S localhost:9000
[Thu Jan  8 02:07:38 2026] PHP 8.4.5 Development Server (http://localhost:9000) started
[Thu Jan  8 02:14:32 2026] 127.0.0.1:51104 Accepted
[Thu Jan  8 02:14:32 2026] 127.0.0.1:51104 [200]: GET /
[Thu Jan  8 02:14:32 2026] 127.0.0.1:51104 Closing
[Thu Jan  8 02:14:32 2026] 127.0.0.1:51114 Accepted
[Thu Jan  8 02:14:32 2026] 127.0.0.1:51114 [200]: GET /css/wallpaper.css
[Thu Jan  8 02:14:32 2026] 127.0.0.1:51114 Closing
[Thu Jan  8 02:14:32 2026] 127.0.0.1:51126 Accepted
[Thu Jan  8 02:14:32 2026] 127.0.0.1:51126 [200]: GET /js/jquery.lazyload.min.js
[Thu Jan  8 02:14:32 2026] 127.0.0.1:51126 Closing
[Thu Jan  8 02:14:33 2026] 127.0.0.1:51140 Accepted
[Thu Jan  8 02:14:33 2026] 127.0.0.1:51140 [200]: GET /js/jquery.onepage-scroll.min.js
[Thu Jan  8 02:14:33 2026] 127.0.0.1:51140 Closing
[Thu Jan  8 02:14:33 2026] 127.0.0.1:51142 Accepted
[Thu Jan  8 02:14:33 2026] 127.0.0.1:51142 [200]: GET /js/wallpaper.js
[Thu Jan  8 02:14:33 2026] 127.0.0.1:51142 Closing
[Thu Jan  8 02:14:34 2026] 127.0.0.1:51154 Accepted
[Thu Jan  8 02:14:34 2026] PHP Warning:  file_get_contents(): php_network_getaddresses: getaddrinfo for wp.birdpaper.com.cn failed: Name or service not known in /home/bosh/pictrues/api.php on line 13
[Thu Jan  8 02:14:34 2026] PHP Warning:  file_get_contents(http://wp.birdpaper.com.cn/intf/getCategory): Failed to open stream: php_network_getaddresses: getaddrinfo for wp.birdpaper.com.cn failed: Name or service not known in /home/bosh/pictrues/api.php on line 13
........

果然:Name or service not known in /home/bosh/pictrues/api.php on line 13

尝试加上代理运行:

1
http_proxy="http://[fe80::1%25eth0]:8888" https_proxy="http://[fe80::1%25eth0]:8888" php -S 0.0.0.0:9000

刷新网页还是努力加载中但是加载不出来。

是时候搬出AI大师了!

经过咨询,让AI修改了api.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php

// --- 配置区 ---
// 注意:在代码中,IPv6 的作用域标识通常直接使用 %eth0,而不是命令行里的 %25eth0
$proxy_url = "tcp://[fe80::1%eth0]:8888";
// --------------

$cid = getParam('cid', '360new');

switch($cid)
{
case '360new': // 360壁纸 新图片
$start = getParam('start', 0);
$count = getParam('count', 10);
$url = "http://wp.birdpaper.com.cn/intf/newestList?pageno={$start}&count={$count}";
echojson(fetchData($url, $proxy_url));
break;

case '360tags':
$url = "http://wp.birdpaper.com.cn/intf/getCategory";
echojson(fetchData($url, $proxy_url));
break;

case 'bing':
$start = getParam('start', -1);
$count = getParam('count', 8);
$url = "http://cn.bing.com/HPImageArchive.aspx?format=js&idx={$start}&n={$count}";
echojson(fetchData($url, $proxy_url));
break;

case '360search':
$content = getParam('content', '');
$start = getParam('start', 0);
$count = getParam('count', 10);
$url = "http://wp.birdpaper.com.cn/intf/search?content={$content}&pageno={$start}&count={$count}";
echojson(fetchData($url, $proxy_url));
break;

default:
$start = getParam('start', 0);
$count = getParam('count', 10);
$url = "http://wp.birdpaper.com.cn/intf/GetListByCategory?cids={$cid}&pageno={$start}&count={$count}";
echojson(fetchData($url, $proxy_url));
}

/**
* 核心修复:通过代理获取远程数据
*/
function fetchData($url, $proxy)
{
$opts = [
"http" => [
"proxy" => $proxy,
"request_fulluri" => true,
"timeout" => 10, // 设置10秒超时
"header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36\r\n"
]
];

$context = stream_context_create($opts);

// 使用 @ 符号抑制警告,通过返回值判断错误
$result = @file_get_contents($url, false, $context);

if ($result === false) {
// 如果失败,返回一个标准的 JSON 错误提示
return json_encode(["error" => "无法连接远程服务器", "debug_url" => $url]);
}

return $result;
}

/**
* 获取GET或POST过来的参数
*/
function getParam($key, $default='')
{
return trim($key && is_string($key) ? (isset($_POST[$key]) ? $_POST[$key] : (isset($_GET[$key]) ? $_GET[$key] : $default)) : $default);
}

/**
* 输出内容
*/
function echojson($data)
{
header('Content-Type: application/json; charset=utf-8');
echo $data;
}

再次运行:

1
php -S localhost:9000

刷新网页,成功加载!

截图_2026-01-08_10-39-39.png

大功告成 😄

修改后的源码

本文作者:BOSh
本文链接:http://bosh.zz.ac/posts/3026062649.html
版权声明:本文由BoSh发布,部分内容来源于网络。