   <?php
   // CRUD 
   @$getId = base64_decode(anti_injection($_GET['id']));  
    if(@$getId){ 
        $query = mysql_query("SELECT * FROM servers WHERE id = + $getId");
        $result = mysql_fetch_array($query);
    }
    
    if(isset ($_POST['save'])){
	$server = $_POST['server'];
	$hostname = $_POST['hostname'];
	$module = $_POST['module'];
	$ip = $_POST['ip'];
	$company = $_POST['company'];
	$price = $_POST['price'];
	$dns1 = $_POST['dns1'];
	$dns2 = $_POST['dns2'];
	$ip1 = $_POST['ip1'];
	$ip2 = $_POST['ip2'];
	$max = $_POST['max'];
	$domain = $_POST['domain'];
	$user = $_POST['user'];
	$pwd = $_POST['pwd'];
	
	$crud = new crud('servers');  // table
    $crud->inserir("server,hostname,module,ip,company,price,dns1,dns2,ip1,ip2,max,domain,user,pwd", "'$server','$hostname','$module','$ip','$company','$price','$dns1','$dns2','$ip1','$ip2','$max','$domain','$user','$pwd'");

	header("Location: index.php?mod=Servers&y=1"); // redirect send mail ok
    
	
	}
	
	if(isset($_POST['update'])) {
	$server = $_POST['server'];
	$hostname = $_POST['hostname'];
	$module = $_POST['module'];
	$ip = $_POST['ip'];
	$company = $_POST['company'];
	$price = $_POST['price'];
	$dns1 = $_POST['dns1'];
	$dns2 = $_POST['dns2'];
	$ip1 = $_POST['ip1'];
	$ip2 = $_POST['ip2'];
	$max = $_POST['max'];
	$domain = $_POST['domain'];
	$user = $_POST['user'];
	$pwd = $_POST['pwd'];
	$registerID = $_POST['registerID'];
	
	
	$crud = new crud('servers'); // Table
    $crud->atualizar("server='$server',hostname='$hostname',module='$module',ip='$ip',company='$company',price='$price',dns1='$dns1',dns2='$dns2',ip1='$ip1',ip2='$ip2',max='$max',domain='$domain',user='$user',pwd='$pwd'", "id='$registerID'");
	
	header("Location: index.php?mod=Servers&y=2");
	}
	
    if ((isset($_GET["action"])) && ($_GET["action"] == "delete")) {
    $id = base64_decode($_GET['id']); 
    $crud = new crud('servers'); // Table
    $crud->excluir("id = $id"); // ID
    
    header("Location: index.php?mod=Servers&y=3");
    }
    
    
    ?>
   
      
    <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            <?php echo $lang['TITLE_NEW_SERVER']; ?>
          </h1>
          
        </section>

       
       <!-- Main content -->
        <section class="content">
          <div class="row">
			  
			  
            <!-- left column -->
            <div class="col-md-6">
              <!-- general form elements -->
              <div class="box box-primary">
                <div class="box-header with-border">
                  <h3 class="box-title"><?php echo $lang['SLOGAN_REGISTER_SERVER']; ?></h3>
                </div><!-- /.box-header -->
                <!-- form start -->
                <form role="form" method="POST" id="ServerForm" name="ServerForm">
				<input type="hidden" name="len" id="pass-len" value="8">
					
                  <div class="box-body">
					  
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['SERVER']; ?></label>
                      <input type="text" name="server" value="<?php echo @$result['server']; ?>" id="server" class="form-control" placeholder="<?php echo $lang['SERVER_PLACEHOLDER']; ?>" required>
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['HOSTNAME']; ?></label>
                      <input type="text" class="form-control" name="hostname" id="hostname" value="<?php echo @$result['hostname']; ?>" placeholder="<?php echo $lang['HOSTNAME']; ?>" required>
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['MODULE']; ?></label>
                      <select name="module" class="form-control">
                      <option value="cPanel/WHM">cPanel/WHM</option>
                      </select>
                    </div>
                   
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['IP']; ?></label>
                      <input type="text" class="form-control" name="ip" id="ip" value="<?php echo @$result['ip']; ?>" placeholder="<?php echo $lang['IP_PLACEHOLDER']; ?>" required>
                    </div>
                   
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['DATECENTER']; ?></label>
                      <input type="text" class="form-control" name="company" value="<?php echo @$result['company']; ?>">
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['MAX']; ?></label>
                      <input type="text" class="form-control" name="max" value="<?php echo @$result['max']; ?>">
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['DOMAIN']; ?></label>
                      <input type="text" class="form-control" name="domain" value="<?php echo @$result['domain']; ?>">
                    </div>
                   
                  </div><!-- /.box-body -->

                 
                
                
              </div><!-- /.box -->
           </div><!-- /.col -->
           
           
           <!-- left column -->
            <div class="col-md-6">
              <!-- general form elements -->
              <div class="box box-info">
                <div class="box-header with-border">
                  <h3 class="box-title"><?php echo $lang['SLOGAN_REGISTER_SERVER']; ?></h3>
                </div><!-- /.box-header -->
                <!-- form start -->
   
                  <div class="box-body">
					 
					<div class="form-group">
                      <label for="Input"><?php echo $lang['PRICE']; ?></label>
                      <input type="text" name="price" onKeyUp="moeda(this);" id="price" value="<?php echo $result['price']; ?>" class="form-control">
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['DNS1']; ?></label>
                      <input type="text" name="dns1" id="dns1" value="<?php echo $result['dns1']; ?>" class="form-control" required>
                    </div> 
					  
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['IP1']; ?></label>
                      <input type="text" name="ip1" id="ip1" value="<?php echo $result['ip1']; ?>" class="form-control">
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['DNS2']; ?></label>
                      <input type="text" name="dns2" id="dns2" value="<?php echo $result['dns2']; ?>" class="form-control" required>
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['IP2']; ?></label>
                      <input type="text" name="ip2" ip="ip2" value="<?php echo $result['ip2']; ?>" class="form-control">
                    </div>
                    
                     <div class="form-group">
                      <label for="Input"><?php echo $lang['USER']; ?></label>
                      <input type="text" name="user" id="user" value="<?php echo $result['user']; ?>" class="form-control" required>
                    </div>
                    
                    <div class="form-group">
                      <label for="Input">Password</label>
                      <input type="text" name="pwd" id="pwd" value="<?php echo $result['pwd']; ?>" class="form-control" required>
                    </div>
                   
                   
                  </div><!-- /.box-body -->

                  <div class="box-footer">
					  
		  <?php if (@$result['id'] <> '') { ?>

		  <input type="submit" value="<?php echo $lang['UPDATE']; ?>" name="update" style="text-transform:uppercase" class="btn btn-info btn-lg btn-block">
		  <input type="hidden" name="registerID" value="<?php echo @$result['id']; ?>"> 
		  <? } else { ?>
		  <input type="submit" value="<?php echo $lang['REGISTER']; ?>" name="save" style="text-transform:uppercase" class="btn btn-success btn-lg btn-block">
		  <?php } ?>
					  
                  </div>
                  
                 
                </form>
                
              </div><!-- /.box -->
           </div><!-- /.col -->
           
          </div><!-- /.row -->
        </section><!-- /.content -->
       
        
      </div><!-- /.content-wrapper -->
   
   
   
   
