source: trunk/Modules/Network/UserHosts.php

Last change on this file was 916, checked in by chronos, 3 years ago
  • Added: Allow to switch Mail class into test mode.
  • Modified: Type checking related changes.
  • Modified: Replace global $Config references with $this->System->Config is possible.
File size: 2.2 KB
Line 
1<?php
2
3class PageNetworkHostList extends Page
4{
5 function __construct(System $System)
6 {
7 parent::__construct($System);
8 $this->Title = 'Registrované počítače';
9 $this->ParentClass = 'PageNetwork';
10 }
11
12 function Show(): string
13 {
14 if (ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] == '') return $this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci');
15 $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
16 $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>';
17 $DbResult = $this->Database->query('SELECT NetworkDevice.*, NetworkDeviceType.Name AS HostType FROM NetworkDevice '.
18 'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '.
19 'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].') ORDER BY NetworkDevice.Name');
20 while ($Device = $DbResult->fetch_assoc())
21 {
22 if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
23 $Output .= '<tr><td colspan="4" style="text-align: left; font-weight: bold; '.
24 $Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td></tr>';
25 $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
26 while ($Interface = $DbResult2->fetch_assoc())
27 {
28 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
29 $InterfaceName = $Device['Name'];
30 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
31 $Output .= '<tr><td style="text-align: left; '.$Style.'">&nbsp;&nbsp;'.
32 $InterfaceName.'</td><td>'.NotBlank($Interface['LocalIP']).'</td><td>'.
33 NotBlank($Interface['ExternalIP']).'</td><td>'.
34 NotBlank($Interface['MAC']).'</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
35 }
36 }
37 $Output .= '</table></div>';
38 return $Output;
39 }
40}
Note: See TracBrowser for help on using the repository browser.