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/TrafficShaping.php

    r790 r873  
    11<?php
    22
    3 if(isset($_SERVER['REMOTE_ADDR'])) die();
     3if (isset($_SERVER['REMOTE_ADDR'])) die();
    44
    55$Enabled = 1;
     
    3737  exec('/sbin/iptables -t mangle -F PREROUTING');
    3838  exec('/sbin/iptables -t mangle -F POSTROUTING');
    39   if($Enabled)
     39  if ($Enabled)
    4040  {
    4141    //exec('/sbin/iptables -t mangle -A FORWARD -j MARK --set-mark 0');
     
    4848  // In going traffic
    4949  fputs($File, "/sbin/tc qdisc del dev ".$InInterface." root\n");
    50   if($Enabled)
     50  if ($Enabled)
    5151  {
    5252    fputs($File, "/sbin/tc qdisc add dev ".$InInterface." root handle 1:0 htb default 2\n");
     
    5959  // Out going traffic
    6060  fputs($File, "/sbin/tc qdisc del dev ".$OutInterface." root\n");
    61   if($Enabled)
     61  if ($Enabled)
    6262  {
    6363    fputs($File, "/sbin/tc qdisc add dev ".$OutInterface." root handle 1:0 htb default 2\n");
     
    6969  }
    7070
    71   if(!$Enabled) die("Traffic shaping disabled\n");
    72 
    73   if($ClassesEnabled)
     71  if (!$Enabled) die("Traffic shaping disabled\n");
     72
     73  if ($ClassesEnabled)
    7474  {
    7575  $ClassId = 3;
     
    124124
    125125  $DbResult = $Database->select('users', '*, CONCAT(second_name, " ", first_name) as fullname', '(inet=1)');
    126   while($User = $DbResult->fetch_array())
     126  while ($User = $DbResult->fetch_array())
    127127  {
    128128    $UserClassId = $ClassId;
     
    152152
    153153    $DbResult2 = $Database->select('hosts','*',"block=0 AND MAC!='' AND user=".$User['id']);
    154     while($Host = $DbResult2->fetch_array())
    155     //if($Row['name'] != 'WOW')
     154    while ($Host = $DbResult2->fetch_array())
     155    //if ($Row['name'] != 'WOW')
    156156    {
    157157      $HostClassId = $ClassId;
     
    160160      fputs($FileClassInfo, '1:'.$HostClassId.' '.$Host['name']."\n");
    161161      //echo('  Host class id: '.$HostClassId."\n");
    162     //if($User['inet'] == 1)
     162    //if ($User['inet'] == 1)
    163163      {
    164164        $Prio = 1;
    165         if($Host['vpn'] == 1)
     165        if ($Host['vpn'] == 1)
    166166        {
    167           if($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip'];
     167          if ($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip'];
    168168          else $Host['IP'] = ToVpnIp($Host);
    169169        }
    170170
    171         //if($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5;
     171        //if ($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5;
    172172          //else
    173173        $SpeedDivider = 1;
    174174
    175         if($Host['name'] == 'centrala')
     175        if ($Host['name'] == 'centrala')
    176176        {
    177177          $Host['IP'] = $Host['external_ip'];
     
    183183           $TableIn = 'FORWARD';
    184184         }
    185         //if($Row['name'] == 'TERMINAL2') $Prio = 0;
    186         //  if($Row['name'] = 'TERMINAL2') $Prio = 0;
    187         if($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp';
     185        //if ($Row['name'] == 'TERMINAL2') $Prio = 0;
     186        //  if ($Row['name'] = 'TERMINAL2') $Prio = 0;
     187        if ($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp';
    188188        else $Protocol = '';
    189         //  if($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000;
     189        //  if ($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000;
    190190        /*
    191 if($Host['name'] == 'GAME')
     191if ($Host['name'] == 'GAME')
    192192        {
    193193          exec('/sbin/iptables -t mangle -F game-server');
     
    195195          $TableIn = 'game-server';
    196196        }*/
    197         //if($Host['name'] == 'TBC') continue;
     197        //if ($Host['name'] == 'TBC') continue;
    198198
    199199        // In going traffic
     
    213213      }
    214214      // Free inet
    215       if($Tarify[$User['inet_tarif_now']]['group_id'] == 3)
     215      if ($Tarify[$User['inet_tarif_now']]['group_id'] == 3)
    216216      {
    217217        //exec('/sbin/iptables -t mangle -A '.$TableIn.' -i eth1 -d '.$Host['IP'].$Protocol." -j MARK --set-mark ".$FreeInetClass);
     
    220220      // VoIP devices
    221221/*
    222       if(($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP'))
     222      if (($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP'))
    223223      {
    224224        exec('/sbin/iptables -t mangle -A '.$TableIn." -i eth1 -d ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId);
    225225        exec('/sbin/iptables -t mangle -A '.$TableOut." -o eth1 -s ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId);
    226226      } else
    227       if($Host['name'] == 'GAME')
     227      if ($Host['name'] == 'GAME')
    228228      {
    229229        exec('/sbin/iptables -t mangle -A FORWARD -o eth1 -s '.$Host['IP']." -j game-server");
Note: See TracChangeset for help on using the changeset viewer.