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91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
{% extends "layout.html" %}

{% block content %}
<div class="main-content pb55">
  <div class="container-fluid">
    <div class="pos-box bgw mtb15">
      <div class="tab-list">
        <div class="tabs-item active">{{data['lan']['H2']}}</div>
      </div>
    </div>
    <div class="safe bgw mtb15 pd15 tab-view-box">
      <div class="info-title-tips">
          <p><span class="glyphicon glyphicon-alert" style="color: #f39c12; margin-right: 10px;"></span>{{data['lan']['PS']}} ftp://{{session['address']}}:{{session['port']}}</p>
      </div>
      <div id="bt_ftp_table"></div>
    </div>
  </div>
</div>
{% endblock %}
{% block scripts %}
	{{ super() }}
<script type="text/javascript">

	bt.set_cookie('sites_path',"{{session['config']['sites_path']}}");
    {% if not data['isSetup'] %}
		layer.msg('{{data["lan"]["JS1"]}}<a href="javascript:;" onclick="bt.soft.install(\'pureftpd\');" style="color:#20a53a; float: right;">立即安装</a>',{icon:7,time:0,shade: [0.3, '#000']});
        $(".layui-layer-shade").css("margin-left", "180px");
    {% else %}
		var ftp_table = bt_tools.table({
			el:'#bt_ftp_table',
			url:'/data?action=getData',
			param:{table:'ftps'},
			minWidth:'1000px',
			autoHeight:true,
			default:"FTP列表为空",
			pageName: 'ftp',
			methods:{
				/**
					* @description 设置FTP端口
					* @param {function} callback 回调函数
					* @return void
				*/
				add_ftp_user:function(callback){
					var that = this;
					bt.ftp.add(function(rdata){
						if(callback) callback(rdata);
						if(rdata.status) that.$refresh_table_list(true);
					})
				},
				/**
				 * @description 设置FTP端口
				 * @param {object} obj 配置对象包含port
				 * @param {function} callback 回调函数
				 * @return void
				*/
				del_ftp_user:function(obj,callback){
					var that = this;
					bt.compute_confirm({title:"删除FTP账号【"+ obj.name +"】",msg:'删除选中的FTP账号后,该FTP账号将彻底删除并失去访问权限,是否继续操作?'},function(){
						bt.ftp.del(obj.id,obj.name,function(rdata){
							if(callback) callback(rdata);
							bt.msg(rdata);
						});
					});
				},
				/**
				 * @description 设置FTP密码
				 * @param {object} obj 配置对象包含id、name、password
				 * @param {function} callback 回调函数
				 * @return void
				*/
				set_ftp_password:function(obj,callback){
					var that = this,bs = bt.ftp.set_password(function(rdata){
						if(callback) callback(rdata);
					});
					$('.id'+bs).val(obj.id);
					$('.ftp_username'+bs).val(obj.name);
					$('.new_password'+bs).val(obj.password);
				},
				/**
				 * @description 设置FTP端口
				 * @param {object} obj 配置对象包含port
				 * @param {function} callback 回调函数
				 * @return void
				*/
				set_ftp_port:function(callback){
					var bs = bt.ftp.set_port(function(rdata){
						if(callback) callback(rdata);
						if (rdata.status) {
							setTimeout(function () {
								window.location.reload()
							}, 1000)
						}
					})
					$('.port'+bs).val('{{session["port"]}}');
				},
				/**
				 * @description 设置ftp状态
				 * @param {object} obj 配置对象包含id、username、status
				 * @param {function} callback 回调函数
				 * @return void
				*/
				set_ftp_status:function(obj,callback){
					if(!parseInt(obj.status)){
						bt.confirm({msg:'启用选中的FTP账号后,该FTP账号恢复访问权限,是否继续操作?',title:'启用FTP账号【'+ obj.name +'】'},function(index){
							bt.ftp.set_status(obj.id,obj.name,"1",function(rdata){
								if(callback) callback(rdata);
							});
						});
					}else{
						bt.confirm({msg:'停用选中的FTP账号后,该FTP账号将失去访问权限,是否继续操作?',title:'停用FTP账号【'+ obj.name +'】'},function(index){
							bt.ftp.set_status(obj.id,obj.name,"0",function(rdata){
								if(callback) callback(rdata);
							});
						});
					}
				}
			},
			column:[
				{type:'checkbox',width:20},
				{fid:'name',title:'用户名',type:'text'},
				{fid:'password',title:'密码',type:'password',copy:true,eye_open:true},
				{fid:'status',title:'状态',sort:true,width:100,config:{
					icon:true,list:[['1','已启用','bt_success','glyphicon-play'],['0','已停用','bt_danger','glyphicon-pause']]},type:'status',event:function(row,index,ev,key,that){
					that.set_ftp_status({id:row.id,status:row.status,name:row.name},function(res){
						if(res.status) that.$modify_row_data({status:parseInt(row.status)?'0':'1'});
					});
				}},
				{fid:'path',title:'根目录',type:'link',align:'left',
				event:function(row,index,ev){
						openPath(row.path)
        }},
				{
					// <span '+(bt.get_cookie('ltd_end')>0?' style="cursor:text" ':'onclick="bt.soft.product_pay_view({ totalNum: 51, limit: \'ltd\', closePro: true })"')+'  class="firwall_place_of_attribution"></span>
					title: '目录详情',
					width:120,
					type: 'text',
					template:function(row,index,ev){
						return bt.files.dir_details_span(row.path);
					},
				},
        bt.public.get_quota_config('ftp'),
				{fid:'ps',title:'备注',type:'input',blur:function(row,index,ev){
					bt.pub.set_data_ps({id:row.id,table:'ftps',ps:ev.target.value},function(res){
						bt_tools.msg(res);
					});
				},keyup:function(row,index,ev){
					if(ev.keyCode === 13){
						$(this).blur();
					}
				}},
				{title:'操作',type:'group',width:170,align:'right',group:[{
					title:'改密',event:function(row,index,ev,key,that){
						that.set_ftp_password({id:row.id,name:row.name,password:row.password},function(rdata){
							if(rdata.status) that.$refresh_table_list(true);
						});
					}
				}, {
					title: '日志', event: function (row, index, ev, key, that) {
						var ltd = parseInt(bt.get_cookie('ltd_end')  || -1)
        				if(ltd > 0) {//为企业版
							bt.send('ftp', 'ftp/set_ftp_logs', {exec_name: 'getlog'}, function (res) {
								var _status = res.msg === 'start' ? true : false
								if(!_status){
									bt.confirm({title:'提示',msg:'当前未开启FTP日志管理,是否开启?',icon:0},function(index){
										layer.close(index);
										bt.send('ftp', 'ftp/set_ftp_logs', {exec_name: 'start'}, function (res) {
											bt_tools.msg(res)
											if(res.status){
												$("#bt_ftp_table #isFtplog").prop("checked", true);
												setTimeout(function(){
													open_ftp_log()
												},1000)
											}
										})
									})
									return
								}else{
									open_ftp_log()
								}
								function open_ftp_log() {
									var web_tab = bt_tools.tab({
										class: 'pd20',
										type: 0,
										theme: { nav: 'ml0' },
										active: 1, //激活TAB下标
										list:[
										{
												title: '登录日志',
												content: '<div id="bt_ftp_Login_logs"></div>',
												success: function () {
													$('#bt_ftp_Login_logs').parent().parent().css('padding','10px 0')
													$('#bt_ftp_Login_logs').empty()
													bt_tools.table({
														el: '#bt_ftp_Login_logs',
														default: '暂无日志信息',
														height: 390,
														url: '/ftp?action=get_login_logs',
														param: {
															user_name: row.name
														},
														column: [
															{ title: '用户名', type: 'text', width: 100,template:function() {
																return '<span>' + row.name + '</span>';
															}},
															{ fid: 'ip', title: '登录IP', type: 'text', width: 110},
															{ fid: 'status', title: '状态', type: 'text', width: 75,
															template: function (rowc, index, ev) {
															    var status = rowc.status.indexOf('登录成功') > -1
																return '<span class="' + (status ?  'btlink' : 'bterror' ) + '">' + (status ?  '登录成功' : '登录失败' ) + '<span>';
															}},
															{ fid: 'in_time', title: '登录时间', type: 'text', width: 150 },
															{ fid: 'out_time', title: '登出时间', type: 'text', width: 200},
														],
														tootls: [
															{
																type:'group',
																positon:['left','top'],
																list:[
																	{title:'刷新日志',active:true,event:function(ev,ethat){
																	    $('#bt_ftp_Login_logs .search_input').val('')
																	    ethat.config.search.value = ''
																		ethat.$refresh_table_list(true)
																	}},
																]
															},
															{
																type: 'search',
																positon: ['right', 'top'],
																placeholder: '请输入登录IP/状态/时间',
																searchParam: 'search', //搜索请求字段,默认为 search
																value: '',// 当前内容,默认为空
															},
															{
																type: 'page',
																positon: ['right', 'bottom'], // 默认在右下角
																pageParam: 'p', //分页请求字段,默认为 : p
																page: 1, //当前分页 默认:1
															}
														]
													})
												}
											}, {
												title: '操作日志',
												content: '<div id="bt_ftp_logsOperation"></div><ul class="help-info-text c7"><li>部分ftp客户端上传带中文名称的文件时,写入的ftp日志中文部分为乱码,这将导致显示的文件名称中文部分无法转换</li></ul>',
												success: function () {
													var typeList = [
														{ title: '全部', value: 'all' },
														{ title: '上传', value: 'upload' },
														{ title: '下载', value: 'download' },
														{ title: '删除', value: 'delete' },
														{ title: '重命名', value: 'rename' }]
													table_logsOperation('all')
													function table_logsOperation(type) {
														$('#bt_ftp_logsOperation').empty()
														bt_tools.table({
															el: '#bt_ftp_logsOperation',
															default: '暂无日志信息',
															height: 350,
															url: '/ftp?action=get_action_logs',
															param: {
																user_name: row.name,
																type: type
															},
															column: [
																{ title: '用户名', type: 'text', width: 100,template:function() {
																	return '<span>' + row.name + '</span>';
																}},
																{ fid: 'ip', title: '操作IP', type: 'text', width: 110},
																{ fid: 'file', title: '文件', type: 'text', width: 240,fixed: true },
																{ fid: 'type', title: '操作类型', type: 'text', width: 75},
																{ fid: 'time', title: '操作时间', type: 'text', width: 100 },
															],
															tootls: [{
																	type:'group',
																	positon:['left','top'],
																	list:[
																		{title:'刷新日志',active:true,event:function(){
																			table_logsOperation(type)
																		}},
																	]
																},
																{
																	type: 'search',
																	positon: ['right', 'top'],
																	placeholder: '请输入操作IP/文件/类型/时间',
																	searchParam: 'search', //搜索请求字段,默认为 search
																	value: '',// 当前内容,默认为空
																},
																{
																	type: 'page',
																	positon: ['right', 'bottom'], // 默认在右下角
																	pageParam: 'p', //分页请求字段,默认为 : p
																	page: 1, //当前分页 默认:1
																}
															],
															success: function () {
																if(!$('#bt_ftp_logsOperation .log_type').length){
																	var _html = ''
																	$.each(typeList, function (index, item) {
																		_html += '<option value="' + item.value + '">' + item.title + '</option>'
																	})
																	$('#bt_ftp_logsOperation .bt_search').before('<select class="bt-input-text mr5 log_type" style="width:110px" name="log_type">'+ _html +'</select>')
																	$('#bt_ftp_logsOperation .log_type').val(type)
																	$('#bt_ftp_logsOperation .log_type').change(function () {
																		table_logsOperation($(this).val())
																	})
																}
															}
														})
													}
												}
										}]
									})
									bt_tools.open({
										area: ['700px', '605px'],
										title: '【' + row.name + '】- 日志',
										closeBtn: 2,
										btn: false,
										skin: 'bt_ftp_logsLogin',
										content: web_tab.$reader_content(),
										success: function () {
											web_tab.$init();
										}
									})
								}
							})

						}else{
							var item = {
								pluginName: 'FTP日志',
								description:['记录和查看当前FTP日志','登录日志','操作日志'],
								ps: 'FTP日志是FTP服务器记录的各种FTP操作、事件以及异常情况等信息的记录,如登录日志、上传下载日志、错误日志等。',
								preview: false,
								limit: 'ltd',
								imgSrc:'https://www.bt.cn/Public/new/plugin/introduce/ftp/ftplog.png'
							}
							product_recommend.recommend_product_view(item, {
								imgArea: ['783px', '718px']
							},'ltd',57,'ltd')
						}

					}
				},{
					title:'删除',event:function(row,index,ev,key,that){
						that.del_ftp_user({id:row.id,name:row.name},function(res){
							if(res.status) that.$refresh_table_list(true);
						});
					}
				}]}
			],
			sortParam: function (data) {
				return { 'order': data.name + ' ' + data.sort };
			},
			tootls:[{
				type:'group',
				positon:['left','top'],
				list:[
					{title:'添加FTP',active:true,event:function(ev,that){
						that.add_ftp_user();
					}},
					{title:'修改FTP端口',event:function(ev,that){
						that.set_ftp_port();
					}}
				]
			},{ // 批量操作
				type:'batch',
				positon:['left','bottom'],
				config:{
					title:"删除",
					url:'/ftp?action=DeleteUser',
					load:true,
					param:function(row){
						return {id:row.id,username:row.name};
					},
					callback:function(that){
						bt.confirm({title:'批量删除FTP',msg:'是否批量删除选中的FTP用户,是否继续?',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 += '<tr><td>'+ item.name +'</td><td><div style="float:right;"><span style="color:'+ (item.request.status?'#20a53a':'red') +'">'+ item.request.msg +'</span></div></td></tr>';
								}
								ftp_table.$batch_success_table({title:'批量删除FTP',th:'FTP用户名',html:html});
								ftp_table.$refresh_table_list(true);
							});
						});
					}
				}
			},{
				type:'search',
				positon:['right','top'],
				placeholder:'请输入FTP用户名',
				searchParam:'search', //搜索请求字段,默认为 search
				value:'',// 当前内容,默认为空
			},{ //分页显示
				type:'page',
				positon:['right','bottom'], // 默认在右下角
				pageParam:'p', //分页请求字段,默认为 : p
				page:1, //当前分页 默认:1
				numberParam:'limit', //分页数量请求字段默认为 : limit
				number:20, //分页数量默认 : 20条
				numberList:[10,20,50,100,200], // 分页显示数量列表
				numberStatus:true, // 是否支持分页数量选择,默认禁用
				jump:true, //是否支持跳转分页,默认禁用
			}],
      success: function (obj) {
        // 详情事件
        bt.files.dir_details()
      }
		});
    {% endif %}
</script>
{% endblock %}