<cpanel setvar="dprefix=../">
<?cptt header.html.tt ?>
<script language="javascript" src="<cpanel MagicRevision="uri("js/expander_optimized.js")">"></script>

<!-- The Dir Box Below
        <cpanel setvar="autodirsonly=1">
        <cpanel setvar="autoinput=path">
        <cpanel setvar="autofunc=pathDirComplete">
-->
<cpanel relinclude="passbar/phrases.html">
<script language="javascript" src="<cpanel MagicRevision="uri("js/password_strength_optimized.js")">"></script>
<cpanel relinclude="passbar/default_settings.html">
<cpanel relinclude="passbar/passbar_dialog.html">
<script>
<?cp Jvm::listappservjs(%,servers) ?>
</script>


<div class="body-content">
<!--<div id="pin2nav">
                <a href="#" onclick="PinItemToNav(); return false;"><img src="../images/pin16.gif" width="16" height="16" border="0" /><cpanel langprint="MENUPinNav"></a>
</div>-->
        <h1 class="page header"><div id="h1Title" class="h1Title" id="h1Title"><div class="icon spriteicon_img icon-jvm" id="icon-jvm" style="float: left;"></div>Private JVM</div></h1>
        <p class="description">A Private JVM give you a ability to install your own java application server in which you have full control over.<br>
        This gives you the flexibilty to restart the application server without interfering with other running servers/services.</p><br />
        <cpanelif !$CPVAR{'jvmsupport'}>
            <font color="red">JVM support is not enabled for your account. Contact server administrator for more information.</font>
        </cpanelif>
        <cpanelif $CPVAR{'jvmsupport'} and $CPVAR{'appserverset'}>
        <script type="text/javascript">

truncate_on=1;
truncate_wrap = 1;
truncate_tooltips = 0;
register_truncate_table('manage-ror');
var chpanel;

function nullop() {
    var hidepanel = function() {
        chpanel.hide();
    }
    setTimeout(hidepanel,5000);
}

function checkpwd(form)
  {

    if(form.pass.value != "" && form.pass.value == form.pass2.value) {
      if(form.pass.value.length < 6) {
        alert("Error: Password must contain at least six characters!");
        form.pass.focus();
        return false;
      }
    } else {
      alert("Error: Passwords do not match!");
      form.pass.focus();
      return false;
    }
    return true;
  }

function complex_password(password)
  {
        var nuclearNailsPassword = /(?=[-_$£a-zA-Z0-9]*?[$£])(?=[-_$£a-zA-Z0-9]*?[_])(?=[-_$£a-zA-Z0-9]*?[A-Z])(?=[-_$£a-zA-Z0-9]*?[a-z])(?=[-_$£a-zA-Z0-9]*?[0-9])/;
        var hardPassword = /(?=[-_$£a-zA-Z0-9]*?[$£])(?=[-_$£a-zA-Z0-9]*?[A-Z])(?=[-_$£a-zA-Z0-9]*?[a-z])(?=[-_$£a-zA-Z0-9]*?[0-9])/;
        var goodPassword = /((?=[-_$£a-zA-Z0-9]*?[A-Z])(?=[-_$£a-zA-Z0-9]*?[a-z])(?=[-_$£a-zA-Z0-9]*?[0-9])|(?=[-_$£a-zA-Z0-9]*?[$?])(?=[-_$£a-zA-Z0-9]*?[a-z])(?=[-_$£a-zA-Z0-9]*?[0-9])|(?=[-_$£a-zA-Z0-9]*?[$?])(?=[-_$£a-zA-Z0-9]*?[A-Z])(?=[-_$£a-zA-Z0-9]*?[0-9])|(?=[-_$£a-zA-Z0-9]*?[$£])(?=[-_$£a-zA-Z0-9]*?[a-z])(?=[-_$£a-zA-Z0-9]*?[A-Z]))/;
        var weakPassword = /(((?=[-_$£a-zA-Z0-9]*?[A-Z])(?=[-_$£a-zA-Z0-9]*?[a-z]))|((?=[-_$£a-zA-Z0-9]*?[a-z])(?=[-_$£a-zA-Z0-9]*?[0-9]))|((?=[-_$£a-zA-Z0-9]*?[A-Z])(?=[-_$£a-zA-Z0-9]*?[0-9])))/;
        var superWeakPassword = /((?=[-_$£a-zA-Z0-9]*?[A-Z])|(?=[-_$£a-zA-Z0-9]*?[a-z])|(?=[-_$£a-zA-Z0-9]*?[0-9]))/;
        if(nuclearNailsPassword.test(password) == true) {
                document.getElementById("status").innerHTML = "Great!"; 
        } else if(hardPassword.test(password) == true) {
                document.getElementById("status").innerHTML = "Pretty good!"; 
        } else if(goodPassword.test(password) == true) {
        document.getElementById("status").innerHTML = "Good."; 
        } else if(weakPassword.test(password) == true) {
                document.getElementById("status").innerHTML = "Weak."; 
        } else if(superWeakPassword.test(password) == true) {
                document.getElementById("status").innerHTML = "Very weak!"; 
        } else {
                document.getElementById("status").innerHTML = "";
        }
}
function showchanged(bodytxt) {

    if (!chpanel) { 
        chpanel = new YAHOO.widget.Panel("chpanel",  
            { width:"350px", 
              fixedcenter:true, 
              close:true, 
              draggable:true, 
              zindex:4,
              modal:false,
              visible:false
            } 
        );
        chpanel.setHeader("<h4>Change complete</h4>");
    }
    chpanel.setBody(bodytxt);
    chpanel.render();
    chpanel.show();
}

function change_boot(appname,checkobj) {
    var newval = checkobj.checked ? 1 : 0;
    showchanged("<p>" + appname  + (checkobj.checked ? ' load on boot is enabled.' : ' load on boot is disabled.</p>'));
    cpanel_api2(nullop,'Jvm','changemap','domain',appname,'newstatus',newval);
};

function remove_object(thisobj) {
    var objEl = document.getElementById(thisobj);
    var objParent = objEl.parentNode;
    objParent.removeChild(objEl);
}

function setpath(inputobj) {
    var pathValue = document.getElementById('appname').value;
    pathValue = pathValue.replace(/\s/g,"");
    if (document.getElementById('path').value == '') {    
        document.getElementById('path').value = 'public_html/' + pathValue;
    }
}
function pathDirComplete(inputObj) {

}

function checkform () {
    var appname = document.addrorform.appname.value;
    if (appname == '') {
        alert("<cpanel langprint="RubyAppsWarnName">");
                document.addrorform.appname.select();
            document.addrorform.appname.focus();
        return false;
        }
        if (appname.length > 15) {
            alert("<cpanel langprint="RubyAppsLengthError">")
            document.addrorform.appname.select();
            document.addrorform.appname.focus();
            return false;
            }
        var path = document.addrorform.path.value;
        if (path == '') {
        alert("<cpanel langprint="RubyAppsWarnPath">");
                document.addrorform.path.select();
            document.addrorform.path.focus();
        return false;
        }
    return true;
}

</script>
<style>
<?cp Branding::spritelist(.spriteicon_img_mini {float:left;margin-right:5px;background: url\{leftparenthesis}%\{rightparenthesis};} %,spriteurl,images::#icon-${img}_mini {background-position\{colon}0 -${cssposition}px;width\{colon}${width}px;height\{colon}${height}px; }:) imgtype=icon,subtype=img,method=scale_60percent,format=png,img=jvm ?>
</style>
<cpanel relinclude="expander/css_include.html">
<script>
register_expander_container('manage-ror');
register_expander_obj('start-button');
register_expander_obj('stop-button');
</script>
</cpanelif>
<cpanelif $CPVAR{'jvmsupport'}>
<script type="text/javascript" >
<?cp Jvm::listappservjs(%,servers) ?>
    function init_servers() {
        var select = document.getElementById('servers');
        select.options.length = 0; // clear out existing items
        for(var i=0; i < servers.length; i++) {
            var d = servers[i];
            select.options.add(new Option(d.name, d.name))
        }
    }
    function PopulateVersions() {
       var srv_select = document.getElementById('servers');
       var ver_select = document.getElementById('versions');
       var m = srv_select[srv_select.selectedIndex];
       ver_select.options.length = 0;
       var versions = servers[srv_select.selectedIndex].versions;
       for(var i=0; i < versions.length; i++) {
             ver_select.options.add(new Option(versions[i], versions[i]))
        }
   }
YAHOO.util.Event.addListener(window, "load", init_servers, false);
</script>
</cpanelif>
<cpanelif $CPVAR{'jvmsupport'} and $CPVAR{'appserverset'}>
<script>

function register_validators() {


            register_validator('nomatch','empty',[document.mainform.dbname],'<cpanel langprint="SQLMsgBlankDB">'); 
                register_validator('nomatch','start_end_space',[document.mainform.dbname],'<cpanel langprint="ValidatorDBSpace">');
                register_validator('nomatch','slashes_dots',[document.mainform.dbname],'<cpanel langprint="ValidatorDBSpaceDot">');
                register_validator('match','alphanum',[document.mainform.dbname],'<cpanel langprint="SQLDBChars">');
                register_validator('nomatch','underscore',[document.mainform.db],'<cpanel langprint="ValidationDBUScore">');
                register_validator('nomatch','spaces_dots_ats_fwdslashes_hyphens',[document.mainform.db],'<cpanel langprint="ValidatorDBStrange">');


                register_validator('nomatch','spaces_dots_ats_fwdslashes_hyphens',[document.userform.user],'<cpanel langprint="ValidatorUserStrange">');
                register_validator('nomatch','empty',[document.userform.user],'<cpanel langprint="SQLMsgBlankUN">');
                register_validator('nomatch','underscore',[document.userform.user],'<cpanel langprint="ValidationUserUScore">');
                register_validator('match','alphanum',[document.userform.user],'<cpanel langprint="ValidatorSSFP">'); 
                register_validator('nomatch','empty',[document.userform.pass],'<cpanel langprint="ValidatorPass">'); 
                register_validator('nomatch','empty',[document.userform.password2],'<cpanel langprint="ValidatorPass2">'); 
            register_validator('Eleq','',[document.userform.password2,document.userform.pass],'<cpanel langprint="ValidatorPassNoMatch">');

            password_strength_validator_init();
            realtime_validate_init("mainform");
                realtime_validate_init("userform");
        }
        <!-- YAHOO.util.Event.addListener(window, "load", register_validators, false); -->

</script>

        <form method="post" onSubmit="return do_validate(this.id);"  action="addbs.html" name="mainform" id="mainform">
                <div class="formbox">
                        <h4 id="manappsrv">Installed private JVM Application Server:</h4>
                <div >
                        <table class="table table-striped"  id="manage-ror" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                                <th>App Name</th>
                                <th>Path</th>
                                <th>Status</th>
                                <th>View Log</th>
                                <th>Monitoring</th>
                                <th>Server.xml</th>
                                <th align="left">Delete</th>
                        </tr>
                        <?cp Jvm::getjvm(
                            [tr]
                [td class="truncate"]%[/td]
                [td class="truncate"][a href="../filemanager/index.html" target="_blank" class="ajaxfiles" ][img src="../images/homeb.gif" align=absmiddle][/a][a href="../filemanager/index.html?dir=%" target="_blank" class="ajaxfiles" ]%[/a][/td]
                [td class="app-status"]%[/td]
                [td class="app-status"][a href="viewlog.html" target="_self" class="ajaxfiles" ]View Log[/a][/td]
                [td][a href="monapp.html" target="_self" class="ajaxfiles" ]Monitoring[/a][/td]
                [td][/span][a href="resetconfconfirm.html" target="_self" class="ajaxfiles" ]Reset[/a][/td]
                [td][a href="deleteappconfirm.html?appname=%"][img border="0" width="20" height="20" src="../images/ror_icons/remove-delete.gif" alt="$LANG{'RubyAppsDelete'}" /][/a][/td]
        [/tr][/table]
         [h4 id="manappsrv"]Tomcat cotrol options:[/h4]
             [table class="table" id="manage-ror" border="0" cellspacing="0" cellpadding="0"]
                [tr][th colspan="4"]Control Options[/th][/tr]
                [tr]
                        [td width="100" nowrap="nowrap"]
                        [div class="expbox" onmouseover="runAnimOver[[this]];" id="start-button-%" style="float:left"]
                        [a class="start button" href="startapp.html?appname=%"]
                        [img width=28 height=28 src="$BRANDINGIMG{'jvm-start'}" border="1" /][br /]
                        Start[/a][/div]
                        [/td]
                        [td]
                        [div class="expbox" onmouseover="runAnimOver[[this]];" id="stop-button-%" style="float:left"]
                        [a class="stop-button" href="stopapp.html?appname=%"]
                        [img width=28 height=28 src="$BRANDINGIMG{'jvm-stop'}"  border="1" /][br /]
                        Stop[/a][/div]
                        [/td]
                        [td]
[!--                        [div class="expbox" onmouseover="runAnimOver[[this]];" id="restart-button-%" style="float:left"]
                        [a class="start-button" href="restartapp.html?appname=%"]
                        [img width=28 height=28 src="$BRANDINGIMG{'jvm-restart'}"  border="1" /][br /]
                        Restart[/a][/div] --]
                        [/td]
                        [td]
                        [div class="expbox" onmouseover="runAnimOver[[this]];" id="restart-button-%" style="float:right"]
                        [a class="start-button" href="restartapp.html?appname=%"]
                        [img width=28 height=28 src="$BRANDINGIMG{'jvm-restart'}"  border="1" /][br /]
                        Restart[/a][/div]
                        [/td]
                [/tr]
             [/table]
                [hr]
                ,name,path,path,running=1?running:not running,name,name,name,name,name,name,name,name) || [tr][td colspan="5"]No Jvm server installed[/tr][/td][/table] 
        ?>
                </div>
    </form></div>
<br /><br />
    <div class="formbox">
        <form method="POST" action="changejdk.html" name="jdkver">
            <div class="formbox">
                <h4 id="dommaps">Select JDK version:</h4>
            </div>
                <cpanel setvar="autoinput=pipefwd">
                <cpanel setvar="autofunc=pipeDirComplete">
                <script>
                function pipeDirComplete(inputObj) {
                    choosefwd('pipe');
                }
                </script>

        <table class="table table-striped" cellspacing="0" cellpadding="0">
                <tr>
                <td width="15%" align="center"> <b> Current JDK version </b></td>
                <td align="right" colspan="3"> <b>Available versions for apache-tomcat-<?cp Jvm::tomcatver(%, tomcatver) ?> </b></td>
                </tr>

                <tr>
                <td align="center"> <?cp Jvm::jdkversion(%, currver) ?> </td>
                <td width="70%"></td>
                <td width="15%"> <select class="form-control" name="jdkver"><?cp Jvm::jdk(%, jdkver) ?></select></td>
                <td> <input type="submit" class="btn btn-primary" value="Apply"></td>
                </tr>

        </table>
        <br />
        </form>
    </div>
<br />


<div id="divgen_expand"></div>
</cpanelif>
<cpanelif !$CPVAR{'appserverset'} and $CPVAR{'jvmsupport'}>
<div class="formbox">

        <form method="POST" action="installjvm.html" name="installjvm">
        <div class="formbox">
                <h4 id="insappsrv">Install Private JVM</h4>
                <table cellpadding="5" cellpadding="0" class="tbl">
                  <tr>
                    <td>Application Server:</td>
                        <td>
                        <select class="form-control" id="servers" name="server" onChange="PopulateVersions();" size="4">
                            <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
                        </select>
                        <select class="form-control" id="versions" name="version"  style="width:150px" size="4">
                            <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
                        </select>
                        </td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                        <td><input type="submit" class="btn btn-primary" value="Install"></td>
                  </tr>
                 </table>
        </div>
</form>
</cpanelif>
<cpanelif $CPVAR{'jvmsupport'} and $CPVAR{'appserverset'}>
</div>
    <div class="formbox">
        <form method="POST" action="adddomainjvm.html" name="domainmaps">
            <div class="formbox">
                <h4 id="dommaps">Map a domain to private JVM</h4>
                <p class="description">Adds a domain/subdomain to the application server. That will create a corresponding Virtual Host inside installed application server configuration</p><br />

            </div>
                <cpanel setvar="autoinput=pipefwd">
                <cpanel setvar="autofunc=pipeDirComplete">
                <script>
                function pipeDirComplete(inputObj) {
                    choosefwd('pipe');
                }   
                </script>
        <table border="0" cellspacing="0" cellpadding="0">
                <tr><td>
                <select class="form-control" name=domain><?cp Jvm::listdomains(%,options) ?></select>
                </td>
                <td></td><td></td><td><td><input type="submit" class="btn btn-primary" value="Assign"></td></td></tr>
        </table><br />
        </form>
    </div>
</cpanelif>
<cpanelif $CPVAR{'jvmsupport'} and $CPVAR{'domainshow'}>

    <div class="formbox">
                        <h4 id="dommapsman">Maped Domains</h4>
                        <p class="description"> To enable a traffic redirection from Apache web server to your Java application server use a Enable/Disable check box for particular domain</p><br />
                <div >
                        <table class="nonsortable table table-striped" id="manage-jvm" border="0" cellspacing="0" cellpadding="0">

                        <tr>
                                <th>Domain</th>
                                <th>Path</th>
                                <th>Enable/Disable</th>
                                <th>Deploy WAR</th>
                                <th>Preview</th>
                                <th>Delete</th>
                        </tr>
                        <?cp Jvm::listdomainmaps(
                            [tr]
                            [td class="truncate"]%[/td]
                            [td class="truncate"][a href="../filemanager/index.html?dir=%" target="_blank" class="ajaxfiles" ]%[/a][/td]
                            [td class="truncate"][a href="mode.live.php?domain=%" target="_self" class="ajaxfiles" ]Enable/Disable[/a][/td]
                            [td class="truncate"][a href="deploywar.html?dir=%" target="_self" class="ajaxfiles" ]Deploy War[/a][/td]
                            [td class="truncate"][a href="../preview/index.html" target="_blank"] Preview [/a][/td]
                            [td align="center"][a href="deletedomainconfirm.html?domain=%"][img border="0" src="../images/ror_icons/remove-delete.gif" alt="$LANG{'RubyAppsDelete'}" /][/a][/td]
                            [/tr]
                                ,domain,path,path,domain,path,domain,path,domain,pp,domain) || [tr][td colspan="6"]No mapped domains[/tr][/td] ?>
                        </table>
                </div>
    <div class="formbox">
        <form METHOD="POST" NAME="setmanagerapp" ACTION="setmngrapp.html" >
            <div class="formbox">
                <h4 id="selmanapp">Select a Managment Application</h4>
                <p class="description">Managment application gives you an ability to dynamic manage your applications, monitor your application server performance, resources, upload your applications etc. We recommend to use Psi Probe - it is a way more advanced than Tomcat manager. Once you select managment app you should see a menu bellow it to set a main user and password to access it. </p>
            </div>
        <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                <td>
                <select class="form-control" name="manapp">
                        <option value="psiprobe">Psi Probe</option>
                        <option value="tomcatmng">Tomcat Manager</option>
                        <option value="none">None</option>
                </select>
                </td>
                <td><input type="submit" class="btn btn-primary" value="Set"></td></td></tr>
        </table>
        <br>
         <?cp Jvm::mngappsel([p]%[/p], content) check=1 ?>
        </form>
    </div>
<div class="formbox">
</cpanelif>
<cpanelif $CPVAR{'mngapp'}>
<h4 id="selmancred">Select your Tomcat main user and password</h4>
<form method="POST" action="manager_cred.html" onSubmit="return checkpwd(this);">
                        </table>
                        <p class="description"> Please set the main username and password you are going to use to access your Tomcat server managment application. A good password consists of small and uppercase letters, number, special sign (e.g. $) and underscope. </p><br />
                        <table class="tbl" id="tomcat_manager" border="0" cellspacing="4" cellpadding="0">
                        <tr id="tm_username">
                                <td> Username: </td>
                                <td><input type="text" class="form-control" name="user" value="<?cp Jvm::tmanager( %, tm_user) getuser=1 ?>" required></td>
                        </tr>
                        <tr>
                                <td><span>Password: </span></td>
                                <td><input type="password" class="form-control" name="pass" onkeyup="complex_password(this.value);" required></td>
                                <td><span id="status">&nbsp;</span></td>
                        </tr>
                        <tr>
                                <td>Confirm Password: </td>
                                <td><input type="password" class="form-control" name="pass2" required></td>
                        </tr><tr><td> &nbsp; </td></tr>
                        <tr><td colspan="2" align="center"><input type="submit" value="Set Account" class="btn btn-primary"></td></tr>
                        </table>
        </form>
</div>
</cpanelif>
</div>
<div id="chpanel"></div>

<cpanel Branding="include(stdfooter.html)">
