Skip to content

Commit

Permalink
Release v2.0.3 🎄 Merry Christmas 🎄
Browse files Browse the repository at this point in the history
Merge pull request #112 from AntSwordProject/v2.0.x
  • Loading branch information
Medicean authored Dec 25, 2018
2 parents a94c3c4 + cfa61fa commit 4539abc
Show file tree
Hide file tree
Showing 18 changed files with 276 additions and 37 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
> 有空会补补BUG、添添新功能。
> 同时也欢迎大家的参与!感谢各位朋友的支持! .TAT.
## 2018/12/25 `(v2.0.3)`

### 模块增强

#### Shell 管理

* 添加 Shell 时 URL 默认前缀 `http://`
* 添加 Shell 时根据文件后缀选择 Shell 类型并赋予默认编码(asp 默认 GBK, 其它默认 UTF8) #109
* 其它配置新增 `Multipart 发包` 功能

#### 后端模块

* 数据存储新增插件配置存储管理功能 (`shell-addPluginDataConf`, `shell-editPluginDataConf`, `shell-delPluginDataConf`, `shell-getPluginDataConf`)
* 后台发包方式支持 `Multipart`, 可在「编辑Shell配置」-「其它配置」里选择是否开启此功能,默认关闭。(thx @phith0n)

### Bug Fix

* 修复数据库编码无法保存的 Bug (#110 thx @Twi1ight)
* 修复 PHP Mysql(i) 数据管理模版代码中编码设置部分的错误 (#110 thx @Twi1ight)

### Other

* 自动检查更新每24小时触发一次(GitHub 访问频率限制)
* 插件市场默认窗口大小调整
* Loading 界面增加了圣诞节彩蛋, 偶尔跟风过个节 🎄 Merry Christmas 🎄

## 2018/12/05 `(v2.0.2)`

### 模块增强
Expand Down
120 changes: 119 additions & 1 deletion modules/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ class Database {
.on('shell-delDataConf', this.delDataConf.bind(this))
.on('shell-getDataConf', this.getDataConf.bind(this))
.on('shell-renameCategory', this.renameShellCategory.bind(this))
.on('shell-updateHttpConf', this.updateHttpConf.bind(this));
.on('shell-updateHttpConf', this.updateHttpConf.bind(this))
.on('shell-addPluginDataConf', this.addPluginDataConf.bind(this))
.on('shell-editPluginDataConf', this.editPluginDataConf.bind(this))
.on('shell-delPluginDataConf', this.delPluginDataConf.bind(this))
.on('shell-getPluginDataConf', this.getPluginDataConf.bind(this));
}

/**
Expand Down Expand Up @@ -389,6 +393,120 @@ class Database {
event.returnValue = err || confs[opts['id']];
});
}

/**
* 添加插件数据配置
* @param {Object} event ipcMain对象
* @param {string} plugin 插件注册的名称
* @param {Object} opts 配置(_id,data
*/
addPluginDataConf(event, plugin, opts) {
logger.info('addPluginDataConf', plugin, opts);
// 1. 获取原配置列表
this.cursor.findOne({
_id: opts['_id']
}, (err, ret) => {
ret['plugins'] = ret['plugins'] || {};
let confs = ret['plugins'][plugin] || {};
// 随机Id(顺序增长
const random_id = parseInt(+new Date + Math.random() * 1000).toString(16);
// 添加到配置
confs[random_id] = opts['data'];
let setdata = {
utime: +new Date,
}
setdata[`plugins.${plugin}`] = confs;

// 更新
this.cursor.update({
_id: opts['_id']
}, {
$set: setdata
}, (_err, _ret) => {
event.returnValue = random_id;
});
});
}
/**
* 修改插件数据配置
* @param {Object} event ipcMain对象
* @param {string} plugin 插件注册的名称
* @param {Object} opts 配置(_id,id,data
*/
editPluginDataConf(event, plugin, opts) {
logger.info('editPluginDataConf', plugin, opts);
// 1. 获取原配置列表
this.cursor.findOne({
_id: opts['_id']
}, (err, ret) => {
ret['plugins'] = ret['plugins'] || {};
let confs = ret['plugins'][plugin] || {};
// 添加到配置
confs[opts['id']] = opts['data'];
let setdata = {
utime: +new Date,
}
setdata[`plugins.${plugin}`] = confs;
// 更新数据库
this.cursor.update({
_id: opts['_id']
}, {
$set: setdata
}, (_err, _ret) => {
event.returnValue = opts['id'];
});
});
}

/**
* 删除插件数据配置
* @param {Object} event ipcMain对象
* @param {string} plugin 插件注册的名称
* @param {Object} opts 配置(_id,id
* @return {[type]} [description]
*/
delPluginDataConf(event, plugin, opts) {
logger.info('delPluginDataConf', plugin, opts);
// 1. 获取原配置
this.cursor.findOne({
_id: opts['_id']
}, (err, ret) => {
ret['plugins'] = ret['plugins'] || {};
let confs = ret['plugins'][plugin] || {};
// 2. 删除配置
delete confs[opts['id']];
let setdata = {
utime: +new Date,
}
setdata[`plugins.${plugin}`] = confs;
// 3. 更新数据库
this.cursor.update({
_id: opts['_id']
}, {
$set: setdata
}, (_err, _ret) => {
event.returnValue = _err || _ret;
});
})
}

/**
* 获取单个插件数据配置
* @param {Object} event ipcMain对象
* @param {string} plugin 插件注册的名称
* @param {Object} opts 配置(_id,id
* @return {[type]} [description]
*/
getPluginDataConf(event, plugin, opts) {
logger.info('getPluginDatConf', plugin, opts);
this.cursor.findOne({
_id: opts['_id']
}, (err, ret) => {
ret['plugins'] = ret['plugins'] || {};
const confs = ret['plugins'][plugin] || {};
event.returnValue = err || confs[opts['id']];
});
}
}

module.exports = Database;
18 changes: 16 additions & 2 deletions modules/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Request {
if(opts['url'].match(CONF.urlblacklist)) {
return event.sender.send('request-error-' + opts['hash'], "Blacklist URL");
}
const _request = superagent.post(opts['url']);
let _request = superagent.post(opts['url']);
// 设置headers
_request.set('User-Agent', USER_AGENT);
// 自定义headers
Expand All @@ -108,6 +108,13 @@ class Request {
}
// 自定义body
const _postData = Object.assign({}, opts.body, opts.data);
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
const old_send = _request.send;
if(opts['useMultipart'] == 1) {
_request.send = _request.field;
}else{
_request.send = old_send;
}
_request
.proxy(APROXY_CONF['uri'])
.type('form')
Expand Down Expand Up @@ -158,7 +165,7 @@ class Request {
let indexEnd = -1;
let tempData = [];

const _request = superagent.post(opts['url']);
let _request = superagent.post(opts['url']);
// 设置headers
_request.set('User-Agent', USER_AGENT);
// 自定义headers
Expand All @@ -167,6 +174,13 @@ class Request {
}
// 自定义body
const _postData = Object.assign({}, opts.body, opts.data);
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
const old_send = _request.send;
if(opts['useMultipart'] == 1) {
_request.send = _request.field;
}else{
_request.send = old_send;
}
_request
.proxy(APROXY_CONF['uri'])
.type('form')
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "antsword",
"version": "2.0.2",
"version": "2.0.3",
"description": "中国蚁剑是一款跨平台的开源网站管理工具",
"main": "app.js",
"dependencies": {
Expand Down
14 changes: 9 additions & 5 deletions source/app.entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,12 @@ antSword.reloadPlug();
antSword['menubar'].reg('check-update', ()=>{
antSword.ipcRenderer.send('check-update');
});
// 检查更新
setTimeout(
antSword.ipcRenderer.send.bind(antSword.ipcRenderer, 'check-update'),
1000 * 60
);

if(new Date() - new Date(antSword['storage']('lastautocheck', false, "0")) >= 86400000) {
// 检查更新
antSword['storage']('lastautocheck', new Date().getTime());
setTimeout(
antSword.ipcRenderer.send.bind(antSword.ipcRenderer, 'check-update'),
1000 * 60
);
}
3 changes: 3 additions & 0 deletions source/core/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class Base {
tag_e: opt['tag_e'],
encode: this.__opts__['encode'],
ignoreHTTPS: (this.__opts__['otherConf'] || {})['ignore-https'] === 1,
useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1,
timeout: parseInt((this.__opts__['otherConf'] || {})['request-timeout']),
headers: (this.__opts__['httpConf'] || {})['headers'] || {},
body: (this.__opts__['httpConf'] || {})['body'] || {}
Expand Down Expand Up @@ -285,6 +286,8 @@ class Base {
data: opt['data'],
tag_s: opt['tag_s'],
tag_e: opt['tag_e'],
ignoreHTTPS: (this.__opts__['otherConf'] || {})['ignore-https'] === 1,
useMultipart: (this.__opts__['otherConf'] || {})['use-multipart'] === 1,
encode: this.__opts__['encode']
});
})
Expand Down
2 changes: 1 addition & 1 deletion source/core/php/template/database/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
// 执行SQL语句
query: {
_:
`$m=get_magic_quotes_gpc();$hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"];$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];$sql=base64_decode($_POST["${arg5}"]);$T=@mysql_connect($hst,$usr,$pwd);@mysql_query("SET NAMES ${arg6}");@mysql_select_db($dbn, $T);$q=@mysql_query($sql);if(is_bool($q)){echo("Status\t|\t\r\n".($q?"VHJ1ZQ==":"RmFsc2U=")."\t|\t\r\n");}else{$i=0;while($col=@mysql_fetch_field($q)){echo($col->name."\t|\t");$i++;}echo("\r\n");while($rs=@mysql_fetch_row($q)){for($c=0;$c<$i;$c++){echo(base64_encode(trim($rs[$c])));echo("\t|\t");}echo("\r\n");}}@mysql_close($T);`,
`$m=get_magic_quotes_gpc();$hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"];$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];$sql=base64_decode($_POST["${arg5}"]);$T=@mysql_connect($hst,$usr,$pwd);@mysql_query("SET NAMES $_POST[${arg6}]");@mysql_select_db($dbn, $T);$q=@mysql_query($sql);if(is_bool($q)){echo("Status\t|\t\r\n".($q?"VHJ1ZQ==":"RmFsc2U=")."\t|\t\r\n");}else{$i=0;while($col=@mysql_fetch_field($q)){echo($col->name."\t|\t");$i++;}echo("\r\n");while($rs=@mysql_fetch_row($q)){for($c=0;$c<$i;$c++){echo(base64_encode(trim($rs[$c])));echo("\t|\t");}echo("\r\n");}}@mysql_close($T);`,
[arg1]: '#{host}',
[arg2]: '#{user}',
[arg3]: '#{passwd}',
Expand Down
2 changes: 1 addition & 1 deletion source/core/php/template/database/mysqli.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
// 执行SQL语句
query: {
_:
`$m=get_magic_quotes_gpc();$hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"];$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];$sql=base64_decode($_POST["${arg5}"]);$T=@mysqli_connect($hst,$usr,$pwd);@mysqli_query($T,"SET NAMES ${arg6}");@mysqli_select_db($T,$dbn);$q=@mysqli_query($T,$sql);if(is_bool($q)){echo("Status\t|\t\r\n".($q?"VHJ1ZQ==":"RmFsc2U=")."\t|\t\r\n");}{$i=0;while($col=@mysqli_fetch_field($q)){echo($col->name."\t|\t");$i++;}echo("\r\n");while($rs=@mysqli_fetch_row($q)){for($c=0;$c<$i;$c++){echo(base64_encode(trim($rs[$c])));echo("\t|\t");}echo("\r\n");}}@mysqli_close($T);`,
`$m=get_magic_quotes_gpc();$hst=$m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"];$usr=$m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"];$pwd=$m?stripslashes($_POST["${arg3}"]):$_POST["${arg3}"];$dbn=$m?stripslashes($_POST["${arg4}"]):$_POST["${arg4}"];$sql=base64_decode($_POST["${arg5}"]);$T=@mysqli_connect($hst,$usr,$pwd);@mysqli_query($T,"SET NAMES $_POST[${arg6}]");@mysqli_select_db($T,$dbn);$q=@mysqli_query($T,$sql);if(is_bool($q)){echo("Status\t|\t\r\n".($q?"VHJ1ZQ==":"RmFsc2U=")."\t|\t\r\n");}{$i=0;while($col=@mysqli_fetch_field($q)){echo($col->name."\t|\t");$i++;}echo("\r\n");while($rs=@mysqli_fetch_row($q)){for($c=0;$c<$i;$c++){echo(base64_encode(trim($rs[$c])));echo("\t|\t");}echo("\r\n");}}@mysqli_close($T);`,
[arg1]: '#{host}',
[arg2]: '#{user}',
[arg3]: '#{passwd}',
Expand Down
1 change: 1 addition & 0 deletions source/language/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ module.exports = {
},
otherConf: {
nohttps: 'Ignore HTTPS certificate',
usemultipart: 'Use Multipart send payload',
terminalCache: "Use the terminal's cache",
filemanagerCache: "Use the filemanager's cache",
uploadFragment: "Upload File Fragmentation Size",
Expand Down
1 change: 1 addition & 0 deletions source/language/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ module.exports = {
},
otherConf: {
nohttps: '忽略HTTPS证书',
usemultipart: '使用 Multipart 发包',
terminalCache: '虚拟终端使用缓存',
filemanagerCache: '文件管理使用缓存',
uploadFragment: '上传文件分片大小',
Expand Down
11 changes: 11 additions & 0 deletions source/load.entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ window.addEventListener('load', () => {
});
}

/**
* 加载界面 UI 修改
*/
function loadingUI() {
let now = new Date();
/** 加载圣诞节 loading 效果 */
if(now.getMonth()+1 == 12) {
document.getElementById('loading').classList.add('loading_christmas');
}
}
loadingUI();
// 开始加载css
loadCSS('ant-static://libs/bmenu/bmenu.css')
.then(() => loadCSS('ant-static://libs/toastr/toastr.min.css'))
Expand Down
49 changes: 29 additions & 20 deletions source/modules/database/php/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,26 +485,35 @@ class PHP {
], true);

form.attachEvent('onChange', (_, id) => {
if (_ !== 'type') { return };
switch(id) {
case 'mysql':
case 'mysqli':
form.setFormData({
user: conf['user'],
passwd: conf['passwd']
});
break;
case 'mssql':
form.setFormData({
user: conf['user'],
passwd: conf['passwd']
});
break;
default:
form.setFormData({
user: conf['user'],
passwd: conf['passwd']
});
if (_ == 'type') {
switch(id) {
case 'mysql':
case 'mysqli':
form.setFormData({
encode: conf['encode'],
user: conf['user'],
passwd: conf['passwd']
});
break;
case 'mssql':
form.setFormData({
encode: conf['encode'],
user: conf['user'],
passwd: conf['passwd']
});
break;
default:
form.setFormData({
encode: conf['encode'],
user: conf['user'],
passwd: conf['passwd']
});
}
};
if(_ == 'encode') {
form.setFormData({
encode: id,
});
}
});

Expand Down
4 changes: 2 additions & 2 deletions source/modules/plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class Plugin {
return this.win.focus();
}
let win = new antSword['remote'].BrowserWindow({
width: 930,
width: 950,
height: 666,
minWidth: 888,
minWidth: 650,
minHeight: 555,
show: false,
title: 'AntSword.Store'
Expand Down
Loading

0 comments on commit 4539abc

Please sign in to comment.