Update normal.php

pull/73/head
qkqpttgf 2020-06-03 20:54:12 +08:00 committed by GitHub
parent 9336280a60
commit f4d5a8b8d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 8 deletions

View File

@ -268,14 +268,17 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
$githubfile = file_get_contents($url); $githubfile = file_get_contents($url);
if (!$githubfile) return 0; if (!$githubfile) return 0;
file_put_contents($tarfile, $githubfile); file_put_contents($tarfile, $githubfile);
$phar = new PharData($tarfile); if (splitfirst(PHP_VERSION, '.')[0] == '7') {
@$phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖 $phar = new PharData($tarfile); // need php7
@ob_start(); $phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
@passthru('tar -xzvf '.$tarfile,$stat); } else {
@ob_get_clean(); ob_start();
passthru('tar -xzvf '.$tarfile,$stat);
ob_get_clean();
}
unlink($tarfile); unlink($tarfile);
$outPath = '';
$tmp = scandir($projectPath); $tmp = scandir($projectPath);
$name = $auth.'-'.$project; $name = $auth.'-'.$project;
foreach ($tmp as $f) { foreach ($tmp as $f) {
@ -285,7 +288,9 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
} }
} }
//error_log($outPath); //error_log($outPath);
unlink($outPath.'/config.php'); if ($outPath=='') return 0;
//unlink($outPath.'/config.php');
rename($projectPath.'/config.php', $outPath.'/config.php'); rename($projectPath.'/config.php', $outPath.'/config.php');
return moveFolder($outPath, $projectPath); return moveFolder($outPath, $projectPath);
@ -304,7 +309,7 @@ function moveFolder($from, $to)
if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归 if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
moveFolder($fromfile, $tofile); moveFolder($fromfile, $tofile);
}else{ }else{
if (file_exists($tofile)) unlink($tofile); //if (file_exists($tofile)) unlink($tofile);
rename($fromfile, $tofile); rename($fromfile, $tofile);
if (file_exists($fromfile)) unlink($fromfile); if (file_exists($fromfile)) unlink($fromfile);
} }