Skip to content

Commit

Permalink
优化主题升级功能
Browse files Browse the repository at this point in the history
  • Loading branch information
amujie committed Jul 1, 2020
1 parent a89e0ad commit d59dbcc
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 63 deletions.
3 changes: 3 additions & 0 deletions about/changelog.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"1.0.7": [
"优化主题升级功能"
],
"1.0.7": [
"使用1.0.6之前版本的请先恢复默认设置再使用",
"修复防红页面点击浏览器图标跳转支付宝的问题",
Expand Down
87 changes: 36 additions & 51 deletions asset/exc/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@
moJiaCollect();
} elseif (@$_GET['id'] == 'url') {
moJiaCommon();
} elseif (@$_GET['id'] == 'upd') {
moJiaUpdate();
}

// 主题设置
function moJiaOptions() {
if (isset($_POST['key'])) {
if (!moJiaPower('mojia', moJiaPath('base'))) {
die(json_encode(array('msg' => '权限不足')));
} elseif (isset($_POST['ver'])) {
if (@$_POST['ver'] == 'now') {
$version = parse_ini_file('../../info.ini');
echo json_encode(array('ver' => $version['version']));
} elseif (@$_POST['ver'] == 'new') {
$versnew = moJiaCurlGet(moJiaPath('vers'));
preg_match_all('/<option\s+value="amujie\/mojia@(.*)">/i', $versnew, $match);
echo json_encode(array('ver' => $match[1][0], 'key' => md5('mojia-' . $match[1][0])));
} elseif (@$_POST['ver'] == 'log') {
echo moJiaCurlGet(str_replace('latest',$_POST['new'],moJiaPath('vers')).'about/changelog.json');
}
} elseif (isset($_POST['key'])) {
if (file_put_contents(moJiaPath('path') . 'application/extra/mojiakey.php', '<?php return ' . var_export($_POST, true) . ';?>')) {
file_put_contents(moJiaPath('path') . 'runtime/temp/' . md5('mojia') . '.php', '<?php return ' . var_export(time(), true) . ';?>');
$path = moJiaPath('path') . 'application/data/config/quickmenu.txt';
Expand All @@ -29,10 +40,8 @@ function moJiaOptions() {
} else {
die(json_encode(array('msg' => '授权失败,请联系QQ1278242793')));
}
} elseif (isset($_POST['type'])) {
if (!moJiaPower('mojia', moJiaPath('base'))) {
die(json_encode(array('msg' => '权限不足')));
} elseif (file_exists(moJiaPath('path') . 'application/extra/mojiaopt.php')) {
} elseif (isset($_POST['def'])) {
if (file_exists(moJiaPath('path') . 'application/extra/mojiaopt.php')) {
if (@unlink(moJiaPath('path') . 'application/extra/mojiaopt.php')) {
$html = file_get_contents('../../html/basics/seokey.html');
$seokey = @require ('config.php');
Expand All @@ -56,29 +65,23 @@ function moJiaOptions() {
$option['weixin']['gjc1'] = @$_POST['send'];
$option['weixin']['gjcm1'] = @$_POST['code'];
$option['site']['site_status'] = @$_POST['close'];
if (!moJiaPower('mojia', moJiaPath('base'))) {
die(json_encode(array('msg' => '权限不足')));
} elseif (file_put_contents(moJiaPath('path') . 'application/extra/maccms.php', '<?php return ' . var_export($option, true) . ';?>')) {
if (file_put_contents(moJiaPath('path') . 'application/extra/maccms.php', '<?php return ' . var_export($option, true) . ';?>')) {
die(json_encode(array('msg' => '修改成功')));
} else {
die(json_encode(array('msg' => '执行失败')));
}
} elseif (isset($_POST['tpl'])) {
$option = @require (moJiaPath('path') . 'application/extra/maccms.php');
$option['site']['template_dir'] = @$_POST['tpl'];
if (!moJiaPower('mojia', moJiaPath('base'))) {
die(json_encode(array('msg' => '权限不足')));
} elseif (file_put_contents(moJiaPath('path') . 'application/extra/maccms.php', '<?php return ' . var_export($option, true) . ';?>')) {
if (file_put_contents(moJiaPath('path') . 'application/extra/maccms.php', '<?php return ' . var_export($option, true) . ';?>')) {
@unlink('../../../' . $_POST['tpl'] . '.zip');
$option = @require (moJiaPath('path') . 'application/extra/maccms.php');
die(json_encode(array('msg' => $option['site']['template_dir'])));
} else {
die(json_encode(array('msg' => '执行失败')));
}
} elseif (isset($_POST['mojia'])) {
if (!moJiaPower('mojia', moJiaPath('base'))) {
die(json_encode(array('msg' => '权限不足')));
} elseif (file_put_contents(moJiaPath('path') . 'application/extra/mojiaopt.php', '<?php return ' . var_export($_POST['mojia'], true) . ';?>')) {
if (file_put_contents(moJiaPath('path') . 'application/extra/mojiaopt.php', '<?php return ' . var_export($_POST['mojia'], true) . ';?>')) {
$html = file_get_contents('../../html/basics/seokey.html');
$seokey = $_POST['mojia']['seo'];
foreach ($seokey as $value => $key) {
Expand All @@ -93,6 +96,21 @@ function moJiaOptions() {
} else {
die(json_encode(array('msg' => '保存失败')));
}
} elseif (isset($_POST['news'])) {
$path = '../../../';
$name = 'mojia-' . $_POST['news'] . '.zip';
$href = moJiaPath('down') . $name . '?v=' . time();
if (!moJiaIsExists($href)) {
die(json_encode(array('code' => '0', 'msg' => '未找到到最新版主题文件')));
}
if (!moJiaDownload($href, $path, $name)) {
die(json_encode(array('code' => '0', 'msg' => '主题下载失败')));
}
if (moJiaUnzip($path, $name, @$_POST['pass'])) {
die(json_encode(array('code' => '1', 'msg' => '主题升级成功')));
} else {
die(json_encode(array('code' => '0', 'msg' => '主题解压失败')));
}
} else {
die(json_encode(array('msg' => '执行失败')));
}
Expand Down Expand Up @@ -197,18 +215,7 @@ function moJiaCollect() {

// 短链生成
function moJiaCommon() {
if (isset($_POST['ver'])) {
if (@$_POST['ver'] == 'now') {
$version = parse_ini_file('../../info.ini');
echo json_encode(array('ver' => $version['version']));
} elseif (@$_POST['ver'] == 'new') {
$versnew = moJiaCurlGet($_POST['cdn']);
preg_match_all('/version=([\w\W]*?)adsdir/i', preg_replace('/\s+/', '', $versnew), $match);
echo json_encode(array('ver' => $match[1][0], 'key' => md5('mojia-' . $match[1][0])));
} elseif (@$_POST['ver'] == 'log') {
echo moJiaCurlGet($_POST['new']);
}
} elseif (isset($_POST['tao'])) {
if (isset($_POST['tao'])) {
$mojia = moJiaPath('mojia');
$taoke = moJiaDaTaoKe('https://openapi.dataoke.com/api/goods/get-goods-list', array('pageSize' => '50', 'cids' => $mojia['home']['taoke']['type'], 'juHuaSuan' => $mojia['home']['taoke']['qiang'] == 1 ? 1 : '', 'taoQiangGou' => $mojia['home']['taoke']['qiang'] == 2 ? 1 : '', 'tmall' => $mojia['home']['taoke']['qiang'] == 3 ? 1 : '', 'tchaoshi' => $mojia['home']['taoke']['qiang'] == 4 ? 1 : '', 'goldSeller' => $mojia['home']['taoke']['qiang'] == 5 ? 1 : '', 'haitao' => $mojia['home']['taoke']['qiang'] == 6 ? 1 : '', 'specialId' => $mojia['home']['taoke']['brand'], 'sort' => $mojia['home']['taoke']['sort'], 'version' => $mojia['home']['taoke']['ver'], 'appKey' => $mojia['other']['taoke']['key']), $mojia['other']['taoke']['secret']);
if (file_put_contents(moJiaPath('path') . 'application/extra/mojiatao.php', '<?php return ' . var_export(array_slice($taoke['data']['list'], 0, $mojia['home']['taoke']['num']), true) . ';?>')) {
Expand Down Expand Up @@ -245,26 +252,4 @@ function moJiaCommon() {
echo $output;
exit ;
}
}

// 主题更新
function moJiaUpdate() {
if (!moJiaPower('mojia', moJiaPath('base'))) {
die(json_encode(array('msg' => '权限不足')));
} elseif (isset($_POST['ver'])) {
$path = '../../../';
$name = 'mojia-' . $_POST['ver'] . '.zip';
$href = moJiaPath('down') . $name . '?v=' . time();
if (!moJiaIsExists($href)) {
die(json_encode(array('code' => '0', 'msg' => '未找到到最新版主题文件')));
}
if (!moJiaDownload($href, $path, $name)) {
die(json_encode(array('code' => '0', 'msg' => '主题下载失败')));
}
if (moJiaUnzip($path, $name, @$_POST['key'])) {
die(json_encode(array('code' => '1', 'msg' => '主题升级成功')));
} else {
die(json_encode(array('code' => '0', 'msg' => '主题解压失败')));
}
}
}
}
4 changes: 3 additions & 1 deletion asset/exc/obtain.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function moJiaPath($path) {
} elseif ($path == 'home') {
return $maccms['site']['install_dir'];
} elseif ($path == 'down') {
return 'https://cdn.jsdelivr.net/gh/amujie/download@master/';
return 'https://cdn.jsdelivr.net/gh/amujie/download@latest/';
} elseif ($path == 'vers') {
return 'https://cdn.jsdelivr.net/gh/amujie/mojia@latest/';
} elseif ($path == 'path') {
return $install;
}
Expand Down
14 changes: 4 additions & 10 deletions asset/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ layui.define(['mojia', 'iconfonts', 'multiple'], function(exports) {
layer.confirm('确定恢复默认设置吗', {
title: '提示'
}, function() {
$.post($('.layui-form-pane').attr('action'), 'type=renews', function(data) {
$.post($('.layui-form-pane').attr('action'), 'def=renews', function(data) {
layer.msg(data.msg, {
time: 500
}, function() {
Expand Down Expand Up @@ -118,10 +118,6 @@ layui.define(['mojia', 'iconfonts', 'multiple'], function(exports) {
$('select[name="mojia[nav][font][artid]"]').next().addClass($('select[name="mojia[nav][font][artid]"]').attr('class'));
});
},
'latest': function(index) {
var href = ['@master', '', '@latest'];
return 'https://cdn.jsdelivr.net/gh/amujie/mojia' + href[index] + '/info.ini';
},
'contra': function(index, nows, news) {
var news = news.split('.');
var nows = nows.split('.');
Expand All @@ -133,7 +129,7 @@ layui.define(['mojia', 'iconfonts', 'multiple'], function(exports) {
return version != 0 ? version : (news.length - nows.length);
},
'record': function(newmojia, password) {
$.post(magic.tpl + 'asset/exc/create.php?id=url', 'ver=log&new=' + encodeURIComponent('https://cdn.jsdelivr.net/gh/amujie/mojia@' + newmojia + '/about/changelog.json'), function(data) {
$.post(magic.tpl + 'asset/exc/create.php?id=opt', 'ver=log&new=' + newmojia, function(data) {
var output = '<table class="layui-table mo-logs-form"><tbody>';
for (var i = 0; i < data[newmojia].length; i++) output += '<tr><td width="20" align="center" class="mo-logs-nums">' + (i + 1) + '</td><td class="mo-logs-item">' + data[newmojia][i] + '</td></tr>';
output += '</tbody></table>';
Expand All @@ -156,18 +152,16 @@ layui.define(['mojia', 'iconfonts', 'multiple'], function(exports) {
},
'update': function(count) {
$('.layui-body', parent.document).css('overflow-y', 'hidden');
$.post(magic.tpl + 'asset/exc/create.php?id=url', 'ver=new&cdn=' + encodeURIComponent(mojia.global.latest(count)), function(data) {
$.post(magic.tpl + 'asset/exc/create.php?id=opt', 'ver=new', function(data) {
if (mojia.global.contra(0, $('.mo-opts-vers').text(), data.ver) > 0) {
$('.mo-opts-news').html('最新版:' + data.ver + '<a href="javascript:;" class="mo-opts-btns mo-pnxs-10px" style="color:red">立即更新</a>').css('color', 'red');
mojia.global.record(data.ver, data.key);
} else if (count < 2) {
mojia.global.update(count + 1);
}
});
},
'change': function(news, pass) {
var index = layer.load(2);
$.post(magic.tpl + 'asset/exc/create.php?id=upd', 'ver=' + news + '&key=' + pass, function(data) {
$.post(magic.tpl + 'asset/exc/create.php?id=opt', 'news=' + news + '&pass=' + pass, function(data) {
layer.close(index);
if (data.code == 1) mojia.global.withfl(news);
else layer.msg(data.msg);
Expand Down
2 changes: 1 addition & 1 deletion info.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ qqcode = 1570457334
qqgroup = 137183109
addgroup= 51Zakp5
lastdate= 2020-06-30
version = 1.0.7
version = 1.0.5
adsdir = about

0 comments on commit d59dbcc

Please sign in to comment.