whatshot一个脚本将php空间挂载为计算机本地磁盘(WebDAV)

@Ta 2023-10-10发布,2023-10-10修改 11529点击
先通过composer安装SabreDAV库:
composer require sabre/dav ~3.2

新建一个server.php文件:
<?php
require 'vendor/autoload.php';

$publicDir = './'; // 你想要作为WebDAV的目录

// 设置用户名和密码
$authBackend = new Sabre\DAV\Auth\Backend\File('./.htdigest');
$authBackend->setRealm('SabreDAV');
$server = new Sabre\DAV\Server(new Sabre\DAV\FS\Directory($publicDir));
$server->setBaseUri('/server.php'); // 设置你的基础URI,与本文件名一致

// 认证插件
$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend);
$server->addPlugin($authPlugin);

/* 支持LOCK和UNLOCK */
$lockBackend = new Sabre\DAV\Locks\Backend\File('/tmp/locksdb');
$lockPlugin = new Sabre\DAV\Locks\Plugin($lockBackend);
$server->addPlugin($lockPlugin);

/* 支持浏览器插件 */
$browser = new Sabre\DAV\Browser\Plugin();
$server->addPlugin($browser);

$server->exec();
?>

同目录新建.htdigest文件,设置账号密码:
admin:SabreDAV:949ceab2f978c57f05bb221b095d4f29

//格式:账号:admin 密码:123456,
//生成工具https://websistent.com/tools/htdigest-generator-tool/
//Realm:填SabreDAV

打开系统,添加网络位置:
QQ截图20231010205505.png(61.57 KB)
QQ截图20231010210823.png(18.88 KB)
QQ截图20231010210857.png(23.64 KB)
QQ截图20231010210857.png(49.31 KB)
DAV.rar(1.16 MB)
完整代码:
DAV.rar(1.16 MB)
回复列表(5|隐藏机器人聊天)
添加新回复
回复需要登录