Changeset 171 for www/system
- Timestamp:
- Mar 24, 2009, 7:28:33 PM (16 years ago)
- Location:
- www/system/generators
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
www/system/generators/dhcp_routerboard.php
r168 r171 20 20 $Commands = implode(';', $Commands); 21 21 $Command = '/usr/bin/ssh -l '.$UserName.' -i id_dsa '.$Subnet['DHCP'].' "'.$Commands.'"'; 22 echo($Command."\n");22 //echo($Command."\n"); 23 23 $Output = ''; 24 24 exec($Command, $Output); -
www/system/generators/dns.php
r161 r171 291 291 fclose($File2); 292 292 } 293 293 294 ?> -
www/system/generators/nat_routerboard.php
r161 r171 1 1 <?php 2 2 3 include_once('../../global.php'); 3 4 … … 8 9 $Commands[] = '/ip firewall nat { remove [find] }'; 9 10 10 $DbResult = $Database-> select('users', 'CONCAT(second_name, " ", first_name) as fullname, id');11 while($ User = $DbResult->fetch_array())11 $DbResult = $Database->query('SELECT Member.*, Subject.* FROM Member ON Member.Subject = Subject.Id'); 12 while($Member = $DbResult->fetch_assoc()) 12 13 { 13 echo($ User['fullname']."\n");14 $DbResult2 = $Database->select('hosts', '*', '(external_ip <> "") AND (user='.$ User['id'].') AND (IP != external_ip) ORDER BY id DESC');15 while($Host = $DbResult2->fetch_a rray())14 echo($Member['Name']."\n"); 15 $DbResult2 = $Database->select('hosts', '*', '(external_ip <> "") AND (user='.$Member['Id'].') AND (IP != external_ip) ORDER BY id DESC'); 16 while($Host = $DbResult2->fetch_assoc()) 16 17 { 17 18 echo($Host['name']."\n"); … … 28 29 29 30 $Commands = addslashes(implode(';', $Commands)); 30 $Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa '.$Router.' "'.$Commands.'"';31 //echo($Command."\n");32 exec($Command, $Output);31 $Command = '/usr/bin/ssh -l admin-ssh -i id_dsa '.$Router.' "'.$Commands.'"'; 32 echo($Command."\n"); 33 //exec($Command, $Output); 33 34 //array_pop($Output); 34 35 //print_r($Output); -
www/system/generators/netwatch.php
r168 r171 24 24 $Commands = implode(';', $Commands); 25 25 $Command = '/usr/bin/ssh -l '.$UserName.' -i id_dsa '.$Router['DHCP'].' "'.$Commands.'"'; 26 echo($Command."\n");26 //echo($Command."\n"); 27 27 $Output = ''; 28 28 exec($Command, $Output); -
www/system/generators/traffic_shaping_routerboard.php
r167 r171 6 6 include_once('../../global.php'); 7 7 $Finance = &$System->Modules['Finance']; 8 $Finance-> NactiMesicniParametry(0);8 $Finance->LoadMonthParameters(0); 9 9 10 10 // Generate traffic shaping rules … … 29 29 30 30 $InetInterface = 'ether3'; 31 $Router = '192.168.0. 99';31 $Router = '192.168.0.11'; 32 32 33 33 $Commands = array(); … … 59 59 // Process users 60 60 $Index = 0; 61 $DbResult = $Database-> select('users', '*, CONCAT(second_name, " ", first_name) as fullname', '(inet=1)');62 while($ User = $DbResult->fetch_array())61 $DbResult = $Database->query('SELECT Member.*, Subject.Name FROM Member LEFT JOIN Subject ON Subject.Id = Member.Subject'); 62 while($Member = $DbResult->fetch_array()) 63 63 { 64 $ User['fullname'] = strtr(strtolower(trim($User['fullname'])), array(' ' => '-', '(' => '-', ')' => '-',64 $Member['Name'] = strtr(strtolower(trim($Member['Name'])), array(' ' => '-', '(' => '-', ')' => '-', 65 65 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', 'ť' => 't', 'ň' => 'n', 'ó' => 'o', 66 66 'Č' => 'c', 'Š' => 's', 'Ě' => 'e', 'Ř' => 'r', 'Ž' => 'z', 'Ý' => 'y', 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd', 'Ť' => 't', 'Ň' => 'n', 'Ó' => 'o', 67 67 )); 68 68 69 echo('Uživatel '.$User['fullname'].": "); 70 $SpeedIn = round($Tarify[$User['inet_tarif_now']]['min_speed'] / $InDivider); 71 $SpeedOut = round($Tarify[$User['inet_tarif_now']]['min_speed'] / $OutDivider); 72 $UserMaxSpeedIn = round($Tarify[$User['inet_tarif_now']]['max_speed'] / $InDivider); 73 $UserMaxSpeedOut = round($Tarify[$User['inet_tarif_now']]['max_speed'] / $OutDivider); 74 $Quantum = $Tarify[$User['inet_tarif_now']]['speed_factor'] * 1500; 75 $Commands[] = ' /queue tree add name='.$User['fullname'].'-out limit-at='.$SpeedIn.' max-limit='.$UserMaxSpeedIn.' parent=main-out queue=wireless-default'; 76 $Commands[] = ' /queue tree add name='.$User['fullname'].'-in limit-at='.$SpeedOut.' max-limit='.$UserMaxSpeedOut.' parent=main-in queue=wireless-default'; 69 echo('Uživatel '.$Member['Name'].": "); 70 $Tariff = $Finance->Tarify[$Member['InternetTariffCurrentMonth']]; 71 $SpeedIn = round($Tariff['min_speed'] / $InDivider); 72 $SpeedOut = round($Tariff['min_speed'] / $OutDivider); 73 $UserMaxSpeedIn = round($Tariff['max_speed'] / $InDivider); 74 $UserMaxSpeedOut = round($Tariff['max_speed'] / $OutDivider); 75 $Quantum = $Tariff['speed_factor'] * 1500; 76 $Commands[] = ' /queue tree add name='.$Member['Name'].'-out limit-at='.$SpeedIn.' max-limit='.$UserMaxSpeedIn.' parent=main-out queue=wireless-default'; 77 $Commands[] = ' /queue tree add name='.$Member['Name'].'-in limit-at='.$SpeedOut.' max-limit='.$UserMaxSpeedOut.' parent=main-in queue=wireless-default'; 77 78 78 $DbResult2 = $Database->select('hosts', 'COUNT(*)', "block=0 AND MAC!='' AND user=".$ User['id']);79 $DbResult2 = $Database->select('hosts', 'COUNT(*)', "block=0 AND MAC!='' AND user=".$Member['Id']); 79 80 $Row = $DbResult2->fetch_array(); 80 81 $HostCount = $Row[0]; … … 82 83 $HostSpeedOut = round($SpeedOut / $HostCount); 83 84 84 $DbResult2 = $Database->select('hosts', '*', "block=0 AND MAC!='' AND user=".$ User['id']);85 $DbResult2 = $Database->select('hosts', '*', "block=0 AND MAC!='' AND user=".$Member['Id']); 85 86 while($Host = $DbResult2->fetch_array()) 86 87 { … … 90 91 $Subnet = $IPParts[2]; 91 92 $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 $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 $Commands[] = ' /queue tree add name='.$Host['name'].'-out limit-at='.$HostSpeedIn.' max-limit='.$UserMaxSpeedIn.' parent='.$Member['Name'].'-out packet-mark='.$PacketMark.' queue=wireless-default'; 93 94 $PacketMark++; 94 95 $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 $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 $Commands[] = ' /queue tree add name='.$Host['name'].'-in limit-at='.$HostSpeedOut.' max-limit='.$UserMaxSpeedOut.' parent='.$Member['Name'].'-in packet-mark='.$PacketMark.' queue=wireless-default'; 96 97 $PacketMark++; 97 98 98 99 // Posílej po menších částech 99 100 if($Index > 50) 100 {101 { 101 102 $Commands = addslashes(implode(';', $Commands)); 102 $Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa '.$Router.' "'.$Commands.'"'; 103 $Command = '/usr/bin/ssh -l admin-ssh -i id_dsa '.$Router.' "'.$Commands.'"'; 104 //echo($Command."\n"); 103 105 exec($Command, $Output); 104 106 print_r($Output); 105 $Commands = array();106 $Index = 0;107 }107 $Commands = array(); 108 $Index = 0; 109 } 108 110 $Index++; 109 111 } … … 112 114 //print_r($Commands); 113 115 $Commands = addslashes(implode(';', $Commands)); 114 $Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa '.$Router.' "'.$Commands.'"';116 $Command = '/usr/bin/ssh -l admin-ssh -i id_dsa '.$Router.' "'.$Commands.'"'; 115 117 //echo($Command."\n"); 116 118 exec($Command, $Output);
Note:
See TracChangeset
for help on using the changeset viewer.