Browse Source

move dir improve, to support root directory

master
filesite 2 years ago
parent
commit
3ed89fb496
  1. 40
      controller/ApiController.php
  2. 1
      controller/Controller.php
  3. 2
      www/content/README.md

40
controller/ApiController.php

@ -49,9 +49,11 @@ Class ApiController extends Controller { @@ -49,9 +49,11 @@ Class ApiController extends Controller {
}
private function getParentDir($realpath) {
if ($realpath == '/') {return $realpath;}
$realpath = preg_replace('/\/$/', '', $realpath);
$arr = explode('/', $realpath);
if (count($arr) < 2) {return $realpath;}
if (count($arr) < 2) {return '/';}
array_pop($arr);
return implode('/', $arr);
@ -61,6 +63,8 @@ Class ApiController extends Controller { @@ -61,6 +63,8 @@ Class ApiController extends Controller {
protected function isParentDirectoryValid($parentDir) {
if (empty($parentDir) || strpos($parentDir, '../') !== false) {
return false;
}else if ($realpath == '/') {
return true;
}
$valid = true;
@ -288,7 +292,17 @@ Class ApiController extends Controller { @@ -288,7 +292,17 @@ Class ApiController extends Controller {
$target = __DIR__ . '/../www/' . FSC::$app['config']['content_directory'];
try {
$res = rename("{$target}/{$fromDir}", "{$target}/{$toDir}");
//兼容已经存在的目录,则移动进去,而不是重命名
if ($toDir == '/') {
$basename = $this->basename($fromDir);
$res = rename("{$target}/{$fromDir}", "{$target}/{$basename}");
}else if (!realpath("{$target}/{$toDir}")) {
$res = rename("{$target}/{$fromDir}", "{$target}/{$toDir}");
}else {
$basename = $this->basename($fromDir);
$res = rename("{$target}/{$fromDir}", "{$target}/{$toDir}/{$basename}");
}
if ($res) {
$code = 1;
$msg = '目录/文件移动完成';
@ -340,9 +354,9 @@ Class ApiController extends Controller { @@ -340,9 +354,9 @@ Class ApiController extends Controller {
$res = rename("{$target}/{$fromDir}", "{$target}/{$toDir}");
if ($res) {
$code = 1;
$msg = '目录移动完成';
$msg = '重命名完成';
}else {
$err = '目录移动失败,请确认被移动目录存在及目标目录权限配置正确!';
$err = '重命名失败,请确认被重命名目录/文件存在及目标目录权限配置正确!';
}
}catch(Exception $e) {
$err = $e->getMessage();
@ -409,7 +423,8 @@ Class ApiController extends Controller { @@ -409,7 +423,8 @@ Class ApiController extends Controller {
$refresh = (int)$this->post('refresh', 0);
try {
$builder = new CaptchaBuilder;
$randNumber = rand(10000, 99999);
$builder = new CaptchaBuilder("{$randNumber}");
$builder->build();
$captcha_jpg = $builder->get();
$captcha_code = $builder->getPhrase();
@ -724,6 +739,21 @@ Class ApiController extends Controller { @@ -724,6 +739,21 @@ Class ApiController extends Controller {
if (!empty($contentDirectory)) {
$jsonData['content_directory'] = $contentDirectory;
}else {
switch($themeName) {
case 'manual':
$jsonData['content_directory'] = 'content';
break;
case 'webdirectory':
$jsonData['content_directory'] = 'navs';
break;
case 'googleimage':
$jsonData['content_directory'] = 'girls';
break;
case 'videoblog':
$jsonData['content_directory'] = 'videos';
break;
}
}
if (file_exists($customConfigFile)) {

1
controller/Controller.php

@ -279,6 +279,7 @@ Class Controller { @@ -279,6 +279,7 @@ Class Controller {
//get basename of realpath, support chinese
protected function basename($realpath) {
$realpath = preg_replace('/\/$/', '', $realpath);
$arr = explode('/', $realpath);
if (count($arr) < 2) {return $realpath;}

2
www/content/README.md

@ -131,7 +131,7 @@ http://127.0.0.1:1080 @@ -131,7 +131,7 @@ http://127.0.0.1:1080
FileSite.io官方提供的皮肤都包含在最新版的源码目录```themes/```中,详情如下:
| 皮肤名称 | 目录 | 适用网站类型 |
| 皮肤名称 | 皮肤目录 | 适用网站类型 |
| ---- | ---- | ---- |
| WebDirectory | webdirectory | 导航站 |
| Manual | manual | 文档站 |

Loading…
Cancel
Save