一点点清洁工作

This commit is contained in:
Chenx221 2024-02-16 11:17:55 +08:00
parent a8902fd449
commit 7743e2db67
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
2 changed files with 2 additions and 8 deletions

View File

@ -56,12 +56,10 @@ class HomeController extends Controller
*/ */
public function actionIndex($directory = null) public function actionIndex($directory = null)
{ {
//Warning: Security Vulnerability: access via $directory parameter = ../ will display the internal files of the server
if (Yii::$app->user->isGuest) { if (Yii::$app->user->isGuest) {
return $this->redirect(Yii::$app->user->loginUrl); return $this->redirect(Yii::$app->user->loginUrl);
} }
$rootDataDirectory = Yii::getAlias(Yii::$app->params['dataDirectory']); $rootDataDirectory = Yii::getAlias(Yii::$app->params['dataDirectory']) . '/' . Yii::$app->user->id;
$userId = Yii::$app->user->id;
if ($directory === '.' || $directory == null) { if ($directory === '.' || $directory == null) {
$directory = null; $directory = null;
@ -71,7 +69,7 @@ class HomeController extends Controller
} else { } else {
$parentDirectory = dirname($directory); $parentDirectory = dirname($directory);
} }
$directoryContents = $this->getDirectoryContents(join(DIRECTORY_SEPARATOR, [$rootDataDirectory, $userId, $directory ?: '.'])); $directoryContents = $this->getDirectoryContents(join(DIRECTORY_SEPARATOR, [$rootDataDirectory, $directory ?: '.']));
foreach ($directoryContents as $key => $item) { foreach ($directoryContents as $key => $item) {
$relativePath = $directory ? $directory . '/' . $item : $item; $relativePath = $directory ? $directory . '/' . $item : $item;
$absolutePath = Yii::getAlias('@app') . '/data/' . Yii::$app->user->id . '/' . $relativePath; $absolutePath = Yii::getAlias('@app') . '/data/' . Yii::$app->user->id . '/' . $relativePath;

View File

@ -95,10 +95,6 @@ $(document).on('click', '.batch-zip-btn', function () {
$('#zipModal').modal('show'); $('#zipModal').modal('show');
}); });
$(document).on('click', '.unzip-btn', function () { $(document).on('click', '.unzip-btn', function () {
console.log('解压按钮被点击'); console.log('解压按钮被点击');
// 在这里添加你的代码 // 在这里添加你的代码