Changeset 124 for system


Ignore:
Timestamp:
Dec 11, 2008, 8:28:30 AM (16 years ago)
Author:
george
Message:
  • Opraveno: Generování traffic shapingu routerboardu se správně zformátovanými jmény uživatelů a počítačů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • system/generators/traffic_shaping_routerboard.php

    r121 r124  
    33$Enabled = 1;
    44$ClassesEnabled = 1;
    5 chdir('/var/www/html/dev/centrala/www');
     5chdir('/a/www/centrala');
    66include_once('global.php');
    77include_once('finance/include.php');
     
    2929
    3030$InetInterface = 'ether3';
    31 $Router = '192.168.10.33';
     31$Router = '192.168.0.11';
    3232
    3333$Commands = array();
     
    5050
    5151// Slow free internet
    52 $Commands[] = ' /queue tree add name=free-out limit-at='.$FreeInetSpeed.' max-limit='.$FreeInetSpeed.' parent=main-out packet-mark='.$PacketMark;
    53 $Commands[] = ' /ip firewall mangle add chain=inet-out out-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' queue=wireless-default';
     52$Commands[] = ' /ip firewall mangle add chain=inet-out out-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' comment="Free inet"';
     53$Commands[] = ' /queue tree add name=free-out limit-at='.$FreeInetSpeed.' max-limit='.$FreeInetSpeed.' parent=main-out packet-mark='.$PacketMark.' queue=wireless-default';
    5454$PacketMark++;
     55$Commands[] = ' /ip firewall mangle add chain=inet-in in-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' comment="Free inet"';
    5556$Commands[] = ' /queue tree add name=free-in limit-at='.$FreeInetSpeed.' max-limit='.$FreeInetSpeed.' parent=main-in packet-mark='.$PacketMark.' queue=wireless-default';
    56 $Commands[] = ' /ip firewall mangle add chain=inet-in in-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark;
    5757$PacketMark++;
    5858
    59 
    6059// Process users
    61 $DbResult = $Database->select('users', '*, CONCAT(second_name, "_", first_name) as fullname', '(inet=1)');
     60$DbResult = $Database->select('users', '*, CONCAT(second_name, " ", first_name) as fullname', '(inet=1)');
    6261while($User = $DbResult->fetch_array())
    6362{
    64   $User['fullname'] = strtr(strtolower($User['fullname']), array(
     63  $User['fullname'] = strtr(strtolower(trim($User['fullname'])), array(' ' => '-', '(' => '-', ')' => '-',
    6564  'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', 'ť' => 't', 'ň' => 'n', 'ó' => 'o',
    6665  'Č' => 'c', 'Š' => 's', 'Ě' => 'e', 'Ř' => 'r', 'Ž' => 'z', 'Ý' => 'y', 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd', 'Ť' => 't', 'Ň' => 'n', 'Ó' => 'o',
     
    8988    $IPParts = explode('.', $Host['IP']);
    9089    $Subnet = $IPParts[2];
    91     $Commands[] = ' /ip firewall mangle add chain=inet-out-'.$Subnet.' src-address='.$Host['IP'].' out-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' passthrough=no';
     90    $Commands[] = ' /ip firewall mangle add chain=inet-out-'.$Subnet.' src-address='.$Host['IP'].' out-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' passthrough=no comment="'.$Host['name'].'"';
    9291    $Commands[] = ' /queue tree add name='.$Host['name'].'-out limit-at='.$HostSpeedIn.' max-limit='.$UserMaxSpeedIn.' parent='.$User['fullname'].'-out packet-mark='.$PacketMark.' queue=wireless-default';
    9392    $PacketMark++;
    94     $Commands[] = ' /ip firewall mangle add chain=inet-in-'.$Subnet.' dst-address='.$Host['IP'].' in-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' passthrough=no';
     93    $Commands[] = ' /ip firewall mangle add chain=inet-in-'.$Subnet.' dst-address='.$Host['IP'].' in-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' passthrough=no comment="'.$Host['name'].'"';
    9594    $Commands[] = ' /queue tree add name='.$Host['name'].'-in limit-at='.$HostSpeedOut.' max-limit='.$UserMaxSpeedOut.' parent='.$User['fullname'].'-in packet-mark='.$PacketMark.' queue=wireless-default';
    9695    $PacketMark++;
     
    114113  echo("\n");
    115114}
    116 $Commands = implode(';', $Commands);
     115print_r($Commands);
     116$Commands = addslashes(implode(';', $Commands));
    117117$Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa '.$Router.' "'.$Commands.'"';
    118118//echo($Command."\n");
    119119exec($Command, $Output);
    120 array_pop($Output);
     120//array_pop($Output);
     121print_r($Output);
    121122
    122123?>
Note: See TracChangeset for help on using the changeset viewer.