1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../Common/Global.php');
|
---|
4 |
|
---|
5 | class PageHostList extends Page
|
---|
6 | {
|
---|
7 | function __construct(System $System)
|
---|
8 | {
|
---|
9 | parent::__construct($System);
|
---|
10 | $this->Title = 'Seznam počítačů';
|
---|
11 | $this->Description = 'Seznam registrovaných počítačů';
|
---|
12 | $this->ParentClass = 'PageNetwork';
|
---|
13 | }
|
---|
14 |
|
---|
15 | function Show(): string
|
---|
16 | {
|
---|
17 | if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Network', 'ShowHostList'))
|
---|
18 | return 'Nemáte oprávnění';
|
---|
19 |
|
---|
20 | if (array_key_exists('admin', $_GET)) $Where = 'AND NetworkDevice.Type IN (1,4,5) ';
|
---|
21 | else $Where = '';
|
---|
22 | $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
|
---|
23 | $Output .= '<tr><th>Jméno počítače</th><th>IP adresa</th><th>Veřejná IP</th><th>Typ</th><th>Naposledy online</th><th>Správce</th></tr>';
|
---|
24 | $DbResult = $this->Database->query('SELECT NetworkDevice.*, User.Name as UserName, NetworkDeviceType.Name AS HostType FROM NetworkDevice '.
|
---|
25 | 'LEFT JOIN Member ON Member.Id = NetworkDevice.Member '.
|
---|
26 | 'LEFT JOIN User ON Member.ResponsibleUser = User.Id '.
|
---|
27 | 'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 '.$Where.'ORDER BY NetworkDevice.Name');
|
---|
28 | while ($Device = $DbResult->fetch_assoc())
|
---|
29 | {
|
---|
30 | if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
|
---|
31 | $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE Device = '.$Device['Id']);
|
---|
32 | $DbRow = $DbResult2->fetch_row();
|
---|
33 | if ($DbRow[0] == 1)
|
---|
34 | {
|
---|
35 | $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
|
---|
36 | $Interface = $DbResult2->fetch_assoc();
|
---|
37 | if ($Interface['ExternalIP'] == '') $Interface['ExternalIP'] = ' ';
|
---|
38 | if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = ' ';
|
---|
39 | if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
|
---|
40 | $InterfaceName = $Device['Name'];
|
---|
41 | if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
|
---|
42 | $Output .= '<tr><td style="text-align: left; '.$Style.'">'.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td>'.$Interface['ExternalIP'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>';
|
---|
43 | } else
|
---|
44 | {
|
---|
45 | $Output .= '<tr><td colspan="3" 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>';
|
---|
46 | $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
|
---|
47 | while ($Interface = $DbResult2->fetch_assoc())
|
---|
48 | {
|
---|
49 | if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = ' ';
|
---|
50 | if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
|
---|
51 | $InterfaceName = $Device['Name'];
|
---|
52 | if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
|
---|
53 | $Output .= '<tr><td style="text-align: left; '.$Style.'"> '.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td> </td><td> </td><td> </td><td> </td></tr>';
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|
57 | $Output .= '</table></div>';
|
---|
58 | return $Output;
|
---|
59 | }
|
---|
60 | }
|
---|