SocialIMOpenfire.jsp 56.7 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 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 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036

<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@page import="weaver.file.FileUpload"%>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="weaver.social.po.SocialProperties"%>
<%@page import="java.io.*"%>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />


<%@ taglib uri="/browserTag" prefix="brow"%>
<% 

%>
<%

if (!HrmUserVarify.checkUserRight("message:manager", user)) {
	response.sendRedirect("/notice/noright.jsp");
	return;
}
int lng = user.getLanguage();
String userid = user.getUID()+ "";
String titlename =SystemEnv.getHtmlLabelName(18014,user.getLanguage()); //微博基本设置
String emPropPath = GCONST.getRootPath()+ "WEB-INF/prop/OpenfireModule.properties"; 
String rongPropPath = GCONST.getRootPath()+ "WEB-INF/prop/EMobileRong.properties"; 
JSONObject result = new JSONObject();
FileUpload fu = new FileUpload(request,false);
String Openfire_save = Util.null2String(fu.getParameter("Openfire"));
System.out.print("Openfire_save=="+Openfire_save);
String openfireDomain_save = Util.null2String(fu.getParameter("openfireDomain"));
String openfireEMobileUrl_save = Util.null2String(fu.getParameter("openfireEMobileUrl"));
String openfireMobileClientUrl_save = Util.null2String(fu.getParameter("openfireMobileClientUrl"));
String openfireHttpbindPort_save = Util.null2String(fu.getParameter("openfireHttpbindPort"));
if("".equals(openfireHttpbindPort_save)){
    openfireHttpbindPort_save = "7070";
}
String openfireEmessageClientUrl_save = Util.null2String(fu.getParameter("openfireEmessageClientUrl"));
String webinf = (GCONST.getRootPath()+ "WEB-INF").replace("\\","/");
String Openfire = "";
String openfireDomain = "";
String openfireEMobileUrl = "";
String openfireMobileClientUrl = "";
String openfireHttpbindPort = "" ;
String openfireEmessageClientUrl = "";
String appkey = "";
boolean needBuyAppkey = false;
boolean  isOpenfire = false;
boolean  isOpenfirePort = false;

JSONObject json = new JSONObject();
if(!Openfire_save.equals("")&&!openfireEMobileUrl_save.equals("")&&!openfireMobileClientUrl_save.equals("")&&!openfireHttpbindPort_save.equals("")&&!openfireEmessageClientUrl_save.equals("")){
    try{
        SocialProperties propertie = new SocialProperties();
        FileInputStream inputFile = new FileInputStream(emPropPath);
        propertie.load(inputFile);
        //propertie.clear();
        inputFile.close();
        propertie.setProperty("Openfire", Openfire_save);
        propertie.setProperty("openfireDomain", openfireDomain_save);
        propertie.setProperty("openfireEMobileUrl", openfireEMobileUrl_save);
        propertie.setProperty("openfireMobileClientUrl", openfireMobileClientUrl_save);
        propertie.setProperty("openfireEmessageClientUrl", openfireEmessageClientUrl_save);
        propertie.setProperty("openfireHttpbindPort", openfireHttpbindPort_save);
        FileOutputStream outputFile = new FileOutputStream(emPropPath);
        propertie.store(outputFile,null);
        outputFile.close();
    }catch(Exception e){}
    Openfire = Openfire_save;
    if(Openfire_save.equals("true")){
        isOpenfire = true;
    }else if(Openfire_save.equals("false")){
        isOpenfire = false;
    }
    openfireDomain = openfireDomain_save;
    openfireEMobileUrl = openfireEMobileUrl_save;
    openfireMobileClientUrl = openfireMobileClientUrl_save;
    openfireHttpbindPort = openfireHttpbindPort_save;
    openfireEmessageClientUrl = openfireEmessageClientUrl_save.equals("")?openfireMobileClientUrl_save:openfireEmessageClientUrl_save;
    
    // 保存host映射
    int itemlen = Util.getIntValue(Util.null2String(fu.getParameter("itemlen")));
    String oaHost, emHost;
    rs.execute("truncate table social_Ipconfig");
    for(int i = 0; i < itemlen; i++) {
    	oaHost = Util.null2String(fu.getParameter("oaInput"+i));
    	emHost = Util.null2String(fu.getParameter("emInput"+i));
    	rs.execute("insert into social_Ipconfig (oahost, emhost) values ('"+ oaHost +"','"+ emHost +"')");
    }
}else{
    try{
        File emPropFile = new File(emPropPath);
        OrderProperties emProp = new OrderProperties();
        if(emPropFile.exists()){
            emProp.load(emPropPath);
            List<String> it=emProp.getKeys();
            for(String key  : it){
                String value = Util.null2String(emProp.get(key));
                result.put(key,value);
            }
        }
    }catch(Exception e){}
    
    Openfire = result.has("Openfire") ? Util.null2String(result.getString("Openfire")) :  "false";
    
    if(Openfire.equals("true")){
        isOpenfire = true;
    }else if(Openfire.equals("false")){
        isOpenfire = false;
    }
    openfireDomain = result.has("openfireDomain") ? openfireDomain = Util.null2String(result.getString("openfireDomain")) : "";
    openfireEMobileUrl = result.has("openfireEMobileUrl") ?  Util.null2String(result.getString("openfireEMobileUrl")) : "";
    openfireMobileClientUrl =  result.has("openfireMobileClientUrl") ? Util.null2String(result.getString("openfireMobileClientUrl")) : "";
    openfireHttpbindPort = result.has("openfireHttpbindPort") ?  Util.null2String(result.getString("openfireHttpbindPort")) : "";
    openfireEmessageClientUrl = result.has("openfireEmessageClientUrl") ? Util.null2String(result.getString("openfireEmessageClientUrl")) : "";
    openfireEmessageClientUrl = openfireEmessageClientUrl.equals("")?openfireMobileClientUrl:openfireEmessageClientUrl;
}
openfireEMobileUrl = openfireEMobileUrl.replace("\\", "");
openfireEmessageClientUrl = openfireEmessageClientUrl.replace("\\", "");

//获取私有云host映射
try{
	rs.execute("select oahost, emhost from social_Ipconfig");
	int index = 0;
	while(rs.next()){
		json.put("oahost"+index, rs.getString(1));
		json.put("emhost"+index, rs.getString(2));
		index++;
	}
	json.put("itemlen", index);
}catch(Exception e) {
	
}
//公有云判断有没有EMobileRong.properties
if (!isOpenfire) {
	try{
		File emPropFile = new File(rongPropPath);
        OrderProperties emProp = new OrderProperties();
        if(emPropFile.exists()){
            emProp.load(rongPropPath);
            appkey = emProp.get("AppKey");
        }
        if (appkey == null || appkey.isEmpty()) {
        	needBuyAppkey = true;
        }
    }catch(Exception e){}
}
// 获取emessage总开关
String emessageSwitch = Prop.getPropValue("Messager2", "IsUseEMessager");
boolean isUseEmessage = emessageSwitch.equals("1");

// 从数据库查询是否有自定义端口
    JSONObject portJson = new JSONObject();
    portJson.put("isOpenfireInited", "0");
    try {
        rs.executeQuery("select name, propvalue from ofproperty where name in ('httpbind.port.plain', 'httpbind.port.secure', 'setup')");
        while(rs.next()){
            if("setup".equals(rs.getString(1))){
                portJson.remove("isOpenfireInited");
            }else{
                portJson.put(rs.getString(1), rs.getString(2));
            }
        }
    }catch(Exception e){}
%>
<!DOCTYPE HTML>
<html>
  <head>
    <link href="/css/Weaver_wev8.css" type=text/css rel=stylesheet>
    <SCRIPT language="javascript"  defer="defer" src="/js/datetime_wev8.js"></script>
	<SCRIPT language="javascript"  src="/js/selectDateTime_wev8.js"></script>
	<SCRIPT language="javascript" defer="defer" src='/js/JSDateTime/WdatePicker_wev8.js?rnd="+Math.random()+"'></script>

 <%@ include file="/systeminfo/TopTitle_wev8.jsp" %>
 <%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp" %>
 <% 
	 RCMenu += "{"+SystemEnv.getHtmlLabelName(86,user.getLanguage())+",javascript:doSave(),_self} ";
	 RCMenuHeight += RCMenuHeightStep ;
 %>
<%@ include file="/systeminfo/RightClickMenu_wev8.jsp" %>
<style>
	.e8Table {width: 100%}
</style>
</head>
<body>
<jsp:include page="/systeminfo/commonTabHead.jsp">
   <jsp:param name="mouldID" value="social"/>
   <jsp:param name="navName" value="<%=SystemEnv.getHtmlLabelName(386634,user.getLanguage()) %>"/>
</jsp:include>

<wea:layout attributes="{layoutTableId:topTitle}">
    <wea:group context="" attributes="{groupDisplay:none}">
        <wea:item attributes="{'customAttrs':'class=rightSearchSpan'}">
            <span title="<%=SystemEnv.getHtmlLabelName(86,user.getLanguage()) %>" style="font-size: 12px;cursor: pointer;">
                <input class="e8_btn_top middle" onclick="doSave()" type="button" value="<%=SystemEnv.getHtmlLabelName(86,user.getLanguage()) %>"/>
            </span>
            <span title="<%=SystemEnv.getHtmlLabelName(81804,user.getLanguage())%>" class="cornerMenu"></span>
        </wea:item>
    </wea:group>
</wea:layout>

<form action="SocialIMOpenfire.jsp" method="post"  id="mainform" enctype="multipart/form-data">
<input type="hidden" value="upload" name="operation"/> 
<wea:layout attributes="{layoutTableId: 'oTableConfigure'}">
    <wea:group context="<%=SystemEnv.getHtmlLabelNames("24532,130730,724",user.getLanguage()) %>">
        <wea:item><%=SystemEnv.getHtmlLabelNames("24532,31693,63",user.getLanguage()) %></wea:item>
        <wea:item>  
        	<span><%=lng==8?"Private Cloud":"私有云"%></span>
        	<input type="radio" name="ServerType" id="Openfire" value="true" class="inputstyle" 
                <%if(isOpenfire)out.println("checked=checked");%> onclick="changeValue(this);"/>
            <span><%=lng==8?"Internet Cloud":"公有云"%></span>
            <input type="radio" name="ServerType" id="Rongcloud" value="false" class="inputstyle" 
                <%if(!isOpenfire)out.println("checked=checked");%> onclick="changeValue(this);"/>
            <input type="hidden" name="Openfire" value="<%=Openfire%>">
                <span id="Openfire_span"></span>
            <span id="appkeytips" <%if(!needBuyAppkey || isOpenfire)out.println("style='display:none;'");%>><%=lng==8?"No private cloud license is requested currently":(lng==9?"當前沒有申請公有云授權。":"当前没有申请公有云授权。")%> <a target='_blank' href='/workflow/request/RequestType.jsp'><%=lng==8?"Third-party software and hardware requirements application entry":(lng==9?"第三方軟、硬件需求申請入口":"第三方软、硬件需求申请入口")%></a></span>
        </wea:item>
        
        <wea:item attributes="{'samePair':'openfireEMobileUrl'}"><%=lng==8?"Set the private cloud service console address":(lng==9?"設置私有云服務控制台地址":"设置私有云服务控制台地址")%></wea:item>
        <wea:item attributes="{'samePair':'openfireEMobileUrl'}">
                <input name="openfireEMobileUrl" id="openfireEMobileUrl" info="<%=lng==8?"the private cloud service console address":(lng==9?"私有云服務控制台地址":"私有云服务控制台地址")%>"
                    value="<%=openfireEMobileUrl%>"
                    valueCache="<%=openfireEMobileUrl%>"
                    placeholder="<%=SystemEnv.getHtmlLabelName(15191,user.getLanguage())%>:http[s]://192.168.x.x:9090"
                    defaultMax="500" maxlength="100" style="width :200px"
                    onchange="checkinput('openfireEMobileUrl', 'openfireEMobileUrl_span');validateValue(this);"
                    class="InputStyle">
                <span id="openfireEMobileUrl_span"></span>
                <span error="false">(<%=SystemEnv.getHtmlLabelName(81804,user.getLanguage())%> http://emessageserviceip:9090,<%=SystemEnv.getHtmlLabelName(18541,user.getLanguage())%>:emessage<%=SystemEnv.getHtmlLabelNames("31693,1994,128047",user.getLanguage())%> ip 192.168.1.3,<%=SystemEnv.getHtmlLabelNames("22012,68",user.getLanguage())%> http://192.168.1.3:9090)</span>
        </wea:item>
        
        <wea:item attributes="{'samePair':'openfireMobileClientUrl'}"><%=lng==8?"emobile client connection message service address":(lng==9?"emobile客戶端連接消息服務地址":"emobile客户端连接消息服务地址")%></wea:item>
        <wea:item attributes="{'samePair':'openfireMobileClientUrl'}">
                <input name="openfireMobileClientUrl" id="openfireMobileClientUrl" info="<%=lng==8?"emobile client connection message service address":(lng==9?"emobile客戶端連接消息服務地址":"emobile客户端连接消息服务地址")%>"
                    value="<%=openfireMobileClientUrl%>" 
                    valueCache="<%=openfireMobileClientUrl%>"
                    placeholder="<%=SystemEnv.getHtmlLabelName(81804,user.getLanguage())%>:x.x.x.x or xx.xx.cn"
                    defaultMax="500" maxlength="100" style="width :200px"
                    onchange="checkinput('openfireMobileClientUrl', 'openfireMobileClientUrl_span');validateValue(this);"
                    class="InputStyle">
                <span id="openfireMobileClientUrl_span"></span>
                <img title="<%=lng==8?"For detailed instructions, please refer to the deployment documentation, click to open":(lng==9?"詳細說明請參考部署文檔,點擊打開":"详细说明请参考部署文档,点击打开")%>" src="/email/images/help_mail_wev8.png" align="absMiddle" onClick = "openUrl()"/>
                <span error="false"><%=lng==8?"(The address of the mobile emobile client accessing the private cloud service is recommended to be configured as a domain name)":(lng==9?"(建議將訪問私有云服務的移動emobile客戶端的地址配置為域名)":"(手机emobile客户端访问私有云服务的地址,建议配置为域名)")%></span>
        </wea:item>
        
        <wea:item attributes="{'samePair':'openfireEmessageClientUrl'}"><%=lng==8?"emessage client connection message service address":(lng==9?"emessage客戶端連接消息服務地址":"emessage客户端连接消息服务地址")%></wea:item>
        <wea:item attributes="{'samePair':'openfireEmessageClientUrl'}">
                <input name="openfireEmessageClientUrl" id="openfireEmessageClientUrl"  info="<%=lng==8?"emessage client connection message service address":(lng==9?"emessage客戶端連接消息服務地址":"emessage客户端连接消息服务地址")%>"
                    value="<%=openfireEmessageClientUrl%>" 
                    valueCache="<%=openfireEmessageClientUrl%>"
                    placeholder="<%=SystemEnv.getHtmlLabelName(15191,user.getLanguage())%>:x.x.x.x or xx.xx.cn"
                    defaultMax="500" maxlength="100" style="width :200px"
                    onchange="validateValue(this);"
                    class="InputStyle">
                <span id="openfireEmessageClientUrl_span"></span>
                <span error="false"><%=lng==8?"(The address of the emessage client accessing the private cloud service is recommended to be configured as a domain name)":(lng==9?"(emessage客戶端訪問私有云服務的地址,建議配置為域名)":"(emessage客户端访问私有云服务的地址,建议配置为域名)")%></span>
        </wea:item>
        <wea:item attributes="{'samePair':'openfireHttpbindPort'}"><%=lng==8?"the PORT Emessage client connection message service":(lng==9?"emessage客戶端連接消息服務端口":"emessage客户端连接消息服务端口")%></wea:item>
        <wea:item attributes="{'samePair':'openfireHttpbindPort'}">
                    <input  name="openfireHttpbindPort" id="openfireHttpbindPort"onKeyPress="ItemPlusCount_KeyPress()"   value='<%=openfireHttpbindPort%>'   maxlength="5"  style="width:80px" onBlur='' class="InputStyle">
                    <span><%=lng==8?"(http default port is 7070, https default port is 7443. If you use https, the private cloud needs to be configured with SSL certificate; please ensure that the message server has been replaced before using other ports to connect to the message service.)":(lng==9?"(http默認端口為7070,https默認端口為7443,如果使用https則私有云需要配置SSL證書; 使用其他端口連接消息服務前請確保消息服務器已更換端口。)":"(http默认端口为7070,https默认端口为7443,如果使用https则私有云需要配置SSL证书; 使用其他端口连接消息服务前请确保消息服务器已更换端口。)")%></span>
        </wea:item>
    </wea:group>
</wea:layout>
<wea:layout type="table" attributes="{'cols':'3','cws':'5%,45%,50%','formTableId':'oTable4op','layoutTableId':'oTableAddress'}">
	<wea:group context='<%="oa-emessage"+SystemEnv.getHtmlLabelNames("110,22618",user.getLanguage())%>'>
		<wea:item type="thead"><input type="checkbox" name="checkall" onclick="checkAllChkBox(this)"/><input type="hidden" name="itemlen" id="itemlen"/></wea:item>
		<wea:item type="thead"><%="oa"+SystemEnv.getHtmlLabelName(20880,user.getLanguage())%></wea:item>
		<wea:item type="thead"><%=lng==8?"Message Service Address (Format: 192.168.x.x or 192.168.x.x: Custom Port Number)":(lng==9?"消息服務地址(格式:192.168.x.x或者192.168.x.x:自定義端口號)":"消息服务地址(格式:192.168.x.x或者192.168.x.x:自定义端口号)")%></wea:item>
		<%
		
		%>
		<wea:item type="groupHead">
			<button type=button id="addBtn" Class=addbtn type=button accessKey=A onclick="addRow4op();" title="A-<%=SystemEnv.getHtmlLabelName(15582,user.getLanguage())%>"></BUTTON>
			<button type=button id="deleteBtn" Class=delbtn type=button accessKey=D onclick="deleteRow4op();" title="D-<%=SystemEnv.getHtmlLabelName(15583,user.getLanguage())%>"></BUTTON></div>
		</wea:item>
	</wea:group>
</wea:layout>
</form>  
<!-- 
     <wea:item attributes="{'samePair':'wayToCheck'}"><%=lng==8?"Visit the emessage problem detection page":(lng==9?"訪問emessage問題檢測頁面":"访问emessage问题检测页面")%></wea:item>
     <wea:item attributes="{'samePair':'wayToCheck'}">
     <input type="button" value="点击跳转" class="e8_btn_submit" onclick="wayToCheck();"/>
     </wea:item>
      -->
<jsp:include page="/systeminfo/commonTabFoot.jsp"></jsp:include>  
</body>
 <script type="text/javascript">
 
  function checkAllChkBox (obj) {
  	$("input[name='check_select']").each(function(){
		if(obj.checked){
			jQuery(this).siblings("span.jNiceCheckbox").addClass("jNiceChecked");
		}else{
			jQuery(this).siblings("span.jNiceCheckbox").removeClass("jNiceChecked");
		}
		this.checked=obj.checked;
	}); 
  
  }
 
  function addRow4op (oahost, emhost) {
    var $tbody = $('#oTable4op tbody')
  	var rowIndex = $tbody.find('tr').length
  	$('#itemlen').val(rowIndex+1)
  	var itemHtml = "<tr rowindex="+ rowIndex +">" +
  		       "<td><input type='checkbox' name='check_select'class='jNiceCheckbox'/></td>" +
  		       "<td><input type='text' name='oaInput"+rowIndex+"' class='oahost' value='"+ (oahost?oahost:'') +"'/></td>" + 
  		       "<td><input type='text' name='emInput"+rowIndex+"' class='emhost'  value='"+ (emhost?emhost:'') +"'/></td>" +
  		     "</tr>";
  	
  	$tbody.append(itemHtml)
  	// $tbody.jNice();
  }
  
  function deleteRow4op () {
  	var $tbody = $('#oTable4op tbody')
  	var $checkbox = $tbody.find('input:checkbox:checked')
  	if($checkbox.length > 0) {
  		$checkbox.closest('tr').remove()
  		$tbody.find('tr').each(function(i) {
  			$(this).attr('rowindex', i).
  				find('input.oahost').attr('name', 'oaInput'+i)
  			$(this).
  				find('input.emhost').attr('name', 'emInput'+i)
  		})
  	} else {
  		$tbody.find('tr:last').remove()
  	}
  	var rowIndex = $tbody.find('tr').length
  	$('#itemlen').val(rowIndex)
  }
  var clickCnt = 0;
  function doSave(){
     if (clickCnt === 0) {
         setTimeout(function(){
             doSave()
         }, 1000);
         clickCnt = 1;
         return;
     }
      clickCnt = 0;
  	 var $tbody = $('#oTable4op input[type=text]')
  	 for(var i = 0; i < $tbody.length; ++i) {
  	 	if($.trim($tbody.get(i).value) == ''){
  	 		window.top.Dialog.alert("<%=SystemEnv.getHtmlLabelName(126984,user.getLanguage())%>");
  	 		return;
  	 	}
  	 }
  	 
     var openfireMobileClientUrl = $(document).find('form').find('input#openfireMobileClientUrl').next().next().next();
     var openfireEMobileUrl = $(document).find('form').find('input#openfireEMobileUrl').next().next();
     var openfireEmessageClientUrl = $(document).find('form').find('input#openfireEmessageClientUrl').next().next();
     var flag = false;
     if(openfireEMobileUrl.attr('error')=='true'){
        flag =true;
        window.top.Dialog.alert('</br><%=lng==8?"Configuration detection is abnormal and cannot be saved.":(lng==9?"配置檢測有異常,無法保存":"配置检测有异常,无法保存")%>',function(){
            openfireEMobileUrl.siblings('input#openfireEMobileUrl').focus();
        });
        return;
     }
     if(openfireMobileClientUrl.attr('error')=='true'){
        flag =true;
        window.top.Dialog.alert('</br><%=lng==8?"Configuration detection is abnormal and cannot be saved.":(lng==9?"配置檢測有異常,無法保存":"配置检测有异常,无法保存")%>',function(){
            openfireMobileClientUrl.siblings('input#openfireMobileClientUrl').focus();
        });
        return;
     }
     if(openfireEmessageClientUrl.attr('error')=='true'){
        flag =true;
        window.top.Dialog.alert('</br><%=lng==8?"Configuration detection is abnormal and cannot be saved.":(lng==9?"配置檢測有異常,無法保存":"配置检测有异常,无法保存")%>',function(){
            openfireEmessageClientUrl.siblings('input#openfireEmessageClientUrl').focus();
        });
        return;
     }
     if(jQuery("input[name='Openfire']").val() === "true"){
         if(parseInt(jQuery("input[name='openfireHttpbindPort']").val()) <= 0 || parseInt(jQuery("input[name='openfireHttpbindPort']").val()) >=65535){
             flag = true;
             window.top.Dialog.alert('</br><%=lng==8?"The port you configured is out of range and cannot be saved.":(lng==9?"您配置的端口超過範圍,無法保存":"您配置的端口超过范围,无法保存")%>',function(){
                 openfireEmessageClientUrl.siblings('input#openfireEmessageClientUrl').focus();
             });
             return;
         }
         var hosts = <%=portJson%>;
         var httpbindPortPlain = hosts['httpbind.port.plain'];
         var httpbindPortSecure = hosts['httpbind.port.secure'];
         var isOpenfireInited = hosts['isOpenfireInited'];


         var alert="";
         var status = 0;
         if(isOpenfireInited == 0){
             alert='<font style=\"color:red;\"><%=lng==8?"It was detected that the private cloud is not installed or has not been initialized!":(lng==9?"檢測到私有云未安裝或者尚未初始化!":"检测到私有云未安装或者尚未初始化!")%></font><br>';
             status = 1;
         }else if(httpbindPortPlain && httpbindPortSecure){
             alert = '<font style=\"color:red;\"><%=lng==8?"A private port is detected and a custom port is set.":(lng==9?"檢測到私有云設置了自定義端口":"检测到私有云设置了自定义端口")%>' + httpbindPortPlain + '<%=lng==8?"And custom https ports":(lng==9?"和自定義https端口":"和自定义https端口")%>' + httpbindPortSecure + '</font><br>';
             status = 2;
         }else if(httpbindPortPlain){
             alert = '<font style=\"color:red;\"><%=lng==8?"A private port is detected and a custom port is set.":(lng==9?"檢測到私有云設置了自定義端口":"检测到私有云设置了自定义端口")%>' + httpbindPortPlain + '</font><br>';
             status = 3;
         }else if(httpbindPortSecure){
             alert = '<font style=\"color:red;\"><%=lng==8?"A private port is detected and a custom https port is set.":(lng==9?"檢測到私有云設置了自定義https端口":"检测到私有云设置了自定义https端口")%>' + httpbindPortSecure + '</font><br>';
             status = 4;
         }
         if(jQuery("input[name='openfireHttpbindPort']").val() == "7070" || jQuery("input[name='openfireHttpbindPort']").val() == ""
             ){
             switch(status){
                 case 1 : alert += '<%=lng==8?"Please initialize the messaging service, emessage will use the default port 7070 to connect to the messaging service!":(lng==9?"請初始化消息服務,emessage將使用默認端口7070連接消息服務!":"请初始化消息服务,emessage将使用默认端口7070连接消息服务!")%>'; break;
                 case 2 : alert += '<%=lng==8?"Are you sure you still want the client to use the 7070 port to connect to the messaging service?":(lng==9?"確定還要客戶端使用7070端口連接消息服務嗎?":"确定还要客户端使用7070端口连接消息服务吗?")%>';break;
                 case 3 : alert += '<%=lng==8?"Are you sure you still want the client to use the 7070 port to connect to the messaging service?":(lng==9?"確定還要客戶端使用7070端口連接消息服務嗎?":"确定还要客户端使用7070端口连接消息服务吗?")%>';break;
                 case 4 : alert += '<%=lng==8?"emessage will use the default port 7070 to connect to the messaging service!":(lng==9?"emessage將使用默認端口7070連接消息服務!":"emessage将使用默认端口7070连接消息服务!")%>';break;
                 default: alert += '<%=lng==8?"emessage will use the default port 7070 to connect to the messaging service!":(lng==9?"emessage將使用默認端口7070連接消息服務!":"emessage将使用默认端口7070连接消息服务!")%>';
             }

         }else if(jQuery("input[name='openfireHttpbindPort']").val() == "7443"){
             switch(status){
                 case 1 : alert +='<%=lng==8?"Please initialize the message service and configure the SSL certificate! Are you sure you want to set the https default 7443 port?":(lng==9?"請初始化消息服務並配置SSL證書!確定還要設置https默認7443端口嗎?":"请初始化消息服务并配置SSL证书!确定还要设置https默认7443端口吗?")%>';break;
                 case 2 : alert +='<%=lng==8?"Please initialize the message service and configure the SSL certificate! Are you sure you want to set the https default 7443 port?":(lng==9?"請初始化消息服務並配置SSL證書!確定還要設置https默認7443端口嗎?":"请初始化消息服务并配置SSL证书!确定还要设置https默认7443端口吗?")%>';break;
                 case 3 : alert +='<%=lng==8?"The client will use the https port 7443 to connect to the messaging service":(lng==9?"客戶端將使用https端口7443連接消息服務":"客户端将使用https端口7443连接消息服务")%>';break;
                 case 4 : alert +='<%=lng==8?"Are you sure you want the client to connect to the messaging service using https port 7443?":(lng==9?"確定還要客戶端使用https端口7443連接消息服務嗎?":"确定还要客户端使用https端口7443连接消息服务吗?")%>';break;
                 default: alert +='<%=lng==8?"The client will use the https port 7443 to connect to the messaging service":(lng==9?"客戶端將使用https端口7443連接消息服務":"客户端将使用https端口7443连接消息服务")%>';
             }
         }else{
             switch(jQuery("input[name='openfireHttpbindPort']").val() == httpbindPortPlain || jQuery("input[name='openfireHttpbindPort']").val() == httpbindPortSecure){
                 case true : alert +='<%=lng==8?"The custom port matches the private cloud port. Do you want to save it?":(lng==9?"自定義端口與私有云端口匹配,要保存嗎?":"自定义端口与私有云端口匹配,要保存吗?")%>';break;
                 default: alert += '<%=lng==8?"Are you sure you want to continue setting up your custom port ":(lng==9?"確定還要繼續設置自定義端口":"确定还要继续设置自定义端口")%>'+ parseInt(jQuery("input[name='openfireHttpbindPort']").val()) + "?";
             }
         }
         window.top.Dialog.confirm(alert, function(){
             if(!flag){
                 jQuery("input[name='openfireHttpbindPort']").val(parseInt(jQuery("input[name='openfireHttpbindPort']").val()))
                 window.top.Dialog.alert("<%=SystemEnv.getHtmlLabelName(18758,user.getLanguage())%>",function(){
                     jQuery("#mainform").submit();
                 });
                 return;
             }
         });
     }else{
         if(!flag){

             window.top.Dialog.alert("<%=SystemEnv.getHtmlLabelName(18758,user.getLanguage())%>",function(){
                 jQuery("#mainform").submit();
             });
             return;
         }
     }
  }
  
  jQuery(document).ready(function(){
       window.isUseEmessage = <%=isUseEmessage%>;
	   var openfire = "<%=Openfire%>";
	   var openfireEMobileUrl = "<%=openfireEMobileUrl%>";
	   var openfireMobileClientUrl = "<%=openfireMobileClientUrl%>";
	   var openfireHttpbindPort = "<%=openfireHttpbindPort%>";
       var openfireEmessageClientUrl = "<%=openfireEmessageClientUrl%>";
	   if(openfire==='false'){
	       hideEle("openfireEMobileUrl");
           hideEle("openfireMobileClientUrl");
           hideEle("openfireEmessageClientUrl");
           hideEle("openfireHttpbindPort");
           hideEle("checkConnect");
           $('#oTableAddress').hide();
	   }else{
	       hideEle("checkToken");
	   }
	   // 没有开启emessage开关,则不显示openfireEmessageClientUrl
       if (!isUseEmessage) {
           hideEle("openfireEmessageClientUrl");
       }
	   var hosts = <%=json%>;
	   var len = hosts.itemlen || 0;
	   for(var i = 0; i < len; i++) {
	       addRow4op(hosts['oahost'+i], hosts['emhost'+i])
	   }
  });
  
  function wayToCheck(){
     var origin = window.location.origin;
     var pathname= "/social/manager/SocialIMCheck.jsp";
     var host = origin+pathname;
     window.open(host,"_blank");
  }
  
  function openErrorPic(obj){
      var dialog = new window.top.Dialog();
      dialog.currentWindow = window;
      dialog.Title = "<%=SystemEnv.getHtmlLabelNames("127353,89",user.getLanguage())%>";
      dialog.normalDialog= false;
      dialog.Drag = true;
      var inhtml = "";
      var name = $(obj).attr('info');
      var img = '';
      if(name=='checkConnect'){
          img = "<img src='../images/socialimcheck/ConnectError.png'>";
          dialog.Width = 700;
          dialog.Height = 600;
      }else if(name=='checkSingleLogin1'){
          img = "<img src='../images/socialimcheck/SingleLoginError.png'>";
          dialog.Width = 1400;
          dialog.Height = 750;
      }else if(name=='checkSingleLogin2'){
          img = "<img src='../images/socialimcheck/DownloadError.png'>";
          dialog.Width = 900;
          dialog.Height = 450;
      }
      inhtml += "<div style='font-size:15px;padding-top:27px;text-align: left;padding-left: 24px;'><h3>案例如图所示:</h3></br>"+
             img;
      dialog.InnerHtml = inhtml;
      dialog.show();
  }
  
  function checkConnect(obj){
      var openfire = "<%=Openfire%>";
      var openfireEMobileUrl = "<%=openfireEMobileUrl%>";
      var openfireMobileClientUrl = "<%=openfireMobileClientUrl%>";
      var openfireHttpbindPort = "<%=openfireHttpbindPort%>";
      var openfireEmessageClientUrl = "<%=openfireEmessageClientUrl%>";
      var a = document.createElement('a');  
      a.href = openfireEMobileUrl;  
      var host = a.hostname;
      var dialog = new window.top.Dialog();
      dialog.currentWindow = window;
      dialog.Title = "解决方案";
      dialog.Width = 300;
      dialog.Height = 200;
      dialog.normalDialog= false;
      dialog.Drag = true;
      var inhtml = '';
      var $main = $(obj).next().next();
      $main.attr("error","true").html('<font color="red">正在检测,请稍候</font>');
      
      checkHostPort(host,"9090",function(flag){
          if(flag){
              checkToken2(function(flag){
                  if(flag){
                      var address = '';
                      if(openfireEmessageClientUrl!==''){
                          address = openfireEmessageClientUrl;
                      }else{
                          address = openfireMobileClientUrl;
                      }
                              testWebSocket(address,openfireHttpbindPort,function(flag){
                                  if(flag){
                                       window.top.Dialog.alert("<font color='green'>消息服务访问正常</font>");
                                       $main.html('');
                                       return;
                                  }else{
                                      //客户端没有端口没有开放
                                       window.top.Dialog.alert("<font color='red'>"+openfireHttpbindPort+"端口访问失败,该电脑无法访问"+address+"的"+openfireHttpbindPort+"端口,请联系网络管理员确认端口是否开放</font>");
                                       $main.html('');
                                       return;
                                  }
                              });
                  }else{
                      //获取token失败
                      window.top.Dialog.alert("<font color='red'>获取token异常,解决方案:</br>请重启一下ecology服务以及私有云消息服务后再登陆</font>");
                      $main.html('');
                      return;
                  }
              }); 
          }else{
              //9090端口访问不通
              //window.top.Dialog.alert("<font color='red'>私有云服务9090端口访问失败,1.请确认私有云服务是否正确启动,</br>2.请确认私有云服务初始化成功,请访问地址"+openfireEMobileUrl+"确认,</br>3.请确认</font>");
              inhtml += "<div style='color:red;font-size:15px;padding-top:27px'>私有云服务9090端口访问失败,解决方案:</br>"+
              "1、请确认私有云服务是否正确启动;</br>"+
              "2、请确认地址"+openfireEMobileUrl+"是否配置正确;</br>"+
              "3、请确认私有云服务是否初始化成功,可以访问地址"+openfireEMobileUrl+"确认<div>";
              dialog.InnerHtml = inhtml;
              $main.html('');
              dialog.show();
              return;
          }
      });
  
  }
  
  function checkSingleLoginBak(obj){
      var webinf = "<%=webinf%>";
      var dialog = new window.top.Dialog();
      dialog.currentWindow = window;
      dialog.Title = "解决方案";
      dialog.Width = 600;
      dialog.Height = 550;
      dialog.normalDialog= false;
      dialog.Drag = true;
      var inhtml = '';
      var $main = $(obj).next().next();
      $main.attr("error","true").html('<font color="red">正在检测,请稍候</font>');
      jQuery.post('/social/manager/SocialIMCheckOperation.jsp?operation=isBaseFilterConfigured', function(flag){
         if(jQuery.trim(flag)==='true'){
             inhtml += "<div style='font-size:15px;padding-top:27px;text-align: left;padding-left: 24px;'><h3>已经配置了SocialIMFilter过滤器,但是问题没有解决,解决方案:</h3></br>"+
             "1、在"+webinf+"目录下找到<font color='red'>web.xml</font>文件;</br></br>" +
             "2、打开该文件,在文件中搜索<font color='red'>SocialIMFilter</font>关键字;</br></br>" +
             "3、把过滤器的配置内容拷贝出来,放到<font color='red'>web-app</font>的下方;</br></br>" + 
             "4、备注:过滤器配置内容应该和下方内容保持一致:</br></br>" + 
              "<div style='color:red;'><xmp><filter></xmp>"+
               "<xmp><filter-name>SocialIMFilter</filter-name></xmp>"+
                       "<xmp><filter-class>weaver.social.filter.SocialIMFilter</filter-class></xmp>"+
                     "<xmp></filter></xmp>"+
                      "<xmp><filter-mapping></xmp>"+
                        "<xmp><filter-name>SocialIMFilter</filter-name></xmp>"+
                        "<xmp><url-pattern>/social/im/*.jsp</url-pattern></xmp>"+
                      "<xmp></filter-mapping></xmp>"+
                      "<xmp><filter-mapping></xmp>"+
                        "<xmp><filter-name>SocialIMFilter</filter-name></xmp>"+
                        "<xmp><url-pattern>/weaver/weaver.file.FileDownload</url-pattern></xmp>"+
                      "<xmp></filter-mapping></xmp></div>";
              dialog.InnerHtml = inhtml;
              $main.html('');
              dialog.show();
             return;
         }else{
             inhtml += "<div style='font-size:15px;padding-top:27px;text-align: left;padding-left: 24px;'><h3>没有配置SocialIMFilter过滤器,解决办法:</h3></br>"+
             "1、在"+webinf+"目录下找到<font color='red'>web.xml</font>文件;</br></br>" +
             "2、打开该文件,在文件中搜索<font color='red'>WSessionClusterFilter</font>关键字,如果找到,就将下面配置内容放到<font color='red'>WSessionClusterFilter</font>过滤器的下方;</br></br>" +
             "3、如果没有找到该过滤器,那就将下面配置内容放到<font color='red'>web-app</font>的下方;</br></br>" + 
             "4、配置内容如下:</br></br>" + 
              "<div style='color:red;'><xmp><filter></xmp>"+
               "<xmp><filter-name>SocialIMFilter</filter-name></xmp>"+
                       "<xmp><filter-class>weaver.social.filter.SocialIMFilter</filter-class></xmp>"+
                     "<xmp></filter></xmp>"+
                      "<xmp><filter-mapping></xmp>"+
                        "<xmp><filter-name>SocialIMFilter</filter-name></xmp>"+
                        "<xmp><url-pattern>/social/im/*.jsp</url-pattern></xmp>"+
                      "<xmp></filter-mapping></xmp>"+
                      "<xmp><filter-mapping></xmp>"+
                        "<xmp><filter-name>SocialIMFilter</filter-name></xmp>"+
                        "<xmp><url-pattern>/weaver/weaver.file.FileDownload</url-pattern></xmp>"+
                      "<xmp></filter-mapping></xmp></div>";
              dialog.InnerHtml = inhtml;
              $main.html('');
              dialog.show();
             return;
         }
     });
  
  }
  
  function checkSingleLogin(obj){
      var webinf = "<%=webinf%>";
      var dialog = new window.top.Dialog();
      dialog.currentWindow = window;
      dialog.Title = "解决方案";
      dialog.Width = 600;
      dialog.Height = 600;
      dialog.normalDialog= false;
      dialog.Drag = true;
      var inhtml = '';
      var $main = $(obj).next().next();
      $main.attr("error","true").html('<font color="red">正在检测,请稍候</font>');
      var title = "";
      var messsage3 = "";
      var messsage2 = "";
      jQuery.post('/social/manager/SocialIMCheckOperation.jsp?operation=checkALLFilter', function(data){
          var result = JSON.parse(jQuery.trim(data));
          var numSocialIMFilter = parseInt(result.isSocialIMFilter);
          var numWSessionClusterFilter = parseInt(result.isWSessionClusterFilter);
          var numSecurityFilter = parseInt(result.isSecurityFilter);
          var errorInfo = result.error;
          if(errorInfo==""){
	      if(numSocialIMFilter > 0){
	           title = "已经配置了SocialIMFilter过滤器,如果问题没有解决,解决方法:";
	           if(numWSessionClusterFilter>0&&numSecurityFilter>0){
	               if(numWSessionClusterFilter>numSocialIMFilter&&numSocialIMFilter>numSecurityFilter){
	                   window.top.Dialog.alert("<font color='green'>配置正确</font>");
	                   $main.html('');
	                   return;
	               }else if(numWSessionClusterFilter<numSocialIMFilter||numSocialIMFilter<numSecurityFilter){
	                   messsage2 = "2、打开该文件,在文件中搜索<font color='red'>WSessionClusterFilter</font>和<font color='red'>SocialIMFilter</font>关键字;</br></br>";
                       messsage3 = "3、把<font color='red'>SocialIMFilter</font>配置的内容剪切到<font color='red'>WSessionClusterFilter</font>过滤器的下方;</br></br>";
	               }else{
	                   messsage2 = "2、打开该文件,在文件中搜索<font color='red'>WSessionClusterFilter</font>和<font color='red'>SocialIMFilter</font>关键字;</br></br>";
                       messsage3 = "3、把<font color='red'>WSessionClusterFilter</font>配置的内容剪切到<font color='red'>web-app</font>节点的下方,并把<font color='red'>SocialIMFilter</font>配置的内容剪切到<font color='red'>WSessionClusterFilter</font>过滤器的下方;</br></br>";
	               }
	           }else if(numWSessionClusterFilter>0){
	               if(numWSessionClusterFilter>numSocialIMFilter){
	                   window.top.Dialog.alert("<font color='green'>配置正确</font>");
	                   $main.html('');
                       return;
	               }else{
	                   messsage2 = "2、打开该文件,在文件中搜索<font color='red'>WSessionClusterFilter</font>和<font color='red'>SocialIMFilter</font>关键字;</br></br>";
                       messsage3 = "3、把<font color='red'>SocialIMFilter</font>配置的内容剪切到<font color='red'>WSessionClusterFilter</font>过滤器的下方;</br></br>";
	               }
	           }else if(numSecurityFilter>0){
	               if(numSocialIMFilter>numSecurityFilter){
                       window.top.Dialog.alert("<font color='green'>配置正确</font>");
                       $main.html('');
                       return;
                   }else{
                       messsage2 = "2、打开该文件,在文件中搜索<font color='red'>SocialIMFilter</font>关键字;</br></br>";
                       messsage3 = "3、把<font color='red'>SocialIMFilter</font>配置的内容剪切到<font color='red'>web-app</font>节点的下方;</br></br>";
                   }
	           }else{
	                messsage2 = "2、打开该文件,在文件中搜索<font color='red'>SocialIMFilter</font>关键字;</br></br>";
                    messsage3 = "3、把<font color='red'>SocialIMFilter</font>配置的内容剪切到<font color='red'>web-app</font>节点的下方;</br></br>";
	           }
	      }else{
	           title = "没有配置SocialIMFilter过滤器,解决办法:";
	           if(numWSessionClusterFilter>0){
	               messsage2 = "2、打开该文件,在文件中搜索<font color='red'>WSessionClusterFilter</font>关键字;</br></br>";
	               messsage3 = "3、将下方标红的内容配置到<font color='red'>WSessionClusterFilter</font>过滤器的下方;</br></br>";
	           }else if(numSecurityFilter>0){
	               messsage2 = "2、打开该文件,在文件中搜索<font color='red'>SecurityFilter</font>关键字;</br></br>";
	               messsage3 = "3、将下方标红的内容配置到<font color='red'>SecurityFilter</font>过滤器的上方;</br></br>";
	           }else{
	               messsage2 = "2、打开该文件,在文件中搜索<font color='red'>web-app</font>关键字;</br></br>";
                   messsage3 = "3、将下方标红的内容配置到<font color='red'>web-app</font>节点的下方;</br></br>";
	           }
	      }
	      }else{
	           window.top.Dialog.alert("<font color='red'>服务异常,检查失败</font>");
	           $main.html('');
               return;
	      }
	      inhtml += "<div style='font-size:15px;padding-top:27px;text-align: left;padding-left: 24px;'><h3>"+title+"</h3></br>"+
	             "1、在<font color='red'>"+webinf+"</font>目录下找到<font color='red'>web.xml</font>文件,并先<font color='red'>备份</font>该文件;</br></br>" +
	              messsage2 +
	              messsage3 + 
	              "4、修改完成后需要重启ecology服务才会生效;</br></br>" +
	              "5、备注:<font color='red'>SocialIMFilter</font>过滤器配置内容应该和下方内容保持一致:</br></br>" + 
	              "<div style='color:red;'><xmp><filter></xmp>"+
	               "<xmp><filter-name>SocialIMFilter</filter-name></xmp>"+
	                       "<xmp><filter-class>weaver.social.filter.SocialIMFilter</filter-class></xmp>"+
	                     "<xmp></filter></xmp>"+
	                      "<xmp><filter-mapping></xmp>"+
	                        "<xmp><filter-name>SocialIMFilter</filter-name></xmp>"+
	                        "<xmp><url-pattern>/social/im/*.jsp</url-pattern></xmp>"+
	                      "<xmp></filter-mapping></xmp>"+
	                      "<xmp><filter-mapping></xmp>"+
	                        "<xmp><filter-name>SocialIMFilter</filter-name></xmp>"+
	                        "<xmp><url-pattern>/weaver/weaver.file.FileDownload</url-pattern></xmp>"+
	                      "<xmp></filter-mapping></xmp></div>";       
	       dialog.InnerHtml = inhtml;
	       $main.html('');
	       dialog.show();
	       return;
	  });
  }
  
  function checkHostPort(host,port,cb){
     jQuery.post('/social/manager/SocialIMCheckOperation.jsp?operation=checkPort',{port: port,hostname : host}, function(flag){
         if(jQuery.trim(flag)==='1'){
             cb(true);
         }else{
             cb(false);
         }
     });
 }
 
 function checkToken2(cb){
     jQuery.post('/social/manager/SocialIMCheckOperation.jsp?operation=checkToken&reFreshToken=1',{"host":""}, function(token){
         if(jQuery.trim(token)!==''){
             cb(true);
         }else{
             cb(false);
         }
     });
 }
  
  function checkToken(obj,host){
     //配置项检查,带有host为参数
     var isOpenfire = $(document).find('form').find('input#Openfire').attr('checked');
     var url = "";
     var userid = "<%=userid%>";
     if(isOpenfire){
       url = "/social/manager/SocialIMCheckOperation.jsp?operation=checkToken&reFreshToken=1";
     }else{
       url = "/social/im/SocialIMOperation.jsp?operation=getUserTokenOfRong&userid="+userid;
       host = "";
     }
     jQuery.post(url,{"host":host},function(token){
          if(jQuery.trim(token)!==''){
             if(isOpenfire){
                $(obj).next().next().attr("error","false").html('<font color="green">检测通过</font>')
             }else{
                window.top.Dialog.alert("获取token成功");
             }
          }else{
             if(isOpenfire){
                //window.top.Dialog.alert("获取token失败,请检查emssage服务是否正常");
                $(obj).next().next().attr("error","true").html('<font color="red">获取私有云token失败,可能是ecology缓存或私有云未能成功初始化,请先重启ecology服务(有运维平台从运维平台重启),如果无效,请检查登录9090管理控制台检查私有云服务是否成功初始化</font>');
                return;
             }else{
                window.top.Dialog.alert("获取token失败,请检查oa服务是否能够正常访问融云服务器");
                return;
             }
          }
     });
  }
   
  function openFilter(){
    window.open("http://emessage.e-cology.com.cn/html/emessagefile/message4.x%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88.htm#_Toc502157626","_blank");
  }
  function openHttps(){
    window.open("http://emessage.e-cology.com.cn/html/download.html","_blank");
  }
  
  function checkEmessagePort(obj,ip,name,checkSocket,callback){
      //  var port = "";
      //  var is7443 = $(document).find('form').find('input#openfireHttpbindPort').attr('checked');
      //  var client = "emessage";
      //  if(is7443){
      //       port = '7443'
      //  }else{
      //       port = '7070'
      //  }
      //  if(name=='openfireMobileClientUrl'){
      //     port = '5222';
      //     client = "emobile";
      //  }
      //
      //  var $mainObj = null;
      //  if(name=='openfireMobileClientUrl'){
      //      $mainObj = $(obj).next().next().next();
      //  }else {
      //      $mainObj = $(obj).next().next();
      //  }
      //
      // if(name=='openfireEMobileUrl'){
      //     port = '9090';
      // }
      //
      //  if(name != 'openfireEMobileUrl' && (ip.substring(0,4)=="http"||ip.substring(0,5)=="https")){
      //      $mainObj.attr("error","true").html('<font color="red">该地址不需要带上http或者https协议头</font>');
      //      return;
      //  }
      //  if(!checkIP(ip)){
      //      $mainObj.attr("error","true").html('<font color="red">该地址ip配置格式不正确</font>');
      //      return;
      //  }
      //
      //  $mainObj.attr("error","true").html('<font color="red">正在检测,请稍候</font>');
      //  // 服务端只检测9090端口
      //  if (name=='openfireEMobileUrl') {
      //      jQuery.post('/social/manager/SocialIMCheckOperation.jsp?operation=checkPort',{"port": port,"hostname" : ip}, function(ok){
      //          if(jQuery.trim(ok)==='1'){
      //              callback && callback(true)
      //          }else{
      //              $mainObj.attr("error","true").html('<font color="red">'+client+'连接消息服务失败,请检查该地址是否配置正确,私有云服务'+port+'端口是否开放,私有云服务是否启动状态</font>');
      //              callback && callback(false)
      //              return;
      //          }
      //      });
      //  } else {
      //      if(checkSocket){
      //          testWebSocket(ip,port,function(flag){
      //              if(flag){
      //                  $mainObj.attr("error","fasle").html('<font color="green">检测通过</font>');
      //                  callback && callback(true)
      //                  return;
      //              }else{
      //                  $mainObj.attr("error","true").html('<font color="red">客户端连接消息服务失败,请尝试:<a href="#" onClick="openHttps()" style="color:red">更新emessage更新包以及私有云更新包(点击跳转)</a></font>');
      //                  callback && callback(false)
      //                  return;
      //              }
      //          });
      //      }else{
      //          $mainObj.attr("error","fasle").html('<font color="green">检测通过</font>');
      //          callback && callback(true)
      //          return;
      //      }
      //  }
  }
  
  function testWebSocket(ip,port,cb){
    //ws://192.168.7.201:7070/ws/ 如果是https下 wss   wss://192.168.7.201:7070/ws/
    var url = '';
    var hostname ="";
    if(port=='7443'){
        hostname = "wss";
    }else{
        hostname = "ws";
    }
    url = hostname+'://'+ip+':'+port+'/ws/';
    var ws = new WebSocket(url,'xmpp');

    ws.onerror = function () {
        cb(false);
    };
        
    ws.onopen = function () {
        cb(true);
    };
  }
  
  function checkFilter(){
    jQuery.post('/social/manager/SocialIMCheckOperation.jsp?operation=checkFilter', function(ok){
            if(jQuery.trim(ok)==='1'){
                window.top.Dialog.alert("过滤器已经配置");
            }else{
                window.top.Dialog.alert("过滤器没有配置成功");
            }
    });
  }
  
  function validateValue(obj){
       var $chk = jQuery(obj);
       var _name = $chk.attr("name");
       var value = $chk.val();
       var info = $chk.attr("info");
       var regex = '(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))';
       var rex = new RegExp(strRegex);
       if(_name==='openfireEMobileUrl'){
           var host = "";
           var strRegex = "^(http\:\/\/|https\:\/\/)?" +
            "(([0-9]{1,3}\.){3}[0-9]{1,3}" +
            "|" +
            "([0-9a-z_!~*'()-]+\.)*" +
            "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." +
            "[a-z]{2,6})" +
            "(:[0-9]{1,5})?" +
            "((/?)|" +
            "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
            var re = new RegExp(strRegex);
            if(value===''){
                $(obj).next().next().attr("error","true").html('<font color="red">'+info+' <%=SystemEnv.getHtmlLabelName(18622,user.getLanguage())%></font>');
                return;
            }
            if (!re.test(value)) {
                //window.top.Dialog.alert("私有云服务控制台地址格式配置不正确");
                $(obj).next().next().attr("error","true").html('<font color="red"><%=lng==8?"The private cloud service console address format is incorrectly configured. Please modify it.":(lng==9?"私有云服務控制台地址格式配置不正確,請修改":"私有云服务控制台地址格式配置不正确,请修改")%></font>');
                return;
            }
            if(value.substring(0,4)!=="http"){
                $(obj).next().next().attr("error","true").html('<font color="red"><%=lng==8?"Private cloud service console address format configuration is incorrect, missing prefix ":(lng==9?"私有云服務控制台地址格式配置不正確,缺少前綴":"私有云服务控制台地址格式配置不正确,缺少前缀")%>http:\/\/ <%=SystemEnv.getHtmlLabelName(21695,user.getLanguage())%> https:\/\/</font>');
                return;
            }
            var port = value.substring(value.lastIndexOf(":")+1,value.length);
           // if(!(value.lastIndexOf(":")!==-1 && port=="9090")){
           //     //window.top.Dialog.alert("私有云服务控制台地址端口为9090");
           //     $(obj).next().next().attr("error","true").html('<font color="red">私有云服务控制台地址端口应配置为9090</font>');
           //     return;
           // } else {
           //     $(obj).next().next().attr("error","false").html('<font color="green">检测通过</font>');
           // }
           $(obj).next().next().attr("error","false").html('<font color="green"><%=SystemEnv.getHtmlLabelName(82190,user.getLanguage())%></font>');
           var hostname = value.substring(value.indexOf('://') + 3, value.lastIndexOf(':'));
           checkEmessagePort(obj,hostname,_name,false, function (isPass) {
               if (isPass) {
                   // 初始配置的时候不需要检测token
                   // checkToken(obj, value)
               }
           });
       }else if(_name==='openfireMobileClientUrl'){
           value = value.replace(/\s/gim, '');
           if(value===''){
                $(obj).next().next().next().attr("error","true").html('<font color="red">'+info+' <%=SystemEnv.getHtmlLabelName(18622,user.getLanguage())%></font>');
                return;
           }
           // 屏蔽localhost和回环地址
           if (value.toLowerCase().indexOf('localhost') === 0 || value.indexOf('127.') === 0) {
               $(obj).next().next().next().attr("error","true").html('<font color="red">'+info+'<%=lng==8?"Loopback address configuration is not allowed":(lng==9?"不允許配置回環地址":"不允许配置回环地址")%></font>');
               return;
           }
           checkEmessagePort(obj,value,_name,false);
       }else if(_name==='openfireEmessageClientUrl'){
           if (!isUseEmessage) {
               return;
           }
           value = value.replace(/\s/gim, '');
           if(value===''){
                $(obj).next().next().attr("error","true").html('<font color="red">'+info+' <%=SystemEnv.getHtmlLabelName(18622,user.getLanguage())%></font>');
                return;
           }
           // 屏蔽localhost
           if (value.toLowerCase().indexOf('localhost') === 0) {
               $(obj).next().next().attr("error","true").html('<font color="red">'+info+'<%=lng==8?"the LOCALHOST address is not allowed":(lng==9?"不允許配置localhost":"不允许配置localhost")%></font>');
               return;
           }
           checkEmessagePort(obj,value,_name,true);
       }
  }
  
  function checkIP(ip){
    var re=/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;//正则表达式   
    if(re.test(ip))
    {   
       if( RegExp.$1<256 && RegExp.$2<256 && RegExp.$3<256 && RegExp.$4<256){
            return true;
       }else{
            return false;
       }
    }else{
        return true;
    }
  }
  
  
  function changeValue(obj){
        var $chk = jQuery(obj);
        var _name = $chk.attr("name");
        if($chk.val()=='true'){
            jQuery("input[name='Openfire']").val('true');
            showEle('openfireEMobileUrl','true');
            showEle('openfireMobileClientUrl','true');
            if (isUseEmessage) {
                showEle('openfireEmessageClientUrl','true');
            }
            hideEle("checkToken");
            showEle('openfireHttpbindPort', 'true');
            showEle('checkConnect','true');
            $('#oTableAddress').show();
            $('#appkeytips').hide();
        }else{
            jQuery("input[name='Openfire']").val('false');
            hideEle("openfireEMobileUrl");
            hideEle("openfireMobileClientUrl");
            hideEle("openfireEmessageClientUrl");
            hideEle("openfireHttpbindPort");
            showEle("checkToken");
            hideEle("checkConnect");
            $('#oTableAddress').hide();
            if (<%=!isOpenfire && needBuyAppkey%>) {
            	$('#appkeytips').show();
            }
        }
   }
   
   function changeHttpValue(obj){
         var $chk = jQuery(obj);
        var _name = $chk.attr("name");
        if($chk.val()=='false'){
            $chk.val('true');
            jQuery("input[name='"+_name+"']").val('true');
        }else{
            jQuery(obj).val('false');
            jQuery("input[name='"+_name+"']").val('false');
        }
   }
   
   function openUrl(){
        window.open("http://emessage.e-cology.com.cn/html/emessagefile/%E6%B3%9B%E5%BE%AEWindows%E7%89%88e-message4.1%E7%A7%81%E6%9C%89%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE%E6%89%8B%E5%86%8C.htm","_blank");
   }

 </script>
</html>