From 63565aea78d73bb3a93a1ada69faaebe2606fda3 Mon Sep 17 00:00:00 2001 From: sunson Date: Mon, 2 Dec 2024 21:48:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20index.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加背景,利用必应的壁纸图 --- index.php | 237 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 136 insertions(+), 101 deletions(-) diff --git a/index.php b/index.php index 07d011f..1f487c6 100644 --- a/index.php +++ b/index.php @@ -3,11 +3,11 @@ $base_dir='/o/';//以/即结束即可 $user="chate.store";// 用户名 $pwd="123456";// 密码,请记得频繁更换 -$auth = false; +$authorization = false; if ($_SERVER['PHP_AUTH_USER'] == $user && $_SERVER['PHP_AUTH_PW'] == $pwd){ - $auth = true; + $authorization = true; } -if(!$auth){ +if(!$authorization){ // 没登录成功,弹出要求输入用户名和密码窗口 header("WWW-Authenticate:Basic realm='Private'"); header('HTTP/1.0 401 Unauthorized'); @@ -28,11 +28,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) { // 兼容跨平台路径 $md5 = md5_file($file_tmp); - $dir1 = substr($md5,0,1); - $dir2 = substr($md5,1,1); - $path = getcwd(); - $upload_dir = $path . $base_dir .$dir1 .'/'. $dir2; - $upload_parent_dir = $path . $base_dir .$dir1 ; + $upload_dir = getcwd() . $base_dir . substr($md5,0,1).'/'.substr($md5,1,1); // 检查并创建目录 if (!is_dir($upload_dir)) { if (!mkdir($upload_dir, 0777, true) && !is_dir($upload_dir)) { @@ -41,9 +37,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) { } // 开始创建index.html file_put_contents($upload_dir .'/index.html', 'no access'); - if(!file_exists($upload_parent_dir. '/index.html')){ - file_put_contents( $upload_parent_dir. '/index.html', 'no access'); - } + file_put_contents( getcwd() . $base_dir . substr($md5,0,1). '/index.html', 'no access'); } // 根据文件内容生成MD5文件名,这样可以排除重复上传 @@ -51,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) { // 这里判断下重复文件不移动文件 $target_file=$upload_dir . '/' .$FileName; if (file_exists($target_file) || move_uploaded_file($file_tmp, $target_file)) { - echo '{"upload_url":"http://'.$_SERVER['HTTP_HOST'] . $base_dir . $dir1. '/' .$dir2 .'/'. $FileName.'"}'; + echo '{"upload_url":"http://'.$_SERVER['HTTP_HOST'] . $base_dir . substr($md5,0,1). '/' .substr($md5,1,1) .'/'. $FileName.'"}'; } else { echo '{"error":"写入失败,无法保存文件"}'; } @@ -63,9 +57,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) { + + - 一个简单的图床 + SIW图床-基于PHP的图床服务 +
-

SIW(Simple Image Web)

-
简单就是美。
-
-
- - -
- -
-
-
- -
支持格式: JPEG, PNG, GIF, WEBP, AVIF 最大上传:
+

SIW(Simple Image Web)

+
简单就是美。
+
+
+ + +
+ +
+
+
+ +
支持格式: JPEG, PNG, GIF, WEBP, AVIF 最大上传: