Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigLinux/Generators/NAT.php

    r790 r873  
    11<?php
    2 if(isset($_SERVER['REMOTE_ADDR'])) die();
     2if (isset($_SERVER['REMOTE_ADDR'])) die();
    33include_once('../../../Common/Global.php');
    44
     
    1414// Blocking according IP address
    1515$DbResult = $Database->select('users', '*', 'inet = 0');
    16 while($User = $DbResult->fetch_array())
     16while ($User = $DbResult->fetch_array())
    1717{
    1818  $DbResult2 = $Database->select('hosts', '*', "block<2 AND MAC!='' AND user=".$User['id']);
    19   while($Row = $DbResult2->fetch_array())
     19  while ($Row = $DbResult2->fetch_array())
    2020  {
    2121    exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local');
     
    2323}
    2424$DbResult = $Database->select('users', '*', 'inet = 1');
    25 while($User = $DbResult->fetch_array())
     25while ($User = $DbResult->fetch_array())
    2626{
    2727  $DbResult2 = $Database->select('hosts','*',"block<2 AND MAC!='' AND vpn=1 AND user=".$User['id']);
    28   while($Row = $DbResult2->fetch_array())
     28  while ($Row = $DbResult2->fetch_array())
    2929  {
    3030    exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local');
     
    3636// Blocking according MAC address
    3737$DbResult = $Database->select('users', '*');
    38 while($User = $DbResult->fetch_array())
     38while ($User = $DbResult->fetch_array())
    3939{
    4040  //echo($User['fullname']."\n");
    4141  $DbResult2 = $Database->select('hosts','*','block<2 AND MAC!="" AND user='.$User['id'].' ORDER BY id DESC');
    42   while($Row = $DbResult2->fetch_array())
     42  while ($Row = $DbResult2->fetch_array())
    4343  {
    4444    //echo(' '.$Row['name']." ".$Row['MAC']." ");
    45     if($User['inet'] == 0)
     45    if ($User['inet'] == 0)
    4646    {
    47       //if(($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
     47      //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
    4848      //    else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local");
    4949    } else {
    50       if($Row['vpn'] == 0)
     50      if ($Row['vpn'] == 0)
    5151      {
    5252  $CZFreeLocalIP = $Row['IP'];
    5353        //echo($Row['external_ip']."\n");
    54   //if($Row['name'] == 'TBC')
     54  //if ($Row['name'] == 'TBC')
    5555  //{
    5656        //  exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725');
    5757        //  exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o eth1 -j SNAT --to-source '.$Row['external_ip'].':3724');
    5858  //}
    59         if(strtolower($Row['name']) != 'centrala')
     59        if (strtolower($Row['name']) != 'centrala')
    6060  {
    61       if($Row['external_ip'] != '')
     61      if ($Row['external_ip'] != '')
    6262          {
    6363            echo($Row['name'].'='.$Row['external_ip']."\n");
     
    7575 //echo('vpn');
    7676        //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP');
    77         if($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');
     77        if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');
    7878        exec('/sbin/iptables -t nat -A Block -s '.ToVpnIp($Row)." -j Proxy");
    7979
    80         //if($Row['vpn'] == 1)
     80        //if ($Row['vpn'] == 1)
    8181  //{
    8282    //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local");
    83         //} else if($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
     83        //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");
    8484      }
    85       if($Row['czfree_ip'] != '')
     85      if ($Row['czfree_ip'] != '')
    8686      {
    8787        // CZFree
Note: See TracChangeset for help on using the changeset viewer.