Changeset 208


Ignore:
Timestamp:
May 6, 2009, 8:21:23 AM (16 years ago)
Author:
george
Message:
  • Upraveno: Tabulka hosts rozdělena na NetworkDevice, NetworkInterface, NetworkInterfaceType a NetworkLink. Jeden počítač může mít více rozhraní. Nově se již nepočítá pouze s stromovou topologií, ale s celkovou sítí s okruhy. Sloupce Parent byl proto nahrazen tabulkou NetworkLink, ve které jsou uchovány informace o tom, co kam je připojeno. Každé rozhraní má definovaný typ dle NetworkInterfaceType.
  • Upraveno: Tabulka HostType přejmenována na NetworkDeviceType.
  • Smazáno: Původní složka komunikačního programu sunrisechat. Nově nahrazena složkou chat pro podporu IRC.
Location:
trunk
Files:
1 added
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/global.php

    r189 r208  
    188188  global $Database;
    189189 
    190   $DbResult = $Database->query('SELECT Id FROM Member WHERE (SELECT user FROM hosts WHERE IP="'.$IP.'") = Member.Id');
     190  $DbResult = $Database->query('SELECT Id FROM Member WHERE (SELECT Member FROM NetworkDevice WHERE (SELECT Device FROM NetworkInterface WHERE LocalIP = "'.$IP.'") = NetworkDevice.Id) = Member.Id');
    191191  if($DbResult->num_rows > 0)
    192192  {
     
    199199{
    200200  return(str_replace(
    201     array("á","č","ď","é","ě","í","ľ","ň","ó","ř","š","ť","ú","ů","ý","ž","Á","Č","Ď","É","Ě","Í","Ľ","Ň","Ó","Ř","Š","Ť","Ú","Ů","Ý","Ž"),
    202     array("a","c","d","e","e","i","l","n","o","r","s","t","u","u","y","z","A","C","D","E","E","I","L","N","O","R","S","T","U","U","Y","Z"),
     201    array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'),
     202    array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'),
    203203    $Text));
    204204}
     
    222222}
    223223
    224 
     224function NotBlank($Text)
     225{
     226  if($Text == '') return('&nbsp'); else return($Text);
     227}
    225228
    226229?>
  • trunk/hostlist.php

    r194 r208  
    99  function Show()
    1010  {
    11     $Output = '<div align="center" style="font-size: small;"><table class="WideTable"><tr><th>Jméno počítače</th><th>IP adresa</th><th>Typ</th><th>Naposledy online</th><th>Správce</th></tr>';
    12     $DbResult = $this->Database->query('SELECT hosts.*, User.Name as UserName, HostType.Name as HostType FROM hosts LEFT JOIN Member ON Member.Id = hosts.user LEFT JOIN User ON Member.ResponsibleUser = User.Id LEFT JOIN HostType ON HostType.Id = hosts.type WHERE hosts.used = 1 ORDER BY hosts.name');
    13     while($Host = $DbResult->fetch_array())
     11    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
     12    $Output .= '<tr><th>Jméno počítače</th><th>IP adresa</th><th>Typ</th><th>Naposledy online</th><th>Správce</th></tr>';
     13    $DbResult = $this->Database->query('SELECT NetworkDevice.*, User.Name as UserName, NetworkDeviceType.Name AS HostType FROM NetworkDevice LEFT JOIN Member ON Member.Id = NetworkDevice.Member LEFT JOIN User ON Member.ResponsibleUser = User.Id LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 ORDER BY NetworkDevice.Name');
     14    while($Device = $DbResult->fetch_assoc())
    1415    {
    15       if($Host['online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
    16       if($Host['IP'] == '') $Host['IP'] = '&nbsp;';
    17       $Output .= '<tr><td style="text-align: left; '.$Style.'">'.$Host['name'].'</td><td>'.$Host['IP'].'</td><td>'.$Host['HostType'].'</td><td style="text-align: right;">'.HumanDate($Host['last_online']).'</td><td style="text-align: right;">'.$Host['UserName'].'</td></tr>';
     16      if($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
     17      $Output .= '<tr><td colspan="2" style="text-align: left; font-weight: bold; '.$Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>';
     18      $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
     19      while($Interface = $DbResult2->fetch_assoc())
     20      {
     21        if($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
     22        if($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
     23        $Output .= '<tr><td style="text-align: left; '.$Style.'">&nbsp;&nbsp;'.$Device['Name'].'-'.$Interface['Name'].'</td><td>'.$Interface['LocalIP'].'</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
     24      }     
    1825    }
    1926    $Output .= '</table></div>';
  • trunk/index.php

    r203 r208  
    107107    $Output2 = '';
    108108
    109     $DbResult = $this->Database->query('SELECT COUNT(*) FROM hosts LEFT JOIN HostType ON HostType.Id = hosts.type WHERE HostType.ShowOnline = 1');
     109    $DbResult = $this->Database->query('SELECT COUNT(*) FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDeviceType.ShowOnline = 1');
    110110    $DbRow = $DbResult->fetch_array();
    111111    $TotalComputers = $DbRow[0];
    112112
    113     $DbResult = $this->Database->query('SELECT COUNT(*) FROM hosts LEFT JOIN HostType ON HostType.Id = hosts.type WHERE (HostType.ShowOnline = 1) AND (hosts.online = 1)');
     113    $DbResult = $this->Database->query('SELECT COUNT(*) FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE (NetworkDeviceType.ShowOnline = 1) AND (NetworkDevice.Online = 1)');
    114114    $DbRow = $DbResult->fetch_array();
    115115    $OnlineComputers = $DbRow[0];
     
    121121    $TotalUser = $DbRow[0];
    122122
    123     $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(user)) FROM hosts LEFT JOIN HostType ON HostType.Id = hosts.type WHERE HostType.ShowOnline = 1 AND hosts.online = 1');
     123    $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(Member)) FROM NetworkDevice LEFT JOIN HostType ON HostType.Id = NetworkDevice.Type WHERE HostType.ShowOnline = 1 AND NetworkDevice.Online = 1');
    124124    $DbRow = $DbResult->fetch_array();
    125125    $OnlineUser = $DbRow[0];
     
    177177  {
    178178    $Output = '<div class="PanelTitle">Online počítače</div><span style="font-size: smaller;">';
    179     $DbResult = $this->Database->query('SELECT hosts.name FROM hosts LEFT JOIN HostType ON HostType.Id = hosts.type WHERE (HostType.ShowOnline = 1) AND (hosts.online = 1) ORDER BY hosts.name');
    180     while($Row = $DbResult->fetch_array())
    181     {
    182       $Output .= $Row['name'].'<br />';
     179    $DbResult = $this->Database->query('SELECT NetworkDevice.Name FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE (NetworkDeviceType.ShowOnline = 1) AND (NetworkDevice.Online = 1) ORDER BY NetworkDevice.Name');
     180    while($Device = $DbResult->fetch_array())
     181    {
     182      $Output .= $Device['Name'].'<br />';
    183183    }
    184184    $Output .= '</span>';
  • trunk/network/dostupnost.php

    r192 r208  
    1414
    1515    $HostTypeList = array();
    16     $DbResult = $this->Database->select('HostType', '*');
     16    $DbResult = $this->Database->select('NetworkDeviceType', '*');
    1717    while($DbRow = $DbResult->fetch_assoc())
    1818      $HostTypeList[$DbRow['Id']] = $DbRow;
     
    2121    $Output .= '<br /><table class="WideTable" style="font-size: small;">';
    2222    $Output .= '<tr><th>Jméno</th><th>Hodina [%]</th><th>Den [%]</th><th>Týden [%]</th><th>Měsíc [%]</th><th>Rok [%]</th></tr>';
    23     $DbResult = $this->Database->query('SELECT hosts.type, hosts.name, PeriodHour.Percent as Hour, PeriodDay.Percent as Day, PeriodWeek.Percent as Week, PeriodMonth.Percent as Month, PeriodYear.Percent as Year FROM hosts LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 1 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 1 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodHour ON PeriodHour.host_id=hosts.id LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodDay ON PeriodDay.host_id=hosts.id LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 7 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 7 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodWeek ON PeriodWeek.host_id=hosts.id LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 30 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 30 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodMonth ON PeriodMonth.host_id=hosts.id LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 365 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 365 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodYear ON PeriodYear.host_id=hosts.id WHERE hosts.used=1 GROUP BY hosts.IP ORDER BY name');
     23    $DbResult = $this->Database->query('SELECT NetworkDevice.Type, NetworkDevice.Name, PeriodHour.Percent AS Hour, PeriodDay.Percent AS Day, PeriodWeek.Percent AS Week, PeriodMonth.Percent AS Month, PeriodYear.Percent AS Year FROM NetworkDevice
     24    LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 1 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 1 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodHour ON PeriodHour.host_id = NetworkDevice.Id
     25    LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodDay ON PeriodDay.host_id = NetworkDevice.Id
     26    LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 7 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 7 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodWeek ON PeriodWeek.host_id = NetworkDevice.Id
     27    LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 30 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 30 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodMonth ON PeriodMonth.host_id = NetworkDevice.id
     28    LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 365 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 365 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodYear ON PeriodYear.host_id = NetworkDevice.Id
     29    WHERE NetworkDevice.Used = 1 ORDER BY Name');
    2430    while($Row = $DbResult->fetch_assoc())
    25     if(($Row['type'] == 1) or ($Row['type'] == 4))
     31    if(($Row['Type'] == 1) or ($Row['Type'] == 4))
    2632    {
    27       $Output .= '<tr><td>'.$Row['name'].'</td><td style="text-align: right;">'.sprintf("%01.2f", $Row['Hour']).'</td><td style="text-align: right;">'.sprintf("%01.2f", $Row['Day']).'</td><td style="text-align: right;">'.sprintf("%01.2f", $Row['Week']).'</td><td style="text-align: right;">'.sprintf("%01.2f", $Row['Month']).'</td><td style="text-align: right;">'.sprintf("%01.2f", $Row['Year']).'</td></tr>';
     33      $Output .= '<tr><td>'.$Row['Name'].'</td><td style="text-align: right;">'.sprintf('%01.2f', $Row['Hour']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Row['Day']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Row['Week']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Row['Month']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Row['Year']).'</td></tr>';
    2834    }
    2935    $Output .= '</table></div>';
  • trunk/network/user_hosts.php

    r204 r208  
    1010  function Show()
    1111  {
    12 
    13     $Output = '<br /><table class="WideTable">
    14 <tr><th>Jméno počítače</th><th>Typ</th><th>Místní IP adresa</th><th>Veřejná IP adresa</th><th>CZFree IP adresa</th><th>Naposledy online</th><th>Fyzická adresa</th></tr>';
    15 
    16     $DbResult = $this->Database->query('SELECT hosts.*, HostType.Name AS HostType FROM hosts LEFT JOIN HostType ON HostType.Id = hosts.type WHERE (hosts.used = 1) AND (hosts.user = '.$this->System->Modules['User']->User['Member'].') ORDER BY hosts.name');
    17     while($Host = $DbResult->fetch_array())
     12    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
     13    $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>CZFree adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>';
     14    $DbResult = $this->Database->query('SELECT NetworkDevice.*, NetworkDeviceType.Name AS HostType FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Id FROM Member WHERE Member.ResponsibleUser = '.$this->System->Modules['User']->User['Member'].') ORDER BY NetworkDevice.Name');
     15    while($Device = $DbResult->fetch_assoc())
    1816    {
    19       if($Host['online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
    20       if($Host['IP'] == '') $Host['IP'] = '&nbsp;';
    21       if($Host['name'] == '') $Host['name'] = '&nbsp;';
    22       if($Host['czfree_ip'] == '') $Host['czfree_ip'] = '&nbsp;';
    23       if($Host['external_ip'] == '') $Host['external_ip'] = '&nbsp;';
    24       if($Host['MAC'] == '') $Host['MAC'] = '&nbsp;';
    25       $Output .= '<tr><td style="text-align: left; '.$Style.'">'.$Host['name'].'</td><td>'.$Host['HostType'].'</td><td>'.$Host['IP'].'</td><td>'.$Host['external_ip'].'</td><td>'.$Host['czfree_ip'].'</td><td >'.HumanDate($Host['last_online']).'</td><td>'.$Host['MAC'].'</td></tr>';
     17      if($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
     18      $Output .= '<tr><td colspan="5" style="text-align: left; font-weight: bold; '.$Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td></tr>';
     19      $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
     20      while($Interface = $DbResult2->fetch_assoc())
     21      {
     22        if($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
     23        $Output .= '<tr><td style="text-align: left; '.$Style.'">&nbsp;&nbsp;'.$Device['Name'].'-'.$Interface['Name'].'</td><td>'.NotBlank($Interface['LocalIP']).'</td><td>'.NotBlank($Interface['ExternalIP']).'</td><td>'.NotBlank($Interface['CZFreeIP']).'</td><td>'.NotBlank($Interface['MAC']).'</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
     24      }     
    2625    }
    27     $Output .= '</table>';
     26    $Output .= '</table></div>';
    2827    return($Output);
    2928  }
  • trunk/system/generators/dhcp_routerboard.php

    r197 r208  
    1212  $Commands = array();
    1313  $Commands[] = '/ip dhcp-server lease { remove [find server=dhcp'.$I.']}';
    14   $DbResult2 = $Database->query('SELECT * FROM `hosts` WHERE (`IP` LIKE "192.168.'.$I.'.%") AND (`MAC` != "00:00:00:00:00:00") ORDER BY `IP`');
    15   while($Host = $DbResult2->fetch_assoc())
     14  $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM `NetworkInterface` LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (`LocalIP` LIKE "192.168.'.$I.'.%") AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`');
     15  while($Interface = $DbResult2->fetch_assoc())
    1616  {
    17     $Commands[] = '/ip dhcp-server lease add mac-address='.$Host['MAC'].' address='.$Host['IP'].' server=dhcp'.$I.' comment='.$Host['name'];
     17    $Commands[] = '/ip dhcp-server lease add mac-address='.$Interface['MAC'].' address='.$Interface['LocalIP'].' server=dhcp'.$I.' comment='.$Interface['DeviceName'].'-'.$Interface['Name'];
    1818  }
    1919  $Commands = implode(';', $Commands);
  • trunk/system/generators/nat_routerboard.php

    r197 r208  
    1414  echo($Member['Name'].': ');
    1515  // Hosts
    16   $DbResult2 = $Database->select('hosts', '*', '(external_ip <> "") AND (user='.$Member['Id'].') AND (IP != external_ip) ORDER BY id DESC');
    17   while($Host = $DbResult2->fetch_assoc())
     16  $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.ExternalIP <> "") AND (NetworkDevice.Member = '.$Member['Id'].') AND (NetworkInterface.LocalIP != NetworkInterface.ExternalIP) ORDER BY id DESC');
     17  while($Interface = $DbResult2->fetch_assoc())
    1818  {
    19     $Host['name'] = RouterOSIdent($Host['name']);
    20     echo($Host['name'].'('.$Host['IP'].'), ');
    21     $Commands[] = ' /ip firewall nat add chain=srcnat src-address='.$Host['IP'].' out-interface='.$InetInterface.' action=src-nat to-addresses='.$Host['external_ip'].' comment="'.$Host['name'].'"';
    22     $Commands[] = ' /ip firewall nat add chain=dstnat dst-address='.$Host['external_ip'].' in-interface='.$InetInterface.' action=dst-nat to-addresses='.$Host['IP'].' comment="'.$Host['name'].'"';
     19    $Name = $Interface['DeviceName'].'-'.$Interface['Name'];
     20    $Name = RouterOSIdent($Name);
     21    echo($Name.'('.$Interface['LocalIP'].'), ');
     22    $Commands[] = ' /ip firewall nat add chain=srcnat src-address='.$Interface['LocalIP'].' out-interface='.$InetInterface.' action=src-nat to-addresses='.$Interface['ExternalIP'].' comment="'.$Name.'"';
     23    $Commands[] = ' /ip firewall nat add chain=dstnat dst-address='.$Interface['ExternalIP'].' in-interface='.$InetInterface.' action=dst-nat to-addresses='.$Interface['LocalIP'].' comment="'.$Name.'"';
    2324  }
    2425
  • trunk/system/generators/netwatch.php

    r197 r208  
    1515    $I = explode('.', $Subnet['AddressRange']);
    1616    $I = $I[2];
    17     $DbResult2 = $Database->query('SELECT * FROM hosts WHERE (IP LIKE "192.168.'.$I.'.%") ORDER BY IP');
    18     while($Host = $DbResult2->fetch_assoc())
     17    $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.LocalIP LIKE "192.168.'.$I.'.%") ORDER BY NetworkInterface.LocalIP');
     18    while($Interface = $DbResult2->fetch_assoc())
    1919    {
    20       $Commands[] = '/tool netwatch add host='.$Host['IP'].' interval=1m comment='.$Host['name'];
     20      $Commands[] = '/tool netwatch add host='.$Interface['LocalIP'].' interval=1m comment='.$Interface['DeviceName'].'-'.$Interface['Name'];
    2121    }
    2222  }
  • trunk/system/generators/traffic_shaping_routerboard.php

    r204 r208  
    6262$Index = 0;
    6363$DbResult = $Database->query('SELECT Member.*, Subject.Name FROM Member LEFT JOIN Subject ON Subject.Id = Member.Subject');
    64 while($Member = $DbResult->fetch_array())
     64while($Member = $DbResult->fetch_assoc())
    6565{
    6666  $Member['Name'] = RouterOSIdent($Member['Name']);
     
    8888  }
    8989
    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())
    9292  {
    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++;
    103107
    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++;
    115121    }
    116     $Index++;
    117122  }
    118123 
  • trunk/system/netwatch_import.php

    r187 r208  
    3333    {
    3434      $Online = 1;
    35       $Values = array('online' => $Online,  'last_online' => 'NOW()');
     35      $Values = array('Online' => $Online,  'LastOnline' => 'NOW()');
    3636    } else
    3737    {
    3838      $Online = 0;
    39       $Values = array('online' => $Online);
     39      $Values = array('Online' => $Online);
    4040    }
    4141
    42     $DbResult = $Database->update('hosts', 'IP="'.$Properties['host'].'"', $Values);
     42    $DbResult = $Database->update('NetworkInterface', 'LocalIP = "'.$Properties['host'].'"', $Values);
    4343    if($Online == 1)
    4444    {
    45       $DbResult = $Database->select('hosts', 'id', 'IP="'.$Properties['host'].'"');
     45      $DbResult = $Database->select('NetworkInterface', 'Id', 'LocalIP = "'.$Properties['host'].'"');
    4646      $DbRow = $DbResult->fetch_array();
    47       $HostId = $DbRow['id'];
     47      $HostId = $DbRow['Id'];
    4848      $DbResult2 = $Database->select('stat_hosts', '*', '(host_id="'.$HostId.'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
    4949      if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO stat_hosts (host_id, time) VALUES ("'.$HostId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');         
  • trunk/system/traffic-flow.php

    r161 r208  
    11<?php
    2 include_once('/a/www/centrala/global.php');
     2include_once('../global.php');
    33
    4 $Config['Web']['ShowErrors'] = 1;
     4//$Config['Web']['ShowErrors'] = 1;
    55
    66$Commands = array();
  • trunk/userlist.php

    r189 r208  
    1212
    1313    $DbResult = $this->Database->select('User', '*', 'Login != "Anonym" ORDER BY Name');
    14     while($User = $DbResult->fetch_array())
     14    while($User = $DbResult->fetch_assoc())
    1515    {
    1616      if($User['ICQ'] > 0) $ICQ = $User['ICQ']; else $ICQ = '&nbsp;';
    1717      if($User['PhoneNumber'] > 0) $Phone = $User['PhoneNumber']; else $Phone = '&nbsp;';
    1818
    19       $DbResult2 = $this->Database->select('hosts', '*', 'user='.$User['Id'].' AND block=0 ORDER BY name');
    20       $Hosts = '';
    21       while($Host = $DbResult2->fetch_array())
     19      $DbResult2 = $this->Database->query('SELECT Name, Id FROM NetworkDevice WHERE Member = (SELECT Id FROM Member WHERE Member.ResponsibleUser = '.$User['Id'].') ORDER BY Name');
     20      $Devices = array();
     21      while($Device = $DbResult2->fetch_assoc())
    2222      {
    23         $Hosts = $Hosts.$Host['name'].', ';
    24         //'<img src="http://wwp.icq.com/scripts/online.dll?icq='.$Row['icq'].'&img=5">'.
     23        $Devices[] = $Device['Name'];
    2524      }
    26       if($Hosts != '') $Hosts = substr($Hosts, 0, -2);
    27       $Output .= '<tr><td>'.$User['Name'].'</td><td>'.$User['Email'].'&nbsp;</td><td>'.$ICQ.'</td><td>'.$Phone.'</td><td>'.$Hosts.'</td></tr>';
     25      $Devices = implode(', ', $Devices);
     26      $Output .= '<tr><td>'.$User['Name'].'</td><td>'.$User['Email'].'&nbsp;</td><td>'.$ICQ.'</td><td>'.$Phone.'</td><td>'.$Devices.'</td></tr>';
    2827    }
    2928    $Output .= '</table>';
Note: See TracChangeset for help on using the changeset viewer.