升级文件检测
This commit is contained in:
parent
032426f71e
commit
29c05d2d24
@ -234,9 +234,27 @@ class Upgrade extends AdminController
|
||||
unlink($upSql);
|
||||
}
|
||||
|
||||
//升级PHP
|
||||
//升级PHP
|
||||
if(is_dir($zipPath))
|
||||
{
|
||||
//升级前的写入文件权限检查
|
||||
$allUpdateFiles = Files::getAllFile($zipPath);
|
||||
|
||||
if (empty($allUpdateFiles)) return json(['code' => -1, 'msg' => '无可更新文件。']);
|
||||
$checkString = '';
|
||||
foreach ($allUpdateFiles as $updateFile) {
|
||||
$coverFile = ltrim(str_replace($zipPath, '', $updateFile), DIRECTORY_SEPARATOR);
|
||||
$dirPath = dirname('../'.$coverFile);
|
||||
if (file_exists('../'.$coverFile)) {
|
||||
if (!is_writable('../'.$coverFile)) $checkString .= $coverFile . ' [<span class="text-red">' . '无写入权限' . '</span>]<br>';
|
||||
} else {
|
||||
if (!is_dir($dirPath)) @mkdir($dirPath, 0777, true);
|
||||
if (!is_writable($dirPath)) $checkString .= $dirPath . ' [<span class="text-red">' . '无写入权限' . '</span>]<br>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($checkString)) return json(['code' => -1, 'msg' => $checkString]);
|
||||
|
||||
$cpRes = Files::copyDirs($zipPath,$this->root_dir);
|
||||
$cpData = $cpRes->getData();
|
||||
//更新失败
|
||||
|
@ -141,12 +141,8 @@
|
||||
});
|
||||
} else {
|
||||
layer.close(load);
|
||||
layer.open({
|
||||
title:'升级失败',
|
||||
content:data.msg,
|
||||
icon:5,
|
||||
anim:6
|
||||
});
|
||||
layer.alert(data.msg,{icon:5,title:'更新失败', area:['50%', '70%']});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -43,7 +43,7 @@ class ZipFile
|
||||
|
||||
if(file_exists($save_path)) {
|
||||
if($overwrite === true){
|
||||
echo $file_name . '<pre />';
|
||||
//echo $file_name . '<pre />';
|
||||
$file_size = zip_entry_filesize($zip);
|
||||
$file = zip_entry_read($zip, $file_size);
|
||||
$fpc = file_put_contents($save_path, $file);
|
||||
|
@ -7,7 +7,7 @@ return [
|
||||
//应用名,此项不可更改
|
||||
'appname' => 'TaoLer',
|
||||
//版本配置
|
||||
'version' => '1.7.13',
|
||||
'version' => '1.7.14',
|
||||
//加盐
|
||||
'salt' => 'taoler',
|
||||
//数据库备份目录
|
||||
|
@ -35,6 +35,28 @@ class Files
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出目录下的所有文件,包括子目录文件,不包含sql目录
|
||||
* @param $dirName
|
||||
* @return array
|
||||
*/
|
||||
public static function getAllFile($dirName)
|
||||
{
|
||||
//$dirName = str_replace('..', '', rtrim($dirName, '/\\'));
|
||||
$fileArray = [];
|
||||
if (is_dir($dirName)) {
|
||||
$dh = scandir($dirName);
|
||||
foreach ($dh as $file) {
|
||||
if (!in_array($file, ['.', '..', 'runtime', '.DS_Store'])) {
|
||||
$path = $dirName . DIRECTORY_SEPARATOR . $file;
|
||||
if (!is_dir($path)) $fileArray[] = $path;
|
||||
$fileArray = array_merge($fileArray, self::getAllFile($path));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fileArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建文件夹及子文件夹
|
||||
* @param $path
|
||||
|
Loading…
x
Reference in New Issue
Block a user