- Timestamp:
- Dec 11, 2008, 8:28:30 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
system/generators/traffic_shaping_routerboard.php
r121 r124 3 3 $Enabled = 1; 4 4 $ClassesEnabled = 1; 5 chdir('/ var/www/html/dev/centrala/www');5 chdir('/a/www/centrala'); 6 6 include_once('global.php'); 7 7 include_once('finance/include.php'); … … 29 29 30 30 $InetInterface = 'ether3'; 31 $Router = '192.168. 10.33';31 $Router = '192.168.0.11'; 32 32 33 33 $Commands = array(); … … 50 50 51 51 // 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'; 54 54 $PacketMark++; 55 $Commands[] = ' /ip firewall mangle add chain=inet-in in-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' comment="Free inet"'; 55 56 $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;57 57 $PacketMark++; 58 58 59 60 59 // 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)'); 62 61 while($User = $DbResult->fetch_array()) 63 62 { 64 $User['fullname'] = strtr(strtolower( $User['fullname']), array(63 $User['fullname'] = strtr(strtolower(trim($User['fullname'])), array(' ' => '-', '(' => '-', ')' => '-', 65 64 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', 'ť' => 't', 'ň' => 'n', 'ó' => 'o', 66 65 'Č' => 'c', 'Š' => 's', 'Ě' => 'e', 'Ř' => 'r', 'Ž' => 'z', 'Ý' => 'y', 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd', 'Ť' => 't', 'Ň' => 'n', 'Ó' => 'o', … … 89 88 $IPParts = explode('.', $Host['IP']); 90 89 $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'].'"'; 92 91 $Commands[] = ' /queue tree add name='.$Host['name'].'-out limit-at='.$HostSpeedIn.' max-limit='.$UserMaxSpeedIn.' parent='.$User['fullname'].'-out packet-mark='.$PacketMark.' queue=wireless-default'; 93 92 $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'].'"'; 95 94 $Commands[] = ' /queue tree add name='.$Host['name'].'-in limit-at='.$HostSpeedOut.' max-limit='.$UserMaxSpeedOut.' parent='.$User['fullname'].'-in packet-mark='.$PacketMark.' queue=wireless-default'; 96 95 $PacketMark++; … … 114 113 echo("\n"); 115 114 } 116 $Commands = implode(';', $Commands); 115 print_r($Commands); 116 $Commands = addslashes(implode(';', $Commands)); 117 117 $Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa '.$Router.' "'.$Commands.'"'; 118 118 //echo($Command."\n"); 119 119 exec($Command, $Output); 120 array_pop($Output); 120 //array_pop($Output); 121 print_r($Output); 121 122 122 123 ?>
Note:
See TracChangeset
for help on using the changeset viewer.