Your IP: 216.73.216.124
Server IP: 50.28.103.30
Server: Linux host.jcukjv-lwsites.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
Server Software: nginx/1.28.0
PHP Version: 8.3.12
Buat File |
Buat Folder
',
success: function () {
if (window.location.href.indexOf('database') != -1) {
$('.re-con-menu p:last-child').addClass('on').siblings().removeClass('on');
that.render_recycle_list(6);
} else {
that.render_recycle_list(1);
}
$('.re-con-menu').on('click', 'p', function () {
var _type = $(this).data('type');
$(this).addClass('on').siblings().removeClass('on');
that.render_recycle_list(_type);
});
},
});
},
// 回收站渲染列表
render_recycle_list: function (num) {
var that = this;
this.$http('Get_Recycle_bin', function (rdata) {
var body = '';
$('#Set_Recycle_bin').attr('checked', rdata.status);
$('#Set_Recycle_bin_db').attr('checked', rdata.status_db);
switch (num) {
case 1:
for (var i = 0; i < rdata.dirs.length; i++) {
var shortwebname = rdata.dirs[i].name.replace(/'/, "\\'");
var shortpath = rdata.dirs[i].dname;
if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + '...';
if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + '...';
body +=
'\
' +
shortwebname +
' \
' +
shortpath +
' \
' +
ToSize(rdata.dirs[i].size) +
' \
' +
getLocalTime(rdata.dirs[i].time) +
' \
\
' +
lan.files.recycle_bin_re +
' \
| ' +
lan.files.recycle_bin_del +
' \
\
';
}
for (var i = 0; i < rdata.files.length; i++) {
if (rdata.files[i].name.indexOf('BTDB_') != -1) {
var shortwebname = rdata.files[i].name.replace(/'/, "\\'");
var shortpath = rdata.files[i].dname;
if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + '...';
if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + '...';
body +=
'\
' +
shortwebname.replace('BTDB_', '') +
' \
mysql://' +
shortpath.replace('BTDB_', '') +
' \
- \
' +
getLocalTime(rdata.files[i].time) +
' \
\
' +
lan.files.recycle_bin_re +
' \
| ' +
lan.files.recycle_bin_del +
' \
\
';
continue;
}
var shortwebname = rdata.files[i].name.replace(/'/, "\\'");
var shortpath = rdata.files[i].dname;
if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + '...';
if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + '...';
body +=
'\
' +
shortwebname +
' \
' +
shortpath +
' \
' +
ToSize(rdata.files[i].size) +
' \
' +
getLocalTime(rdata.files[i].time) +
' \
\
' +
lan.files.recycle_bin_re +
' \
| ' +
lan.files.recycle_bin_del +
' \
\
';
}
$('#RecycleBody').html(body);
return;
break;
case 2:
for (var i = 0; i < rdata.dirs.length; i++) {
var shortwebname = rdata.dirs[i].name.replace(/'/, "\\'");
var shortpath = rdata.dirs[i].dname;
if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + '...';
if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + '...';
body +=
'\
' +
shortwebname +
' \
' +
shortpath +
' \
' +
ToSize(rdata.dirs[i].size) +
' \
' +
getLocalTime(rdata.dirs[i].time) +
' \
\
' +
lan.files.recycle_bin_re +
' \
| ' +
lan.files.recycle_bin_del +
' \
\
';
}
$('#RecycleBody').html(body);
return;
break;
case 3:
for (var i = 0; i < rdata.files.length; i++) {
if (rdata.files[i].name.indexOf('BTDB_') != -1) continue;
var shortwebname = rdata.files[i].name.replace(/'/, "\\'");
var shortpath = rdata.files[i].dname;
if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + '...';
if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + '...';
body +=
'\
' +
shortwebname +
' \
' +
shortpath +
' \
' +
ToSize(rdata.files[i].size) +
' \
' +
getLocalTime(rdata.files[i].time) +
' \
\
' +
lan.files.recycle_bin_re +
' \
| ' +
lan.files.recycle_bin_del +
' \
\
';
}
$('#RecycleBody').html(body);
return;
break;
case 4:
for (var i = 0; i < rdata.files.length; i++) {
if (ReisImage(getFileName(rdata.files[i].name))) {
var shortwebname = rdata.files[i].name.replace(/'/, "\\'");
var shortpath = rdata.files[i].dname;
if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + '...';
if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + '...';
body +=
'\
' +
shortwebname +
' \
' +
shortpath +
' \
' +
ToSize(rdata.files[i].size) +
' \
' +
getLocalTime(rdata.files[i].time) +
' \
\
' +
lan.files.recycle_bin_re +
' \
| ' +
lan.files.recycle_bin_del +
' \
\
';
}
}
$('#RecycleBody').html(body);
return;
break;
case 5:
for (var i = 0; i < rdata.files.length; i++) {
if (rdata.files[i].name.indexOf('BTDB_') != -1) continue;
if (!ReisImage(getFileName(rdata.files[i].name))) {
var shortwebname = rdata.files[i].name.replace(/'/, "\\'");
var shortpath = rdata.files[i].dname;
if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + '...';
if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + '...';
body +=
'\
' +
shortwebname +
' \
' +
shortpath +
' \
' +
ToSize(rdata.files[i].size) +
' \
' +
getLocalTime(rdata.files[i].time) +
' \
\
' +
lan.files.recycle_bin_re +
' \
| ' +
lan.files.recycle_bin_del +
' \
\
';
}
}
$('#RecycleBody').html(body);
return;
case 6:
for (var i = 0; i < rdata.files.length; i++) {
if (rdata.files[i].name.indexOf('BTDB_') != -1) {
var shortwebname = rdata.files[i].name.replace(/'/, "\\'");
var shortpath = rdata.files[i].dname;
if (shortwebname.length > 20) shortwebname = shortwebname.substring(0, 20) + '...';
if (shortpath.length > 20) shortpath = shortpath.substring(0, 20) + '...';
body +=
'\
' +
shortwebname.replace('BTDB_', '') +
' \
mysql://' +
shortpath.replace('BTDB_', '') +
' \
- \
' +
getLocalTime(rdata.files[i].time) +
' \
\
' +
lan.files.recycle_bin_re +
' \
| ' +
lan.files.recycle_bin_del +
' \
\
';
}
}
$('#RecycleBody').html(body);
return;
break;
}
function getFileName(name) {
var text = name.split('.');
var n = text.length - 1;
text = text[n];
return text;
}
function ReisImage(fileName) {
var exts = ['jpg', 'jpeg', 'png', 'bmp', 'gif', 'tiff', 'ico'];
for (var i = 0; i < exts.length; i++) {
if (fileName == exts[i]) return true;
}
return false;
}
$('#RecycleBody').html(body);
});
},
/**
* @description 回收站视图
* @return void
*/
recycle_bin_view: function () {
var that = this;
layer.open({
title: lan.files.recycle_bin_title,
type: 1,
skin: 'recycle_view',
area: ['80%', '672px'],
closeBtn: 2,
content:
'\
\
\
' +
lan.files.recycle_bin_on +
' \
\
\
\
\
' +
lan.files.recycle_bin_on_db +
' \
\
\
\
\
\
' +
lan.files.recycle_bin_ps +
' \
' +
lan.files.recycle_bin_close +
' \
\
\
',
success: function () {
if (window.location.href.indexOf('database') != -1) {
$('.re-con-menu p:last-child').addClass('on').siblings().removeClass('on');
$('.re-con-menu p:eq(5)').click();
} else {
$('.re-con-menu p:eq(0)').click();
}
var render_recycle = that.render_recycle_list();
$('.re-con-menu').on('click', 'p', function () {
var _type = $(this).data('type');
$(this).addClass('on').siblings().removeClass('on');
render_recycle.$refresh_table_list(true);
});
},
});
},
/**
* @description 回收站渲染列表
* @return void
*/
render_recycle_list: function () {
var that = this;
$('#recycle_table').empty();
var recycle_list = bt_tools.table({
el: '#recycle_table',
url: '/files?action=Get_Recycle_bin',
height: 488,
dataFilter: function (res) {
var files = [];
switch ($('.re-con-menu p.on').index()) {
case 0:
for (var i = 0; i < res.dirs.length; i++) {
var item = res.dirs[i];
if (item.name.indexOf('BTDB_') > -1) {
item.dname = item.dname.replace('BTDB_', '');
item.name = item.name.replace('BTDB_', '');
files.push($.extend(item, { type: 'files' }));
} else {
var item = res.dirs[i];
files.push($.extend(item, { type: 'folder' }));
}
}
for (var j = 0; j < res.files.length; j++) {
var item = res.files[j],
ext_list = item.dname.split('.'),
ext = that.determine_file_type(ext_list[ext_list.length - 1]);
if (ext == 'images') {
files.push($.extend(item, { type: ext }));
} else {
files.push($.extend(item, { type: 'files' }));
}
}
break;
case 1:
for (var i = 0; i < res.dirs.length; i++) {
var item = res.dirs[i];
files.push($.extend(item, { type: 'folder' }));
}
break;
case 2:
for (var j = 0; j < res.files.length; j++) {
var item = res.files[j],
ext_list = item.dname.split('.'),
ext = that.determine_file_type(ext_list[ext_list.length - 1]);
if (item.name.indexOf('BTDB') == -1) files.push($.extend(item, { type: ext }));
}
break;
case 3:
for (var j = 0; j < res.files.length; j++) {
var item = res.files[j],
ext_list = item.dname.split('.'),
ext = that.determine_file_type(ext_list[ext_list.length - 1]);
if (ext == 'images') files.push($.extend(item, { type: ext }));
}
break;
case 4:
for (var j = 0; j < res.files.length; j++) {
var item = res.files[j],
ext_list = item.dname.split('.'),
ext = that.determine_file_type(ext_list[ext_list.length - 1]);
if (ext != 'images' && ext != 'compress' && ext != 'video' && item.name.indexOf('BTDB') == -1) files.push($.extend(item, { type: ext }));
}
break;
case 5:
for (var j = 0; j < res.dirs.length; j++) {
var item = res.dirs[j];
if (item.name.indexOf('BTDB_') > -1) {
item.dname = item.dname.replace('BTDB_', '');
item.name = item.name.replace('BTDB_', '');
files.push($.extend(item, { type: 'files' }));
}
}
break;
}
$('#Set_Recycle_bin').attr('checked', res.status);
$('#Set_Recycle_bin_db').attr('checked', res.status_db);
return { data: files };
},
column: [
{ type: 'checkbox', class: '', width: 18 },
{
fid: 'name',
title: lan.files.recycle_bin_th1,
width: 150,
template: function (row) {
return (
'' +
row.name +
'
'
);
},
},
{
fid: 'dname',
title: lan.files.recycle_bin_th2,
width: 150,
template: function (row) {
return '' + row.dname + '
';
},
},
{
fid: 'size',
title: lan.files.recycle_bin_th3,
width: 85,
template: function (row) {
return '' + bt.format_size(row.size) + ' ';
},
},
{
fid: 'time',
title: lan.files.recycle_bin_th4,
width: 130,
template: function (row, index) {
return '' + bt.format_data(row.time) + ' ';
},
},
{
type: 'group',
align: 'right',
width: 170,
title: lan.files.recycle_bin_th5,
group: [
{
title: lan.files.recycle_bin_re,
event: function (row, index, ev, key, that) {
bt_file.ReRecycleBin(row.rname, function () {
that.$delete_table_row(index);
});
},
},
{
title: lan.files.recycle_bin_del,
event: function (row, index, ev, key, that) {
bt_file.DelRecycleBin(row.rname, function () {
that.$delete_table_row(index);
});
},
},
],
},
],
tootls: [
{
// 批量操作
type: 'batch', //batch_btn
positon: ['left', 'bottom'],
placeholder: 'Please Choose',
buttonValue: 'Execute',
disabledSelectValue: 'Please select the port that needs batch operation!',
selectList: [
{
title: 'Restore',
url: '/files?action=Re_Recycle_bin',
load: true,
param: function (row) {
return { path: row.rname };
},
callback: function (that) {
bt.confirm({ title: 'Restore files', msg: 'Batch restore selected files, do you want to continue?', icon: 0 }, function (index) {
layer.close(index);
that.start_batch({}, function (list) {
var html = '';
for (var i = 0; i < list.length; i++) {
var item = list[i];
html +=
'' +
item.name +
' ' +
(item.request.status ? 'Successful recovery' : 'Recovery failed') +
'
';
}
recycle_list.$batch_success_table({ title: 'Restore files', th: 'File name', html: html });
recycle_list.$refresh_table_list(true);
});
});
},
},
{
title: 'Delete files permanently',
url: '/files?action=Del_Recycle_bin',
load: true,
param: function (row) {
return { path: row.rname };
},
callback: function (that) {
bt.confirm(
{ title: 'Delete selected files', msg: 'Delete the selected file. The file will be completely deleted and cannot be recovered. Do you want to continue?', icon: 0 },
function (index) {
layer.close(index);
that.start_batch({}, function (list) {
var html = '';
for (var i = 0; i < list.length; i++) {
var item = list[i];
html +=
'' +
item.name +
' ' +
(item.request.status ? 'Successfully deleted' : 'Failed to delete') +
' ';
}
recycle_list.$batch_success_table({ title: 'Delete multiple files', th: 'File name', html: html });
recycle_list.$refresh_table_list(true);
});
}
);
},
},
],
},
],
});
bt_tools.$fixed_table_thead('#recycle_table .divtable');
return recycle_list;
},
// 回收站开关
Set_Recycle_bin: function (db) {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
var that = this,
data = {};
if (db == 1) {
data = { db: db };
}
$.post('/files?action=Recycle_bin', data, function (rdata) {
layer.close(loadT);
if (rdata.status) {
if (db == undefined) that.is_recycle = $('#Set_Recycle_bin').prop('checked');
}
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
});
},
// 回收站恢复
ReRecycleBin: function (path, obj) {
layer.confirm(lan.files.recycle_bin_re_msg, { title: lan.files.recycle_bin_re_title, closeBtn: 2, icon: 3 }, function () {
var loadT = layer.msg(lan.files.recycle_bin_re_the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/files?action=Re_Recycle_bin', 'path=' + encodeURIComponent(path), function (rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
$(obj).parents('tr').remove();
});
});
},
//回收站删除
DelRecycleBin: function (path, obj) {
layer.confirm(lan.files.recycle_bin_del_msg, { title: lan.files.recycle_bin_del_title, closeBtn: 2, icon: 3 }, function () {
var loadT = layer.msg(lan.files.recycle_bin_del_the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/files?action=Del_Recycle_bin', 'path=' + encodeURIComponent(path), function (rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
$(obj).parents('tr').remove();
});
});
},
//清空回收站
CloseRecycleBin: function () {
var _this = this;
layer.confirm(lan.files.recycle_bin_close_msg, { title: lan.files.recycle_bin_close, closeBtn: 2, icon: 3 }, function () {
var loadT = layer.msg("" + lan.files.recycle_bin_close_the + '
', { icon: 16, time: 0, shade: [0.3, '#000'] });
setTimeout(function () {
getSpeed('.myspeed');
}, 1000);
$.post('/files?action=Close_Recycle_bin', '', function (rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
_this.render_recycle_list();
});
});
},
/**
* @description 打开属性视图
* @param {Object} data 当前文件的数据对象
* @return void
*/
open_property_view: function (data) {
var _this = this;
_this.$http('get_file_attribute', { filename: data.path }, function (res) {
layer.open({
type: 1,
closeBtn: 2,
title: '[ ' + data.filename + ' ] - ' + (data.is_dir ? 'Folder' : 'File') + ' properties',
area: ['580px', '500px'],
shadeClose: false,
// btn:['确认','取消'],
content:
'\
\
General \
Detail \
History \
\
\
\
\
\
\
Type:
\
' +
(res.is_dir || res.is_link ? res.st_type : _this.ext_type_tips(res.st_type)) +
'
\
\
\
Location:
\
\
' +
(res.path + '/' + data.filename).replace('//', '/') +
' \
\
\
\
\
Size:
\
' +
bt.format_size(res.st_size) +
' (' +
(_this.font_thousandth(res.st_size) + ' byte') +
')' +
'
\
\
\
\
Permissions:
\
' +
res.mode +
'
\
\
\
Group:
\
' +
res.group +
'
\
\
\
User:
\
' +
res.user +
'
\
\
\
\
Visit time:
\
' +
bt.format_data(res.st_atime) +
'
\
\
\
Modified time:
\
' +
bt.format_data(res.st_mtime) +
'
\
\
\
\
\
\
Modified time
Size
MD5
OPT
\
\
\
\
\
',
success: function (layero, index) {
var copy_properyt_path = new ClipboardJS('.copyProperytPath');
copy_properyt_path.on('success', function (e) {
layer.msg(lan.public.cp_success, {
icon: 1,
});
});
$('.bt-property-setting .tab-nav span').click(function () {
var index = $(this).index();
$(this).addClass('on').siblings().removeClass('on');
$('.property-box:eq(' + index + ')')
.addClass('active')
.siblings()
.removeClass('active');
});
$('.history_box_view').on('click', '.open_history_file', function () {
var _history = $(this).attr('data-time');
openEditorView(0, data.path);
setTimeout(function () {
aceEditor.openHistoryEditorView({ filename: data.path, history: _history }, function () {
layer.close(index);
$('.ace_conter_tips').show();
$('.ace_conter_tips .tips').html(
'Read-only file, the file is ' +
_item.path +
', historic version [ ' +
bt.format_data(new Number(_history)) +
' ]Click to restore '
);
});
}, 500);
});
$('.history_box_view').on('click', '.recovery_file_historys', function () {
aceEditor.event_ecovery_file(this);
});
var config = {
filename: ['Name', data.filename],
type: ['Type', res.is_dir || res.is_link ? res.st_type : _this.ext_type_tips(res.st_type)],
path: 'Location',
st_size: ['Size', bt.format_size(res.st_size) + ' (' + (_this.font_thousandth(res.st_size) + ' byte') + ')'],
st_atime: ['Visit time', bt.format_data(res.st_atime)],
st_mtime: ['Modified time', bt.format_data(res.st_mtime)],
st_ctime: ['Metadata modification time', bt.format_data(res.st_ctime)],
md5: 'MD5',
sha1: 'sha1',
user: 'User',
group: 'Group',
mode: 'Permissions',
st_uid: 'UID',
st_gid: 'GID',
st_nlink: 'Num of inode links',
st_ino: 'inode node num',
st_mode: 'inode protection mode',
st_dev: 'inode resident device',
},
html = '',
html2 = '';
for (var key in config) {
if (Object.hasOwnProperty.call(config, key)) {
var element = config[key],
value = $.isArray(element) ? element[1] : res[key];
html +=
'' +
($.isArray(element) ? element[0] : element) +
'
' +
value +
'
';
}
}
for (let i = 0; i < res.history.length; i++) {
const item = res.history[i];
html2 +=
'' +
bt.format_data(item.st_mtime) +
'
' +
bt.format_size(item.st_size) +
'
' +
item.md5 +
'
';
}
if (html2 === '') html2 += 'No historical version
';
$('.details_list').html(html);
$('.history_list ').html(html2);
_this.fixed_table_thead('.details_box_view');
_this.fixed_table_thead('.history_box_view ');
},
});
});
},
/**
* @description 固定表头
* @param {string} el DOM选择器
* @return void
*/
fixed_table_thead: function (el) {
$(el).scroll(function () {
var scrollTop = this.scrollTop;
this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)';
});
},
/**
* @description 字符千分隔符
* @param {string} el DOM选择器
* @return void
*/
font_thousandth: function (num) {
var source = String(num).split('.'); //按小数点分成2部分
source[0] = source[0].replace(new RegExp('(\\d)(?=(\\d{3})+$)', 'ig'), '$1,'); //只将整数部分进行都好分割
return source.join('.'); //再将小数部分合并进来
},
/**
* @description 打开图片预览
* @param {Object} data 当前文件的数据对象
* @return void
*/
open_images_preview: function (data) {
var that = this,
mask = $(
'' +
'
' +
'' +
data.filename +
' ' +
' ' +
' ' +
' ' +
'
' +
'
' +
'
' +
'
' +
'
'
),
images_config = {
natural_width: 0,
natural_height: 0,
init_width: 0,
init_height: 0,
preview_width: 0,
preview_height: 0,
current_width: 0,
current_height: 0,
current_left: 0,
current_top: 0,
rotate: 0,
scale: 1,
images_mouse: false,
};
if ($('.preview_images_mask').length > 0) {
$('#preview_images').attr('src', '/download?filename=' + data.path);
return false;
}
$('body').css('overflow', 'hidden').append(mask);
images_config.preview_width = mask[0].clientWidth;
images_config.preview_height = mask[0].clientHeight;
// 图片预览
$('.preview_body img').load(function () {
var img = $(this)[0];
if (!$(this).attr('data-index')) $(this).attr('data-index', data.images_id);
images_config.natural_width = img.naturalWidth;
images_config.natural_height = img.naturalHeight;
auto_images_size(false);
});
//图片头部拖动
$('.preview_images_mask .preview_head').on('mousedown', function (e) {
e = e || window.event; //兼容ie浏览器
var drag = $(this).parent();
$('body').addClass('select'); //webkit内核和火狐禁止文字被选中
$(this).onselectstart = $(this).ondrag = function () {
//ie浏览器禁止文字选中
return false;
};
if ($(e.target).hasClass('preview_close')) {
//点关闭按钮不能拖拽模态框
return;
}
var diffX = e.clientX - drag.offset().left;
var diffY = e.clientY - drag.offset().top;
$(document)
.on('mousemove', function (e) {
e = e || window.event; //兼容ie浏览器
var left = e.clientX - diffX;
var top = e.clientY - diffY;
if (left < 0) {
left = 0;
} else if (left > window.innerWidth - drag.width()) {
left = window.innerWidth - drag.width();
}
if (top < 0) {
top = 0;
} else if (top > window.innerHeight - drag.height()) {
top = window.innerHeight - drag.height();
}
drag.css({
left: left,
top: top,
margin: 0,
});
})
.on('mouseup', function () {
$(this).unbind('mousemove mouseup');
});
});
//图片拖动
$('.preview_images_mask #preview_images')
.on('mousedown', function (e) {
e = e || window.event;
$(this).onselectstart = $(this).ondrag = function () {
return false;
};
var images = $(this);
var preview = $('.preview_images_mask').offset();
var diffX = e.clientX - preview.left;
var diffY = e.clientY - preview.top;
$('.preview_images_mask')
.on('mousemove', function (e) {
e = e || window.event;
var offsetX = e.clientX - preview.left - diffX,
offsetY = e.clientY - preview.top - diffY,
rotate = Math.abs(images_config.rotate / 90),
preview_width = rotate % 2 == 0 ? images_config.preview_width : images_config.preview_height,
preview_height = rotate % 2 == 0 ? images_config.preview_height : images_config.preview_width,
left,
top;
if (images_config.current_width > preview_width) {
var max_left = preview_width - images_config.current_width;
left = images_config.current_left + offsetX;
if (left > 0) {
left = 0;
} else if (left < max_left) {
left = max_left;
}
images_config.current_left = left;
}
if (images_config.current_height > preview_height) {
var max_top = preview_height - images_config.current_height;
top = images_config.current_top + offsetY;
if (top > 0) {
top = 0;
} else if (top < max_top) {
top = max_top;
}
images_config.current_top = top;
}
if (images_config.current_height > preview_height && images_config.current_top <= 0) {
if (images_config.current_height - preview_height <= images_config.current_top) {
images_config.current_top -= offsetY;
}
}
images.css({ left: images_config.current_left, top: images_config.current_top });
})
.on('mouseup', function () {
$(this).unbind('mousemove mouseup');
})
.on('dragstart', function () {
e.preventDefault();
});
})
.on('dragstart', function () {
return false;
});
//关闭预览图片
$('.preview_close').click(function (e) {
$('.preview_images_mask').remove();
});
//图片工具条预览
$('.preview_toolbar a').click(function () {
var index = $(this).index(),
images = $('#preview_images');
switch (index) {
case 0: //左旋转,一次旋转90度
case 1: //右旋转,一次旋转90度
images_config.rotate = index ? images_config.rotate + 90 : images_config.rotate - 90;
auto_images_size();
break;
case 2:
case 3:
if ((images_config.scale == 3 && index == 2) || (images_config.scale == 0.2 && index == 3)) {
layer.msg(images_config.scale >= 1 ? 'The image is the maximum size' : 'The image is the minimum size');
return false;
}
images_config.scale = (index == 2 ? Math.round((images_config.scale + 0.4) * 10) : Math.round((images_config.scale - 0.4) * 10)) / 10;
auto_images_size();
break;
case 4:
var scale_offset = images_config.rotate % 360;
if (scale_offset >= 180) {
images_config.rotate += 360 - scale_offset;
} else {
images_config.rotate -= scale_offset;
}
images_config.scale = 1;
auto_images_size();
break;
}
});
// 最大最小化图片
$('.preview_full,.preview_small').click(function () {
if ($(this).hasClass('preview_full')) {
$(this).addClass('hidden').prev().removeClass('hidden');
images_config.preview_width = that.area[0];
images_config.preview_height = that.area[1];
mask.css({ width: that.area[0], height: that.area[1], top: 0, left: 0, margin: 0 }).data('type', 'full');
auto_images_size();
} else {
$(this).addClass('hidden').next().removeClass('hidden');
$('.preview_images_mask').removeAttr('style');
images_config.preview_width = 750;
images_config.preview_height = 650;
auto_images_size();
}
});
// 上一张,下一张
$('.preview_cut_view a').click(function () {
var images_src = '',
preview_images = $('#preview_images'),
images_id = parseInt(preview_images.attr('data-index'));
if (!$(this).index()) {
images_id = images_id === 0 ? that.file_images_list.length - 1 : images_id - 1;
images_src = that.file_images_list[images_id];
} else {
images_id = images_id == that.file_images_list.length - 1 ? 0 : images_id + 1;
images_src = that.file_images_list[images_id];
}
preview_images.attr('data-index', images_id).attr('src', '/download?filename=' + images_src);
$('.preview_title').html(that.get_path_filename(images_src));
});
// 自动图片大小
function auto_images_size(transition) {
var rotate = Math.abs(images_config.rotate / 90),
preview_width = rotate % 2 == 0 ? images_config.preview_width : images_config.preview_height,
preview_height = rotate % 2 == 0 ? images_config.preview_height : images_config.preview_width,
preview_images = $('#preview_images'),
css_config = {};
images_config.init_width = images_config.natural_width;
images_config.init_height = images_config.natural_height;
if (images_config.init_width > preview_width) {
images_config.init_width = preview_width;
images_config.init_height = parseFloat(((preview_width / images_config.natural_width) * images_config.init_height).toFixed(2));
}
if (images_config.init_height > preview_height) {
images_config.init_width = parseFloat(((preview_height / images_config.natural_height) * images_config.init_width).toFixed(2));
images_config.init_height = preview_height;
}
images_config.current_width = parseFloat(images_config.init_width * images_config.scale);
images_config.current_height = parseFloat(images_config.init_height * images_config.scale);
images_config.current_left = parseFloat(((images_config.preview_width - images_config.current_width) / 2).toFixed(2));
images_config.current_top = parseFloat(((images_config.preview_height - images_config.current_height) / 2).toFixed(2));
css_config = {
width: images_config.current_width,
height: images_config.current_height,
top: images_config.current_top,
left: images_config.current_left,
display: 'inline',
transform: 'rotate(' + images_config.rotate + 'deg)',
opacity: 1,
transition: 'all 100ms',
};
if (transition === false) delete css_config.transition;
preview_images.css(css_config);
}
},
/**
* @description 打开视频播放
* @param {Object} data 当前文件的数据对象
* @return void
*/
open_video_play: function (data) {
var old_filename = data.path,
imgUrl = '/download?filename=' + data.path,
p_tmp = data.path.split('/'),
path = p_tmp.slice(0, p_tmp.length - 1).join('/');
layer.open({
type: 1,
closeBtn: 2,
title: 'Playing [' + p_tmp[p_tmp.length - 1] + ' ]',
area: ['890px', '402px'],
shadeClose: false,
skin: 'movie_pay',
content:
'\
Your browser does not support video tags\
',
success: function () {
$.post('/files?action=get_videos', { path: path }, function (rdata) {
var video_list =
'File name Size ',
index = 0;
for (var i = 0; i < rdata.length; i++) {
var filename = path + '/' + rdata[i].name;
if (filename === old_filename) index = i;
video_list +=
'' +
rdata[i].name +
' ' +
ToSize(rdata[i].size) +
' ';
}
video_list += '
';
$('.video-list')
.html(video_list)
.scrollTop(index * 34);
});
},
});
},
/**
* @description 切换播放
* @param {String} obj
* @param {String} filename 文件名
* @return void
*/
play_file: function (obj, filename) {
if ($('#btvideo video').attr('data-filename') == filename) return false;
var imgUrl = '/download?filename=' + filename + '&play=true';
var v = 'Your browser does not support the [video] tag. ';
$('#btvideo').html(v);
var p_tmp = filename.split('/');
$('.btvideo-title').html(p_tmp[p_tmp.length - 1]);
$('.video-avt').removeClass('video-avt');
$(obj).parents('tr').addClass('video-avt');
},
/**
* @description 复制文件和目录
* @param {Object} data 当前文件的数据对象
* @return void
*/
copy_file_or_dir: function (data) {
bt.set_cookie('record_paste', data.path);
bt.set_cookie('record_paste_type', 'copy');
$('.file_all_paste').removeClass('hide');
layer.msg('Copy successfully. Please click [Paste] or Ctrl + V to paste');
},
/**
* @description 剪切文件和目录
* @param {Object} data 当前文件的数据对象
* @return void
*/
cut_file_or_dir: function (data) {
bt.set_cookie('record_paste', data.path);
bt.set_cookie('record_paste_type', 'cut');
$('.file_all_paste').removeClass('hide');
layer.msg('Cut successfully. Please click [Paste] or Ctrl + V to paste');
},
/**
* @descripttion 粘贴文件和目录
* @return: 无返回值
*/
paste_file_or_dir: function () {
var that = this,
_isPaste = bt.get_cookie('record_paste_type'),
_paste = bt.get_cookie('record_paste'),
_filename = '';
if (_paste != 'null' && _paste != undefined) {
_filename = _paste.split('/').pop();
}
if (that.file_path.indexOf(_paste) > -1) {
layer.msg('Can not paste [' + _filename + '] here, Because the item cannot be pasted into itself.', { icon: 0 });
return false;
}
if (_isPaste != 'null' && _isPaste != undefined) {
switch (_isPaste) {
case 'cut':
case 'copy':
this.check_exists_files_req({ dfile: this.file_path, filename: _filename }, function (result) {
if (result.length > 0) {
var tbody = '';
for (var i = 0; i < result.length; i++) {
tbody += '' + result[i].filename + ' ' + ToSize(result[i].size) + ' ' + getLocalTime(result[i].mtime) + ' ';
}
var mbody =
'File name Size Last edit time \
' +
tbody +
' \
';
SafeMessage('This files will be overwritten', mbody, function () {
that.config_paste_to(_paste, _filename);
});
} else {
that.config_paste_to(_paste, _filename);
}
});
break;
case '1':
case '2':
that.batch_file_paste();
break;
}
}
},
/**
* @descripttion 粘贴到
* @param {String} path 复制/剪切路径
* @param {String} _filename 文件名称
* @return: 无返回值
*/
config_paste_to: function (path, _filename) {
var that = this,
_type = bt.get_cookie('record_paste_type');
this.$http(_type == 'copy' ? 'CopyFile' : 'MvFile', { sfile: path, dfile: this.file_path + '/' + _filename }, function (rdata) {
if (rdata.status) {
bt.set_cookie('record_paste', null);
bt.set_cookie('record_paste_type', null);
that.reader_file_list({ path: that.file_path });
}
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
},
/**
* @description 重命名文件和目录
* @param {Object} data 当前文件的数据对象
* @return void
*/
rename_file_or_dir: function (data) {
var that = this;
that.is_editor = true;
$('.file_list_content .file_tr:nth-child(' + (data.index + 1) + ')')
.addClass('editr_tr')
.find('.file_title')
.empty()
.append(
$(
bt.get_cookie('rank') == 'icon'
? '' + data.filename + ' '
: ' '
)
);
if (bt.get_cookie('rank') == 'icon') {
$('textarea[name=rename_file_input]').css({ height: $('textarea[name=rename_file_input]')[0].scrollHeight });
}
$((bt.get_cookie('rank') == 'icon' ? 'textarea' : 'input') + '[name=rename_file_input]')
.on('input', function () {
if (bt.get_cookie('rank') == 'icon') {
this.style.height = 'auto';
this.style.height = this.scrollHeight + 'px';
}
if (data.type == 'file') {
var ext_arry = $(this).val().split('.'),
ext = ext_arry[ext_arry.length - 1];
$(this)
.parent()
.prev()
.find('.file_icon')
.removeAttr('class')
.addClass('file_icon file_' + ext);
}
})
.keyup(function (e) {
if (e.keyCode == 13) $(this).blur();
e.stopPropagation();
e.preventDefault();
})
.blur(function () {
var _val = $(this)
.val()
.replace(/[\r\n]/g, ''),
config = { sfile: data.path, dfile: that.path_resolve(that.file_path, _val) };
if (data.filename == _val || _val == '') {
$('.file_list_content .file_tr:nth-child(' + (data.index + 1) + ')')
.removeClass('editr_tr')
.find('.file_title')
.empty()
.append($('' + data.filename + ' '));
that.is_editor = false;
return false;
}
if (that.match_unqualified_string(_val)) return layer.msg('The name cannot have /\\:*?"<>| symbol', { icon: 2 });
that.rename_file_req(config, function (res) {
that.reader_file_list({ path: that.file_path }, function () {
layer.msg(res.msg, { icon: res.status ? 1 : 2 });
});
});
that.is_editor = false;
})
.focus();
},
/**
* @description 设置文件和目录分享
* @param {Object} data 当前文件的数据对象
* @returns void
*/
set_file_share: function (data) {
var that = this;
this.loadY = bt.open({
type: 1,
shift: 5,
closeBtn: 2,
area: '450px',
title: 'Set share ' + data.type_tips + '-[' + data.filename + ']',
btn: ['Create', 'Cancel'],
content:
'' +
'' +
'' +
'' +
' ',
yes: function (indexs, layers) {
var ps = $('[name=ps]').val(),
expire = $('[name=expire]:checked').val(),
password = $('[name=password]').val();
if (ps === '') {
layer.msg('No sharing name!', { icon: 2 });
return false;
}
that.create_download_url(
{
filename: data.path,
ps: ps,
password: password,
expire: expire,
},
function (res) {
if (!res.status) {
layer.msg(res.msg, { icon: res.status ? 1 : 2 });
return false;
} else {
var rdata = res.msg;
that.file_list[data.index] = $.extend(that.file_list[data.index], { down_id: rdata.id, down_info: rdata });
that.loadY.close();
that.info_file_share(data);
that.reader_file_list_content(that.file_list);
}
}
);
},
success: function (layers, index) {
$('#random_paw').click(function () {
$(this).prev().val(bt.get_random(6));
});
},
});
},
/**
* @description 分享信息查看
* @param {Object} data 当前文件的数据对象
* @returns void
*/
info_file_share: function (data) {
var that = this;
if (typeof data.down_info == 'undefined') {
this.get_download_url_find({ id: data.down_id }, function (res) {
that.file_list[data.index] = $.extend(that.file_list[data.index], { down_info: res });
that.file_share_view(that.file_list[data.index], 'fonticon');
});
return false;
}
this.file_share_view(data, 'fonticon');
},
/**
* @description 分享信息视图
* @param {Object} data 当前文件的数据对象
* @param {String} type 区别通过右键打开或是图标点击
* @returns void
*/
file_share_view: function (datas, type) {
var data = datas;
if (type == 'fonticon') {
data = datas.down_info;
}
var that = this,
download_url = location.origin + '/down/' + data.token;
this.loadY = bt.open({
type: 1,
shift: 5,
closeBtn: 2,
area: '550px',
title: 'Share details-[' + data.filename + ']',
content:
'',
success: function (layers, index) {
var copy_url = new ClipboardJS('.copy_url');
var copy_paw = new ClipboardJS('.copy_paw');
copy_url.on('success', function (e) {
layer.msg('Copy link succeeded!', { icon: 1 });
e.clearSelection();
});
copy_paw.on('success', function (e) {
layer.msg('Copy link and extraction code succeeded!', { icon: 1 });
e.clearSelection();
});
$('.layer_close').click(function () {
layer.close(index);
});
$('.QR_code').click(function () {
layer.closeAll('tips');
layer.tips('
', '.QR_code', {
area: ['150px', '150px'],
tips: [1, '#ececec'],
time: 0,
shade: [0.05, '#000'],
shadeClose: true,
success: function () {
jQuery('#QR_code').qrcode({
render: 'canvas',
text: download_url,
height: 130,
width: 130,
});
},
});
});
$('.close_down').click(function () {
that.remove_download_url({ id: data.id, fileName: data.filename }, function (res) {
that.loadY.close();
if (type == 'fonticon') {
that.file_list[datas.index].down_id = 0;
that.reader_file_list_content(that.file_list);
}
if (type == 'list') {
that.render_share_list();
}
layer.msg(res.msg, { icon: res.status ? 1 : 2 });
});
});
},
});
},
/**
* @description 删除文件和目录
* @param {Object} data 当前文件的数据对象
* @return void
*/
del_file_or_dir: function (data) {
var that = this;
if (that.is_recycle) {
bt.confirm(
{
title: 'Delete ' + data.type_tips + '[ ' + data.filename + ' ]',
msg: 'Confirm delete ' + data.type_tips + '[ ' + data.path + ' ],it will move to recycle bin after delete, continue? ',
},
function () {
that.del_file_req(data, function (res) {
that.reader_file_list({ path: that.file_path });
layer.msg(res.msg, { icon: res.status ? 1 : 2 });
});
}
);
} else {
bt.show_confirm(
'Delete ' + data.type_tips + '[ ' + data.filename + ' ]',
'Recycle bin is not currently open, delete ' +
(data.type == 'dir' ? 'directory' : 'file') +
' cannot be restored after, continue? ',
function () {
that.del_file_req(data, function (res) {
that.reader_file_list({ path: that.file_path });
layer.msg(res.msg, { icon: res.status ? 1 : 2 });
});
}
);
}
},
/**
* @description 取消文件收藏
* @param {Object} data 当前文件的数据对象
* @param {Object} el 当前元素对象
* @returns void
*/
cancel_file_favorites: function (data) {
var that = this,
index = data.index;
this.loadY = bt.confirm({ title: data['filename'] + lan.files.unfavorite1, msg: lan.files.unfavorite1 + ' [' + data['path'] + '] ' + lan.files.continue }, function () {
that.$http('del_files_store', { path: data.path }, function (res) {
if (res.status) {
that.file_list[index].caret = false;
that.reader_file_list_content(that.file_list);
that.load_favorites_index_list();
}
layer.msg(res.msg, { icon: res.status ? 1 : 2 });
});
});
},
/**
* @description 创建软链接
* @param {Object} data 当前文件的数据对象
*/
set_soft_link: function (data) {
var that = this;
bt_tools.open({
title: 'Create Softlink',
area: '520px',
content: {
class: 'pd20',
formLabelWidth: '110px',
form: [
{
label: 'Source file',
group: {
type: 'text',
name: 'sfile',
width: '280px',
placeholder: 'Please select the folder and file to be linked',
icon: { type: 'glyphicon-folder-open', event: function (ev) {}, select: 'all' },
value: '',
input: function (ev) {},
},
},
{
label: 'Softlink name',
group: {
type: 'text',
name: 'name',
width: '280px',
placeholder: 'Please enter the name of the softlink',
value: '',
},
},
],
},
init: function () {
var e = null,
t = setInterval(function () {
if (($('input[name="sfile"]').length < 1 && clearInterval(t), e != $('input[name="sfile"]').val())) {
e = $('input[name="sfile"]').val();
var i = e.split('/');
i.length > 1 && $('[name="name"]').val(i[i.length - 1]);
}
}, 100);
},
yes: function (e, i, a) {
(e = $.extend(e, { dfile: that.file_path + '/' + e.name })),
delete e.name,
bt_tools.send(
'files/CreateLink',
e,
function (e) {
e.status && (layer.close(i), bt.msg(e), that.reader_file_list());
},
{
tips: 'Create Softlink',
}
);
},
});
},
/**
* @description 设置文件权限 - ok
* @param {Object} data 当前文件的数据对象
* @param {Boolean} isPatch 是否多选
* @returns void
*/
set_file_authority: function (data, isPatch) {
var that = this;
that.get_file_authority({ path: data.path }, function (rdata) {
var tex =
'';
that.loadY = layer.open({
type: 1,
closeBtn: 2,
title: lan.files.set_auth + '[' + data.filename + ']',
area: '465px',
shadeClose: false,
content:
'',
success: function (index, layers) {
that.edit_access_authority();
$('#access').keyup(function () {
that.edit_access_authority();
});
$('input[type=checkbox]').change(function () {
var idName = ['owner', 'group', 'public'];
var onacc = '';
for (var n = 0; n < idName.length; n++) {
var access = 0;
access += $('#' + idName[n] + '_x').prop('checked') ? 1 : 0;
access += $('#' + idName[n] + '_w').prop('checked') ? 2 : 0;
access += $('#' + idName[n] + '_r').prop('checked') ? 4 : 0;
onacc += access;
}
$('#access').val(onacc);
});
//提交
$('.set_access_authority').click(function () {
var chmod = $('#access').val();
var chown = $('#chown').val();
var all = $('#accept_all').prop('checked') ? 'True' : 'False';
var _form = {};
_form = {
user: chown,
access: chmod,
all: all,
};
if (isPatch) {
_form['type'] = data.type;
_form['path'] = data.path;
_form['data'] = data.filelist;
} else {
_form['filename'] = data.path;
}
that.$http(isPatch ? 'SetBatchData' : 'SetFileAccess', _form, function (res) {
if (res.status) {
layer.close(layers);
that.reader_file_list({ path: that.file_path, is_operating: false });
}
layer.msg(res.msg, { icon: res.status ? 1 : 2 });
});
});
$('.layer_close').click(function () {
layer.close(layers);
});
that.$http('get_path_premissions', { path: data.path }, function (edata) {
if (edata.length == 0) $('.backuptip').text('No backup');
});
$('button.restore').click(function () {
that.backup_files_permission(data.path, 1);
});
$('.tolist').click(function () {
$('.backup-list').click();
});
$('.bt_tab_list .bt_tab_index').click(function () {
$(this).addClass('active').siblings().removeClass('active');
if ($(this).index() == 0) {
$('.backup_lists').empty();
$('.chmodset').show();
} else {
that.backup_files_list(data.path);
}
});
},
});
});
},
/**
* 购买引导判定
* @param {Object} item 数据对象
* @param {number} source 来源
* @param {Object} config 配置对象
**/
check_ltd_end: function (item, source, config) {
var ltd_cookie = bt.get_cookie('pro_end') > 0;
if (!ltd_cookie) {
bt.soft.product_pay_view({
totalNum: source,
limit: 'pro',
closePro: true,
pluginName: item.pluginName,
fun: function () {
product_recommend.recommend_product_view(item, config, 'pro', source, 'pro', true);
},
});
return false;
}
return true;
},
/**
* @description 备份权限弹窗
* @returns void
*/
backup_files_permission: function (file, type) {
//文件夹type为0
var sub_type = 1;
if (type == 1) {
sub_type = $('#accept_all').prop('checked') ? 1 : 0;
}
// if (file == '' || typeof (file) == 'undefined') {
// layer.msg('Please select a directory or file', {
// icon: 2,
// time: 1900
// });
// return false;
// }
var that = this;
var layerss = layer.open({
type: 1,
closeBtn: 2,
title: 'Confirm backup?',
area: '300px',
shadeClose: false,
btn: ['Yes', 'No'],
content:
'\
Please enter the current backup name
\
Remarks\
\
\
',
yes: function (layerss, index) {
$('.layer_close').click(function () {
layer.close(index);
});
that.$http('back_path_permissions', { back_sub_dir: sub_type, path: file, remark: $('input.form-control').val() }, function (edata) {
layer.close(layerss);
if (!edata.status) {
layer.msg(edata.msg, {
time: 1900,
icon: 2,
});
return false;
}
if (type == 0) {
var new_back = that.backup_list();
$('.buplist').html(new_back);
} else if (type == 3) {
var chmod = $('#access').val();
var chown = $('#chown').val();
var all = $('#accept_all').prop('checked') ? 'True' : 'False';
var data = 'filename=' + encodeURIComponent(file) + '&user=' + chown + '&access=' + chmod + '&all=' + all;
Oksend(data);
layer.closeAll();
}
layer.msg(edata.msg, {
time: 1900,
icon: 1,
});
});
},
btn2: function () {
layer.close(layerss);
},
cancel: function () {
layer.close(layerss);
},
});
},
/**
* @description 全部备份权限列表
* @returns void
*/
backup_list: function () {
var all_back = '',
that = this;
that.$http('get_all_back', function (edata) {
for (var i = 0; i < edata.length; i++) {
var d = new Date(edata[i][2] * 1000);
var minut = d.getMinutes();
var hours = d.getHours();
var second = d.getSeconds();
if (minut <= 9) minut = '0' + minut + '';
if (hours <= 9) hours = '0' + hours + '';
if (second <= 9) second = '0' + second + '';
var date = d.getFullYear() + '/' + (d.getMonth() + 1) + '/' + d.getDate() + ' ' + hours + ':' + minut + ':' + second;
all_back +=
'\
' +
date +
' \
\
' +
edata[i][3] +
' \
\
' +
edata[i][1] +
' \
Del \
';
}
$('.allback .buplist').html(all_back);
});
},
/**
* @description 全部备份权限弹窗
* @returns void
*/
manage_backup: function () {
var that = this;
var layerss = layer.open({
type: 1,
closeBtn: 2,
title: 'Manage Backups',
area: ['630px', '500px'],
shadeClose: false,
content:
'\
\
\
\
\
Backup time \
Backup path \
Name \
Delect \
\
\
\
\
',
cancel: function () {
layer.close(layerss);
},
success: function () {
that.backup_list();
$('#btn-backup').click(function (e) {
var backup_path = $('#server_path').val();
that.backup_files_permission(backup_path, 0);
});
$('.allback').on('click', '.del_back', function () {
var _id = $(this).parents('tr').attr('data-id');
that.del_backup(_id);
});
},
});
},
/**
* @description 删除备份
* @returns void
*/
del_backup: function (id) {
var that = this;
layer.confirm('The backup cannot be restored after deletion. Continue to delete?', { title: 'Confirm delete?', btn: ['Yes', 'No'], closeBtn: 2 }, function (index, layero) {
that.$http('del_path_premissions', { id: id }, function (edata) {
var file = $('.layui-layer-title:eq(0)').text();
if (file !== 'Manage Backups') {
file = $('.backup_list').attr('data-path');
that.backup_files_list(file);
} else {
$('.allback tbody tr[data-id=' + id + ']').remove();
}
layer.msg(edata.msg, { icon: edata.status ? 1 : 2 });
});
});
},
/**
* @description 本文件备份列表
* @returns void
*/
backup_files_list: function (fileName) {
var that = this;
that.$http('get_path_premissions', { path: fileName }, function (edata) {
var tbody = '',
cont = '';
if (edata.length == 0) {
tbody = 'No data ';
} else {
for (var i = 0; i < edata.length; i++) {
var d = new Date(edata[i][3] * 1000),
minut = d.getMinutes(),
hours = d.getHours();
if (minut <= 9) minut = '0' + minut + '';
if (hours <= 9) hours = '0' + hours + '';
var date = d.getFullYear() + '/' + (d.getMonth() + 1) + '/' + d.getDate();
tbody +=
'\
' +
edata[i][4] +
' \
' +
edata[i][2] +
' \
' +
edata[i][1] +
' \
' +
date +
' \
Restore | Del \
';
}
}
cont =
'\
\
\
Fix all permissions to [ Folder: 755, File: 644 ] \
Fix permissions \
\
\
\
\
Name \
permission \
Owner \
Backup Time \
Opt \
\
\
\
' +
tbody +
'\
\
\
';
$('.chmodset').hide();
$('.backup_lists').html(cont);
$('.fixper').click(function () {
layer.confirm(
'Note: Under the file or folder all permissions will be fixed to [ Folder: 755, File: 644 ]',
{ title: 'Fix Permissions?', btn: ['Confirm', 'Cancel'], closeBtn: 2 },
function (index, layero) {
that.$http('fix_permissions', { path: fileName }, function (res) {
layer.closeAll();
that.reader_file_list({ path: that.file_path, is_operating: false });
layer.msg(res.msg, { icon: res.status ? 1 : 2 });
});
}
);
});
$('.restore_backup').click(function () {
that.restore_file_permission($(this).attr('data-time'), fileName);
});
$('.backup_list').on('click', '.del_back', function () {
var _id = $(this).attr('data-id');
that.del_backup(_id);
});
});
},
/**
* @description 权限备份的还原
* @returns void
*/
restore_file_permission: function (restore_time, fileName) {
var that = this,
sub_type = $('#accept_all').prop('checked') ? 1 : 0;
var layerss = layer.open({
type: 1,
closeBtn: 2,
title: 'Confirm restore',
area: '330px',
shadeClose: false,
btn: ['Yes', 'No'],
content:
'\
Restore would overwrite the current settings, continue?\
',
yes: function (layerss, index) {
that.$http('restore_path_permissions', { restore_sub_dir: sub_type, date: restore_time, path: fileName }, function (edata) {
layer.closeAll();
layer.msg(edata.msg, {
icon: 1,
time: 1900,
});
});
},
btn2: function () {
layer.close(layerss);
},
cancel: function () {
layer.close(layerss);
},
});
},
/**
* @description 获取实时任务视图
* @returns void
*/
get_present_task_view: function () {
this.file_present_task = layer.open({
type: 1,
title: 'Real-time task queue',
area: '500px',
closeBtn: 2,
skin: 'present_task_list',
shadeClose: false,
shade: false,
offset: 'auto',
content: '
',
});
},
/**
* @description 渲染实时任务列表数据
* @returns void
*/
render_present_task_list: function () {
var that = this;
this.get_task_req({ status: -3 }, function (lists) {
if (lists.length == 0) {
layer.close(that.file_present_task);
that.file_present_task = null;
that.reader_file_list({ path: that.file_path, is_operating: false });
return;
}
var task_body = '',
is_add = false;
$.each(lists, function (index, item) {
if (item.status == -1) {
if (!that.file_present_task) that.get_present_task_view();
if (item.type == '1') {
task_body +=
'\
\
\
' +
lan.layout.download +
item.shell +
' ' +
item.log.pre +
'% ' +
lan.public.cancel +
'
\
\
' +
item.log.used +
'/' +
ToSize(item.log.total) +
' ' +
(item.log.speed == 0 ? lan.layout.connect : item.log.speed) +
'/s ' +
lan.files.expected_to_be +
': ' +
item.log.time +
'
\
\
\
';
} else {
task_body +=
'' +
item.name +
': ' +
item.shell +
' ' +
lan.public.cancel +
'
\
\
' +
item.log +
'\
';
}
} else {
if (!is_add) {
task_body += '' + lan.layout.wait_task + '
';
is_add = true;
}
task_body +=
'' +
item.name +
': ' +
item.shell +
' X ';
}
});
if (that.file_present_task) {
if (is_add) task_body += ' ';
$('.message-list').html(task_body);
}
setTimeout(function () {
that.render_present_task_list();
}, 1000);
});
},
/**
* @description 取消实时任务列表
* @returns void
*/
remove_present_task: function (id) {
var that = this;
layer.confirm(
'Do you want to cancel the current task queue?',
{
title: 'Cancel task queue',
icon: 0,
},
function (indexs) {
layer.close(indexs);
var loadT = bt.load('Canceling task...');
$.post(
'/task?action=remove_task',
{
id: id,
},
function (rdata) {
loadT.close();
bt.msg(rdata);
}
);
}
);
},
/**
* @descripttion 设置访问权限
* @returns void
*/
edit_access_authority: function () {
var access = $('#access').val();
var idName = ['owner', 'group', 'public'];
for (var n = 0; n < idName.length; n++) {
$('#' + idName[n] + '_x').prop('checked', false);
$('#' + idName[n] + '_w').prop('checked', false);
$('#' + idName[n] + '_r').prop('checked', false);
}
for (var i = 0; i < access.length; i++) {
var onacc = access.substr(i, 1);
if (i > idName.length) continue;
if (onacc > 7) $('#access').val(access.substr(0, access.length - 1));
switch (onacc) {
case '1':
$('#' + idName[i] + '_x').prop('checked', true);
break;
case '2':
$('#' + idName[i] + '_w').prop('checked', true);
break;
case '3':
$('#' + idName[i] + '_x').prop('checked', true);
$('#' + idName[i] + '_w').prop('checked', true);
break;
case '4':
$('#' + idName[i] + '_r').prop('checked', true);
break;
case '5':
$('#' + idName[i] + '_r').prop('checked', true);
$('#' + idName[i] + '_x').prop('checked', true);
break;
case '6':
$('#' + idName[i] + '_r').prop('checked', true);
$('#' + idName[i] + '_w').prop('checked', true);
break;
case '7':
$('#' + idName[i] + '_r').prop('checked', true);
$('#' + idName[i] + '_w').prop('checked', true);
$('#' + idName[i] + '_x').prop('checked', true);
break;
}
}
},
/**
* @description 获取文件权限 - ok
* @param {Object} data 当前文件的数据对象
* @param {Object} el 当前元素对象
* @returns void
*/
get_file_authority: function (data, callback) {
this.$http('GetFileAccess', { filename: data.path }, function (rdata) {
if (callback) callback(rdata);
});
},
/**
* @description 文件夹目录查杀
* @param {Object} data 当前文件的数据对象
* @returns void
*/
set_dir_kill: function (data) {
var that = this;
if (data.ext == 'php') {
that.$http('file_webshell_check', { filename: data.path }, function (rdata) {
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
} else {
layer.confirm('目录查杀将包含子目录中的php文件,是否操作?', { title: '目录查杀[' + data['filename'] + ']', closeBtn: 2, icon: 3 }, function (index) {
that.$http('dir_webshell_check', { path: data.path }, function (rdata) {
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
});
}
},
/**
* @description 文件路径合并
* @param {String} paths 旧路径
* @param {String} param 新路径
* @return {String} 新的路径
*/
path_resolve: function (paths, param) {
var path = '',
split = '';
if (!Array.isArray(param)) param = [param];
paths.replace(/([\/|\/]*)$/, function ($1) {
split = $1;
return 'www';
});
$.each(param, function (index, item) {
path += '/' + item;
});
return (paths + path).replace('//', '/');
},
/**
* @descripttion 取扩展名
* @return: 返回扩展名
*/
get_ext_name: function (fileName) {
var extArr = fileName.split('.');
var exts = [
'folder',
'folder-unempty',
'sql',
'c',
'cpp',
'cs',
'flv',
'css',
'js',
'htm',
'html',
'java',
'log',
'mht',
'php',
'url',
'xml',
'ai',
'bmp',
'cdr',
'gif',
'ico',
'jpeg',
'jpg',
'JPG',
'png',
'psd',
'webp',
'ape',
'avi',
'mkv',
'mov',
'mp3',
'mp4',
'mpeg',
'mpg',
'rm',
'rmvb',
'swf',
'wav',
'webm',
'wma',
'wmv',
'rtf',
'docx',
'fdf',
'potm',
'pptx',
'txt',
'xlsb',
'xlsx',
'7z',
'cab',
'iso',
'rar',
'zip',
'gz',
'bt',
'file',
'apk',
'bookfolder',
'folder-empty',
'fromchromefolder',
'documentfolder',
'fromphonefolder',
'mix',
'musicfolder',
'picturefolder',
'videofolder',
'sefolder',
'access',
'mdb',
'accdb',
'fla',
'doc',
'docm',
'dotx',
'dotm',
'dot',
'pdf',
'ppt',
'pptm',
'pot',
'xls',
'csv',
'xlsm',
];
var extLastName = extArr[extArr.length - 1];
for (var i = 0; i < exts.length; i++) {
if (exts[i] == extLastName) {
return exts[i];
}
}
return 'file';
},
/**
* @description 获取路径上的文件名称
* @param {String} path 路径
* @return {String} 文件名称
*/
get_path_filename: function (path) {
var paths = path.split('/');
return paths[paths.length - 1];
},
/**
* @description 返回上一层目录地址
* @param {String} path 当前路径
* @returns 返回上一层地址
*/
retrun_prev_path: function (path) {
var dir_list = path.split('/');
dir_list.splice(dir_list.length - 1);
if (dir_list == '') dir_list = ['/'];
return dir_list.join('/');
},
/**
* @descripttion: 路径过滤
* @return: 无返回值
*/
path_check: function (path) {
path = path.replace('//', '/');
if (path === '/') return path;
path = path.replace(/\/+$/g, '');
return path;
},
/**
* @description 获取文件权限信息
* @param {Object} data 请求传入参数
* @param {Function} callback 回调参数
* @returns void
*/
get_file_access: function (data, callback) {
var that = this;
this.layerT = bt.load('Getting file permissions, please wait...');
bt.send('GetFileAccess', 'files/GetFileAccess', { path: data.path }, function (res) {
that.loadT.close();
if (callback) callback();
});
},
/**
* @description 创建外链下载
* @param {Object} data 请求传入参数
* @param {Function} callback 回调参数
* @returns void
*/
create_download_url: function (data, callback) {
var that = this;
this.layerT = bt.load('sharing file, please wait...');
bt.send('create_download_url', 'files/create_download_url', { filename: data.filename, ps: data.ps, password: data.password, expire: data.expire }, function (res) {
that.layerT.close();
if (callback) callback(res);
});
},
/**
* @description 获取外链下载数据
* @param {Object} data 请求传入参数
* @param {Function} callback 回调参数
* @returns void
*/
get_download_url_find: function (data, callback) {
var that = this;
this.layerT = bt.load('Getting sharing file datals, please wait...');
bt.send('get_download_url_find', 'files/get_download_url_find', { id: data.id }, function (res) {
that.layerT.close();
if (callback) callback(res);
});
},
/**
* @description 删除外链下载
* @param {Object} data 请求传入参数
* @param {Function} callback 回调参数
* @returns void
*/
remove_download_url: function (data, callback) {
var that = this;
layer.confirm('Confirm to stop sharing【' + data.fileName + '】, continue?', { title: 'Cancel sharing', closeBtn: 2, icon: 3 }, function () {
this.layerT = bt.load('Canceling sharing files, please wait...');
bt.send('remove_download_url', 'files/remove_download_url', { id: data.id }, function (res) {
if (callback) callback(res);
});
});
},
/**
* @description 获取磁盘列表
* @param {Function} callback 回调参数
* @returns void
*/
get_disk_list: function (callback) {
bt_tools.send(
'system/GetDiskInfo',
function (res) {
if (callback) callback(res);
},
'Getting disk list'
);
},
// 新建文件(文件和文件夹)
create_file_req: function (data, callback) {
var _req = data.type === 'folder' ? 'CreateDir' : 'CreateFile';
bt.send(
_req,
'files/' + _req,
{
path: data.path,
},
function (res) {
if (callback) callback(res);
}
);
},
// 重命名文件(文件或文件夹)
rename_file_req: function (data, callback) {
bt_tools.send(
'files/MvFile',
{
sfile: data.sfile,
dfile: data.dfile,
rename: data.rename || true,
},
function (res) {
if (callback) callback(res);
},
'Renaming'
);
},
// 剪切文件请求(文件和文件夹)
shear_file_req: function (data, callback) {
this.rename_file_req(
{
sfile: data.sfile,
dfile: data.dfile,
rename: false,
},
function (res) {
if (callback) callback(res);
},
'Cutting'
);
},
// 检查文件是否存在(复制文件和文件夹前需要调用)
check_exists_files_req: function (data, callback) {
var layerT = bt.load('Checking files, please wait...');
bt.send(
'CheckExistsFiles',
'files/CheckExistsFiles',
{
dfile: data.dfile,
filename: data.filename,
},
function (res) {
layerT.close();
if (callback) callback(res);
}
);
},
// 复制文件(文件和文件夹)
copy_file_req: function (data, callback) {
bt.send(
'CopyFile',
'files/CopyFile',
{
sfile: data.sfile,
dfile: data.dfile,
},
function (res) {
if (callback) callback(res);
}
);
},
// 压缩文件(文件和文件夹)
compress_file_req: function (data, callback) {
bt.send(
'Zip',
'files/Zip',
{
sfile: data.sfile,
dfile: data.dfile,
z_type: data.z_type,
path: data.path,
},
function (res) {
if (callback) callback(res);
}
);
},
// 获取实时任务
get_task_req: function (data, callback) {
bt.send(
'get_task_lists',
'task/get_task_lists',
{
status: data.status,
},
function (res) {
if (callback) callback(res);
}
);
},
// 获取文件权限
get_file_access: function () {
bt.send(
'GetFileAccess',
'files/GetFileAccess',
{
filename: data.filename,
},
function (res) {
if (callback) callback(res);
}
);
},
// 设置文件权限
set_file_access: function () {
bt.send(
'SetFileAccess',
'files/SetFileAccess',
{
filename: data.filename,
user: data.user,
access: data.access,
all: data.all,
},
function (res) {
if (callback) callback(res);
}
);
},
/**
* @description 删除文件(文件和文件夹)
* @param {Object} data 文件目录参数
* @param {Function} callback 回调函数
* @return void
*/
del_file_req: function (data, callback) {
var _req = data.type === 'dir' ? 'DeleteDir' : 'DeleteFile';
var layerT = bt.load('Deleting file, please wait...');
bt.send(_req, 'files/' + _req, { path: data.path }, function (res) {
layerT.close();
layer.msg(res.msg, { icon: res.status ? 1 : 2 });
if (callback) callback(res);
});
},
/**
* @description 下载文件
* @param {Object} 文件目录参数
* @param {Function} callback 回调函数
* @return void
*/
down_file_req: function (data, callback) {
window.open('/download?filename=' + encodeURIComponent(data.path));
},
/**
* @description 获取文件大小(文件夹)
* @param {*} data 文件目录参数
* @param {Function} callback 回调函数
* @return void
*/
get_file_size: function (data, callback) {
bt_tools.send('files/get_path_size', { path: data.path }, callback, 'Getting directory size');
},
/**
* @description 获取目录大小
* @param {*} data 文件目录地址
* @return void
*/
get_dir_size: function (data, callback) {
bt_tools.send(
'files/GetDirSize',
{ path: data.path },
function (rdata) {
$('#file_all_size').text(rdata);
if (callback) callback(rdata);
},
{ tips: 'Counting, please wait...', verify: true }
);
},
/**
* @description 获取文件目录
* @param {*} data 文件目录参数
* @param {Function} callback 回调函数
*/
get_dir_list: function (data, callback) {
var that = this,
f_sort = bt.get_cookie('files_sort');
if (f_sort) {
data['sort'] = f_sort;
data['reverse'] = bt.get_cookie('name_reverse');
}
bt_tools.send('files/GetDir', $.extend({ p: 1, showRow: bt.get_storage('local', 'showRow') || that.file_page_num, path: bt.get_cookie('Path') || data.path }, data), callback, { tips: false });
},
/**
* @description 文件、文件夹压缩
* @param {Object} data 文件目录参数
* @param {Boolean} isbatch 是否批量操作
*/
compress_file_or_dir: function (data, isbatch) {
var that = this;
$('.selection_right_menu').removeAttr('style');
this.reader_form_line(
{
url: 'Zip',
overall: { width: '310px' },
data: [
{
label: 'Compress type',
type: 'select',
name: 'z_type',
value: data.open,
list: [
['tar_gz', 'tar.gz'],
['zip', 'zip'],
['rar', 'rar'],
],
},
{ label: 'Compress path', id: 'compress_path', name: 'dfile', placeholder: 'URL address', value: data.path + '.' + (data.open == 'tar_gz' ? 'tar.gz' : data.open) },
],
beforeSend: function (updata) {
var ind = data.path.lastIndexOf('/'),
_url = data.path.substring(0, ind + 1); // 过滤路径文件名
return { sfile: data.filename, dfile: updata.dfile, z_type: updata.z_type == 'tar_gz' ? 'tar.gz' : updata.z_type, path: _url };
},
},
function (form, html) {
var loadT = layer.open({
type: 1,
title: 'Compress ' + data.type_tips + '[ ' + data.filename + ' ]',
area: '520px',
shadeClose: false,
closeBtn: 2,
skin: 'compress_file_view',
btn: ['Compress', 'Close'],
content: html[0].outerHTML,
success: function () {
// 切换压缩格式
$('select[name=z_type]').change(function () {
var _type = $(this).val(),
_inputVel = $('input[name=dfile]').val(),
path_list = [];
_type == 'tar_gz' ? 'tar.gz' : _type;
_inputVel = _inputVel.substring(0, _inputVel.lastIndexOf('/'));
path_list = _inputVel.split('/');
$('input[name=dfile]').val(_inputVel + '/' + (isbatch ? path_list[path_list.length - 1] : data.filename) + '.' + _type);
});
// 插入选择路径
$('.compress_file_view .line:nth-child(2)')
.find('.info-r')
.append(' ');
},
yes: function () {
var ress = form.getVal();
if (ress.dfile == '') return layer.msg('Please select a valid address', { icon: 2 });
form.submitForm(function (res, datas) {
setTimeout(function () {
that.reader_file_list({ path: datas.path });
}, 1000);
if (res == null || res == undefined) {
layer.msg(lan.files.zip_ok, { icon: 1 });
}
if (res.status) {
that.render_present_task_list();
}
layer.close(loadT);
});
},
});
}
);
},
/**
* @description 文件、文件夹解压
* @param {*} data 文件目录参数
*/
unpack_file_to_path: function (data) {
var that = this,
_type = 'zip',
spath = '';
spath = data.path.substring(0, data.path.lastIndexOf('/'));
this.reader_form_line(
{
url: 'UnZip',
overall: { width: '310px' },
data: [
{ label: 'File name', name: 'z_name', placeholder: 'Compress file name', value: data.path },
{ label: 'Compress path', name: 'z_path', placeholder: 'Compress path', value: spath },
{
label: 'Encoding',
name: 'z_code',
type: 'select',
value: 'UTF-8',
list: [
['UTF-8', 'UTF-8'],
['gb18030', 'GBK'],
],
},
],
beforeSend: function (updata) {
return { sfile: updata.z_name, dfile: updata.z_path, type: _type, coding: updata.z_code, password: updata.z_password };
},
},
function (form, html) {
var loadT = layer.open({
type: 1,
title: 'Decompress file',
area: '520px',
shadeClose: false,
closeBtn: 2,
skin: 'unpack_file_view',
btn: ['Confirm', 'Cancel'],
content: html[0].outerHTML,
success: function () {
if (data.ext == 'gz') _type = 'tar'; //解压格式
if (_type == 'zip') {
// 判断是否插入解压密码
$('.unpack_file_view .line:nth-child(2)').append(
''
);
}
},
yes: function () {
var ress = form.getVal();
if (ress.z_name == '') return layer.msg('Please enter the file name path', { icon: 2 });
if (ress.z_path == '') return layer.msg('Please enter the decompression address', { icon: 2 });
form.submitForm(function (res, datas) {
layer.close(loadT);
setTimeout(function () {
that.reader_file_list({ path: datas.path });
}, 1000);
if (res.status) {
that.render_present_task_list();
}
layer.msg(res.msg, { icon: res.status ? 1 : 2 });
});
},
});
}
);
},
/**
* @description 匹配非法字符
* @param {Array} item 配置对象
* @return 返回匹配结果
*/
match_unqualified_string: function (item) {
var containSpecial = RegExp(/[(\*)(\|)(\\)(\:)(\")(\/)(\<)(\>)(\?)(\)]+/);
return containSpecial.test(item);
},
/**
* @description 渲染表单
* @param {Array} config 配置对象
* @param {Function} callback 回调函数
* @return void
*/
reader_form_line: function (config, callback) {
var that = this,
random = bt.get_random(10),
html = $(' '),
data = config,
eventList = [],
that = this;
if (!Array.isArray(config)) data = config.data;
$.each(data, function (index, item) {
var labelWidth = item.labelWidth || config.overall.labelWidth || null,
event_random = bt.get_random(10),
width = item.labelWidth || config.overall.width || null,
form_line = $('' + (item.label || '') + '
'),
form_el = $(
(function () {
switch (item.type) {
case 'select':
return (
'' +
(function (item) {
var options_list = '';
$.each(item.list, function (key, items) {
if (!Array.isArray(items)) {
//判断是否为二维数组
options_list += '' + items + ' ';
} else {
options_list += '' + items[1] + ' ';
}
});
return options_list;
})(item) +
' '
);
break;
case 'text':
default:
return (
' '
);
break;
}
})(item)
);
if (item.eventType || item.event) {
if (!Array.isArray(item.eventType)) item.eventType = [item.eventType];
$.each(item.eventType, function (index, items) {
eventList.push({ el: event_random, type: items || 'click', event: item[items] || null });
if (config.el) {
var els = $('[data-event="' + item.el + '"]');
if (item[items]) {
if (items == 'enter') {
els.on('keyup', function (e) {
if (e.keyCode == 13) item.event(e);
});
} else {
els.on(item || 'click', item.event);
}
} else {
if (items == 'focus') {
var vals = els.val();
if (vals != '') {
els.val('').focus().val(vals);
}
} else {
els[items]();
}
}
}
});
}
form_line.find('.info-r').append(form_el);
html.append(form_line);
});
if (config.el) $(config.el).empty().append(html);
if (callback)
callback(
{
// 获取内容
getVal: function () {
return $('#' + random).serializeObject();
},
// 设置事件,没有设置el参数,需要
setEvent: function () {
$.each(eventList, function (index, item) {
var els = $('[data-event="' + item.el + '"]');
if (item.event === null) {
if (item.type == 'focus') {
var vals = els.val();
if (vals != '') {
els.val('').focus().val(vals);
}
} else {
els[item.type]();
}
} else {
if (item.type == 'enter') {
els.on('keyup', function (e) {
if (e.keyCode == 13) item.event(e);
});
} else {
els.on(item.type, item.event);
}
}
});
},
// 提交表单
submitForm: function (callback) {
var data = this.getVal();
if (config.beforeSend) data = config.beforeSend(data);
that.loadT = bt.load('submitting the form, please wait...');
bt.send(config.url, 'files/' + config.url, data, function (rdata) {
that.loadT.close();
if (callback) callback(rdata, data);
});
},
},
html
);
},
/**
* @description 文件管理请求方法
* @param {*} data
* @param {*} data
* @param {*} callback
*/
$http: function (data, parem, callback) {
var that = this,
loadT = '';
if (typeof data == 'string') {
if (typeof parem != 'object') (callback = parem), (parem = {});
if (!Array.isArray(that.method_list[data])) that.method_list[data] = ['files', that.method_list[data]];
that.$http({ method: data, tips: that.method_list[data][1] ? that.method_list[data][1] : false, module: that.method_list[data][0], data: parem, msg: true }, callback);
} else {
if (typeof data.tips != 'undefined' && data.tips) loadT = bt.load(data.tips);
bt.send(data.method, (data.module || 'files') + '/' + data.method, data.data || {}, function (res) {
if (loadT != '') loadT.close();
if (typeof res == 'string') res = JSON.parse(res);
if (res.status === false && res.msg) {
bt.msg(res);
return false;
}
if (parem) parem(res);
});
}
},
};
// 获取支付状态
function getPaymentStatus() {
bt.send('get_pd', 'ajax/get_pd', {}, function (res) {
bt.set_cookie('pro_end', res[1]);
bt.set_cookie('ltd_end', res[2]);
});
}
getPaymentStatus();
bt_file.init();
Function.prototype.delay = function (that, arry, time) {
if (!Array.isArray(arry)) (time = arry), (arry = []);
if (typeof time == 'undefined') time = 0;
setTimeout(this.apply(that, arry), time);
return this;
};
jQuery.prototype.serializeObject = function () {
var a, o, h, i, e;
a = this.serializeArray();
o = {};
h = o.hasOwnProperty;
for (i = 0; i < a.length; i++) {
e = a[i];
if (!h.call(o, e.name)) {
o[e.name] = e.value;
}
}
return o;
};
Simpan