* user: move the checkTmp method from model.php to zen.php bacause it's only used in zen.php.

This commit is contained in:
liugang
2023-12-16 17:21:06 +08:00
parent b46e0c55c6
commit 8bf2aff2f1
2 changed files with 26 additions and 26 deletions
-25
View File
@@ -1626,31 +1626,6 @@ class userModel extends model
return 0;
}
/**
* 检查缓存目录是否有写权限。
* Check if the tmp directory is writable.
*
* @access public
* @return bool
*/
public function checkTmp(): bool
{
if(!is_dir($this->app->tmpRoot)) mkdir($this->app->tmpRoot, 0755, true);
if(!is_dir($this->app->cacheRoot)) mkdir($this->app->cacheRoot, 0755, true);
if(!is_dir($this->app->logRoot)) mkdir($this->app->logRoot, 0755, true);
if(!is_dir($this->app->logRoot)) return false;
$file = $this->app->logRoot . DS . 'demo.txt';
if($fp = @fopen($file, 'a+'))
{
@fclose($fp);
@unlink($file);
return true;
}
return false;
}
/**
* Compute user view.
*
+26 -1
View File
@@ -11,7 +11,7 @@ class userZen extends user
public function checkDirPermission(): void
{
$canModifyDIR = true;
if($this->user->checkTmp() === false)
if($this->checkTmp() === false)
{
$canModifyDIR = false;
$folderPath = $this->app->tmpRoot;
@@ -33,6 +33,31 @@ class userZen extends user
}
}
/**
* 检查缓存目录是否有写权限。
* Check if the tmp directory is writable.
*
* @access public
* @return bool
*/
public function checkTmp(): bool
{
if(!is_dir($this->app->tmpRoot)) mkdir($this->app->tmpRoot, 0755, true);
if(!is_dir($this->app->cacheRoot)) mkdir($this->app->cacheRoot, 0755, true);
if(!is_dir($this->app->logRoot)) mkdir($this->app->logRoot, 0755, true);
if(!is_dir($this->app->logRoot)) return false;
$file = $this->app->logRoot . DS . 'demo.txt';
if($fp = @fopen($file, 'a+'))
{
@fclose($fp);
@unlink($file);
return true;
}
return false;
}
/**
* 获取一个用户用于 json 格式返回给前台。
* Get a user for json format to return to the front end.