var l2tp_server_record_next_index = 0;
var l2tp_server_record_edit_index = 0;
var l2tp_server_max_number = 10;
var l2tp_server_count =0;
var l2tp_client_record_next_index = 0;
var l2tp_client_max_number = 8;
var l2tp_client_count =0;
/*------- l2tp_server start --------------------*/
/*
Add/Delete/Edit l2tp server account
l2tp_account_next_index => �n���J C_WEBUI_VPNL2TPACC_RECORD_RULE ���U�@�� index �ΨӰO��Ū��CSID �o����
l2tp_server_record_next_index => �U�@�� account �� index  �� C_L2TPSERV_ACCOUNT_USER �Ĥ@�Ӫťժ�CSID
by kent
*/
var l2tp_server_account_csid = new Array(
"N002020C0",
"N002020C1",
"N002020C2",
"N002020C3",
"N002020C4",
"N002020C5",
"N002020C6",
"N002020C7",
"N002020C8",
"N002020C9",
""
)
var l2tp_server_account_index = new Array(
"1",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
)
var l2tp_server_user_csid = new Array(
"S001B0100",
"S001B0101",
"S001B0102",
"S001B0103",
"S001B0104",
"S001B0105",
"S001B0106",
"S001B0107",
"S001B0108",
"S001B0109",
""
)
var l2tp_server_password_csid = new Array(
"S001B0200",
"S001B0201",
"S001B0202",
"S001B0203",
"S001B0204",
"S001B0205",
"S001B0206",
"S001B0207",
"S001B0208",
"S001B0209",
""
)
var l2tp_server_account_active_csid = new Array(
"N001B0300",
"N001B0301",
"N001B0302",
"N001B0303",
"N001B0304",
"N001B0305",
"N001B0306",
"N001B0307",
"N001B0308",
"N001B0309",
""
)
var l2tp_account_next_index = 0;
for(a=0;a<l2tp_server_account_index.length;a++)
{
if(l2tp_server_account_index[a] == "")
{
l2tp_account_next_index = a;
break;
}
}
function add_edit_l2tp_server_account(type,edit_user_index)
{
var add_edit_table = document.getElementById("add_edit_account_table");
var add_button = document.getElementById("add_save_button");
var edit_button = document.getElementById("edit_save_button");
var user_name_contant = document.getElementById("l2tp_ser_username_text");
var user_password_contant = document.getElementById("l2tp_ser_password_text");
var user_active_checked = document.getElementById("l2tp_ser_active_check");
var anchor = document.getElementById("_a_anchor");
if(type == 'add')
{
if(l2tp_account_next_index == l2tp_server_max_number){
alert(GetElmCont("pptps_0","Rule could not be added anymore."));
return false;
}
}
else
{
user_name_contant.value = document.getElementById("s_account_username_"+edit_user_index).innerHTML;
user_password_contant.value = document.getElementById("s_account_password_"+edit_user_index).innerHTML;
user_active_checked.checked = (document.getElementById("s_account_active_"+edit_user_index).checked)?"checked":"";
l2tp_server_record_edit_index = edit_user_index;
}
add_edit_table.style.display = "";
add_button.style.display = (type == "add")?"":"none";
edit_button.style.display = (type == "add")?"none":"";
anchor.click();
}
function save_l2tp_server_user_account(type,obj)
{
var add_user_name = document.getElementById("l2tp_ser_username_text").value;
var add_user_password = document.getElementById("l2tp_ser_password_text").value;
var add_user_avtive_check = document.getElementById("l2tp_ser_active_check").checked;
var add_user_avtive = (add_user_avtive_check)?1:0;
var account_str = "l2tps.htm?";
var add_index = l2tp_server_record_next_index;
var div_obj =  document.getElementById("d_hidden_element");
var str_message = "";
if(add_user_name == "" || add_user_password == "")
{
str_message = (add_user_name == "")?GetElmCont("pptps_0","Username can not be empty."):GetElmCont("pptps_0","Password can not be empty.");
alert(str_message);
return false;
}
if(type == 'add')
{
account_str += "<input typt='text' name='"+l2tp_server_account_csid[l2tp_account_next_index]+"' value='"+(add_index+1)+"'>";
account_str += "<input typt='text' name='"+l2tp_server_user_csid[add_index]+"' value='"+add_user_name+"'>";
/*  -- �H�U�OPassword�[�K�ɪ��t�@�ؤ��k[�A�Ω��n�[�K��CSID�S���X�{�bHTML�ɸ̡A�άO��CSID�H�}�C�B�r�굥�覡�p�X�e�X������] --  */
/*  -- Password�b�e�X�e�������i���[�K�A�Φr�����N���覡�⥻�ӭn�ǥX��"S?"�令"P?"�A�[�K�����e(function)�@�w�n�g�b�o�̡A�g�bHTML�̭��e���X�{BUG --  */
var encrypt_pw_v = pwd_trans("l2tp_ser_password_text");  /*  -- 1.�ɤJ�[�K��function --  */
var encrypt_pw_n = l2tp_server_password_csid[add_index];  /*  -- 2.���oCSID�����m --  */
encrypt_pw_n = "P"+encrypt_pw_n.substr(1 , encrypt_pw_n.length);  /*  -- 3.���NCSID��P?�t�C --  */
account_str += "<input typt='text' name='"+encrypt_pw_n+"' value='"+encrypt_pw_v+"'>";  /*  -- 4.�[�K����Password�|�b�o�̦s�J�r�ꤤ�A�b�᭱��submit�Τ@�ǰe�X�h[�����սЦb�����W��] --  */
account_str += "<input typt='text' name='"+l2tp_server_account_active_csid[add_index]+"' value='"+add_user_avtive+"'>";
}
else if(type == 'edit')
{
account_str += "<input typt='text' name='"+l2tp_server_user_csid[l2tp_server_record_edit_index]+"' value='"+add_user_name+"'>"
var encrypt_pw_v = pwd_trans("l2tp_ser_password_text");
var encrypt_pw_n = l2tp_server_password_csid[l2tp_server_record_edit_index];
encrypt_pw_n = "P"+encrypt_pw_n.substr(1 , encrypt_pw_n.length);
account_str += "<input typt='text' name='"+encrypt_pw_n+"' value='"+encrypt_pw_v+"'>";
account_str += "<input typt='text' name='"+l2tp_server_account_active_csid[l2tp_server_record_edit_index]+"' value='"+add_user_avtive+"'>"
}
div_obj.innerHTML = account_str;
document.forms[0].submit()
}
function del_l2tp_server_user_account()
{
var tmp_del = document.getElementsByName("del_account");
var del_arr = new Array();
var index = 0;
var new_index = 0;
var sent_str ="l2tps.htm?N801B0001=1";
for(var t=0;t<tmp_del.length;t++)
{
if(tmp_del[t].checked)
{
del_arr[index] = tmp_del[t].value;
index++;
}
}
if(del_arr.length == 0)
{
alert(GetElmCont("lb_0","Please choose one or more rule."));
return false;
}
for(var r=0;r<l2tp_server_account_index.length;r++)
{
for(var n=0;n<del_arr.length;n++)
{
if(l2tp_server_account_index[r] == del_arr[n])
{
l2tp_server_account_index[r] = "";
}
}
}
for(var a=0;a<l2tp_server_account_csid.length;a++)
{
if(l2tp_server_account_index[a] != "")
{
sent_str += (sent_str == "l2tps.htm?")?l2tp_server_account_csid[new_index]+"="+l2tp_server_account_index[a]:"&"+l2tp_server_account_csid[new_index]+"="+l2tp_server_account_index[a];
new_index++;
}
}
for(var c=new_index;c<l2tp_server_account_csid.length-1;c++)
{
sent_str += (sent_str == "l2tps.htm?")?l2tp_server_account_csid[c]+"=":"&"+l2tp_server_account_csid[c]+"=";
}
for(var x=0;x<del_arr.length;x++)
{
var xx = del_arr[x]-1;
sent_str += (sent_str == "l2tps.htm?")?l2tp_server_user_csid[xx]+"=":"&"+l2tp_server_user_csid[xx]+"=";
}
GURL(sent_str);
}
function controlsmit(_b,_tag){
if((document.getElementById('_wary_99')!=null)&&(document.getElementById('_wary_99').value == "Save"))
{
if(smit_str0 == "") { smit_str0 = _tag }
else if((smit_str0 != "")&&(smit_str0 != _tag)&&(_tag != "clr")){
smit_str0 = _tag
}
else if(_tag == "clr"){
if(smit_str0 != ""){
document.getElementById('add_edit_account_table').style.display = 'none';
}
smit_str0 = "";
}
document.getElementById('_wary_99').disabled = _b;
}
}
/*------- l2tp_server end --------------------*/
/*------- l2tp_client start --------------------*/
/*
Add/Delete/Edit pptp client account
pptp_account_next_index => �n���J C_WEBUI_VPNPPTPACC_RECORD_RULE ���U�@�� index �ΨӰO��Ū��CSID �o����
l2tp_client_record_next_index => �U�@�� account �� index  �� C_L2TP_CLI_TUNLNAME �Ĥ@�Ӫťժ�CSID
by kent
*/
var l2tp_client_record_csid = new Array(
"N00202100",
"N00202101",
"N00202102",
"N00202103",
"N00202104",
"N00202105",
"N00202106",
"N00202107",
""
)
var l2tp_client_record_index = new Array(
"1",
"",
"",
"",
"",
"",
"",
"",
""
)
var l2tp_client_tunlname_csid = new Array(
"S00061200",
"S00061201",
"S00061202",
"S00061203",
"S00061204",
"S00061205",
"S00061206",
"S00061207",
""
)
var l2tp_client_tunlname_xx = new Array(
"L2TP #1",
"",
"",
"",
"",
"",
"",
"",
""
)
var l2tp_client_tunlen_csid = new Array(
"N00061100",
"N00061101",
"N00061102",
"N00061103",
"N00061104",
"N00061105",
"N00061106",
"N00061107",
""
)
var l2tp_client_record_length = 0;
for(var g=0;g<l2tp_client_record_index.length;g++)
{
if(l2tp_client_record_index[g] == "")
{
l2tp_client_record_length = g;
break;
}
}
function add_l2tp_client_account(obj)
{
if(l2tp_client_record_length != l2tp_client_max_number)
{
obj.form.action = "l2tpcadd.htm";
obj.form.Ntid.value = (l2tp_client_record_next_index+1);
obj.form.Nl2tpclen.value = l2tp_client_record_length;
obj.form.Nrule.value = l2tp_client_record_next_index;
obj.form.submit();
}
else
{
alert(GetElmCont("pptps_0","Rule could not be added anymore."));
}
}
function del_l2tp_client_user_account()
{
var tmp_del = document.getElementsByName("l2tp_ckient_del");
var del_arr = new Array();
var index = 0;
var new_index = 0;
var sent_str ="l2tps.htm?Nserver="+document.forms[0].Nserver.value;
for(var t=0;t<tmp_del.length;t++)
{
if(tmp_del[t].checked)
{
del_arr[index] = tmp_del[t].value;
index++;
}
}
if(del_arr.length == 0)
{
alert(GetElmCont("lb_0","Please choose one or more rule."));
return false;
}
for(var r=0;r<l2tp_client_record_index.length;r++)
{
for(var n=0;n<del_arr.length;n++)
{
if(l2tp_client_record_index[r] == del_arr[n])
{
l2tp_client_record_index[r] = "";
}
}
}
for(var a=0;a<l2tp_client_record_csid.length;a++)
{
if(l2tp_client_record_index[a] != "")
{
sent_str += (sent_str == "l2tps.htm?")?l2tp_client_record_csid[new_index]+"="+l2tp_client_record_index[a]:"&"+l2tp_client_record_csid[new_index]+"="+l2tp_client_record_index[a];
new_index++;
}
}
for(var c=new_index;c<l2tp_client_record_csid.length-1;c++)
{
sent_str += (sent_str == "l2tps.htm?")?l2tp_client_record_csid[c]+"=":"&"+l2tp_client_record_csid[c]+"=";
}
for(var r=0;r<del_arr.length;r++)
{
var tunlname_index = del_arr[r]-1;
sent_str += "&"+l2tp_client_tunlname_csid[tunlname_index]+"=";
}
for(var r=0;r<del_arr.length;r++)
{
var tunlen_index = del_arr[r]-1;
sent_str += "&"+l2tp_client_tunlen_csid[tunlen_index]+"=0";
}
var ovdel_arr=[];
for(var r=0;r<del_arr.length;r++)
{
var tunlen_index = del_arr[r]-1;
if(l2tp_cli_ovipsec_xxx[tunlen_index]!="0"){
ovdel_arr.push(del_arr[r]);
}
}
sent_str += L2TPovIPsec_info(0,ovdel_arr) //del L2TP over IPsec all item
GURL(sent_str);
}
/*------- l2tp_client end --------------------*/