Changeset 171 for www


Ignore:
Timestamp:
Mar 24, 2009, 7:28:33 PM (16 years ago)
Author:
george
Message:
  • Opraveno: Konfigurační skripty síťových zařízení opraveny pro nové tabulky Member a Subject.
Location:
www
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • www/finance/finance.php

    r165 r171  
    9393      $Tarify[$Index]['aggregation'] = '1:'.round($Tarify[$Index]['max_speed'] / $Tarify[$Index]['min_speed']);
    9494    }
    95         $this->Tarify = $Tarify;
     95          $this->Tarify = $Tarify;
    9696  }
    9797
  • www/system/generators/dhcp_routerboard.php

    r168 r171  
    2020  $Commands = implode(';', $Commands);
    2121  $Command = '/usr/bin/ssh -l '.$UserName.' -i id_dsa '.$Subnet['DHCP'].' "'.$Commands.'"';
    22   echo($Command."\n");
     22  //echo($Command."\n");
    2323  $Output = '';
    2424  exec($Command, $Output);
  • www/system/generators/dns.php

    r161 r171  
    291291  fclose($File2);
    292292}
     293
    293294?>
  • www/system/generators/nat_routerboard.php

    r161 r171  
    11<?php
     2
    23include_once('../../global.php');
    34
     
    89$Commands[] = '/ip firewall nat { remove [find] }';
    910
    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');
     12while($Member = $DbResult->fetch_assoc())
    1213{
    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_array())
     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())
    1617  {
    1718    echo($Host['name']."\n");
     
    2829
    2930$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.'"';
     32echo($Command."\n");
     33//exec($Command, $Output);
    3334//array_pop($Output);
    3435//print_r($Output);
  • www/system/generators/netwatch.php

    r168 r171  
    2424  $Commands = implode(';', $Commands);
    2525  $Command = '/usr/bin/ssh -l '.$UserName.' -i id_dsa '.$Router['DHCP'].' "'.$Commands.'"';
    26   echo($Command."\n");
     26  //echo($Command."\n");
    2727  $Output = '';
    2828  exec($Command, $Output);
  • www/system/generators/traffic_shaping_routerboard.php

    r167 r171  
    66include_once('../../global.php');
    77$Finance = &$System->Modules['Finance'];
    8 $Finance->NactiMesicniParametry(0);
     8$Finance->LoadMonthParameters(0);
    99
    1010// Generate traffic shaping rules
     
    2929
    3030$InetInterface = 'ether3';
    31 $Router = '192.168.0.99';
     31$Router = '192.168.0.11';
    3232
    3333$Commands = array();
     
    5959// Process users
    6060$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');
     62while($Member = $DbResult->fetch_array())
    6363{
    64   $User['fullname'] = strtr(strtolower(trim($User['fullname'])), array(' ' => '-', '(' => '-', ')' => '-',
     64  $Member['Name'] = strtr(strtolower(trim($Member['Name'])), array(' ' => '-', '(' => '-', ')' => '-',
    6565  'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', 'ť' => 't', 'ň' => 'n', 'ó' => 'o',
    6666  'Č' => 'c', 'Š' => 's', 'Ě' => 'e', 'Ř' => 'r', 'Ž' => 'z', 'Ý' => 'y', 'Á' => 'a', 'Í' => 'i', 'É' => 'e', 'Ů' => 'u', 'Ú' => 'u', 'Ď' => 'd', 'Ť' => 't', 'Ň' => 'n', 'Ó' => 'o',
    6767));
    6868
    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';
    7778
    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']);
    7980  $Row = $DbResult2->fetch_array();
    8081  $HostCount = $Row[0];
     
    8283  $HostSpeedOut = round($SpeedOut / $HostCount);
    8384
    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']);
    8586  while($Host = $DbResult2->fetch_array())
    8687  {
     
    9091    $Subnet = $IPParts[2];
    9192    $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';
    9394    $PacketMark++;
    9495    $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';
    9697    $PacketMark++;
    9798
    9899    // Posílej po menších částech
    99100    if($Index > 50)
    100         {
     101          {
    101102      $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");
    103105      exec($Command, $Output);
    104106      print_r($Output);
    105           $Commands = array();
    106           $Index = 0;
    107         }
     107          $Commands = array();
     108            $Index = 0;
     109          }
    108110    $Index++;
    109111  }
     
    112114//print_r($Commands);
    113115$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.'"';
    115117//echo($Command."\n");
    116118exec($Command, $Output);
Note: See TracChangeset for help on using the changeset viewer.