升级文件检测
This commit is contained in:
parent
032426f71e
commit
29c05d2d24
@ -233,10 +233,28 @@ class Upgrade extends AdminController
|
|||||||
//删除sql语句
|
//删除sql语句
|
||||||
unlink($upSql);
|
unlink($upSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
//升级PHP
|
//升级PHP
|
||||||
if(is_dir($zipPath))
|
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);
|
$cpRes = Files::copyDirs($zipPath,$this->root_dir);
|
||||||
$cpData = $cpRes->getData();
|
$cpData = $cpRes->getData();
|
||||||
//更新失败
|
//更新失败
|
||||||
|
@ -141,12 +141,8 @@
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
layer.close(load);
|
layer.close(load);
|
||||||
layer.open({
|
layer.alert(data.msg,{icon:5,title:'更新失败', area:['50%', '70%']});
|
||||||
title:'升级失败',
|
return false;
|
||||||
content:data.msg,
|
|
||||||
icon:5,
|
|
||||||
anim:6
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -43,7 +43,7 @@ class ZipFile
|
|||||||
|
|
||||||
if(file_exists($save_path)) {
|
if(file_exists($save_path)) {
|
||||||
if($overwrite === true){
|
if($overwrite === true){
|
||||||
echo $file_name . '<pre />';
|
//echo $file_name . '<pre />';
|
||||||
$file_size = zip_entry_filesize($zip);
|
$file_size = zip_entry_filesize($zip);
|
||||||
$file = zip_entry_read($zip, $file_size);
|
$file = zip_entry_read($zip, $file_size);
|
||||||
$fpc = file_put_contents($save_path, $file);
|
$fpc = file_put_contents($save_path, $file);
|
||||||
|
@ -7,7 +7,7 @@ return [
|
|||||||
//应用名,此项不可更改
|
//应用名,此项不可更改
|
||||||
'appname' => 'TaoLer',
|
'appname' => 'TaoLer',
|
||||||
//版本配置
|
//版本配置
|
||||||
'version' => '1.7.13',
|
'version' => '1.7.14',
|
||||||
//加盐
|
//加盐
|
||||||
'salt' => 'taoler',
|
'salt' => 'taoler',
|
||||||
//数据库备份目录
|
//数据库备份目录
|
||||||
|
@ -34,6 +34,28 @@ class Files
|
|||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列出目录下的所有文件,包括子目录文件,不包含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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建文件夹及子文件夹
|
* 创建文件夹及子文件夹
|
||||||
|
Loading…
x
Reference in New Issue
Block a user