afae8657651d98abc1da523cf88a4c100132ec4f.svn-base
8.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
//SMTP设置
var reg = /^([a-zA-Z\.0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
var SMTP_LIST="";//SMTP信息集合
var SMTP_IsEdit=0;//是不是编辑
var SMTP_OldAccount="";//默认帐号
$(document).ready(function(){
//查询SMTP信息
findAllSmtp();
//查询SMTP list信息
fincSmtpList();
//SMTP选择事件
$("#smtp_list").live("change",function (){
if($("#smtp_list").val()=="请选择SMTP服务器"){
$("#smtp_host").val("");
}else{
$("#smtp_host").val($("#smtp_list").val());
}
});
//是否启用SSL
$("#smtp_isssl").live("click",function (){
if($("#smtp_isssl").attr("checked")==true||$("#smtp_isssl").attr("checked")=="checked"){
$("#smtp_portdiv").show();
}else{
$("#smtp_portdiv").hide();
}
});
$("#smtp_isssl1").live("click",function (){
$("#smtp_portdiv").hide();
});
//SMTP服务器验证
$("#smtp_host").live("blur",function (){
hostYZ();
});
//SMTP帐号验证
$("#smtp_account").live("blur",function (){
accountYZ();
});
//SMTP密码验证
$("#smtp_pass").live("blur",function (){
passYZ();
});
});
//查询所有SMTP信息
function findAllSmtp(){
$.ajax({
type:"POST",
url: "smtp_findAllSmtp.action",
cache: false,
async: false,
success: function(msg) {
SMTP_LIST=msg;
var html="";
if(msg==null||msg==""){
$("#smtpset_list").html('<div class="re_mcon" style="color:#CCC; height:100px; font-size:36px" align="center">无数据</div>'); }else{
$.each(msg,function(index,row){
html+='<dl>';
html+='<dd class="tdt5">'+(index+1)+'</dd>';
html+='<dd class="tdt2">'+row.smtp_service_number+'</dd>';
html+='<dd class="tdt2">'+row.smtp_service_account+'</dd>';
html+='<dd class="tdt3">'+row.smtp_service_creatdate+'</dd>';
html+='<dd class="tdt3"><a href=\'javascript:smtpedit('+row.smtp_service_id+')\'>编辑</a> | <a href=\'javascript:smtpdel('+row.smtp_service_id+')\'>删除</a> | <a href=\'javascript:smtpYZ('+row.smtp_service_id+')\'>验证</a></dd>';
html+="</dl>";
});
$("#smtpset_list").html(html);
}
}
});
}
//查询SMTP list信息
function fincSmtpList(){
$.ajax({
type:"POST",
url: "smtp_findSmtpList.action",
cache: false,
async: false,
success: function(msg) {
var html="";
$.each(msg,function(index,row){
html+='<option>'+row.smtpname+'</option>';
});
$("#smtp_list").append(html);
}
});
}
//SMTP服务器验证
function hostYZ(){
//是否为空
if($("#smtp_host").val()==""){
$("#smtp_hostYZ").attr("style","color:#F00");
$("#smtp_hostYZ").html("请选择或输入SMTP服务器");
return false;
}else{
$("#smtp_hostYZ").attr("style","color:#096");
$("#smtp_hostYZ").html("输入正确!");
return true;
}
//是否存在
}
//SMTP邮箱帐号验证
function accountYZ(){
if($("#smtp_account").val()==""){//是否为空
$("#smtp_accountYZ").attr("style","color:#F00");
$("#smtp_accountYZ").html("请输入SMTP帐号");
return false;
}
if(!reg.test($("#smtp_account").val())){//格式
$("#smtp_accountYZ").attr("style","color:#F00");
$("#smtp_accountYZ").html("SMTP帐号格式不正确!");
return false;
}
if(!smtpaccountisexits()){//是否存在
$("#smtp_accountYZ").attr("style","color:#F00");
$("#smtp_accountYZ").html("SMTP帐号已存在!");
return false;
}
$("#smtp_accountYZ").attr("style","color:#096");
$("#smtp_accountYZ").html("输入正确!");
return true;
}
//SMTP邮箱密码验证
function passYZ(){
//是否为空
if($("#smtp_pass").val()==""){
$("#smtp_passYZ").attr("style","color:#F00");
$("#smtp_passYZ").html("请输入SMTP密码");
return false;
}else{
$("#smtp_passYZ").attr("style","color:#096");
$("#smtp_passYZ").html("输入正确!");
return true;
}
}
//添加SMTP
function smtp_addcomit(){
//验证格式正确性
if(passYZ()&&accountYZ()&&hostYZ()){
var option={
url: 'smtp_addSmtpInfo.action',
dataType:'json',
success: function(msg){
if(msg==1){
yxy_confirmTerm('smtpset_adddiv');
findAllSmtp();
alert("操作成功!");
}else{
alert("操作失败!");
}
}
}
$("#smtp_addForm").ajaxSubmit(option);
}
}
//判断SMTP账号是否存在了
function smtpaccountisexits(){
var isexits=true;
if(SMTP_IsEdit==1&&SMTP_OldAccount==$("#smtp_account").val()){
isexits=true;
}else{
$.ajax({
type:"POST",
url: "smtp_findBySmtp.action",
cache: false,
async: false,
data:{
account:$("#smtp_account").val(),
},
success: function(msg) {
if(msg==1){
isexits= true;
}else{
isexits= false;
}
}
});
}
return isexits;
}
//SMTP服务器验证
function SmtpValidation(){
}
//SMTP添加
function smtpadd(){
yxy_tipsWindown('添加SMTP','smtpset_adddiv',700) ;
$("#smtp_savebutton").show();
$("#smtp_editbutton").hide();
}
//SMTP编辑页面赋值
function smtpedit(id){
SMTP_IsEdit=1;
yxy_tipsWindown('编辑SMTP','smtpset_adddiv',700);
$("#smtp_savebutton").hide();
$("#smtp_editbutton").show();
$.each(SMTP_LIST,function(index,row){
if(id==row.smtp_service_id){
$("#smtp_id").val(row.smtp_service_id);
SMTP_OldAccount=row.smtp_service_account;
$("#smtp_host").val(row.smtp_service_number);
$("#smtp_account").val(row.smtp_service_account);
$("#smtp_pass").val(row.smtp_service_password);
if(row.smtp_is_ssl==1){
$("#smtp_isssl").attr("checked","checked");
$("#smtp_portdiv").show();
$("#smtp_port").val(row.smtp_service_port);
}else{
$("#smtp_isssl1").attr("checked","checked");
$("#smtp_portdiv").hide();
$("#smtp_port").val("");
}
return;
}
});
}
//SMTP删除
function smtpdel(id){
var a= confirm("确定删除该服务器信息?");
if(a){
$.ajax({
type:"POST",
url: "smtp_delSmtp.action",
cache: false,
async: false,
data:{
smtpid:id
},
success: function(msg) {
if(msg==1){
findAllSmtp();
alert("删除成功!");
}else{
alert("删除失败!");
}
}
});
}else{
return;
}
}
//SMTP验证
function smtpYZ(id){
$.each(SMTP_LIST,function(index,row){
if(id==row.smtp_service_id){
$("#smtp_id").val(row.smtp_service_id);
SMTP_OldAccount=row.smtp_service_account;
$("#smtp_host").val(row.smtp_service_number);
$("#smtp_account").val(row.smtp_service_account);
$("#smtp_pass").val(row.smtp_service_password);
if(row.smtp_is_ssl==1){
$("#smtp_isssl").attr("checked","checked");
$("#smtp_portdiv").show();
$("#smtp_port").val(row.smtp_service_port);
}else{
$("#smtp_isssl1").attr("checked","checked");
$("#smtp_portdiv").hide();
$("#smtp_port").val("");
}
return;
}
});
var option={
url: 'smtp_connectionService.action',
dataType:'json',
success: function(msg){
if(msg==1){
alert("验证通过!");
}else if(msg==2){
alert("帐号或密码错误!");
}else if(msg==3){
alert("服务器登录失败!");
}else if(msg==4){
alert("服务器链接失败!");
}else{
alert("SMTP验证未通过!请确定SMTP的正确性!");
}
}
}
$("#smtp_addForm").ajaxSubmit(option);
}
//模糊查询SMTP
function smtp_findlike(){
$.ajax({
type:"POST",
url: "smtp_findSmtpLike.action",
cache: false,
async: false,
data:{
account:$("#smtp_likevalue").val()
},
success: function(msg) {
var html="";
if(msg==null||msg==""){
$("#smtpset_list").html('<div class="re_mcon" style="color:#CCC; height:100px; font-size:36px" align="center">无数据</div>'); }else{
$.each(msg,function(index,row){
html+='<dl>';
html+='<dd class="tdt5">'+(index+1)+'</dd>';
html+='<dd class="tdt2">'+row.smtp_service_number+'</dd>';
html+='<dd class="tdt2">'+row.smtp_service_account+'</dd>';
html+='<dd class="tdt3">'+row.smtp_service_creatdate+'</dd>';
html+='<dd class="tdt3"><a href=\'javascript:smtpedit('+row.smtp_service_id+')\'>编辑</a> | <a href=\'javascript:smtpdel('+row.smtp_service_id+')\'>删除</a> | <a href=\'javascript:smtpYZ('+row.smtp_service_id+')\'>验证</a></dd>';
html+="</dl>";
});
$("#smtpset_list").html(html);
}
}
});
}