Commit eec4a82d authored by Medicean's avatar Medicean

fix Buffer deprecated warning.

parent 736ec1a7
...@@ -130,7 +130,7 @@ class Request { ...@@ -130,7 +130,7 @@ class Request {
this.parse(opts['tag_s'], opts['tag_e'], (chunk) => { this.parse(opts['tag_s'], opts['tag_e'], (chunk) => {
event.sender.send('request-chunk-' + opts['hash'], chunk); event.sender.send('request-chunk-' + opts['hash'], chunk);
}, res, (err, ret)=>{ }, res, (err, ret)=>{
let buff = ret ? ret : new Buffer(); let buff = ret ? ret : Buffer.from();
// 自动猜测编码 // 自动猜测编码
let encoding = detectEncoding(buff, {defaultEncoding: "unknown"}); let encoding = detectEncoding(buff, {defaultEncoding: "unknown"});
logger.debug("detect encoding:", encoding); logger.debug("detect encoding:", encoding);
...@@ -180,7 +180,7 @@ class Request { ...@@ -180,7 +180,7 @@ class Request {
// 请求失败 TIMEOUT // 请求失败 TIMEOUT
return event.sender.send('request-error-' + opts['hash'], err); return event.sender.send('request-error-' + opts['hash'], err);
} }
let buff = ret.hasOwnProperty('body') ? ret.body : new Buffer(); let buff = ret.hasOwnProperty('body') ? ret.body : Buffer.from();
// 解码 // 解码
let text = ""; let text = "";
// 自动猜测编码 // 自动猜测编码
...@@ -257,7 +257,7 @@ class Request { ...@@ -257,7 +257,7 @@ class Request {
indexStart = tempDataBuffer.indexOf(opts['tag_s']) || 0; indexStart = tempDataBuffer.indexOf(opts['tag_s']) || 0;
// 截取最后的数据 // 截取最后的数据
let finalData = new Buffer(tempDataBuffer.slice( let finalData = Buffer.from(tempDataBuffer.slice(
indexStart + opts['tag_s'].length, indexStart + opts['tag_s'].length,
indexEnd indexEnd
), 'binary'); ), 'binary');
...@@ -301,7 +301,7 @@ class Request { ...@@ -301,7 +301,7 @@ class Request {
indexStart = tempDataBuffer.indexOf(opts['tag_s']) || 0; indexStart = tempDataBuffer.indexOf(opts['tag_s']) || 0;
// 截取最后的数据 // 截取最后的数据
let finalData = new Buffer(tempDataBuffer.slice( let finalData = Buffer.from(tempDataBuffer.slice(
indexStart + opts['tag_s'].length, indexStart + opts['tag_s'].length,
indexEnd indexEnd
), 'binary'); ), 'binary');
...@@ -330,8 +330,8 @@ class Request { ...@@ -330,8 +330,8 @@ class Request {
res.setEncoding('binary'); res.setEncoding('binary');
res.data = ''; res.data = '';
// 2. 把分隔符转换为16进制 // 2. 把分隔符转换为16进制
const tagHexS = new Buffer(tag_s).toString('hex'); const tagHexS = Buffer.from(tag_s).toString('hex');
const tagHexE = new Buffer(tag_e).toString('hex'); const tagHexE = Buffer.from(tag_e).toString('hex');
let foundTagS = false; let foundTagS = false;
let foundTagE = false; let foundTagE = false;
...@@ -339,7 +339,7 @@ class Request { ...@@ -339,7 +339,7 @@ class Request {
// 这样吧,我们尝试一种新的数据截取算法: // 这样吧,我们尝试一种新的数据截取算法:
// 1. 把数据流转换为16进制 // 1. 把数据流转换为16进制
let chunkHex = new Buffer(chunk).toString('hex'); let chunkHex = Buffer.from(chunk).toString('hex');
// 3. 根据分隔符进行判断截断数据流 // 3. 根据分隔符进行判断截断数据流
let temp = ''; let temp = '';
// 如果包含前后截断,则截取中间 // 如果包含前后截断,则截取中间
...@@ -364,7 +364,7 @@ class Request { ...@@ -364,7 +364,7 @@ class Request {
temp = chunkHex; temp = chunkHex;
} }
// 4. 十六进制还原为二进制 // 4. 十六进制还原为二进制
let finalData = new Buffer(temp, 'hex'); let finalData = Buffer.from(temp, 'hex');
// 5. 返回还原好的数据 // 5. 返回还原好的数据
chunkCallBack(finalData); chunkCallBack(finalData);
...@@ -372,7 +372,7 @@ class Request { ...@@ -372,7 +372,7 @@ class Request {
}); });
res.on('end', () => { res.on('end', () => {
logger.info(`end.size=${res.data.length}`, res.data); logger.info(`end.size=${res.data.length}`, res.data);
callback(null, new Buffer(res.data, 'binary')); callback(null, Buffer.from(res.data, 'binary'));
}); });
} }
...@@ -440,7 +440,7 @@ class AntRead extends Readable { ...@@ -440,7 +440,7 @@ class AntRead extends Readable {
if('string' === typeof data) { if('string' === typeof data) {
chunk = data; chunk = data;
}else if('object' === typeof data && Buffer.isBuffer(data)) { // buffer }else if('object' === typeof data && Buffer.isBuffer(data)) { // buffer
chunk = new Buffer(data).toString(); chunk = Buffer.from(data).toString();
}else{ }else{
throw Error("data must be string, buffer."); throw Error("data must be string, buffer.");
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
module.exports = (pwd, data) => { module.exports = (pwd, data) => {
let randomID = `_0x${Math.random().toString(16).substr(2)}`; let randomID = `_0x${Math.random().toString(16).substr(2)}`;
data[randomID] = new Buffer(data['_']).toString('base64'); data[randomID] = Buffer.from(data['_']).toString('base64');
data[pwd] = `eval(System.Text.Encoding.GetEncoding(936).GetString(System.Convert.FromBase64String(Request.Item["${randomID}"])),"unsafe");`; data[pwd] = `eval(System.Text.Encoding.GetEncoding(936).GetString(System.Convert.FromBase64String(Request.Item["${randomID}"])),"unsafe");`;
delete data['_']; delete data['_'];
return data; return data;
......
...@@ -10,7 +10,7 @@ module.exports = (pwd, data) => { ...@@ -10,7 +10,7 @@ module.exports = (pwd, data) => {
let randomID = `_0x${Math.random().toString(16).substr(2)}`; let randomID = `_0x${Math.random().toString(16).substr(2)}`;
let hexencoder = "function HexAsciiConvert(hex:String) {var sb:System.Text.StringBuilder = new System.Text.StringBuilder();var i;for(i=0; i< hex.Length; i+=2){sb.Append(System.Convert.ToString(System.Convert.ToChar(Int32.Parse(hex.Substring(i,2), System.Globalization.NumberStyles.HexNumber))));}return sb.ToString();};"; let hexencoder = "function HexAsciiConvert(hex:String) {var sb:System.Text.StringBuilder = new System.Text.StringBuilder();var i;for(i=0; i< hex.Length; i+=2){sb.Append(System.Convert.ToString(System.Convert.ToChar(Int32.Parse(hex.Substring(i,2), System.Globalization.NumberStyles.HexNumber))));}return sb.ToString();};";
data[randomID] = new Buffer(data['_']).toString('hex'); data[randomID] = Buffer.from(data['_']).toString('hex');
data[pwd] = `${hexencoder};eval(HexAsciiConvert(Request.Item["${randomID}"]),"unsafe");`; data[pwd] = `${hexencoder};eval(HexAsciiConvert(Request.Item["${randomID}"]),"unsafe");`;
delete data['_']; delete data['_'];
return data; return data;
......
...@@ -85,8 +85,8 @@ class Base { ...@@ -85,8 +85,8 @@ class Base {
* @return {String} 编码后的字符串 * @return {String} 编码后的字符串
*/ */
base64(str) { base64(str) {
return new Buffer( return Buffer.from(
iconv.encode(new Buffer(str), encode) iconv.encode(Buffer.from(str), encode)
).toString('base64'); ).toString('base64');
}, },
/** /**
...@@ -95,7 +95,7 @@ class Base { ...@@ -95,7 +95,7 @@ class Base {
* @return {Buffer} 转换完成的buffer * @return {Buffer} 转换完成的buffer
*/ */
buffer(str) { buffer(str) {
return new Buffer(str).toString('hex').toUpperCase(); return Buffer.from(str).toString('hex').toUpperCase();
}, },
/** /**
* 字符串转16进制(进行编码转换 * 字符串转16进制(进行编码转换
...@@ -103,8 +103,8 @@ class Base { ...@@ -103,8 +103,8 @@ class Base {
* @return {Buffer} 转换完成的buffer * @return {Buffer} 转换完成的buffer
*/ */
hex(str) { hex(str) {
return new Buffer( return Buffer.from(
iconv.encode(new Buffer(str), encode) iconv.encode(Buffer.from(str), encode)
).toString('hex').toUpperCase(); ).toString('hex').toUpperCase();
} }
} }
......
...@@ -10,7 +10,7 @@ module.exports = (pwd, data) => { ...@@ -10,7 +10,7 @@ module.exports = (pwd, data) => {
let ret = {}; let ret = {};
for (let _ in data) { for (let _ in data) {
if (_ === '_') { continue }; if (_ === '_') { continue };
ret[_] = new Buffer(data[_]).toString('base64'); ret[_] = Buffer.from(data[_]).toString('base64');
} }
ret[pwd] = data['_']; ret[pwd] = data['_'];
return ret; return ret;
......
...@@ -8,7 +8,7 @@ module.exports = (pwd, data) => { ...@@ -8,7 +8,7 @@ module.exports = (pwd, data) => {
let ret = {}; let ret = {};
for (let _ in data) { for (let _ in data) {
if (_ === '_') { continue }; if (_ === '_') { continue };
ret[_] = new Buffer(data[_]).toString('hex'); ret[_] = Buffer.from(data[_]).toString('hex');
} }
ret[pwd] = data['_']; ret[pwd] = data['_'];
return ret; return ret;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
module.exports = (pwd, data) => { module.exports = (pwd, data) => {
// 生成一个随机变量名 // 生成一个随机变量名
let randomID = `_0x${Math.random().toString(16).substr(2)}`; let randomID = `_0x${Math.random().toString(16).substr(2)}`;
data[randomID] = new Buffer(data['_']).toString('base64'); data[randomID] = Buffer.from(data['_']).toString('base64');
data[pwd] = `@eval(@base64_decode($_POST[${randomID}]));`; data[pwd] = `@eval(@base64_decode($_POST[${randomID}]));`;
delete data['_']; delete data['_'];
return data; return data;
......
...@@ -42,7 +42,7 @@ class ASP { ...@@ -42,7 +42,7 @@ class ASP {
id: arr[0] id: arr[0]
}); });
if (arr.length > 1) { if (arr.length > 1) {
this.dbconf['database'] = new Buffer(arr[1], 'base64').toString(); this.dbconf['database'] = Buffer.from(arr[1], 'base64').toString();
// 更新SQL编辑器 // 更新SQL编辑器
this.enableEditor(); this.enableEditor();
// manager.query.update(this.currentConf); // manager.query.update(this.currentConf);
...@@ -64,7 +64,7 @@ class ASP { ...@@ -64,7 +64,7 @@ class ASP {
let _db = arr[1].split(':'); let _db = arr[1].split(':');
this.getTables( this.getTables(
_db[0], _db[0],
new Buffer(_db[1], 'base64').toString() Buffer.from(_db[1], 'base64').toString()
); );
break; break;
// 获取表名字段 // 获取表名字段
...@@ -72,15 +72,15 @@ class ASP { ...@@ -72,15 +72,15 @@ class ASP {
let _tb = arr[1].split(':'); let _tb = arr[1].split(':');
this.getColumns( this.getColumns(
_tb[0], _tb[0],
new Buffer(_tb[1], 'base64').toString(), Buffer.from(_tb[1], 'base64').toString(),
new Buffer(_tb[2], 'base64').toString() Buffer.from(_tb[2], 'base64').toString()
); );
break; break;
// 生成查询SQL语句 // 生成查询SQL语句
case 'column': case 'column':
let _co = arr[1].split(':'); let _co = arr[1].split(':');
const table = new Buffer(_co[2], 'base64').toString(); const table = Buffer.from(_co[2], 'base64').toString();
const column = new Buffer(_co[3], 'base64').toString(); const column = Buffer.from(_co[3], 'base64').toString();
const sql = `SELECT TOP 20 [${column}] FROM [${table}] ORDER BY 1 DESC;`; const sql = `SELECT TOP 20 [${column}] FROM [${table}] ORDER BY 1 DESC;`;
this.manager.query.editor.session.setValue(sql); this.manager.query.editor.session.setValue(sql);
...@@ -367,7 +367,7 @@ class ASP { ...@@ -367,7 +367,7 @@ class ASP {
// 添加子节点 // 添加子节点
arr.map((_) => { arr.map((_) => {
if (!_) { return }; if (!_) { return };
const _db = new Buffer(_).toString('base64'); const _db = Buffer.from(_).toString('base64');
this.tree.insertNewItem( this.tree.insertNewItem(
`conn::${id}`, `conn::${id}`,
`database::${id}:${_db}`, `database::${id}:${_db}`,
...@@ -401,13 +401,13 @@ class ASP { ...@@ -401,13 +401,13 @@ class ASP {
).then((res) => { ).then((res) => {
let ret = res['text']; let ret = res['text'];
const arr = ret.split('\t'); const arr = ret.split('\t');
const _db = new Buffer(db).toString('base64'); const _db = Buffer.from(db).toString('base64');
// 删除子节点 // 删除子节点
this.tree.deleteChildItems(`database::${id}:${_db}`); this.tree.deleteChildItems(`database::${id}:${_db}`);
// 添加子节点 // 添加子节点
arr.map((_) => { arr.map((_) => {
if (!_) { return }; if (!_) { return };
const _table = new Buffer(_).toString('base64'); const _table = Buffer.from(_).toString('base64');
this.tree.insertNewItem( this.tree.insertNewItem(
`database::${id}:${_db}`, `database::${id}:${_db}`,
`table::${id}:${_db}:${_table}`, `table::${id}:${_db}:${_table}`,
...@@ -443,14 +443,14 @@ class ASP { ...@@ -443,14 +443,14 @@ class ASP {
).then((res) => { ).then((res) => {
let ret = res['text']; let ret = res['text'];
const arr = ret.split('\t'); const arr = ret.split('\t');
const _db = new Buffer(db).toString('base64'); const _db = Buffer.from(db).toString('base64');
const _table = new Buffer(table).toString('base64'); const _table = Buffer.from(table).toString('base64');
// 删除子节点 // 删除子节点
this.tree.deleteChildItems(`table::${id}:${_db}:${_table}`); this.tree.deleteChildItems(`table::${id}:${_db}:${_table}`);
// 添加子节点 // 添加子节点
arr.map((_) => { arr.map((_) => {
if (!_) { return }; if (!_) { return };
const _column = new Buffer(_.split(' ')[0]).toString('base64'); const _column = Buffer.from(_.split(' ')[0]).toString('base64');
this.tree.insertNewItem( this.tree.insertNewItem(
`table::${id}:${_db}:${_table}`, `table::${id}:${_db}:${_table}`,
`column::${id}:${_db}:${_table}:${_column}`, `column::${id}:${_db}:${_table}:${_column}`,
...@@ -558,7 +558,7 @@ class ASP { ...@@ -558,7 +558,7 @@ class ASP {
if (!filePath) { return; }; if (!filePath) { return; };
let headerStr = grid.hdrLabels.join(','); let headerStr = grid.hdrLabels.join(',');
let dataStr = grid.serializeToCSV(); let dataStr = grid.serializeToCSV();
let tempDataBuffer = new Buffer(headerStr+'\n'+dataStr); let tempDataBuffer = Buffer.from(headerStr+'\n'+dataStr);
fs.writeFileSync(filePath, tempDataBuffer); fs.writeFileSync(filePath, tempDataBuffer);
toastr.success(LANG['result']['dump']['success'], LANG_T['success']); toastr.success(LANG['result']['dump']['success'], LANG_T['success']);
}); });
......
...@@ -37,7 +37,7 @@ class CUSTOM { ...@@ -37,7 +37,7 @@ class CUSTOM {
id: arr[0] id: arr[0]
}); });
if (arr.length > 1) { if (arr.length > 1) {
this.dbconf['database'] = new Buffer(arr[1], 'base64').toString(); this.dbconf['database'] = Buffer.from(arr[1], 'base64').toString();
// 更新SQL编辑器 // 更新SQL编辑器
this.enableEditor(); this.enableEditor();
// manager.query.update(this.currentConf); // manager.query.update(this.currentConf);
...@@ -59,7 +59,7 @@ class CUSTOM { ...@@ -59,7 +59,7 @@ class CUSTOM {
let _db = arr[1].split(':'); let _db = arr[1].split(':');
this.getTables( this.getTables(
_db[0], _db[0],
new Buffer(_db[1], 'base64').toString() Buffer.from(_db[1], 'base64').toString()
); );
break; break;
// 获取表名字段 // 获取表名字段
...@@ -67,16 +67,16 @@ class CUSTOM { ...@@ -67,16 +67,16 @@ class CUSTOM {
let _tb = arr[1].split(':'); let _tb = arr[1].split(':');
this.getColumns( this.getColumns(
_tb[0], _tb[0],
new Buffer(_tb[1], 'base64').toString(), Buffer.from(_tb[1], 'base64').toString(),
new Buffer(_tb[2], 'base64').toString() Buffer.from(_tb[2], 'base64').toString()
); );
break; break;
// 生成查询SQL语句 // 生成查询SQL语句
case 'column': case 'column':
let _co = arr[1].split(':'); let _co = arr[1].split(':');
const db = new Buffer(_co[1], 'base64').toString(); const db = Buffer.from(_co[1], 'base64').toString();
const table = new Buffer(_co[2], 'base64').toString(); const table = Buffer.from(_co[2], 'base64').toString();
const column = new Buffer(_co[3], 'base64').toString(); const column = Buffer.from(_co[3], 'base64').toString();
const sql = `SELECT ${column} FROM ${db}.${table} ORDER BY 1 DESC;`; const sql = `SELECT ${column} FROM ${db}.${table} ORDER BY 1 DESC;`;
this.manager.query.editor.session.setValue(sql); this.manager.query.editor.session.setValue(sql);
...@@ -363,7 +363,7 @@ class CUSTOM { ...@@ -363,7 +363,7 @@ class CUSTOM {
// 添加子节点 // 添加子节点
arr.map((_) => { arr.map((_) => {
if (!_) { return }; if (!_) { return };
const _db = new Buffer(_).toString('base64'); const _db = Buffer.from(_).toString('base64');
this.tree.insertNewItem( this.tree.insertNewItem(
`conn::${id}`, `conn::${id}`,
`database::${id}:${_db}`, `database::${id}:${_db}`,
...@@ -398,13 +398,13 @@ class CUSTOM { ...@@ -398,13 +398,13 @@ class CUSTOM {
).then((res) => { ).then((res) => {
let ret = res['text']; let ret = res['text'];
const arr = ret.split('\t'); const arr = ret.split('\t');
const _db = new Buffer(db).toString('base64'); const _db = Buffer.from(db).toString('base64');
// 删除子节点 // 删除子节点
this.tree.deleteChildItems(`database::${id}:${_db}`); this.tree.deleteChildItems(`database::${id}:${_db}`);
// 添加子节点 // 添加子节点
arr.map((_) => { arr.map((_) => {
if (!_) { return }; if (!_) { return };
const _table = new Buffer(_).toString('base64'); const _table = Buffer.from(_).toString('base64');
this.tree.insertNewItem( this.tree.insertNewItem(
`database::${id}:${_db}`, `database::${id}:${_db}`,
`table::${id}:${_db}:${_table}`, `table::${id}:${_db}:${_table}`,
...@@ -442,14 +442,14 @@ class CUSTOM { ...@@ -442,14 +442,14 @@ class CUSTOM {
).then((res) => { ).then((res) => {
let ret = res['text']; let ret = res['text'];
const arr = ret.split('\t'); const arr = ret.split('\t');
const _db = new Buffer(db).toString('base64'); const _db = Buffer.from(db).toString('base64');
const _table = new Buffer(table).toString('base64'); const _table = Buffer.from(table).toString('base64');
// 删除子节点 // 删除子节点
this.tree.deleteChildItems(`table::${id}:${_db}:${_table}`); this.tree.deleteChildItems(`table::${id}:${_db}:${_table}`);
// 添加子节点 // 添加子节点
arr.map((_) => { arr.map((_) => {
if (!_) { return }; if (!_) { return };
const _column = new Buffer(_.split(' ')[0]).toString('base64'); const _column = Buffer.from(_.split(' ')[0]).toString('base64');
this.tree.insertNewItem( this.tree.insertNewItem(
`table::${id}:${_db}:${_table}`, `table::${id}:${_db}:${_table}`,
`column::${id}:${_db}:${_table}:${_column}`, `column::${id}:${_db}:${_table}:${_column}`,
...@@ -558,7 +558,7 @@ class CUSTOM { ...@@ -558,7 +558,7 @@ class CUSTOM {
if (!filePath) { return; }; if (!filePath) { return; };
let headerStr = grid.hdrLabels.join(','); let headerStr = grid.hdrLabels.join(',');
let dataStr = grid.serializeToCSV(); let dataStr = grid.serializeToCSV();
let tempDataBuffer = new Buffer(headerStr+'\n'+dataStr); let tempDataBuffer = Buffer.from(headerStr+'\n'+dataStr);
fs.writeFileSync(filePath, tempDataBuffer); fs.writeFileSync(filePath, tempDataBuffer);
toastr.success(LANG['result']['dump']['success'], LANG_T['success']); toastr.success(LANG['result']['dump']['success'], LANG_T['success']);
}); });
......
...@@ -31,7 +31,7 @@ class PHP { ...@@ -31,7 +31,7 @@ class PHP {
id: arr[0] id: arr[0]
}); });
if (arr.length > 1) { if (arr.length > 1) {
this.dbconf['database'] = new Buffer(arr[1], 'base64').toString(); this.dbconf['database'] = Buffer.from(arr[1], 'base64').toString();
// 更新SQL编辑器 // 更新SQL编辑器
this.enableEditor(); this.enableEditor();
// manager.query.update(this.currentConf); // manager.query.update(this.currentConf);
...@@ -54,7 +54,7 @@ class PHP { ...@@ -54,7 +54,7 @@ class PHP {
let _db = arr[1].split(':'); let _db = arr[1].split(':');
this.getTables( this.getTables(
_db[0], _db[0],
new Buffer(_db[1], 'base64').toString() Buffer.from(_db[1], 'base64').toString()
); );
break; break;
// 获取表名字段 // 获取表名字段
...@@ -62,15 +62,15 @@ class PHP { ...@@ -62,15 +62,15 @@ class PHP {
let _tb = arr[1].split(':'); let _tb = arr[1].split(':');
this.getColumns( this.getColumns(
_tb[0], _tb[0],
new Buffer(_tb[1], 'base64').toString(), Buffer.from(_tb[1], 'base64').toString(),
new Buffer(_tb[2], 'base64').toString() Buffer.from(_tb[2], 'base64').toString()
); );
break; break;
// 生成查询SQL语句 // 生成查询SQL语句
case 'column': case 'column':
let _co = arr[1].split(':'); let _co = arr[1].split(':');
const table = new Buffer(_co[2], 'base64').toString(); const table = Buffer.from(_co[2], 'base64').toString();
const column = new Buffer(_co[3], 'base64').toString(); const column = Buffer.from(_co[3], 'base64').toString();
const sql = `SELECT \`${column}\` FROM \`${table}\` ORDER BY 1 DESC LIMIT 0,20;`; const sql = `SELECT \`${column}\` FROM \`${table}\` ORDER BY 1 DESC LIMIT 0,20;`;
this.manager.query.editor.session.setValue(sql); this.manager.query.editor.session.setValue(sql);
...@@ -685,7 +685,7 @@ class PHP { ...@@ -685,7 +685,7 @@ class PHP {
editDatabase() { editDatabase() {
// 获取配置 // 获取配置
const id = this.tree.getSelected().split('::')[1].split(":")[0]; const id = this.tree.getSelected().split('::')[1].split(":")[0];
let dbname = new Buffer(this.tree.getSelected().split('::')[1].split(":")[1],"base64").toString(); let dbname = Buffer.from(this.tree.getSelected().split('::')[1].split(":")[1],"base64").toString();
const hash = (+new Date * Math.random()).toString(16).substr(2, 8); const hash = (+new Date * Math.random()).toString(16).substr(2, 8);
switch(this.dbconf['type']){ switch(this.dbconf['type']){
case "mysqli": case "mysqli":
...@@ -809,7 +809,7 @@ class PHP { ...@@ -809,7 +809,7 @@ class PHP {
delDatabase() { delDatabase() {
// 获取配置 // 获取配置
const id = this.tree.getSelected().split('::')[1].split(":")[0]; const id = this.tree.getSelected().split('::')[1].split(":")[0];
let dbname = new Buffer(this.tree.getSelected().split('::')[1].split(":")[1],"base64").toString(); let dbname = Buffer.from(this.tree.getSelected().split('::')[1].split(":")[1],"base64").toString();
layer.confirm(LANG['form']['deldb']['confirm'](dbname), { layer.confirm(LANG['form']['deldb']['confirm'](dbname), {
icon: 2, shift: 6, icon: 2, shift: 6,
title: LANG['form']['deldb']['title'] title: LANG['form']['deldb']['title']
...@@ -844,7 +844,7 @@ class PHP { ...@@ -844,7 +844,7 @@ class PHP {
addTable() { addTable() {
// 获取配置 // 获取配置
const id = this.tree.getSelected().split('::')[1].split(":")[0]; const id = this.tree.getSelected().split('::')[1].split(":")[0];
let dbname = new Buffer(this.tree.getSelected().split('::')[1].split(":")[1],"base64").toString(); let dbname = Buffer.from(this.tree.getSelected().split('::')[1].split(":")[1],"base64").toString();
const hash = (+new Date * Math.random()).toString(16).substr(2, 8); const hash = (+new Date * Math.random()).toString(16).substr(2, 8);
switch(this.dbconf['type']){ switch(this.dbconf['type']){
case "mysqli": case "mysqli":
...@@ -1031,8 +1031,8 @@ class PHP { ...@@ -1031,8 +1031,8 @@ class PHP {
// 获取配置 // 获取配置
const treeselect = this.tree.getSelected(); const treeselect = this.tree.getSelected();
const id = treeselect.split('::')[1].split(":")[0]; const id = treeselect.split('::')[1].split(":")[0];
let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString(); let dbname = Buffer.from(treeselect.split('::')[1].split(":")[1],"base64").toString();
let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString(); let tablename = Buffer.from(treeselect.split('::')[1].split(":")[2],"base64").toString();
// const hash = (+new Date * Math.random()).toString(16).substr(2, 8); // const hash = (+new Date * Math.random()).toString(16).substr(2, 8);
layer.prompt({ layer.prompt({
value: tablename, value: tablename,
...@@ -1073,8 +1073,8 @@ class PHP { ...@@ -1073,8 +1073,8 @@ class PHP {
// 获取配置 // 获取配置
const treeselect = this.tree.getSelected(); const treeselect = this.tree.getSelected();
const id = treeselect.split('::')[1].split(":")[0]; const id = treeselect.split('::')[1].split(":")[0];
let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString(); let dbname = Buffer.from(treeselect.split('::')[1].split(":")[1],"base64").toString();
let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString(); let tablename = Buffer.from(treeselect.split('::')[1].split(":")[2],"base64").toString();
layer.confirm(LANG['form']['deltable']['confirm'](tablename), { layer.confirm(LANG['form']['deltable']['confirm'](tablename), {
icon: 2, shift: 6, icon: 2, shift: 6,
title: LANG['form']['deltable']['title'] title: LANG['form']['deltable']['title']
...@@ -1108,8 +1108,8 @@ class PHP { ...@@ -1108,8 +1108,8 @@ class PHP {
descTable() { descTable() {
const treeselect = this.tree.getSelected(); const treeselect = this.tree.getSelected();
const id = treeselect.split('::')[1].split(":")[0]; const id = treeselect.split('::')[1].split(":")[0];
let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString(); let dbname = Buffer.from(treeselect.split('::')[1].split(":")[1],"base64").toString();
let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString(); let tablename = Buffer.from(treeselect.split('::')[1].split(":")[2],"base64").toString();
switch(this.dbconf['type']){ switch(this.dbconf['type']){
case "mysqli": case "mysqli":
case "mysql": case "mysql":
...@@ -1126,8 +1126,8 @@ class PHP { ...@@ -1126,8 +1126,8 @@ class PHP {
showcreateTable() { showcreateTable() {
const treeselect = this.tree.getSelected(); const treeselect = this.tree.getSelected();
const id = treeselect.split('::')[1].split(":")[0]; const id = treeselect.split('::')[1].split(":")[0];
let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString(); let dbname = Buffer.from(treeselect.split('::')[1].split(":")[1],"base64").toString();
let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString(); let tablename = Buffer.from(treeselect.split('::')[1].split(":")[2],"base64").toString();
switch(this.dbconf['type']){ switch(this.dbconf['type']){
case "mysqli": case "mysqli":
case "mysql": case "mysql":
...@@ -1146,9 +1146,9 @@ class PHP { ...@@ -1146,9 +1146,9 @@ class PHP {
// 获取配置 // 获取配置
const treeselect = this.tree.getSelected(); const treeselect = this.tree.getSelected();
const id = treeselect.split('::')[1].split(":")[0]; const id = treeselect.split('::')[1].split(":")[0];
let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString(); let dbname = Buffer.from(treeselect.split('::')[1].split(":")[1],"base64").toString();
let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString(); let tablename = Buffer.from(treeselect.split('::')[1].split(":")[2],"base64").toString();
let columnname = new Buffer(treeselect.split('::')[1].split(":")[3],"base64").toString(); let columnname = Buffer.from(treeselect.split('::')[1].split(":")[3],"base64").toString();
} }
...@@ -1157,9 +1157,9 @@ class PHP { ...@@ -1157,9 +1157,9 @@ class PHP {
// 获取配置 // 获取配置
const treeselect = this.tree.getSelected(); const treeselect = this.tree.getSelected();
const id = treeselect.split('::')[1].split(":")[0]; const id = treeselect.split('::')[1].split(":")[0];
let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString(); let dbname = Buffer.from(treeselect.split('::')[1].split(":")[1],"base64").toString();
let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString(); let tablename = Buffer.from(treeselect.split('::')[1].split(":")[2],"base64").toString();
let columnname = new Buffer(treeselect.split('::')[1].split(":")[3],"base64").toString(); let columnname = Buffer.from(treeselect.split('::')[1].split(":")[3],"base64").toString();
let columntyperaw = this.tree.getSelectedItemText(); let columntyperaw = this.tree.getSelectedItemText();
let columntype = null; let columntype = null;
var ctypereg = new RegExp(columnname+'\\s\\((.+?\\))\\)'); var ctypereg = new RegExp(columnname+'\\s\\((.+?\\))\\)');
...@@ -1210,9 +1210,9 @@ class PHP { ...@@ -1210,9 +1210,9 @@ class PHP {
// 获取配置 // 获取配置
const treeselect = this.tree.getSelected(); const treeselect = this.tree.getSelected();
const id = treeselect.split('::')[1].split(":")[0]; const id = treeselect.split('::')[1].split(":")[0];
let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString(); let dbname = Buffer.from(treeselect.split('::')[1].split(":")[1],"base64").toString();
let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString(); let tablename = Buffer.from(treeselect.split('::')[1].split(":")[2],"base64").toString();
let columnname = new Buffer(treeselect.split('::')[1].split(":")[3],"base64").toString(); let columnname = Buffer.from(treeselect.split('::')[1].split(":")[3],"base64").toString();
layer.confirm(LANG['form']['delcolumn']['confirm'](columnname), { layer.confirm(LANG['form']['delcolumn']['confirm'](columnname), {
icon: 2, shift: 6, icon: 2, shift: 6,
title: LANG['form']['delcolumn']['title'] title: LANG['form']['delcolumn']['title']
...@@ -1268,7 +1268,7 @@ class PHP { ...@@ -1268,7 +1268,7 @@ class PHP {
// 添加子节点 // 添加子节点
arr.map((_) => { arr.map((_) => {
if (!_) { return }; if (!_) { return };
const _db = new Buffer(_).toString('base64'); const _db = Buffer.from(_).toString('base64');
this.tree.insertNewItem( this.tree.insertNewItem(
`conn::${id}`, `conn::${id}`,
`database::${id}:${_db}`, `database::${id}:${_db}`,
...@@ -1303,13 +1303,13 @@ class PHP { ...@@ -1303,13 +1303,13 @@ class PHP {
).then((res) => { ).then((res) => {
let ret = res['text']; let ret = res['text'];
const arr = ret.split('\t'); const arr = ret.split('\t');
const _db = new Buffer(db).toString('base64'); const _db = Buffer.from(db).toString('base64');
// 删除子节点 // 删除子节点
this.tree.deleteChildItems(`database::${id}:${_db}`); this.tree.deleteChildItems(`database::${id}:${_db}`);
// 添加子节点 // 添加子节点
arr.map((_) => { arr.map((_) => {
if (!_) { return }; if (!_) { return };
const _table = new Buffer(_).toString('base64'); const _table = Buffer.from(_).toString('base64');
this.tree.insertNewItem( this.tree.insertNewItem(
`database::${id}:${_db}`, `database::${id}:${_db}`,
`table::${id}:${_db}:${_table}`, `table::${id}:${_db}:${_table}`,
...@@ -1347,14 +1347,14 @@ class PHP { ...@@ -1347,14 +1347,14 @@ class PHP {
).then((res) => { ).then((res) => {
let ret = res['text']; let ret = res['text'];
const arr = ret.split('\t'); const arr = ret.split('\t');
const _db = new Buffer(db).toString('base64'); const _db = Buffer.from(db).toString('base64');
const _table = new Buffer(table).toString('base64'); const _table = Buffer.from(table).toString('base64');
// 删除子节点 // 删除子节点
this.tree.deleteChildItems(`table::${id}:${_db}:${_table}`); this.tree.deleteChildItems(`table::${id}:${_db}:${_table}`);
// 添加子节点 // 添加子节点
arr.map((_) => { arr.map((_) => {
if (!_) { return }; if (!_) { return };
const _column = new Buffer(_.split(' ')[0]).toString('base64'); const _column = Buffer.from(_.split(' ')[0]).toString('base64');
this.tree.insertNewItem( this.tree.insertNewItem(
`table::${id}:${_db}:${_table}`, `table::${id}:${_db}:${_table}`,
`column::${id}:${_db}:${_table}:${_column}`, `column::${id}:${_db}:${_table}:${_column}`,
...@@ -1436,7 +1436,7 @@ class PHP { ...@@ -1436,7 +1436,7 @@ class PHP {
arr.map((_) => { arr.map((_) => {
let _data = _.split('\t|\t'); let _data = _.split('\t|\t');
for (let i = 0; i < _data.length; i ++) { for (let i = 0; i < _data.length; i ++) {
_data[i] = antSword.noxss(new Buffer(_data[i], "base64").toString()); _data[i] = antSword.noxss(Buffer.from(_data[i], "base64").toString());
} }
data_arr.push(_data); data_arr.push(_data);
}); });
...@@ -1469,7 +1469,7 @@ class PHP { ...@@ -1469,7 +1469,7 @@ class PHP {
arr.map((_) => { arr.map((_) => {
let _data = _.split('\t|\t'); let _data = _.split('\t|\t');
for (let i = 0; i < _data.length; i ++) { for (let i = 0; i < _data.length; i ++) {
_data[i] = antSword.noxss(new Buffer(_data[i], "base64").toString(), false); _data[i] = antSword.noxss(Buffer.from(_data[i], "base64").toString(), false);
} }
data_arr.push(_data); data_arr.push(_data);
}); });
...@@ -1510,7 +1510,7 @@ class PHP { ...@@ -1510,7 +1510,7 @@ class PHP {
if (!filePath) { return; }; if (!filePath) { return; };
let headerStr = grid.hdrLabels.join(','); let headerStr = grid.hdrLabels.join(',');
let dataStr = grid.serializeToCSV(); let dataStr = grid.serializeToCSV();
let tempDataBuffer = new Buffer(headerStr+'\n'+dataStr); let tempDataBuffer = Buffer.from(headerStr+'\n'+dataStr);
fs.writeFileSync(filePath, tempDataBuffer); fs.writeFileSync(filePath, tempDataBuffer);
toastr.success(LANG['result']['dump']['success'], LANG_T['success']); toastr.success(LANG['result']['dump']['success'], LANG_T['success']);
}); });
......
...@@ -474,7 +474,7 @@ class Files { ...@@ -474,7 +474,7 @@ class Files {
refreshPath(p) { refreshPath(p) {
let path = p || this.manager.path; let path = p || this.manager.path;
// delete this.manager.cache[path]; // delete this.manager.cache[path];
this.manager.cache.del('filemanager-files-' + new Buffer(path).toString('base64')); this.manager.cache.del('filemanager-files-' + Buffer.from(path).toString('base64'));
// 删除文件夹缓存 // 删除文件夹缓存
for (let _ in this.manager.folder.cache) { for (let _ in this.manager.folder.cache) {
if (_.indexOf(path) === 0 && _ != path) { if (_.indexOf(path) === 0 && _ != path) {
......
...@@ -152,7 +152,7 @@ class FileManager { ...@@ -152,7 +152,7 @@ class FileManager {
if (!path.endsWith('/')) { path += '/' }; if (!path.endsWith('/')) { path += '/' };
this.path = path; this.path = path;
let cache_tag = 'filemanager-files-' + new Buffer(this.path).toString('base64'); let cache_tag = 'filemanager-files-' + Buffer.from(this.path).toString('base64');
// 判断是否有缓存 // 判断是否有缓存
// if (cache = this.cache[path]) { // if (cache = this.cache[path]) {
...@@ -535,7 +535,7 @@ class FileManager { ...@@ -535,7 +535,7 @@ class FileManager {
height: 600, height: 600,
}); });
var filemime = mime.lookup(name); var filemime = mime.lookup(name);
let savepath = PATH.join(process.env.AS_WORKDIR,`antData/.temp/`,new Buffer(name).toString("hex")); let savepath = PATH.join(process.env.AS_WORKDIR,`antData/.temp/`,Buffer.from(name).toString("hex"));
win.cell.lastChild['style']['overflow'] = 'scroll'; win.cell.lastChild['style']['overflow'] = 'scroll';
win.cell.lastChild['style']['textAlign'] = 'center'; win.cell.lastChild['style']['textAlign'] = 'center';
...@@ -556,7 +556,7 @@ class FileManager { ...@@ -556,7 +556,7 @@ class FileManager {
let buff = fs.readFileSync(savepath); let buff = fs.readFileSync(savepath);
switch (filemime){ switch (filemime){
default: default:
let data = new Buffer(buff).toString('base64'); let data = Buffer.from(buff).toString('base64');
win.attachHTMLString(`<img style="width:100%" src="data:/${filemime};base64,${data}"/>`); win.attachHTMLString(`<img style="width:100%" src="data:/${filemime};base64,${data}"/>`);
break; break;
} }
...@@ -907,7 +907,7 @@ class FileManager { ...@@ -907,7 +907,7 @@ class FileManager {
editor.session.setMode(`ace/mode/${mode}`); editor.session.setMode(`ace/mode/${mode}`);
}else if (id.startsWith('encode_')) { }else if (id.startsWith('encode_')) {
let encode = id.split('_')[1]; let encode = id.split('_')[1];
editor.session.setValue(iconv.decode(new Buffer(codes), encode).toString()); editor.session.setValue(iconv.decode(Buffer.from(codes), encode).toString());
}else{ }else{
console.info('toolbar.onClick', id); console.info('toolbar.onClick', id);
} }
......
...@@ -291,7 +291,7 @@ module.exports = (pwd, data) => { ...@@ -291,7 +291,7 @@ module.exports = (pwd, data) => {
let randomID = \`_0x\${Math.random().toString(16).substr(2)}\`; let randomID = \`_0x\${Math.random().toString(16).substr(2)}\`;
// 原有的 payload 在 data['_']中 // 原有的 payload 在 data['_']中
// 取出来之后,转为 base64 编码并放入 randomID key 下 // 取出来之后,转为 base64 编码并放入 randomID key 下
data[randomID] = new Buffer(data['_']).toString('base64'); data[randomID] = Buffer.from(data['_']).toString('base64');
// shell 在接收到 payload 后,先处理 pwd 参数下的内容, // shell 在接收到 payload 后,先处理 pwd 参数下的内容,
data[pwd] = \`eval(base64_decode($_POST[\${randomID}]));\`; data[pwd] = \`eval(base64_decode($_POST[\${randomID}]));\`;
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* 更新:2016/04/13 * 更新:2016/04/13
* 作者:蚁逅 <https://github.com/antoor> * 作者:蚁逅 <https://github.com/antoor>
*/ */
const LANG = antSword['language']['terminal']; const LANG = antSword['language']['terminal'];
const LANG_T = antSword['language']['toastr']; const LANG_T = antSword['language']['toastr'];
...@@ -155,7 +154,7 @@ class Terminal { ...@@ -155,7 +154,7 @@ class Terminal {
} }
term.pause(); term.pause();
// 是否有缓存 // 是否有缓存
let cacheTag = 'command-' + new Buffer(this.path + cmd).toString('base64'); let cacheTag = 'command-' + Buffer.from(this.path + cmd).toString('base64');
let cacheCmd = this.cache.get(cacheTag); let cacheCmd = this.cache.get(cacheTag);
if ( if (
(this.opts.otherConf || {})['terminal-cache'] === 1 && cacheCmd (this.opts.otherConf || {})['terminal-cache'] === 1 && cacheCmd
......
...@@ -58,7 +58,7 @@ class Tabbar { ...@@ -58,7 +58,7 @@ class Tabbar {
* @return {Object} this * @return {Object} this
*/ */
safeHTML(html = "") { safeHTML(html = "") {
let _html = new Buffer(html).toString('base64'); let _html = Buffer.from(html).toString('base64');
let _iframe = ` let _iframe = `
<iframe <iframe
src="data:text/html;base64,${_html}" src="data:text/html;base64,${_html}"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment