<?php
$error = '';
$succuss = '';
if (isset($_POST['ip'])) {
	if (!empty($_POST['ip'])) {
	   if (!filter_var($_POST['ip'], FILTER_VALIDATE_IP)) {
          $error = '<i class="fa fa-fw fa-exclamation-triangle"></i> ' . $wo['lang']['invalid_ip'];
       } else {
       	  $add_ip = Wo_BanNewIp($_POST['ip']);
       	  if ($add_ip === true) {
       	  	$succuss = '<i class="fa fa-fw fa-check"></i> ' . $wo['lang']['ip_banned'];
       	  } else {
       	  	$error = '<i class="fa fa-fw fa-exclamation-triangle"></i> ' . $wo['lang']['ip_exist'];
       	  }
       }
    } else {
       $error = '<i class="fa fa-fw fa-exclamation-triangle"></i> ' . $wo['lang']['please_add_ip'];
    }
}
if (!empty($_GET['delete_ip'])) {
	if (Wo_DeleteBanned($_GET['delete_ip']) === true) {
		$succuss = '<i class="fa fa-fw fa-check"></i> ' . $wo['lang']['ip_deleted'];
	}
}
?>

   <div class="list-group setting-banned-container">
   <div class="list-group-item"><i class="fa fa-fw fa-user-times"></i> <?php echo $wo['lang']['ban_user']; ?></div>
   <div class="setting-well">
      <?php if (!empty($error)) { ?>
      <div class="alert alert-danger">
      	<?php echo $error;?>
      </div>
      <?php } ?>
      <?php if (!empty($succuss)) { ?>
      <div class="alert alert-success">
      	<?php echo $succuss;?>
      </div>
      <?php } ?>
      <form method="post" class="setting-add-ip form-inline <?php echo Wo_RightToLeft('pull-left');?>">
         <div class="form-group add-ip-progress-icon">
            <input type="text" name="ip" id="ip" placeholder="<?php echo $wo['lang']['ip_address'];?>" class="form-control">
         </div>
          <div class="form-group">
            <button type="submit" class="btn btn-default form-control"><i class="fa fa-plus"></i> <?php echo $wo['lang']['ban'];?></button>
         </div>
      </form>
      <div class="clear"></div>
      <div class="page-margin">
      <table class="table table-hover table-bordered table-condensed setting-table">
         <thead>
            <tr>
               <th><?php echo $wo['lang']['id'];?></th>
               <th><?php echo $wo['lang']['banned'];?> </th>
               <th><?php echo $wo['lang']['ip_address'];?> </th>
               <th><?php echo $wo['lang']['action'];?> </th>
            </tr>
         </thead>
         <tbody class="result">
            <?php 
               $ips = Wo_GetBanned();
               if (count($ips) > 0) {
                 foreach ($ips as $wo['ip']) {
                    echo Wo_LoadPage('admin/banned_ip/ban-list');
                 }
               } 
               ?>
         </tbody>
      </table>
      </div>
      <div class="no-result">
         <?php 
            if (count($ips) == 0) {
              echo '<span class="center-text">' . $wo['lang']['there_are_no_banned_ips'] . '</span>';
            }
            ?>
      </div>
   </div>
</div>
<script>
function Wo_DeleteBanned(id) {

}
function Wo_AddIpToBanList(ip) {

}
</script>