<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="stylemain.css" type="text/css">
<link rel="stylesheet" href="colors.css" type="text/css">
<meta http-equiv="Pragma" content="no-cache">
<title>OpenVPN</title>
<script language="javascript" src="util.js"></script>
<script language="javascript" src="openvpn_msg.js"></script>
<script language="javascript">
<!-- hide  
var sessionKey='<%ejGetOther(sessionKey)%>';

var mode = '<%ejGet(ovpnMajorMode)%>';

//setLanguage('<%ejGet(webUILanguage)%>'); 
//Butterlate.setTextDomain("advanced_1");

var ovpnStatus = '<%ejGet(ovpnStatus)%>';
var ovpnSSLFile='<%ejGet(ovpnSSLFile)%>';
var ovpnSSLFiles=ovpnSSLFile.split(',');
var ovpnIndexName='<%ejGet(ovpnIndexName)%>';

/*
function initTranslation() 
{
    var idArray = new Array("ovpn_certfile", "ovpn_upcertfile", "ovpn_btnNext", 
		"ovpn_btnBack", "ovpn_btnUpload", "ovpn_btnRemove", "ovpn_btnSave", 
		"ovpn_btnDownload", "ovpn_remove", "ovpn_download", "ovpn_unloaded");
        
    setAllIdValue(idArray);
}
*/

function formLoad()
{
    //initTranslation();
    if(ovpnStatus==0)
    {
        ovpnSSLFile='';
    }
}

function DownloadClick(name)
{
    if(name!='')
    {
        var loc = 'openvpnexport.cgi?';
        loc += 'filename=' + name;
        loc += '&sessionKey=' + sessionKey;
        var code = 'location="' + loc + '"';
       eval(code);
    }
}

function removeClick(rml) 
{
    var lst = '';
    var i;
    if (rml.length > 0)
    {
        for (i = 0; i < rml.length; i++)
        {
            if ( rml[i].checked == true )
            {
                lst += rml[i].value + ',';
            }
        }
    }
    else if ( rml.checked == true )
    {
        lst = rml.value;
    }   
    var loc = 'openvpn.cmd?action=remove&page=2&rmLst=' + lst;
    loc += '&sessionKey=' + sessionKey;
    var code = 'location="' + loc + '"';
    eval(code);
}


function uploadClick()
{
    if(document.importForm.fileSSLfile.value=='' || document.importForm.fileSSLfile.value.length<=0)
    {
        alert(_("ovpn_alertsctFile"));   
        return;
    }

    for(var i=0;i<ovpnSSLFiles.length; i++)
    {
        if(ovpnSSLFiles[i]==' ' ||ovpnSSLFiles[i]=='')
        {
            continue;
        }
        if( document.importForm.fileSSLfile.value.indexOf(ovpnSSLFiles[i])!=-1)
        {
            alert(_("ovpn_alertTheSameFile"));  
            return;
        }
        
    }
   document.importForm.submit();
}

function fillObj1Items()
{
    isSet = 0;
    if(ovpnSSLFile!='')
    {
        var i;
        for(i=0; i < ovpnSSLFiles.length; i++)
        {
            if(ovpnSSLFiles[i]!='')
            {
                document.writeln("<tr>");
                document.writeln("<td class='tablesize'><font color='green'>&nbsp;"+ ovpnSSLFiles[i] +"</font></td>");
                document.writeln("<td align='center'><input type='checkbox' name='rml' value='"+ ovpnSSLFiles[i] +"'></td>");
                document.writeln("<td align='center'><input type='button' onClick='DownloadClick(\"" 
                    + ovpnSSLFiles[i]+ "\")' id='ovpn_btnDownload' value='Download'></td>");
                document.writeln("</tr>");
            isSet = 1;
            }
        }
    }
    else
    {
        document.writeln("<tr>");
        document.writeln("<td align='center'><font color='red' id='ovpn_unloaded'>Not Loaded</font></td>");
        document.writeln("<td align='center'><input type='checkbox' name='rml' disabled></td>");
        document.writeln("<td align='center'><input type='button' value='Download' disabled></td>");
        document.writeln("</tr>");
    }
}

function backClick() 
{
    var loc = 'openvpnmanual1.cgi?ovpnStatus=1';
    loc += '&sessionKey=' + sessionKey;
    var code = 'location="' + loc + '"';
    eval(code);
}
function saveClick()
{
  var loc = 'openvpn.cmd?action=save&ovpnIndexName=' + ovpnIndexName;
    loc += '&sessionKey=' + sessionKey;
    var code = 'location="' + loc + '"';
    eval(code);
}
// done hiding -->
</script>
</head>
<body onLoad="formLoad()">
<blockquote> <b id="ovpn_title">OpenVPN<br>
  </b> <br>
  <br>
  <form name="importForm" method="post" ENCTYPE="multipart/form-data" action="openvpnuploadcert.cgi">
    <table border='1' cellpadding='4' cellspacing='0'>
      <tr>
        <td class='hd' id="ovpn_certfile">The Secret Keys</td>
        <td class='hd' id="ovpn_remove">Remove</td>
        <td class='hd' id="ovpn_download">Download</td>
      </tr>
      <script language='javascript'>
            fillObj1Items();
        </script>
    </table>
    <span id='ovpn_upcertfile'>Upload the secret key</span>
    <input type='file' name='fileSSLfile' id='ovpn_fileSSLfile'>&nbsp;<input type='button' name='btnUpload' id='ovpn_btnUpload' value='Upload' onClick="uploadClick()">
    <br>
      <input type='button' onClick='removeClick(this.form.rml)' value='Remove'  id='ovpn_btnRemove'>
      &nbsp;
      <input type='button' onClick='backClick()' value='Back' id='ovpn_btnBack'>
      &nbsp;
      <input type='button' onClick='saveClick()' value='Save' id='ovpn_btnSave'>

    <br>
    <br>
  </form>
</blockquote>
</body>
</html>
