mirror of
https://github.com/LyLme/lylme_spage.git
synced 2024-11-17 14:34:08 +08:00
优化 更新
This commit is contained in:
parent
aaf393aa68
commit
610ed8c386
@ -19,13 +19,6 @@ switch($submit) {
|
||||
$DB->query($sql);
|
||||
}
|
||||
break;
|
||||
case 'pwd_link':
|
||||
//链接加密
|
||||
foreach($_POST['links'] as $lk=> $lv) {
|
||||
$sql = "UPDATE `lylme_links` SET `link_pwd` = '".$_POST['pwd_id']."' WHERE `lylme_links`.`id` = ".$lv.";";
|
||||
$DB->query($sql);
|
||||
}
|
||||
break;
|
||||
case 'on':
|
||||
//链接启用
|
||||
foreach($_POST['links'] as $lk=> $lv) {
|
||||
@ -78,6 +71,57 @@ switch($submit) {
|
||||
header('Content-Type:application/json');
|
||||
exit('{"title": "'.$head['title'].'", "icon": "'.$head['icon'].'","charset": "'.$head['charset'].'"}');
|
||||
break;
|
||||
//检测更新
|
||||
case 'update':
|
||||
function zipExtract ($src, $dest) {
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($src)===true) {
|
||||
$zip->extractTo($dest);
|
||||
$zip->close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function deldir($dir) {
|
||||
if(!is_dir($dir))return false;
|
||||
$dh=opendir($dir);
|
||||
while ($file=readdir($dh)) {
|
||||
if($file!="." && $file!="..") {
|
||||
$fullpath=$dir."/".$file;
|
||||
if(!is_dir($fullpath)) {
|
||||
unlink($fullpath);
|
||||
} else {
|
||||
deldir($fullpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
if(rmdir($dir)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$scriptpath=str_replace('\\','/',$_SERVER['SCRIPT_NAME']);
|
||||
$scriptpath = substr($scriptpath, 0, strrpos($scriptpath, '/'));
|
||||
$admin_path = substr($scriptpath, strrpos($scriptpath, '/')+1);
|
||||
$RemoteFile = $_POST['file'];
|
||||
$ZipFile = "lylme_spage-update.zip";
|
||||
copy($RemoteFile,$ZipFile) or die("无从更新服务器下载更新包文件!");
|
||||
if (zipExtract($ZipFile,ROOT)) {
|
||||
if($admin_path!='admin' && is_dir(ROOT.'admin')) {
|
||||
//修改后台地址
|
||||
deldir(ROOT.$admin_path);
|
||||
rename(ROOT.'admin',ROOT.$admin_path);
|
||||
}
|
||||
unlink($ZipFile);
|
||||
exit ('success');
|
||||
}
|
||||
else {
|
||||
unlink($ZipFile);
|
||||
exit('无法解压文件!请手动下载更新包解压');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
exit('error');
|
||||
break;
|
||||
|
@ -163,7 +163,7 @@ if($applyrows>0) {
|
||||
<b>最新版本:</b> <?php echo $update['version']?> <a href="https://gitee.com/LyLme/lylme_spage/releases" target="_blant">查看更新说明</a>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<b>项目作者:</b>六零
|
||||
<b>项目作者:</b>六零 <a href="https://www.lylme.com/support/" target="_blant">捐赠作者</a>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<b>项目地址:</b>https://github.com/LyLme/lylme_spage
|
||||
|
118
admin/update.php
118
admin/update.php
@ -9,15 +9,11 @@ $update = update();
|
||||
<div class="container-fluid">
|
||||
<?php
|
||||
if(getver($update['version']) > getver($conf['version']) && !empty($update['version']) ) {
|
||||
echo '<script type="text/javascript">
|
||||
window.onload=function() {
|
||||
var update=document.getElementById("update");
|
||||
update.onclick=function() {if(confirm("注意:更新将会替换部分文件,是否继续?")) {window.location.href="./update.php?set=update";}
|
||||
else {return false;}}}</script> ';
|
||||
echo '<div class="alert alert-info" role="alert">当前版本:</b>'.$conf['version'].' 发现新版本:'.$update['version'].' <a href="https://gitee.com/LyLme/lylme_spage/releases" target="_blant" class="alert-link">查看发行版</a></div>
|
||||
|
||||
echo '<div class="alert alert-info" role="alert">发现新版本:'.$update['version'].' 当前版本:</b>'.$conf['version'].' <a href="https://gitee.com/LyLme/lylme_spage/releases" target="_blant" class="alert-link">查看发行版</a></div>
|
||||
<div class="card"><div class="card-header"><h4>更新说明</h4></div><ul class="list-group">
|
||||
'.$update['update_log'].'
|
||||
<li class="list-group-item"><button id="update" class="btn btn-primary">更新</button></li>';
|
||||
<li class="list-group-item"><button onclick="update()" class="btn btn-primary">更新</button></li>';
|
||||
} else if(!empty($update['version'])) {
|
||||
echo '<div class="alert alert-success" role="alert">当前已是最新版本! <a href="https://gitee.com/LyLme/lylme_spage/releases" target="_blant" class="alert-link">查看发行版</a></div>
|
||||
<div class="card"><div class="card-header"><h4>版本更新</h4></div><ul class="list-group">
|
||||
@ -27,68 +23,62 @@ window.onload=function() {
|
||||
echo '<div class="alert alert-danger" role="alert">检查更新失败!</div>
|
||||
<div class="card"><div class="card-header"><h4>版本更新</h4></div><ul class="list-group">
|
||||
<li class="list-group-item"><b>当前版本:</b>'.$conf['version'].'</li>
|
||||
<li class="list-group-item"><b>最新版本:</b>Unknown</li>
|
||||
<li class="list-group-item"><b>手动更新:</b>点击<a href="'.$update['file'].'" target="_blant">这里</a>或前往码云<a href="https://gitee.com/LyLme/lylme_spage/releases" target="_blant" class="alert-link">下载<code>update.zip</code>后缀的更新包</a>解压到网站根目即可</a></li>';
|
||||
<li class="list-group-item"><b>手动更新:</b>请前往<a href="https://gitee.com/LyLme/lylme_spage/releases" target="_blant" class="alert-link">码云</a>下载最新版本<code>lylme_spage_update.zip</code>后缀的更新包上传到网站根目录解压即可,程序会自动更新数据库</a></li>';
|
||||
}
|
||||
?>
|
||||
</ul></div>
|
||||
</div>
|
||||
</main>
|
||||
<!--End 页面主要内容-->
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$set=isset($_GET['set'])?$_GET['set']:null;
|
||||
if($set=='update') {
|
||||
function zipExtract ($src, $dest) {
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($src)===true) {
|
||||
$zip->extractTo($dest);
|
||||
$zip->close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function deldir($dir) {
|
||||
if(!is_dir($dir))return false;
|
||||
$dh=opendir($dir);
|
||||
while ($file=readdir($dh)) {
|
||||
if($file!="." && $file!="..") {
|
||||
$fullpath=$dir."/".$file;
|
||||
if(!is_dir($fullpath)) {
|
||||
unlink($fullpath);
|
||||
} else {
|
||||
deldir($fullpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
if(rmdir($dir)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$scriptpath=str_replace('\\','/',$_SERVER['SCRIPT_NAME']);
|
||||
$scriptpath = substr($scriptpath, 0, strrpos($scriptpath, '/'));
|
||||
$admin_path = substr($scriptpath, strrpos($scriptpath, '/')+1);
|
||||
$RemoteFile = $update['file'];
|
||||
$ZipFile = "lylme_spage_update.zip";
|
||||
copy($RemoteFile,$ZipFile) or die("无法下载更新包文件!".'<a href="update.php">返回上级</a>');
|
||||
if (zipExtract($ZipFile,ROOT)) {
|
||||
if($admin_path!='admin' && is_dir(ROOT.'admin')) {
|
||||
//修改后台地址
|
||||
deldir(ROOT.$admin_path);
|
||||
rename(ROOT.'admin',ROOT.$admin_path);
|
||||
}
|
||||
if(function_exists("opcache_reset"))@opcache_reset();
|
||||
$upsql=true;
|
||||
unlink($ZipFile);
|
||||
} else {
|
||||
unlink($ZipFile);
|
||||
echo('<script language="javascript">alert("无法解压文件!请手动下载更新包解压");window.location.href="./update.php";</script>');
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
include './footer.php';
|
||||
?>
|
||||
?>
|
||||
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/layer/3.1.1/layer.min.js" type="application/javascript"></script>
|
||||
<script type="text/javascript" src="js/lightyear.js"></script>
|
||||
<script src="js/bootstrap-notify.min.js"></script>
|
||||
<link href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery-confirm/3.3.0/jquery-confirm.min.css" type="text/css" rel="stylesheet" />
|
||||
<script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery-confirm/3.3.0/jquery-confirm.min.js" type="application/javascript"></script>
|
||||
<script>
|
||||
function update() {
|
||||
$.confirm({
|
||||
title: '更新',
|
||||
content: '<p><b>注意:更新会替换大部分文件(不会删除原有文件)</b></p><p>若您修改了源码的内容,为防止丢失请先进行备份</p><p>另外:不建议通过修改源码的方式来修改内容,本程序预留了自定义JS的功能,建议通过JS的方式来修改内容,欢迎加群讨论获取',
|
||||
type: 'orange',
|
||||
buttons: {
|
||||
omg: {
|
||||
text: '更新',
|
||||
btnClass: 'btn-orange',
|
||||
action: function(){
|
||||
lightyear.loading('show');
|
||||
$.ajax({
|
||||
url:"ajax_link.php?submit=update",
|
||||
method:"POST",
|
||||
data:{file:"<?php echo $update['file'] ?>"},
|
||||
success:function(data){
|
||||
if(data == 'success'){
|
||||
lightyear.loading('hide');
|
||||
lightyear.notify('更新成功!', 'success', 1000);
|
||||
window.location.replace("./");
|
||||
return true;
|
||||
}else{
|
||||
lightyear.loading('hide');
|
||||
lightyear.notify(data, 'warning', 2000);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
error:function(data){
|
||||
layer.msg('服务器错误');
|
||||
lightyear.loading('hide');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
close: {
|
||||
text: '取消',
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user