Changeset 208 for trunk/system/generators/traffic_shaping_routerboard.php
- Timestamp:
- May 6, 2009, 8:21:23 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/generators/traffic_shaping_routerboard.php
r204 r208 62 62 $Index = 0; 63 63 $DbResult = $Database->query('SELECT Member.*, Subject.Name FROM Member LEFT JOIN Subject ON Subject.Id = Member.Subject'); 64 while($Member = $DbResult->fetch_a rray())64 while($Member = $DbResult->fetch_assoc()) 65 65 { 66 66 $Member['Name'] = RouterOSIdent($Member['Name']); … … 88 88 } 89 89 90 $DbResult2 = $Database->select(' hosts', '*', '(block=0) AND (MAC != "") AND (user='.$Member['Id'].')');91 while($ Host = $DbResult2->fetch_array())90 $DbResult2 = $Database->select('NetworkDevice', '*', 'Member = '.$Member['Id']); 91 while($Device = $DbResult2->fetch_assoc()) 92 92 { 93 $Host['name'] = RouterOSIdent($Host['name']); 94 echo($Host['name'].', '); 95 $IPParts = explode('.', $Host['IP']); 96 $Subnet = $IPParts[2]; 97 $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'].'"'; 98 $Commands[] = ' /queue tree add name='.$Host['name'].'-out limit-at='.$HostSpeedIn.' max-limit='.$UserMaxSpeedIn.' parent='.$Member['Name'].'-out packet-mark='.$PacketMark.' queue=wireless-default'; 99 $PacketMark++; 100 $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'].'"'; 101 $Commands[] = ' /queue tree add name='.$Host['name'].'-in limit-at='.$HostSpeedOut.' max-limit='.$UserMaxSpeedOut.' parent='.$Member['Name'].'-in packet-mark='.$PacketMark.' queue=wireless-default'; 102 $PacketMark++; 93 $DbResult3 = $Database->select('NetworkInterface', '*', 'Device = '.$Device['Id']); 94 while($Interface = $DbResult3->fetch_assoc()) 95 { 96 $Name = $Device['Name'].'-'.$Interface['Name']; 97 $Name = RouterOSIdent($Name); 98 echo($Name.', '); 99 $IPParts = explode('.', $Interface['LocalIP']); 100 $Subnet = $IPParts[2]; 101 $Commands[] = ' /ip firewall mangle add chain=inet-out-'.$Subnet.' src-address='.$Interface['LocalIP'].' out-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' passthrough=no comment="'.$Name.'"'; 102 $Commands[] = ' /queue tree add name='.$Name.'-out limit-at='.$HostSpeedIn.' max-limit='.$UserMaxSpeedIn.' parent='.$Member['Name'].'-out packet-mark='.$PacketMark.' queue=wireless-default'; 103 $PacketMark++; 104 $Commands[] = ' /ip firewall mangle add chain=inet-in-'.$Subnet.' dst-address='.$Interface['LocalIP'].' in-interface='.$InetInterface.' action=mark-packet new-packet-mark='.$PacketMark.' passthrough=no comment="'.$Name.'"'; 105 $Commands[] = ' /queue tree add name='.$Name.'-in limit-at='.$HostSpeedOut.' max-limit='.$UserMaxSpeedOut.' parent='.$Member['Name'].'-in packet-mark='.$PacketMark.' queue=wireless-default'; 106 $PacketMark++; 103 107 104 // Posílej po menších částech 105 if($Index > 50) 106 { 107 //print_r($Commands); 108 $Commands = addslashes(implode(';', $Commands)); 109 $Command = '/usr/bin/ssh -l '.$Config['MainRouter']['UserName'].' -i id_dsa '.$Config['MainRouter']['HostName'].' "'.$Commands.'"'; 110 $Output = array(); 111 exec($Command, $Output); 112 print_r($Output); 113 $Commands = array(); 114 $Index = 0; 108 // Posílej po menších částech 109 if($Index > 50) 110 { 111 //print_r($Commands); 112 $Commands = addslashes(implode(';', $Commands)); 113 $Command = '/usr/bin/ssh -l '.$Config['MainRouter']['UserName'].' -i id_dsa '.$Config['MainRouter']['HostName'].' "'.$Commands.'"'; 114 $Output = array(); 115 exec($Command, $Output); 116 print_r($Output); 117 $Commands = array(); 118 $Index = 0; 119 } 120 $Index++; 115 121 } 116 $Index++;117 122 } 118 123
Note:
See TracChangeset
for help on using the changeset viewer.