From 67bf1ff3798db64e957ed2597d28a56b711ae503 Mon Sep 17 00:00:00 2001 From: LyLme Date: Sun, 27 Mar 2022 03:01:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/update.php | 129 +++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 59 deletions(-) diff --git a/admin/update.php b/admin/update.php index 3e489db..e49e564 100644 --- a/admin/update.php +++ b/admin/update.php @@ -4,88 +4,99 @@ include './head.php'; ?>
-
getver($conf['version']) && !empty($update['version']) ){ - echo ' -

版本更新

    -
  • 当前版本:'.$conf['version'].'
  • -
  • 最新版本:'.$update['version'].'
  • -
  • 更新说明:点击这里 下载更新包:lylme_spage_update_'.$update['version'].'.zip 上传到网站根目录后解压,点击更新数据库
  • -
  • ';} -else if(!empty($update['version'])){ -echo ' +if(getver($update['version']) > getver($conf['version']) && !empty($update['version']) ) { + echo ' '; + echo ' +

    更新说明

      + '.$update['update_log'].' +
    • '; +} else if(!empty($update['version'])) { + echo '

      版本更新

      • 当前版本:'.$conf['version'].'
      • 最新版本:'.$update['version'].'
      • '; -} -else{ - echo ' +} else { + echo '

        版本更新

        -
      -
- - - alert('数据库更新文件:".$sqlpath." 不存在!\n请下载更新包解压到网站根目录');window.location.href='./';");} - $sql = file_get_contents($sqlpath); - $version = 'v1.1.1'; - saveSetting('version',$version); -} - -else{ - echo ""; -} - +if($set=='update') { + function zipExtract ($src, $dest) { + $zip = new ZipArchive(); + if ($zip->open($src)===true) { + $zip->extractTo($dest); + $zip->close(); + return true; + } + return false; + } + $RemoteFile = $update['file']; + $ZipFile = "lylme_spage_update.zip"; + copy($RemoteFile,$ZipFile) or die("无法下载更新包文件!".'返回上级'); + $scriptpath=str_replace('\\','/',$_SERVER['SCRIPT_NAME']); + $scriptpath = substr($scriptpath, 0, strrpos($scriptpath, '/')); + $admin_path = substr($scriptpath, strrpos($scriptpath, '/')+1); + if (zipExtract($ZipFile,ROOT)) { + if($admin_path!='admin' && is_dir(ROOT.'admin')) { + //修改后台地址 + deldir(ROOT.$admin_path); + rename(ROOT.'admin',ROOT.$admin_path); + } + @header("Location: ./update.php?set=updatesql"); + } +} else if($set=='updatesql') { + $vn=explode('.',str_replace('v','',$conf['version'])); + $vernum = $vn[0].sprintf("%02d",$vn[1]).sprintf("%02d",$vn[2]); + if($vernum < 10100) { + exit(""); + } + if($vernum < 10101) { + $sql = file_get_contents(ROOT.'install/update.sql'); + $version = 'v1.1.1'; + saveSetting('version',$version); + } + if($vernum < 10103) { + @unlink(ROOT.'include/head.php'); + @unlink(ROOT.'include/home.php'); + @unlink(ROOT.'include/apply.php'); + @unlink(ROOT.'include/footer.php'); + $sql = $sql.file_get_contents(ROOT.'install/update1.sql'); + $version = 'v1.1.3'; + saveSetting('version',$version); + } else { + exit(""); + } $sql=explode(';',$sql); - $t=0; $e=0; $error=''; - for($i=0;$iquery($sql[$i])) { ++$t; } else { ++$e; - $error.=mysqli_error($con).'\n'; + $error.=$DB->error().'\n'; } } -if($e!=0) { -exit(''); -} -else{ -echo ""; -} + echo(''); } +include './footer.php'; ?> \ No newline at end of file