更新 index.php

加入多用户管理。
This commit is contained in:
sunson 2024-12-03 12:45:32 +08:00
parent d831c5c0de
commit d948a693ba

View File

@ -1,12 +1,15 @@
<?php
$base_dir = '/o/';//以/即结束即可
$user="chate.store";// 用户名
$pwd="123456";// 密码,请记得频繁更换
$user = array("admin1","admin2");// 用户名,可多个
$pwd = array("chate.store1","chate.store2");// 密码,跟用户一一对应,请记得更换
$authorization = false;
if ($_SERVER['PHP_AUTH_USER'] == $user && $_SERVER['PHP_AUTH_PW'] == $pwd){
$key = array_search($_SERVER['PHP_AUTH_USER'], $user);
if($key !== false){
if($_SERVER['PHP_AUTH_PW'] ==$pwd[$key]){
$authorization = true;
}
}
if(!$authorization){
// 没登录成功,弹出要求输入用户名和密码窗口
header("WWW-Authenticate:Basic realm='Private'");
@ -200,12 +203,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
</div>
</div>
<script>
async function setBackgroundImages() {
const images = ['https://cn.bing.com/th?id=OHR.SnowMoose_EN-US6949674639_1920x1080.jpg','https://cn.bing.com/th?id=OHR.IcebergsAntarctica_EN-US6829804691_1920x1080.jpg','https://cn.bing.com/th?id=OHR.KilchurnAutumn_EN-US6737063910_1920x1080.jpg','https://cn.bing.com/th?id=OHR.MtStMichel_EN-US6641012356_1920x1080.jpg','https://cn.bing.com/th?id=OHR.TomTurkeys_EN-US6212893518_1920x1080.jpg'];
const backgroundDiv = document.getElementById('background');
// 取必应每天的壁纸做背景
var response = await fetch('https://raw.onmicrosoft.cn/Bing-Wallpaper-Action/main/data/zh-CN_all.json');
var data = await response.json();
var images = data.data.map(image => image.url);
var backgroundDiv = document.getElementById('background');
if (images.length > 0) {
backgroundDiv.style.backgroundImage = 'url(' + images[0] + ')';
backgroundDiv.style.backgroundImage = 'url(https://www.bing.com/' + images[0] + ')';
}
let index = 0;
let currentBackgroundDiv = backgroundDiv;
@ -213,7 +218,7 @@ async function setBackgroundImages() {
const nextIndex = (index + 1) % images.length;
const nextBackgroundDiv = document.createElement('div');
nextBackgroundDiv.className = 'background next';
nextBackgroundDiv.style.backgroundImage = 'url(' + images[nextIndex] + ')';
nextBackgroundDiv.style.backgroundImage = 'url(https://www.bing.com/' + images[nextIndex] + ')';
document.body.appendChild(nextBackgroundDiv);
nextBackgroundDiv.style.opacity = 0;
setTimeout(() => {
@ -223,9 +228,12 @@ nextBackgroundDiv.style.opacity = 1;
document.body.removeChild(currentBackgroundDiv);
currentBackgroundDiv = nextBackgroundDiv;
index = nextIndex;
if(index>10)index=0;// 只取前十张
}, 1000);
}, 5000);
}
$(document).ready(function() {
setBackgroundImages();// 设置背景
// 初始化时显示格式提示