<!DOCTYPE html>
<html lang="en">
<?php
    include_once '../account/session.php';
    include_once 'scripts.php';
    $id_manager=$_SESSION['id-manager'];
    $username_manager=$_SESSION['username-manager'];

    if($_SESSION["type"] != "admin") {
    header("location: ../");
    }
    
?>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Install servers</title>
    <link type="text/css" href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link type="text/css" href="../../bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">
    <link type="text/css" href="../../css/theme.css" rel="stylesheet">
    <link type="text/css" href="../../images/icons/css/font-awesome.css" rel="stylesheet">
    <link type="text/css" href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600' rel='stylesheet'>
    <script src="../../scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="../../scripts/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
    <script src="../../bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="../../scripts/flot/jquery.flot.js" type="text/javascript"></script>
    <script>
    function run()
    {
    	$('#frame').css('height','404px');
		document.getElementById("sendform").action = "run.php";
		document.forms["sendform"].submit();
    }
    function show_servers(){
    html= "<option value='0' disabled=''>Waiting for extracting Servers...</option>";
    $("#server").html(html);
    $.ajax({
        url: '/app/manager/server/vmta/scripts.php?action=get_servers',
        type: 'get',
        success: function(data) {
            var list = JSON.parse(data);
            var html = "<option value='0'>Select here...</option>";
            for (var i = 0; i < list.length; i++) {
                html += "<option value='"+list[i].id+"'>"+list[i].name+"</option>";
            }
            $("#server").html(html);
        }
    });
	}
	show_servers();
    </script>
</head>
<body>
    
     <?php include('../include/inc.top_menu.php'); ?>

    <div class="wrapper">
        <div class="container">
            <div class="row">
                
				<?php include('../include/inc.left_menu.php'); ?>
				
                <div class="span9">
                    <div class="content">
                        <div class="module">
                            <div class="module-head"><h3>RUN SHELL <div class="processing" id="processing"></div></h3></div>
                        <form id="sendform" name="sendform" method="POST" action="" target="frame">
                            <div class="module-body">
                                    <div class="control-group">
                                        <label class="control-label" for="basicinput">Servers</label>
                                        <div class="controls">
                                            <select id="server" name="server" style="width: 100%;"></select>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="basicinput">LOCAL IP</label>
                                        <div class="controls">
                                            <input type="text" id="ip_local" name="ip_local" value="<?php echo $_SERVER["REMOTE_ADDR"]; ?>" style="width: 99%;">
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="basicinput">Hostname</label>
                                        <div class="controls">
                                            <input type="text" id="hostname" name="hostname" style="width: 99%;">
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="basicinput">Domain DKIM</label>
                                        <div class="controls">
                                            <input type="text" id="domain" name="domain" style="width: 99%;">
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="basicinput">Relay Domain</label>
                                        <div class="controls">
                                            <textarea type="text" id="relay" name="relay" style="margin: 0px 0px 10px;width: 827px;height: 122px;"></textarea>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <label class="control-label" for="basicinput">IPs (SMTP LISTENER)</label>
                                        <div class="controls">
                                            <textarea type="text" id="ips" name="ips" style="margin: 0px 0px 10px;width: 827px;height: 122px;"></textarea>
                                        </div>
                                    </div>
                                    
                                    <div class="control-group">
                                        <label class="control-label" for="basicinput"></label>
                                        <div class="controls">
                                            <button class="btn btn-primary" type="button" onclick="run();">Install</button>
                                        </div>
                                    </div>

                        
                                    <div class="control-group">
                                        <label class="control-label">Output</label>
                                        <div class="controls">
                                            <iframe name="frame" id="frame" scrolling="yes" frameborder="0" style="height: 86px;width: 100%;"></iframe>
                                        </div>
                                    </div>
                        </form>
                                </div>
                            </div>
                        </div>
                    </div><!--/.content-->
                </div><!--/.span9-->
            </div>
        </div><!--/.container-->
    </div><!--/.wrapper-->

</body>