<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
global $configverssion_id; global $configapp_version; global $userID; global $server; global $LANG; $resellerID = getReseller();
//=== List page stuffs =============
$pag = $pag1 = $pag2 = $pag3 = $page = 1; $setLimit = 20;
if(isset($_GET["page"])) $page = (int)$_GET["page"];
$pageLimit = ($page * $setLimit) - $setLimit; 
if(isset($_GET["pag"])) $pag = (int)$_GET["pag"];
$pageLimit2 = ($pag * $setLimit) - $setLimit; 
if(isset($_GET["pag1"])) $pag1 = (int)$_GET["pag1"];
$pageLimit3 = ($pag1 * $setLimit) - $setLimit; 
if(isset($_GET["pag2"])) $pag2 = (int)$_GET["pag2"];
$pageLimit4 = ($pag2 * $setLimit) - $setLimit; 
if(isset($_GET["pag3"])) $pag3 = (int)$_GET["pag3"];
$pageLimit5 = ($pag3 * $setLimit) - $setLimit; 

$pageurl=$_SERVER['REQUEST_URI']."?";
if(count($_GET)) { $pageurl = $_SERVER['REQUEST_URI'].'&'; }
$trans = array("s=d_o" => "", "s=d_n" => "", "s=r_h" => "", "s=r_l" => "", "s=s_r" => "", "s=s_u" => "", "s=s_q" => "", "s=s_c" => "", "s=s_f" => "", "s=s_p" => "");
$pageurl = strtr($pageurl,$trans);
$pageurl = str_replace('&&','&',$pageurl);
//====End ==============
define('TITLE','Blocking');

if(userRole()> 1) {
	header('location: index.php');	
}

$today = date('Y-m-d'); $time = strtotime($today.'-1 months'); $lastMonth = date("Y-m", $time); $time = strtotime($today.'-1 years'); $lastYear = date("Y", $time);
?>
<?php

 if(isset($_REQUEST['di'])) {
	$tdelete = mysqli_real_escape_string($server,$_REQUEST['di']);
	mysqli_query($server,"DELETE FROM `fobidden_ip` WHERE id = '$tdelete'") or die(mysqli_error($server));
	$_SESSION['message'] = $LANG['The item(s) has been deleted from the list'];
	header('location: abanned?err=0&i');
 }
 if(isset($_REQUEST['de'])) {
	$tdelete = mysqli_real_escape_string($server,$_REQUEST['de']);
	mysqli_query($server,"DELETE FROM `fobidden_email` WHERE id = '$tdelete'") or die(mysqli_error($server));
	$_SESSION['message'] = $LANG['The item(s) has been deleted from the list'];
	header('location: abanned?err=0&e');
 }
 if(isset($_REQUEST['de'])) {
	$tdelete = mysqli_real_escape_string($server,$_REQUEST['de']);
	mysqli_query($server,"DELETE FROM `fobidden_sender` WHERE id = '$tdelete'") or die(mysqli_error($server));
	$_SESSION['message'] = $LANG['The item(s) has been deleted from the list'];
	header('location: abanned?err=0&e');
 }
 if(isset($_REQUEST['dc'])) {
	$tdelete = mysqli_real_escape_string($server,$_REQUEST['dc']);
	mysqli_query($server,"DELETE FROM `forbidden_country` WHERE id = '$tdelete'") or die(mysqli_error($server));
	$_SESSION['message'] = $LANG['The item(s) has been deleted from the list'];
	header('location: abanned?err=0&c');
 }
 if(isset($_REQUEST['dw'])) {
	$tdelete = mysqli_real_escape_string($server,$_REQUEST['dw']);
	mysqli_query($server,"DELETE FROM `forbidden_words` WHERE id = '$tdelete'") or die(mysqli_error($server));
	$_SESSION['message'] = $LANG['The item(s) has been deleted from the list'];
	header('location: abanned?err=0&w');
 }
?>
 <div class="row no-m-t no-m-b">
 	<div class="col s12 m12 l12">
        <div class="card blue">
            <div class="card-content white-text"><?=$LANG['banned_tip']?></div>
        </div>
    </div>
 </div>
 
<div class="row no-m-t no-m-b">
	<div class="col s12 m12 l12 responsive-tabs">
            
      <h5><?=$LANG['Banned IPs']?></h5>
      <div class="card card-white <?php if(isset($_GET['i'])) echo ' responsive-tabs__panel--active'?>">
            <div class="card-content">
            	<div class="row no-m-t no-m-b">   
                
                     <div class="col s12 m6 l7">
                          <h5><?=$LANG['Banned IPs']?></h5> 
                     <?php
                    $query="SELECT * FROM fobidden_ip WHERE customer_id = 0 ORDER BY id DESC limit $pageLimit2,$setLimit";
					$result = mysqli_query($server,$query) or die(mysqli_error($server));
					$x = mysqli_num_rows($result);
                    if($x < 1) {
                    ?><table>	   
                      <div class="col s12 m12 l12">
                            <div class="card blue lighten-5">
                                <div class="card-content">
                                     <h3 class="center-align"><i class="fa fa-exclamation-circle"></i></h3>
                                     <h5 class="center-align"><?=$LANG['You have not created any records yet']?></h5>
                                </div>
                            </div>
                        </div>
                       </table> 
                      <?php } else { ?>  
                      <table class="responsive-table bordered">
                          <thead>
                            <tr>
                                <th data-field="date"><?=$LANG['IP Address']?></th>
                                <th data-field="status"><?=$LANG['Reason']?></th>
                                <th data-field="act"></th>
                             </tr>
                          </thead>
                          <tbody>
                          <?php
                        while ($rows = mysqli_fetch_assoc($result)) { 
						?>
                             <tr>
                                 <td><?=$rows['ip']?> </td>
                                 <td><?=$rows['reason']?></td>
                                  <td><a class="hoverable red-text" onclick="return confirm('<?=$LANG['delete_confirm']?>');" href="abanned?di=<?=$rows['id']?>"><?=$LANG['Delete']?></a></td>
                             </tr>
                       <?php } ?>   
                          </tbody>
                      </table>
                      <?php } ?>
                       <div class="col s12 m12 l12" style="margin-top: 5px;">
                          <?php displayPaginationN($setLimit,$page,$query,'i','');  ?>
                      </div>
                      <br><br>
                     </div>
                
                     <div class="col s12 m6 l5 yellow lighten-5" style="border:1px solid black">
                          <form action="" method="post" id="credit-form" onSubmit="return false;">
                          	<h5><?=$LANG['Add New Record']?></h5> 

                           <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <input id="ip" type="text" required class="validate" placeholder="" >
                                       <label for="ip"><?=$LANG['IP Address']?></label>
                                 </div>
                            </div>
                            <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <input id="ireason" type="text" class="validate">
                                       <label for="ireason"><?=$LANG['Reason']?> </label>
                                 </div>
                            </div>
                           <div class="card-action">
                                <button id="isave-button" class="btn green darken-4" type="submit"><i class="fa fa-save"></i> <?=$LANG['Save Record']?> </button>
                                <span id="isave-spin" class="btn-flat" style="display: none;"><i class="fa fa-spinner fa-spin"></i> <strong><?=$LANG['Please wait']?>...</strong></span>
                           </div>
                        </form>
                     </div>
				</div>                
            </div>
      </div>     
      
      <h5><?=$LANG['Banned Email/Domains']?></h5>
      <div class="card card-white <?php if(isset($_GET['e'])) echo ' responsive-tabs__panel--active'?>">
            <div class="card-content">
            	<div class="row no-m-t no-m-b">   
                
                     <div class="col s12 m6 l7">
                          <h5><?=$LANG['Banned Email/Domains']?></h5> 
                     <?php
                    $query="SELECT * FROM fobidden_email WHERE customer_id = 0 ORDER BY id DESC limit $pageLimit3,$setLimit";
					$result = mysqli_query($server,$query) or die(mysqli_error($server));
					$x = mysqli_num_rows($result);
                    if($x < 1) {
                    ?><table>	   
                      <div class="col s12 m12 l12">
                            <div class="card blue lighten-5">
                                <div class="card-content">
                                     <h3 class="center-align"><i class="fa fa-exclamation-circle"></i></h3>
                                     <h5 class="center-align"><?=$LANG['You have not created any records yet']?></h5>
                                </div>
                            </div>
                        </div>
                       </table> 
                      <?php } else { ?>  
                      <table class="responsive-table bordered">
                          <thead>
                            <tr>
                                <th data-field="date"><?=$LANG['Email']?></th>
                                <th data-field="status"><?=$LANG['Reason']?></th>
                                <th data-field="act"></th>
                             </tr>
                          </thead>
                          <tbody>
                          <?php
                        while ($rows = mysqli_fetch_assoc($result)) { 
						?>
                             <tr>
                                 <td><?=$rows['email']?> </td>
                                 <td><?=$rows['reason']?></td>
                                  <td><a class="hoverable red-text" onclick="return confirm('<?=$LANG['delete_confirm']?>');" href="abanned?de=<?=$rows['id']?>"><?=$LANG['Delete']?></a></td>
                             </tr>
                       <?php } ?>   
                          </tbody>
                      </table>
                      <?php } ?>
                       <div class="col s12 m12 l12" style="margin-top: 5px;">
                          <?php displayPaginationN($setLimit,$pag1,$query,'e',1);  ?>
                      </div>
                      <br><br>
                     </div>
                
                     <div class="col s12 m6 l5 yellow lighten-5" style="border:1px solid black">
                          <form action="" method="post" id="credit-form" onSubmit="return false;">
                          	<h5><?=$LANG['Add New Record']?></h5> 

                           <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <input id="email" type="text" required class="validate" placeholder="" >
                                       <label for="email"><?=$LANG['Email/Domain']?></label>
                                 </div>
                            </div>
                            <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <input id="ereason" type="text" class="validate">
                                       <label for="ereason"><?=$LANG['Reason']?> </label>
                                 </div>
                            </div>
                           <div class="card-action">
                                <button id="esave-button" class="btn green darken-4" type="submit"><i class="fa fa-save"></i> <?=$LANG['Save Record']?> </button>
                                <span id="esave-spin" class="btn-flat" style="display: none;"><i class="fa fa-spinner fa-spin"></i> <strong><?=$LANG['Please wait']?>...</strong></span>
                           </div>
                        </form>
                     </div>
				</div>                
            </div>
      </div>
                
      <h5><?=$LANG['Banned Countries']?></h5>
      <div class="card invoices-card <?php if(isset($_GET['c'])) echo ' responsive-tabs__panel--active'?>">
            <div class="card-content">
            	<div class="row no-m-t no-m-b">   
                
                     <div class="col s12 m6 l7">
                          <h5><?=$LANG['Banned Countries']?></h5> 
                     <?php
                    $query="SELECT * FROM forbidden_country WHERE customer_id = 0 ORDER BY id DESC limit $pageLimit4,$setLimit";
					$result = mysqli_query($server,$query) or die(mysqli_error($server));
					$x = mysqli_num_rows($result);
                    if($x < 1) {
                    ?><table>	   
                      <div class="col s12 m12 l12">
                            <div class="card blue lighten-5">
                                <div class="card-content">
                                     <h3 class="center-align"><i class="fa fa-exclamation-circle"></i></h3>
                                     <h5 class="center-align"><?=$LANG['You have not created any records yet']?></h5>
                                </div>
                            </div>
                        </div>
                       </table> 
                      <?php } else { ?>  
                      <table class="responsive-table bordered">
                          <thead>
                            <tr>
                                <th data-field="date"><?=$LANG['Country']?></th>
                                <th data-field="status"><?=$LANG['Reason']?></th>
                                <th data-field="act"></th>
                             </tr>
                          </thead>
                          <tbody>
                          <?php
                        while ($rows = mysqli_fetch_assoc($result)) { 
						?>
                             <tr>
                                 <td><?=countryName($rows['country_id'])?> </td>
                                 <td><?=$rows['reason']?></td>
                                  <td><a class="hoverable red-text" onclick="return confirm('<?=$LANG['delete_confirm']?>');" href="abanned?dc=<?=$rows['id']?>"><?=$LANG['Delete']?></a></td>
                             </tr>
                       <?php } ?>   
                          </tbody>
                      </table>
                      <?php } ?>
                       <div class="col s12 m12 l12" style="margin-top: 5px;">
                          <?php displayPaginationN($setLimit,$pag2,$query,'c',2);  ?>
                      </div>
                      <br><br>
                     </div>
                
                     <div class="col s12 m6 l5 yellow lighten-5" style="border:1px solid black">
                          <form action="" method="post" id="credit-form" onSubmit="return false;">
                          	<h5><?=$LANG['Add New Record']?></h5> 

                           <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                        <select id="country" required class="js-states browser-default"  style="width: 100%" >
                                            <?=getCountryList('') ?>                            
                                       </select>
                                       <label class="active"><?=$LANG['Country']?></label>
                                 </div>
                            </div>
                            <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <input id="creason" type="text" class="validate">
                                       <label for="creason"><?=$LANG['Reason']?> </label>
                                 </div>
                            </div>
                           <div class="card-action">
                                <button id="csave-button" class="btn green darken-4" type="submit"><i class="fa fa-save"></i> <?=$LANG['Save Record']?> </button>
                                <span id="csave-spin" class="btn-flat" style="display: none;"><i class="fa fa-spinner fa-spin"></i> <strong><?=$LANG['Please wait']?>...</strong></span>
                           </div>
                        </form>
                     </div>
				</div>                
            </div>

      </div>  
      
      <h5><?=$LANG['Banned Sender IDs']?></h5>
      <div class="card card-white <?php if(isset($_GET['s'])) echo ' responsive-tabs__panel--active'?>">
             <div class="card-content">
            	<div class="row no-m-t no-m-b">   
                
                     <div class="col s12 m6 l7">
                          <h5><?=$LANG['Banned Sender IDs']?></h5> 
                     <?php
                    $query="SELECT * FROM fobidden_sender WHERE customer_id = 0 ORDER BY id DESC limit $pageLimit5,$setLimit";
					$result = mysqli_query($server,$query) or die(mysqli_error($server));
					$x = mysqli_num_rows($result);
                    if($x < 1) {
                    ?><table>	   
                      <div class="col s12 m12 l12">
                            <div class="card blue lighten-5">
                                <div class="card-content">
                                     <h3 class="center-align"><i class="fa fa-exclamation-circle"></i></h3>
                                     <h5 class="center-align"><?=$LANG['You have not created any records yet']?></h5>
                                </div>
                            </div>
                        </div>
                       </table> 
                      <?php } else { ?>  
                      <table class="responsive-table bordered">
                          <thead>
                            <tr>
                                <th data-field="date"><?=$LANG['Sender ID']?></th>
                                <th data-field="status"><?=$LANG['Reason']?></th>
                                <th data-field="act"></th>
                             </tr>
                          </thead>
                          <tbody>
                          <?php
                        while ($rows = mysqli_fetch_assoc($result)) { 
						?>
                             <tr>
                                 <td><?=$rows['sender_id']?> </td>
                                 <td><?=$rows['reason']?></td>
                                  <td><a class="hoverable red-text" onclick="return confirm('<?=$LANG['delete_confirm']?>');" href="abanned?ds=<?=$rows['id']?>"><?=$LANG['Delete']?></a></td>
                             </tr>
                       <?php } ?>   
                          </tbody>
                      </table>
                      <?php } ?>
                       <div class="col s12 m12 l12" style="margin-top: 5px;">
                          <?php displayPaginationN($setLimit,$pag3,$query,'s',3);  ?>
                      </div>
                      <br><br>
                     </div>
                
                     <div class="col s12 m6 l5 yellow lighten-5" style="border:1px solid black">
                          <form action="" method="post" id="credit-form" onSubmit="return false;">
                          	<h5><?=$LANG['Add New Record']?></h5> 

                           <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <input id="sender" type="text" required class="validate" placeholder="" >
                                       <label for="sender"><?=$LANG['Sender ID']?></label>
                                 </div>
                            </div>
                            <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <input id="season" type="text" class="validate">
                                       <label for="season"><?=$LANG['Reason']?> </label>
                                 </div>
                            </div>
                           <div class="card-action">
                                <button id="ssave-button" class="btn green darken-4" type="submit"><i class="fa fa-save"></i> <?=$LANG['Save Record']?> </button>
                                <span id="ssave-spin" class="btn-flat" style="display: none;"><i class="fa fa-spinner fa-spin"></i> <strong><?=$LANG['Please wait']?>...</strong></span>
                           </div>
                        </form>
                     </div>
				</div>                
            </div>
      </div> 
      
      <h5><?=$LANG['Banned Words']?></h5>
      <div class="card card-white <?php if(isset($_GET['w'])) echo ' responsive-tabs__panel--active'?>">
           <div class="card-content">
            	<div class="row no-m-t no-m-b">   
                
                     <div class="col s12 m6 l7">
                          <h5><?=$LANG['Banned Words']?></h5> 
                     <?php
                    $query="SELECT * FROM forbidden_words WHERE customer_id = 0 ORDER BY id DESC limit $pageLimit,$setLimit";
					$result = mysqli_query($server,$query) or die(mysqli_error($server));
					$x = mysqli_num_rows($result);
                    if($x < 1) {
                    ?><table>	   
                      <div class="col s12 m12 l12">
                            <div class="card blue lighten-5">
                                <div class="card-content">
                                     <h3 class="center-align"><i class="fa fa-exclamation-circle"></i></h3>
                                     <h5 class="center-align"><?=$LANG['You have not created any records yet']?></h5>
                                </div>
                            </div>
                        </div>
                       </table> 
                      <?php } else { ?>  
                      <table class="responsive-table bordered">
                          <thead>
                            <tr>
                                <th data-field="date"><?=$LANG['Words']?></th>
                                <th data-field="status"><?=$LANG['Reason']?></th>
                                <th data-field="act"></th>
                             </tr>
                          </thead>
                          <tbody>
                          <?php
                        while ($rows = mysqli_fetch_assoc($result)) { 
						?>
                             <tr>
                                 <td><?=$rows['word']?> </td>
                                 <td><?=$rows['reason']?></td>
                                  <td><a class="hoverable red-text" onclick="return confirm('<?=$LANG['delete_confirm']?>');" href="abanned?dw=<?=$rows['id']?>"><?=$LANG['Delete']?></a></td>
                             </tr>
                       <?php } ?>   
                          </tbody>
                      </table>
                      <?php } ?>
                       <div class="col s12 m12 l12" style="margin-top: 5px;">
                          <?php displayPagination($setLimit,$page,$query,'w');  ?>
                      </div>
                      <br><br>
                     </div>
                
                     <div class="col s12 m6 l5 yellow lighten-5" style="border:1px solid black">
                          <form action="" method="post" id="credit-form" onSubmit="return false;">
                          	<h5><?=$LANG['Add New Record']?></h5> 

                           <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <input id="word" type="text" required class="validate" placeholder="" >
                                       <label for="word"><?=$LANG['Words']?></label>
                                 </div>
                            </div>
                            <div class="row no-m-t no-m-b">
                                 <div class="input-field col s12">
                                       <input id="wreason" type="text" class="validate">
                                       <label for="wreason"><?=$LANG['Reason']?> </label>
                                 </div>
                            </div>
                           <div class="card-action">
                                <button id="wsave-button" class="btn green darken-4" type="submit"><i class="fa fa-save"></i> <?=$LANG['Save Record']?> </button>
                                <span id="wsave-spin" class="btn-flat" style="display: none;"><i class="fa fa-spinner fa-spin"></i> <strong><?=$LANG['Please wait']?>...</strong></span>
                           </div>
                        </form>
                     </div>
				</div>                
            </div>
      </div>  
  
</div>
